<?php
session_name("vadmin_session");
session_start();
if (!$_SESSION["vname"]) {

    header("Location:index.php");
}

?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">

    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>DROP SHIPPING PANEL : VADMIN</title>

    <!-- Google Font: Source Sans Pro -->
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700&display=fallback">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="plugins/fontawesome-free/css/all.min.css">

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.css">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.js"></script>
    <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
    <!-- Tempusdominus Bootstrap 4 -->
    <link rel="stylesheet" href="plugins/tempusdominus-bootstrap-4/css/tempusdominus-bootstrap-4.min.css">
    <!-- iCheck -->
    <link rel="stylesheet" href="plugins/icheck-bootstrap/icheck-bootstrap.min.css">
    <!-- JQVMap -->
    <link rel="stylesheet" href="plugins/jqvmap/jqvmap.min.css">
    <!-- Theme style -->
    <link rel="stylesheet" href="dist/css/adminlte.min.css">
    <!-- overlayScrollbars -->
    <link rel="stylesheet" href="plugins/overlayScrollbars/css/OverlayScrollbars.min.css">
    <!-- Daterange picker -->
    <link rel="stylesheet" href="plugins/daterangepicker/daterangepicker.css">
    <!-- select option -->
    <link href="https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.13/css/select2.min.css" rel="stylesheet">
    <!-- all css  -->
    <link rel="stylesheet" href="allstylecode.css">

    <!-- summernote -->
    <link rel="stylesheet" href="plugins/summernote/summernote-bs4.min.css">
    <!-- DataTables -->
    <link rel="stylesheet" href="plugins/datatables-bs4/css/dataTables.bootstrap4.min.css">
    <link rel="stylesheet" href="plugins/datatables-responsive/css/responsive.bootstrap4.min.css">
    <link rel="stylesheet" href="plugins/datatables-buttons/css/buttons.bootstrap4.min.css">

    <!--This prevents the default right-click context menu-->
    <!-- <script type="text/javascript">
        document.addEventListener('contextmenu', function (e) {
        e.preventDefault(); 
  });
  </script>-->
</head>

