Mini Shell

Direktori : /home2/aravindar/public_html/admin/
Upload File :
Current File : /home2/aravindar/public_html/admin/testimonials.php

<?php
/* Database connection */
include("config.php");
$conn = dbconnect();
session_start();

// login or not
if ($_SESSION['name'] == '' || $_SESSION['admin_id'] == '') {
    header('location:logout.php');
    die();
}

$name = $_SESSION['name'];
$admin_id = $_SESSION['admin_id'];
$query  = "SELECT * FROM tb1_admin WHERE name='" . $name . "' AND admin_id='" . $admin_id . "'";
$res_query = mysqli_query($conn, $query);
$fetch = mysqli_fetch_object($res_query);
$username = $fetch->user_name;
$phone = $fetch->phone;
$adminposition = $fetch->position;
if ($adminposition == 1) {
    $type = 'Main Admin';
} elseif ($adminposition == 2) {
    $type = 'Accounts';
} elseif ($adminposition == 3) {
    $type = 'Marketing';
} else {
    $type = 'Others';
}

?>
<!DOCTYPE html>
<html lang="en">
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<title>Admin - Sri Aravindar Arts & Science College </title>
<!-- Meta -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimal-ui">
<meta http-equiv="X-UA-Compatible" content="IE=edge" />

<!-- Favicon icon -->
<link rel="icon" href="assets/images/favicon.png" type="image/x-icon">
<!-- Google font-->
<link href="https://fonts.googleapis.com/css?family=Open+Sans:400,600,800" rel="stylesheet">
<!-- Required Fremwork -->
<link rel="stylesheet" type="text/css" href="plugin/bootstrap/dist/css/bootstrap.min.css">
<!-- themify-icons line icon -->
<link rel="stylesheet" type="text/css" href="assets/icon/themify-icons/themify-icons.css">
<!-- ico font -->
<link rel="stylesheet" type="text/css" href="assets/icon/icofont/css/icofont.css">
<!-- feather Awesome -->
<link rel="stylesheet" type="text/css" href="assets/icon/feather/css/feather.css">
<!-- Style.css -->
<!-- Style.css -->
<link rel="stylesheet" type="text/css" href="assets/icon/font-awesome/css/font-awesome.min.css">
<link rel="stylesheet" type="text/css" href="assets/css/style.css">
<link rel="stylesheet" type="text/css" href="assets/css/jquery.mCustomScrollbar.css">
<link rel="stylesheet" type="text/css" href="assets/css/jquery.mCustomScrollbar.css">
<link rel="stylesheet" href="assets/vendors/datatables.net-bs4/dataTables.bootstrap4.css">

<link rel="stylesheet" href="assets/vendors/datatables.net-fixedcolumns-bs4/fixedColumns.bootstrap4.min.css">
<style type="text/css">
    @media (min-width:768px) {
        td {
            white-space: normal !important;
            word-wrap: break-word;
        }

        table {
            table-layout: fixed;
        }
    }
</style>
</head>
<!-- Menu sidebar static layout -->

