Mini Shell

Direktori : /home2/aravindar/public_html/admin/
Upload File :
Current File : /home2/aravindar/public_html/admin/gallery.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';
}


$url_query  = "SELECT * FROM tb1_url WHERE url_title='gallery'";
$res_url = mysqli_query($conn, $url_query);
$fetch_url = mysqli_fetch_object($res_url);
$url_path = $fetch_url->url_path;

?>
<!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">
<!-- font awesome Fremwork -->
<link rel="stylesheet" type="text/css" href="plugin/font-awesome/css/font-awesome.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 -->
<!-- feather Awesome -->
<link rel="stylesheet" type="text/css" href="assets/icon/feather/css/feather.css">
<!-- Style.css -->
<link rel="stylesheet" type="text/css" href="assets/css/style.css">
<link rel="stylesheet" type="text/css" href="assets/css/jquery.mCustomScrollbar.css">
<!-- jquery file upload Frame work -->
<link href="assets/pages/jquery.filer/css/jquery.filer.css" type="text/css" rel="stylesheet" />
<link href="assets/pages/jquery.filer/css/themes/jquery.filer-dragdropbox-theme.css" type="text/css" rel="stylesheet" />
<!-- animation nifty modal window effects css -->
<link rel="stylesheet" type="text/css" href="assets/css/component.css">
<link rel="stylesheet" type="text/css" href="assets/css/validation/tooltip-style.css">
<!-- hover-effect.css -->
<link rel="stylesheet" type="text/css" href="assets/pages/hover-effect/normalize.css">
<link rel="stylesheet" type="text/css" href="assets/pages/hover-effect/set2.css">
</head>
<!-- Menu sidebar static layout -->