<body class="hold-transition sidebar-mini layout-fixed">
    <div class="wrapper">

        <!-- Preloader -->
        <div class="preloader flex-column justify-content-center align-items-center">
            <img class="animation__shake" src="dist/img/AdminLTELogo.png" alt="AdminLTELogo" height="60" width="60">
        </div>

        <!-- Navbar -->
        <nav class="main-header navbar navbar-expand navbar-white navbar-light" style="background-color: black;">
            <!-- Left navbar links -->
            <ul class="navbar-nav">
                <li class="nav-item">
                    <a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars" style="color:white"></i></a>
                </li>

            </ul>

            <!-- Right navbar links -->
            <ul class="navbar-nav ml-auto">


                <!-- Notifications Dropdown Menu -->
                <!-- Notifications Dropdown Menu -->
                <li class="nav-item dropdown">
                    <a class="nav-link" data-toggle="dropdown" href="#">

                        <i class="far fa-bell" style="color:white" id="notification-bell"></i>
                        <?php
                        include('connection.php');
                        $query = "SELECT count(id) as num FROM notifications WHERE  seen_status='0' ";
                        $result = mysqli_query($conn, $query);
                        if ($data = mysqli_fetch_array($result)) {
                            $p = $data['num'];
                        }
                        ?>
                        <span class="badge badge-warning navbar-badge"><?php echo $p; ?></span>
                    </a>
                    <div class="dropdown-menu dropdown-menu-lg dropdown-menu-right">
                        <span class="dropdown-item dropdown-header"> Notifications <?php echo $p; ?></span>
                        <div class="dropdown-divider"></div>
                        <?php
                        include('connection.php');

                        if (isset($_GET['notification_id'])) {
                            $notification_id = $_GET['notification_id'];

                            $update_sql = "UPDATE notifications SET seen_status = '1' WHERE id = $notification_id";
                            mysqli_query($conn, $update_sql);
                        }

                        $sql = "SELECT * FROM notifications WHERE seen_status='0' ORDER BY id DESC";
                        $res = mysqli_query($conn, $sql);
                        $unread_notifications = array();

                        while ($row = mysqli_fetch_array($res)) {
                            $unread_notifications[] = $row;
                        }
                        ?>

                        <div id="unread-notifications">
                            <?php
                            $count = 0;
                            foreach ($unread_notifications as $notification) {
                                if ($count < 2) {
                            ?>
                                    <a href="?notification_id=<?php echo $notification['id']; ?>" class="dropdown-item">
                                        <i class="fas fa-envelope mr-2"></i> <?php echo $notification['message'] ?>
                                    </a>
                                <?php
                                } else {
                                ?>
                                    <a href="?notification_id=<?php echo $notification['id']; ?>" class="dropdown-item hidden-notification" style="display: none;">
                                        <i class="fas fa-envelope mr-2"></i> <?php echo $notification['message'] ?>
                                    </a>
                            <?php
                                }
                                $count++;
                            }
                            ?>
                        </div>

                        <div class="dropdown-divider"></div>
                        <a href="#" class="dropdown-item" id="view-all-link" onclick="showAllMessages();">
                            <i class="fas fa-file mr-2"></i> View All Message
                        </a>

                        <script>
                            function showAllMessages() {
                                var hiddenNotifications = document.querySelectorAll('.hidden-notification');
                                var viewAllLink = document.getElementById('view-all-link');

                                hiddenNotifications.forEach(function(notification) {
                                    notification.style.display = 'block';
                                });

                                viewAllLink.style.display = 'none';
                            }
                        </script>


                </li>

                <li class="nav-item">
                    <a class="nav-link" href="logout.php" style="color:white">
                        <i class="fa fa-sign-out" style="color:white"></i>logout
                    </a>
                </li>

            </ul>
        </nav>
        <!-- /.navbar -->

        <!-- Main Sidebar Container -->
        <aside class="main-sidebar sidebar-dark-primary elevation-4"  style="background-color: black;">

            <!-- Brand Logo -->
            <a href="#" class="brand-link">
                <?php
                include('connection.php');
                $sql = "SELECT * FROM user_admin";
                $res = mysqli_query($conn, $sql);
                while ($row = mysqli_fetch_array($res)) {


                ?>
                    <!-- <img src="dist/img/avatar5.png" height="30" width="30" class="brand-image img-circle elevation-3" style="opacity: .8"> -->
                    <span class="brand-text font-weight-light"><span style="margin-left: 3%;font-weight:600;font-size: 33px;"><?php echo $row['title']; ?></span></span>
                <?php
                }
                ?>

            </a>

            <!-- Sidebar -->
            <div class="sidebar">
                <!-- Sidebar user panel (optional) -->
                <div class="user-panel mt-1 mb-1 p-1 d-flex">
                    <div class="image" style="padding-left: 0;">
                        <img src="dist/img/avatar5.png" class="img-circle elevation-2" alt="User Image" style="margin-left: 12px;">

                    </div>
                    <div class="info">
                        <a href="#" class="d-block" style="font-size: 150%;">Admin</a>
                        <span class="right badge badge-success" style="margin-top: 3%;height: 19px;">online</span>
                    </div>
                    <br>
                </div>



                <!-- Sidebar Menu -->
                <nav class="mt-2" style="font-weight:600">
                    <ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false" style="text-transform: uppercase;">
                        <!-- Add icons to the links using the .nav-icon class
               with font-awesome or any other icon font library -->
                        <li class="nav-item">
                            <a href="dashboad.php" class="nav-link">
                                <i class="nav-icon fas fa-tachometer-alt"></i>
                                <p>
                                    Dashboard
                                </p>
                            </a>
                        </li>
                        <li class="nav-header">Vendor</li>
                        <li class="nav-item">
                            <a href="add_track.php" class="nav-link">
                                <i class="nav-icon fas fa-truck"></i>
                                <p>
                                    Add Track
                                </p>
                            </a>
                        </li>

                        <li class="nav-item">
                            <a href="order_sent.php" class="nav-link">
                                <i class="nav-icon fa fa-shopping-bag"></i>
                                <p>
                                    Order Sent
                                    <!-- <span class="right badge badge-danger">New</span> -->
                                </p>
                            </a>
                        </li>
                        <li class="nav-header">ORDERS</li>
                        <li class="nav-item">
                            <a href="pending_order.php" class="nav-link">
                                <i class="nav-icon fas fa-clock-o"></i>
                                <p>
                                    Pending Orders
                                    <!-- <span class="right badge badge-danger">New</span> -->
                                </p>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a href="order_history.php" class="nav-link">
                                <i class="nav-icon fas fa-history"></i>
                                <p>
                                    Order History
                                </p>
                            </a>
                        </li>
                        <li class="nav-item">
                            <a href="cancel_order.php" class="nav-link">
                                <i class="nav-icon fas fa-times"></i>
                                <p>
                                    Cancel Orders
                                </p>
                            </a>
                        </li>
                        <li class="nav-header">Settings</li>
                        <li class="nav-item">
                            <a href="#" class="nav-link">
                                <i class="nav-icon fa fa-gear"></i>
                                <p>
                                    Setting
                                    <i class="fas fa-chevron-circle-left right"></i>
                                </p>
                            </a>
                            <ul class="nav nav-treeview">


                                <li class="nav-item">
                                    <a href="profile_setting.php" class="nav-link">
                                        <i class="far fa-circle nav-icon"></i>
                                        <p>Profile Setting</p>
                                    </a>
                                </li>
                            </ul>
                        </li>
                    </ul>

                </nav>
                <!-- /.sidebar-menu -->

            </div>

            <!-- <footer class="sidebar-footer ">
                <div class="flex-col">



                    <div class="translate" id="google_translate_element"></div>
                    <div class="skiptranslate goog-te-gadget" dir="ltr">
                        <div id=":0.targetLanguage">
                        </div>
                    </div>
                    <script type="text/javascript">
                        function googleTranslateElementInit() {
                            new google.translate.TranslateElement({
                                pageLanguage: 'en'
                            }, 'google_translate_element');
                        }
                    </script>
                    <script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script>
                    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@10.15.5/dist/sweetalert2.all.min.js"></script>

            </footer> -->

            <!-- /.sidebar -->
        </aside>
        <!-- Content Wrapper. Contains page content -->