<body>

    <!-- Pre-loader start -->
    <div class="theme-loader">
        <div class="ball-scale">
            <div class='contain'>
                <div class="ring">
                    <div class="frame"></div>
                </div>
                <div class="ring">
                    <div class="frame"></div>
                </div>
                <div class="ring">
                    <div class="frame"></div>
                </div>
                <div class="ring">
                    <div class="frame"></div>
                </div>
                <div class="ring">
                    <div class="frame"></div>
                </div>
                <div class="ring">
                    <div class="frame"></div>
                </div>
                <div class="ring">
                    <div class="frame"></div>
                </div>
                <div class="ring">
                    <div class="frame"></div>
                </div>
                <div class="ring">
                    <div class="frame"></div>
                </div>
                <div class="ring">
                    <div class="frame"></div>
                </div>
            </div>
        </div>
    </div>
    <!-- Pre-loader end -->
    <div id="pcoded" class="pcoded">
        <div class="pcoded-overlay-box"></div>
        <div class="pcoded-container navbar-wrapper">

            <?php include('static-header.php') ?>

            <div class="pcoded-main-container">
                <div class="pcoded-wrapper">

                    <?php include('static-sidebar.php') ?>

                    <div class="pcoded-content">
                        <div class="pcoded-inner-content">
                            <!-- Main-body start -->
                            <div class="main-body">
                                <div class="page-wrapper">
                                    <!-- Page-header start -->
                                    <div class="page-header">
                                        <div class="row align-items-end">
                                            <div class="col-lg-8">
                                                <div class="page-header-title">
                                                    <div class="d-inline">
                                                        <h4>Testimonials</h4>
                                                        <span>You can add the website Testimonials here!</span>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="col-lg-4">
                                                <div class="page-header-breadcrumb">
                                                    <ul class="breadcrumb-title">
                                                        <li class="breadcrumb-item" style="float: left;">
                                                            <a href="dashboard"> <i class="feather icon-home"></i> </a>
                                                        </li>
                                                        <li class="breadcrumb-item" style="float: left;"><a href="#!">Home Page</a>
                                                        </li>
                                                        <li class="breadcrumb-item" style="float: left;"><a href="#!">Testimonials</a>
                                                        </li>
                                                    </ul>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <!-- Page-header end -->

                                    <!-- Inline Editor start -->
                                    <div class="card">
                                        <div class="card-header">
                                            <h5>Add New Testimonials</h5>
                                            <span>Click on text to change it</span>

                                        </div>
                                        <div class="card-block">
                                            <div id="header" class="row">
                                                <div class="col-md-4">
                                                    <label>Name</label>
                                                    <input type="text" class="form-control" id="title" name="title" required>
                                                </div>
                                                <div class="col-md-4">
                                                    <label>Description</label>
                                                    <input type="text" class="form-control" id="description" name="description" required>
                                                </div>
                                                <div class="col-md-4">
                                                    <label>Student Image</label>
                                                    <input class="form-control" type="file" id="image" accept="image/*">
                                                </div>

                                                <button class="btn btn-success pl-3 pr-3 mt-3 ml-3" type="button" id="flash-btn">Submit</button>
                                            </div>


                                        </div>
                                    </div>
                                    <!-- Inline Editor end -->

                                    <!-- Page body start -->
                                    <div class="page-body">

                                        <!-- Zero config.table start -->
                                        <div class="card">

                                            <div class="card-block">
                                                <div class="table-responsive">

                                                    <table id="fixed-column" class="table table-striped table-bordered" cellspacing="0" width="100%">
                                                        <thead>
                                                            <tr>
                                                                <th>SI No</th>
                                                                <th>Name</th>
                                                                <th>Description</th>

                                                                <th>Action</th>
                                                                <th>Updated By</th>
                                                                <th>Last Update</th>

                                                            </tr>
                                                        </thead>
                                                        <tbody>
                                                            <?php

                                                            $content_query = "SELECT * FROM tb1_testimonial WHERE status ='1' ORDER BY updated_log DESC";
                                                            //echo $content_query;
                                                            $content_res = mysqli_query($conn, $content_query);
                                                            $counter = 0;
                                                            while ($content_row = mysqli_fetch_object($content_res)) {
                                                                $counter++;
                                                                $event_id = $content_row->id;
                                                                $title = $content_row->name;
                                                                $event_content = $content_row->description;
                                                                $status = $content_row->status;


                                                                $crm_id = $content_row->crm_id;
                                                                $updated_at = $content_row->updated_log;
                                                                $updated_log = date('d-m-Y h:i:s A', strtotime($updated_at));
                                                                $created_at = $content_row->created_log;
                                                                $created_log = date('d-m-Y h:i:s A', strtotime($created_at));

                                                                $crm_query = "SELECT * FROM tb1_admin WHERE admin_id ='$crm_id' ";
                                                                $crm_res = mysqli_query($conn, $crm_query);
                                                                $crm_row = mysqli_fetch_object($crm_res);
                                                                $crm_name = strtolower($crm_row->name);
                                                            ?>
                                                                <tr>
                                                                    <td><?php
                                                                        if ($status == 1) {
                                                                        ?>
                                                                            <i class="fa fa-circle" aria-hidden="true" style="color:#008000" title="Event Active"></i>
                                                                        <?php
                                                                        } else {
                                                                        ?>
                                                                            <i class="fa fa-circle" aria-hidden="true" style="color:#FF0000" title="Event Deactive"></i>
                                                                        <?php
                                                                        }
                                                                        echo $counter;
                                                                        ?>
                                                                    </td>
                                                                    <td><?php echo $title; ?>
                                                                    </td>
                                                                    <td><?php echo $event_content; ?>

                                                                    </td>

                                                                    <td>
                                                                        <button class="btn btn-sm mt-2 btn-success " type="button" id="edit" data-id="<?php echo $event_id; ?>">Edit</button>
                                                                        <button class="btn btn-danger mt-2 btn-sm delete" type="button" id="delete" data-id="<?php echo $event_id; ?>"><i class="fa fa-trash"></i></button>
                                                                    </td>


                                                                    <td><?php echo ucfirst($crm_name); ?></td>
                                                                    <td><?php echo $updated_log; ?></td>
                                                                </tr>
                                                            <?php
                                                            }
                                                            ?>

                                                        </tbody>
                                                    </table>

                                                </div>
                                            </div>
                                        </div>
                                        <!-- Zero config.table end -->


                                        <div class="md-overlay"></div>
                                    </div>
                                    <!-- Page body end -->
                                </div>
                                <!-- Page body end -->
                            </div>
                        </div>
                        <!-- Main-body end -->
                    </div>
                </div>
            </div>
        </div>
    </div>
    </div>

    <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
        <div class="modal-dialog" role="document">
            <div class="modal-content">
                <div class="modal-header">
                    <h5 class="modal-title" id="exampleModalLabel">Edit</h5>
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                        <span aria-hidden="true">&times;</span>
                    </button>
                </div>
                <input type="hidden" id="editid">
                <div class="modal-body">
                    <div class="col-md-12">
                        <label>Name</label>
                        <input type="text" class="form-control" id="edittitle" name="title" required>
                    </div>
                    <div class="col-md-12">
                        <label>Description</label>
                        <input type="text" class="form-control" id="editdescription" name="description" required>
                    </div>
                    <div class="col-md-12">
                        <label>Student Image</label>
                        <input class="form-control" type="file" id="editimage" accept="image/*">
                    </div>

                    <!-- <button class="btn btn-success pl-3 pr-3 mt-3 ml-3" type="button" id="submit-btn">Submit</button> -->
                </div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
                    <button type="button" class="btn btn-primary" id="updatebtn">Update</button>
                </div>
            </div>
        </div>
    </div>

    <!-- Required Jquery -->
    <script type="text/javascript" src="plugin/jquery/dist/jquery.min.js"></script>
    <script type="text/javascript" src="plugin/jquery-ui/jquery-ui.min.js"></script>
    <script type="text/javascript" src="plugin/popper.js/dist/umd/popper.min.js"></script>
    <script type="text/javascript" src="plugin/bootstrap/dist/js/bootstrap.min.js"></script>
    <!-- jquery slimscroll js -->
    <script type="text/javascript" src="plugin/jquery-slimscroll/jquery.slimscroll.js"></script>
    <!-- modernizr js -->
    <script type="text/javascript" src="plugin/modernizr/modernizr.js"></script>
    <script type="text/javascript" src="plugin/modernizr/feature-detects/css-scrollbars.js"></script>
    <!-- ck editor -->
    <script src="assets/pages/ckeditor/ckeditor.js"></script>
    <!-- Custom js -->
    <script type="text/javascript" src="assets/pages/ckeditor/ckeditor-custom.js"></script>

    <!-- Plugin js for this page -->
    <script src="assets/vendors/datatables.net/jquery.dataTables.js"></script>
    <script src="assets/vendors/datatables.net-bs4/dataTables.bootstrap4.js"></script>
    <script src="assets/vendors/datatables.net-fixedcolumns/dataTables.fixedColumns.min.js"></script>
    <!-- BEGIN PAGE LEVEL CUSTOM SCRIPTS -->
    <script src="assets/vendors/table/datatable/datatables.js"></script>
    <!-- NOTE TO Use Copy CSV Excel PDF Print Options You Must Include These Files  -->
    <script src="assets/vendors/table/datatable/button-ext/dataTables.buttons.min.js"></script>
    <script src="assets/vendors/table/datatable/button-ext/jszip.min.js"></script>
    <script src="assets/vendors/table/datatable/button-ext/buttons.html5.min.js"></script>
    <script src="assets/vendors/table/datatable/button-ext/buttons.print.min.js"></script>
    <!-- End plugin js for this page -->

    <script src="assets/js/pcoded.min.js"></script>
    <script src="assets/js/vartical-layout.min.js"></script>
    <script src="assets/js/jquery.mCustomScrollbar.concat.min.js"></script>
    <script src="assets/js/sweetalert.min.js"></script>
    <script type="text/javascript" src="assets/js/script.js"></script>
    <script src="assets/js/data-table.js"></script>
    <script type="text/javascript">
        $(".active").on('click', function() {
            var type = "active";
            var news_id = $(this).attr('data-id');
            swal({
                title: 'Are you sure?',
                text: "You want to active this Testimonials?",
                icon: 'warning',
                showCancelButton: true,
                confirmButtonColor: '#3f51b5',
                cancelButtonColor: '#ff4081',
                confirmButtonText: 'Great ',
                closeOnEsc: false,
                closeOnClickOutside: false,
                buttons: {
                    cancel: {
                        text: "No",
                        value: null,
                        visible: true,
                        className: "btn btn-danger",
                        closeModal: true,
                    },
                    confirm: {
                        text: "Yes",
                        value: true,
                        visible: true,
                        className: "btn btn-primary",
                        closeModal: true
                    }
                }
            }).then((value) => {
                if (value == true) {
                    $.ajax({
                        url: "ajax/event_action.php",
                        type: "POST",
                        data: {
                            "news_id": news_id,
                            "type": type
                        },
                        dataType: "json",
                        success: function(data) {
                            if (data == 'done') {
                                swal({
                                    title: "Successfully Activated!",
                                    text: "The Testimonials has been successfully activated.",
                                    type: "success",
                                    icon: 'success',
                                    confirmButtonColor: '#3f51b5',
                                    confirmButtonText: 'OK ',
                                    closeOnEsc: false,
                                    closeOnClickOutside: false,
                                    buttons: {
                                        confirm: {
                                            text: "Okay",
                                            value: true,
                                            visible: true,
                                            className: "btn btn-primary",
                                            closeModal: true
                                        }
                                    }
                                }).then((value) => {
                                    if (value == true) {
                                        location.reload();
                                    }
                                })
                            } else {
                                swal("Internal Server Error!", "Please try again", "error");
                            }
                        },
                        error: function(xhr, ajaxOptions, thrownError) {
                            swal("Internal Server Error!", "Please try again", "error");
                        }
                    });

                } else {
                    // swal(`The returned value is: ${value}`);
                }
            });
        });
    </script>
    <script type="text/javascript">
        $(".delete").on('click', function() {
            var type = "delete";
            var news_id = $(this).attr('data-id');
            swal({
                title: 'Are you sure?',
                text: "You want to delete this Testimonials?",
                icon: 'warning',
                showCancelButton: true,
                confirmButtonColor: '#3f51b5',
                cancelButtonColor: '#ff4081',
                confirmButtonText: 'Great ',
                closeOnEsc: false,
                closeOnClickOutside: false,
                buttons: {
                    cancel: {
                        text: "No",
                        value: null,
                        visible: true,
                        className: "btn btn-danger",
                        closeModal: true,
                    },
                    confirm: {
                        text: "Yes",
                        value: true,
                        visible: true,
                        className: "btn btn-primary",
                        closeModal: true
                    }
                }
            }).then((value) => {
                if (value == true) {
                    $.ajax({
                        url: "ajax/deletetestimonial.php",
                        type: "POST",
                        data: {
                            "news_id": news_id,
                            "type": type
                        },
                        dataType: "json",
                        success: function(data) {
                            if (data.status == '200') {
                                swal({
                                    title: "Successfully Deleted!",
                                    text: "The Testimonials has been successfully Deleted.",
                                    type: "success",
                                    icon: 'success',
                                    confirmButtonColor: '#3f51b5',
                                    confirmButtonText: 'OK ',
                                    closeOnEsc: false,
                                    closeOnClickOutside: false,
                                    buttons: {
                                        confirm: {
                                            text: "Okay",
                                            value: true,
                                            visible: true,
                                            className: "btn btn-primary",
                                            closeModal: true
                                        }
                                    }
                                }).then((value) => {
                                    if (value == true) {
                                        location.reload();
                                    }
                                })
                            } else {
                                swal("Internal Server Error!", "Please try again", "error");
                            }
                        },
                        error: function(xhr, ajaxOptions, thrownError) {
                            swal("Internal Server Error!", "Please try again", "error");
                        }
                    });

                } else {
                    // swal(`The returned value is: ${value}`);
                }
            });
        });
    </script>
    <script type="text/javascript">
        $(".inactive").on('click', function() {
            var type = "inactive";
            var news_id = $(this).attr('data-id');
            swal({
                title: 'Are you sure?',
                text: "You want to inactive this Testimonials?",
                icon: 'warning',
                showCancelButton: true,
                confirmButtonColor: '#3f51b5',
                cancelButtonColor: '#ff4081',
                confirmButtonText: 'Great ',
                closeOnEsc: false,
                closeOnClickOutside: false,
                buttons: {
                    cancel: {
                        text: "No",
                        value: null,
                        visible: true,
                        className: "btn btn-danger",
                        closeModal: true,
                    },
                    confirm: {
                        text: "Yes",
                        value: true,
                        visible: true,
                        className: "btn btn-primary",
                        closeModal: true
                    }
                }
            }).then((value) => {
                if (value == true) {
                    $.ajax({
                        url: "ajax/event_action.php",
                        type: "POST",
                        data: {
                            "news_id": news_id,
                            "type": type
                        },
                        dataType: "json",
                        success: function(data) {
                            if (data == 'done') {
                                swal({
                                    title: "Successfully Inactive!",
                                    text: "The Testimonials has been successfully deactivated.",
                                    type: "success",
                                    icon: 'success',
                                    confirmButtonColor: '#3f51b5',
                                    confirmButtonText: 'OK ',
                                    closeOnEsc: false,
                                    closeOnClickOutside: false,
                                    buttons: {
                                        confirm: {
                                            text: "Okay",
                                            value: true,
                                            visible: true,
                                            className: "btn btn-primary",
                                            closeModal: true
                                        }
                                    }
                                }).then((value) => {
                                    if (value == true) {
                                        location.reload();
                                    }
                                })
                            } else {
                                swal("Internal Server Error!", "Please try again", "error");
                            }
                        },
                        error: function(xhr, ajaxOptions, thrownError) {
                            swal("Internal Server Error!", "Please try again", "error");
                        }
                    });

                } else {
                    // swal(`The returned value is: ${value}`);
                }
            });
        });
    </script>
    <script type="text/javascript">
        $(document).ready(function() {
            // $("#updatebtn").on('click', function() {
            //     var type = "update";
            //     var event_date = $('#event_date').val();
            //     var event_time = $('#event_time').val();
            //     var event_place = $('#event_place').val();
            //     var title = $('#title').val();
            //     var description = $('#description').val();
            //     $('.is-invalid').removeClass('is-invalid');
            //     var isvalid = true;

            //     if (event_date == '') {
            //         $('#event_date').addClass('is-invalid');
            //         isvalid = false;
            //     }
            //     if (description == '') {
            //         $('#description').addClass('is-invalid');
            //         isvalid = false;
            //     }
            //     if (title == '') {
            //         $('#title').addClass('is-invalid');
            //         isvalid = false;
            //     }
            //     if (event_time == '') {
            //         $('#event_time').addClass('is-invalid');
            //         isvalid = false;
            //     }
            //     if (event_place == '') {
            //         $('#event_place').addClass('is-invalid');
            //         isvalid = false;
            //     }
            //     var imageFile = $('#image')[0].files[0];
            //     if (!imageFile) {
            //         $('#image').addClass('is-invalid');
            //         isvalid = false;
            //     }
            //     const file = $('#image')[0].files[0];

            //     if (file) {
            //         if (file.size > 500 * 1024) {
            //             isvalid = false;
            //             swal({
            //                 title: 'File too large!',
            //                 text: "Please upload an image under 500 KB.",
            //                 icon: 'warning',
            //                 buttons: {
            //                     confirm: {
            //                         text: 'Okay',
            //                         value: true,
            //                         visible: true,
            //                         className: 'btn btn-primary',
            //                         closeModal: true
            //                     }
            //                 },
            //                 closeOnEsc: false,
            //                 closeOnClickOutside: false
            //             });
            //         }
            //     }
            //     if (isvalid) {
            //         var formData = new FormData();
            //         formData.append('type', type);
            //         formData.append('title', title);
            //         formData.append('description', description);
            //         formData.append('video', imageFile);

            //         $.ajax({
            //             type: "POST",
            //             url: "ajax/testmonial_action.php",
            //             data: formData,
            //             processData: false,
            //             contentType: false,
            //             dataType: 'json',

            //             success: function(data) {
            //                 if (data == 'done') {
            //                     swal({
            //                         title: 'Added Successfully!',
            //                         text: "Testimonial has been successfully created",
            //                         icon: 'success',
            //                         confirmButtonColor: '#3f51b5',
            //                         closeOnEsc: false,
            //                         closeOnClickOutside: false,
            //                         buttons: {
            //                             confirm: {
            //                                 text: "Okay",
            //                                 value: true,
            //                                 visible: true,
            //                                 className: "btn btn-primary",
            //                                 closeModal: true
            //                             }
            //                         }
            //                     }).then((value) => {
            //                         if (value == true) {
            //                             location.reload();
            //                         }
            //                     });
            //                 } else {
            //                     swal({
            //                         title: 'Internal Server Error!',
            //                         text: "Try again",
            //                         icon: 'warning',
            //                         closeOnEsc: false,
            //                         closeOnClickOutside: false,
            //                     });
            //                 }
            //             },
            //             error: function(jqXHR, textStatus, errorThrown) {
            //                 swal({
            //                     title: 'Request Failed!',
            //                     text: "Please try again",
            //                     icon: 'error',
            //                     closeOnEsc: false,
            //                     closeOnClickOutside: false,
            //                 });
            //             }
            //         });
            //     }
            // });
           
            $("#flash-btn").on('click', function() {
                var type = "update";
                var event_date = $('#event_date').val();
                var event_time = $('#event_time').val();
                var event_place = $('#event_place').val();
                var title = $('#title').val();
                var description = $('#description').val();
                $('.is-invalid').removeClass('is-invalid');
                var isvalid = true;

                if (event_date == '') {
                    $('#event_date').addClass('is-invalid');
                    isvalid = false;
                }
                if (description == '') {
                    $('#description').addClass('is-invalid');
                    isvalid = false;
                }
                if (title == '') {
                    $('#title').addClass('is-invalid');
                    isvalid = false;
                }
                if (event_time == '') {
                    $('#event_time').addClass('is-invalid');
                    isvalid = false;
                }
                if (event_place == '') {
                    $('#event_place').addClass('is-invalid');
                    isvalid = false;
                }
                var imageFile = $('#image')[0].files[0];
                if (!imageFile) {
                    $('#image').addClass('is-invalid');
                    isvalid = false;
                }
                const file = $('#image')[0].files[0];

                if (file) {
                    if (file.size > 500 * 1024) {
                        isvalid = false;
                        swal({
                            title: 'File too large!',
                            text: "Please upload an image under 500 KB.",
                            icon: 'warning',
                            buttons: {
                                confirm: {
                                    text: 'Okay',
                                    value: true,
                                    visible: true,
                                    className: 'btn btn-primary',
                                    closeModal: true
                                }
                            },
                            closeOnEsc: false,
                            closeOnClickOutside: false
                        });
                    }
                }
                if (isvalid) {
                    var formData = new FormData();
                    formData.append('type', type);
                    formData.append('title', title);
                    formData.append('description', description);
                    formData.append('video', imageFile);

                    $.ajax({
                        type: "POST",
                        url: "ajax/testmonial_action.php",
                        data: formData,
                        processData: false,
                        contentType: false,
                        dataType: 'json',

                        success: function(data) {
                            if (data == 'done') {
                                swal({
                                    title: 'Added Successfully!',
                                    text: "Testimonial has been successfully created",
                                    icon: 'success',
                                    confirmButtonColor: '#3f51b5',
                                    closeOnEsc: false,
                                    closeOnClickOutside: false,
                                    buttons: {
                                        confirm: {
                                            text: "Okay",
                                            value: true,
                                            visible: true,
                                            className: "btn btn-primary",
                                            closeModal: true
                                        }
                                    }
                                }).then((value) => {
                                    if (value == true) {
                                        location.reload();
                                    }
                                });
                            } else {
                                swal({
                                    title: 'Internal Server Error!',
                                    text: "Try again",
                                    icon: 'warning',
                                    closeOnEsc: false,
                                    closeOnClickOutside: false,
                                });
                            }
                        },
                        error: function(jqXHR, textStatus, errorThrown) {
                            swal({
                                title: 'Request Failed!',
                                text: "Please try again",
                                icon: 'error',
                                closeOnEsc: false,
                                closeOnClickOutside: false,
                            });
                        }
                    });
                }
            });
        });
    </script>
    <script>
        $(document).ready(function() {
            $('#edit').click(function() {
                var eventId = $(this).data('id');

                $.ajax({
                    url: './ajax/edittestmonial.php', // Replace with your endpoint URL
                    type: 'POST',
                    data: {
                        id: eventId
                    },
                    success: function(response) {
                        $('#edittitle').val(response.data.name);
                        $('#editid').val(response.data.id);
                        $('#editdescription').val(response.data.description);
                        $('#exampleModal').modal('show');

                    },
                    error: function(xhr, status, error) {
                        // Handle error response
                        console.error('Error:', error);
                    }
                });
            });
        });
    </script>
    <script>
        $(document).ready(function() {
            $('#updatebtn').click(function() {
                $('#exampleModal').modal('hide');
                var isvalid = true;
                var formData = new FormData();
                formData.append('title', $('#edittitle').val());
                formData.append('slider_id', $('#editid').val());
                formData.append('description', $('#editdescription').val());
                formData.append('name', $('#editimage')[0].files[0]);
                const file = $('#editimage')[0].files[0];

                if (file) {
                    if (file.size > 500 * 1024) {
                        isvalid = false;
                        swal({
                            title: 'File too large!',
                            text: "Please upload an image under 500 KB.",
                            icon: 'warning',
                            buttons: {
                                confirm: {
                                    text: 'Okay',
                                    value: true,
                                    visible: true,
                                    className: 'btn btn-primary',
                                    closeModal: true
                                }
                            },
                            closeOnEsc: false,
                            closeOnClickOutside: false
                        });
                    }
                }
                if (isvalid) {
                    $.ajax({
                        url: './ajax/updateimage.php', // Replace with your API endpoint
                        type: 'POST',
                        data: formData,
                        processData: false,
                        contentType: false,
                        success: function(response) {
                            if (response == 'done') {
                                swal({
                                    title: 'Updated Successfully!',
                                    text: "Testimonial has been successfully Updated",
                                    icon: 'success',
                                    confirmButtonColor: '#3f51b5',
                                    closeOnEsc: false,
                                    closeOnClickOutside: false,
                                    buttons: {
                                        confirm: {
                                            text: "Okay",
                                            value: true,
                                            visible: true,
                                            className: "btn btn-primary",
                                            closeModal: true
                                        }
                                    }
                                }).then((value) => {
                                    if (value == true) {
                                        location.reload();
                                    }
                                });
                            } else {
                                swal({
                                    title: 'Internal Server Error!',
                                    text: "Try again",
                                    icon: 'warning',
                                    closeOnEsc: false,
                                    closeOnClickOutside: false,
                                });
                            }
                        },
                        error: function(xhr, status, error) {
                            // Handle error
                            console.error(error);
                        }
                    });
                }
            });

        });
    </script>
</body>

</html>

Zerion Mini Shell 1.0