<body>
    <div id="loaderid" class="spinner-container hideloader">
        <div class="loader"></div>
    </div>
    <!-- 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">
                            <div class="main-body">
                                <div class="page-wrapper">
                                    <?php $year_id = base64_decode($_GET['id']); ?>
                                    <!-- 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>Gallery - <?php echo $year_id ?></h4>
                                                        <span>You can edit The website gallery image 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="#!">Gallery</a>
                                                        </li>
                                                    </ul>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                    <!-- Page-header end -->
                                    <!-- Page body start -->
                                    <div class="page-body gallery-page">
                                        <div class="col-md-12 text-right mb-3">
                                            <button type="button" class="btn btn-info pl-3 pr-3 mt-3 waves-effect md-trigger" data-modal="modal-11">Add Gallery</button>
                                        </div>
                                        <section class="course">
                                            <div class="container">

                                                <ul class="nav nav-pills mb-3 p-0 justify-content-center" id="pills-tab" role="tablist" data-aos="fade-up" data-aos-duration="1000">
                                                    <li class="nav-item">
                                                        <a class="nav-link active" id="showall-tab" data-toggle="pill" href="#showall" role="tab" aria-controls="showall" aria-selected="true">Show All</a>
                                                    </li>
                                                    <?php
                                                    $year_id = base64_decode($_GET['id']);
                                                    $content_query = "SELECT * FROM tb1_gallery WHERE status=1 AND year='$year_id' GROUP BY category ORDER BY gallery_id ASC";
                                                    $content_res = mysqli_query($conn, $content_query);
                                                    while ($content_row = mysqli_fetch_object($content_res)) {
                                                        $category1 = $content_row->category;
                                                        $category = str_replace(' ', '', $category1);
                                                    ?>
                                                        <li class="nav-item">
                                                            <a class="nav-link" id="<?php echo $category ?>-tab" data-toggle="pill" href="#<?php echo $category ?>" role="tab" aria-selected="false"><?php echo $category1 ?></a>
                                                        </li>
                                                    <?php
                                                    }
                                                    ?>

                                                </ul>

                                                <div class="row">
                                                    <div class="tab-content" id="pills-tabContent">
                                                        <div class="tab-pane  fade show active" id="showall" role="tabpanel" aria-labelledby="showall-tab">
                                                            <div class="grid">
                                                                <?php
                                                                $url_query  = "SELECT * FROM tb1_url WHERE url_title='gallery'";
                                                                $res_url = mysqli_query($conn, $url_query);
                                                                $fetch_url = mysqli_fetch_object($res_url);
                                                                $url_path = $fetch_url->url_path;

                                                                $year_id = base64_decode($_GET['id']);
                                                                $content_query = "SELECT * FROM tb1_gallery WHERE status=1 AND year='$year_id' ORDER BY gallery_id ASC";
                                                                //echo $content_query;
                                                                $content_res = mysqli_query($conn, $content_query);
                                                                while ($content_row = mysqli_fetch_object($content_res)) {

                                                                    $gallery_id = $content_row->gallery_id;
                                                                    $status = $content_row->status;
                                                                    $category1 = $content_row->category;
                                                                    $category = str_replace(' ', '', $category1);
                                                                    $img = $content_row->img;
                                                                    $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));

                                                                    $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);
                                                                ?>
                                                                    <figure class="effect-apollo">
                                                                        <img src="<?php echo $url_path . $img ?>" alt="img" class="img-fluid" style="height: 300px;width: 100%;" />
                                                                        <figcaption>
                                                                            <h2><?php echo $category ?></h2>
                                                                            <p><?php echo $updated_log; ?>
                                                                                <?php echo ucfirst($crm_name); ?>
                                                                            </p>
                                                                            <a href="#" title="Click to Edit" class="waves-effect md-trigger" data-modal="modal-10" data-id="<?php echo $gallery_id; ?>">Click to Edit</a>
                                                                        </figcaption>
                                                                    </figure>

                                                                <?php
                                                                }
                                                                ?>
                                                            </div>
                                                        </div>
                                                        <?php
                                                        $url_query  = "SELECT * FROM tb1_url WHERE url_title='gallery'";
                                                        $res_url = mysqli_query($conn, $url_query);
                                                        $fetch_url = mysqli_fetch_object($res_url);
                                                        $url_path = $fetch_url->url_path;

                                                        $year_id = base64_decode($_GET['id']);
                                                        $content_query = "SELECT * FROM tb1_gallery WHERE status=1 AND year='$year_id' GROUP BY category ORDER BY gallery_id ASC";
                                                        //echo $content_query;
                                                        $content_res = mysqli_query($conn, $content_query);
                                                        while ($content_row = mysqli_fetch_object($content_res)) {


                                                            $category1 = $content_row->category;
                                                            $category = str_replace(' ', '', $category1);
                                                            $category_list[] = $category1;
                                                            $cat_array = implode(',', $category_list);
                                                        }
                                                        $myArray = explode(',', $cat_array);
                                                        // print_r( $myArray);      
                                                        foreach ($myArray as $title_cat) {
                                                            $title_cat1 = str_replace(' ', '', $title_cat);
                                                        ?>

                                                            <div class="tab-pane  fade" id="<?php echo $title_cat1; ?>" role="tabpanel" aria-labelledby="<?php echo $title_cat1; ?>-tab">
                                                                <div class="grid">
                                                                    <?php

                                                                    $content_query = "SELECT * FROM tb1_gallery WHERE status=1 AND year='$year_id' AND category='$title_cat'    ORDER BY gallery_id ASC";
                                                                    //echo $content_query;
                                                                    $content_res = mysqli_query($conn, $content_query);
                                                                    while ($content_row = mysqli_fetch_object($content_res)) {

                                                                        $gallery_id = $content_row->gallery_id;
                                                                        $status = $content_row->status;
                                                                        $category1 = $content_row->category;
                                                                        $category = str_replace(' ', '', $category1);
                                                                        $img = $content_row->img;
                                                                        $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));

                                                                        $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);
                                                                    ?>
                                                                        <figure class="effect-apollo">
                                                                            <img src="<?php echo $url_path . $img ?>" alt="img" class="img-fluid" style="height: 300px;width: 100%;" />
                                                                            <figcaption>
                                                                                <h2><?php echo $category1 ?></h2>
                                                                                <p><?php echo $updated_log; ?>
                                                                                    <?php echo ucfirst($crm_name); ?>
                                                                                </p>
                                                                                <a href="#" title="Click to Edit" class="waves-effect md-trigger" data-modal="modal-10" data-id="<?php echo $gallery_id; ?>">Click to Edit</a>
                                                                            </figcaption>
                                                                        </figure>
                                                                    <?php
                                                                    }
                                                                    ?>
                                                                </div>
                                                            </div>
                                                        <?php
                                                        }
                                                        ?>
                                                    </div>
                                                </div>
                                            </div>
                                        </section>
                                    </div>
                                    <!-- Page body end -->
                                </div>
                                <div class="md-modal md-effect-10" id="modal-10">
                                    <div class="col-md-12 text-right">
                                        <button class="md-close btn" style="background: #fe5d70;    position: absolute;left: 99%;color: #fff;cursor: pointer;">X</button>
                                    </div>
                                    <div class="md-content modal-content">

                                    </div>

                                </div>
                                <div class="md-modal md-effect-10" id="modal-11">
                                    <div class="col-md-12 text-right">
                                        <button class="md-close btn" style="background: #fe5d70;    position: absolute;left: 99%;color: #fff;cursor: pointer;">X</button>
                                    </div>
                                    <div class="md-content">
                                        <h3>Add gallery image</h3>
                                        <form class="add-form" id="addForm" enctype="multipart/form-data">
                                            <div class="col-md-12">
                                                <div class="card-block">
                                                    <input type="hidden" name="type" value="add">
                                                    <div class="form-group row">
                                                        <label class="col-md-3 col-form-label">Year </label>
                                                        <div class="col-md-9">
                                                            <input type="text" name="year" class="form-control">
                                                        </div>
                                                    </div>
                                                    <div class="form-group row">
                                                        <label class="col-md-3 col-form-label">Category </label>
                                                        <div class="col-md-9">
                                                            <input type="text" name="category" class="form-control">
                                                        </div>
                                                    </div>
                                                    <div class="form-group row">
                                                        <label class="col-md-3 col-form-label">Upload Image <small>(Max 3 images)</small></label>
                                                        <div class="col-md-9">
                                                            <input type="file" name="images[]" class="form-control" multiple>
                                                        </div>
                                                    </div>


                                                </div>
                                            </div>
                                            <div class="col-md-12 text-center">
                                                <button type="submit" class="btn btn-success text-bold" id="sub1-btn" style="width: -webkit-fill-available;">Submit</button>
                                            </div>
                                        </form>
                                    </div>

                                </div>

                            </div>

                            <div class="md-overlay"></div>
                            <div id="styleSelector">

                            </div>
                        </div>
                    </div>
                </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>
    <!-- <script type="text/javascript" src="assets/js/modal.js"></script> 
 -->
    <!-- modalEffects js nifty modal window effects -->
    <script type="text/javascript" src="assets/js/modalEffects.js"></script>
    <script type="text/javascript" src="assets/js/classie.js"></script>
    <!-- jquery file upload js -->
    <script src="assets/pages/jquery.filer/js/jquery.filer.min.js"></script>
    <script src="assets/pages/filer/custom-filer.js" type="text/javascript"></script>
    <script src="assets/pages/filer/jquery.fileuploads.init.js" type="text/javascript"></script>
    <!-- Custom js -->
    <script src="assets/js/pcoded.min.js"></script>
    <script src="assets/js/vartical-layout.min.js"></script>
    <script src="assets/js/sweetalert.min.js"></script>
    <script src="assets/js/jquery.mCustomScrollbar.concat.min.js"></script>
    <script type="text/javascript" src="assets/js/script.js"></script>
    <script src="assets/validation/jquery-validation/jquery.validate.min.js"></script>
    <script src="assets/css/validation/form-validation.js"></script>
    <script type="text/javascript">
        $('.md-trigger').click(function() {
            var id = $(this).attr('data-id');
            $.ajax({
                url: "galleryedit_model.php?id=" + id,
                cache: false,
                success: function(result) {
                    $(".modal-content").html(result);
                }
            });
        });
    </script>
    <script type="text/javascript">
        // initialize validate plugin on the form
        $("#addForm").validate({
            errorPlacement: function(error, element) {
                var ele = $(element),
                    err = $(error),
                    msg = err.text();
                if (msg != null && msg !== "") {
                    ele.tooltipster('content', msg);
                    ele.tooltipster('open'); //open only if the error message is not blank. By default jquery-validate will return a label with no actual text in it so we have to check the innerHTML.
                }
            },
            unhighlight: function(element, errorClass, validClass) {
                $(element).removeClass(errorClass).addClass(validClass).tooltipster('close');
            },

            submitHandler: function(form) { // for demo
                var form = $('#addForm')[0];
                var formData = new FormData(form);
                event.preventDefault();
                $("#sub1-btn").attr("disabled", true);
                $.ajax({
                    type: 'POST',
                    url: 'ajax/gallery_action',
                    processData: false,
                    contentType: false,
                    dataType: "json",
                    data: formData,
                    success: function(data) {
                        if (data == 'done') {
                            swal({
                                title: 'Updated Successfully!',
                                text: "Gallery 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();
                                }
                            });
                        }
                    },
                    error: function(data) {
                        swal({
                            title: 'Internal Sever Error!',
                            text: "Try again",
                            icon: 'warning',
                            closeOnEsc: false,
                            closeOnClickOutside: false,
                        })
                    },
                });
            }
        });
    </script>

</body>

</html>

Zerion Mini Shell 1.0