<?php 
ini_set('display_errors', 1); // Disable displaying errors
ini_set('log_errors', 1); // Log errors instead
ini_set('error_log', 'error.log'); // Specify the log file
include "include/auth.php"; 
include('include/auth.php');
 $dateTimeZone = new DateTimeZone("Europe/Athens");
 $dateTime = new DateTime("now", $dateTimeZone);
 $timeOffset = $dateTimeZone->getOffset($dateTime);
 $today = time() + $timeOffset;
 $from1=strtotime('yesterday midnight');
 $from=strtotime('today midnight');
 $from2=strtotime('tomorrow midnight');
 $to1=strtotime('yesterday 23:59:59');
 $to=strtotime('today 23:59:59');
 $to2=strtotime('tomorrow  23:59:59');
 if (isset($_GET['status'])  && $_GET['status']!='0') {
    $status=$_GET['status'];
}
else {
$status='0';
}
if (isset($_GET['stationid2'])  && $_GET['stationid2']!=0) {
    $stationid2=$_GET['stationid2'];
}
else {
    $stationid2='0';
}
?>
<!doctype html>
<html class="fixed dark">
	<?php 
	$pagerole="lists";

	$dash = isset($_GET['dash']) ? $_GET['dash'] : '';
	include('include/head.php'); ?><style>.noshow{display:none;} .done{text-decoration:line-through;} .canc{color:red!important;}</style>
	<body>
		<section class="body">

			<!-- start: header -->
			<header class="header">
				<div class="logo-container">
					<a href="index.php" class="logo">
						<img src="img/logo-light.png" width="75" height="35" alt="Web Voyage" />
					</a>
					<div class="d-md-none toggle-sidebar-left" data-toggle-class="sidebar-left-opened" data-target="html" data-fire-event="sidebar-left-opened">
						<i class="fas fa-bars" aria-label="Toggle sidebar"></i>
					</div>
				</div>
			
				<!-- start: search & user box -->
				<div class="header-right">
			<?php include('include/search.php');?>
					
			
					<span class="separator"></span>
			<?php include('include/notifications.php');?>
				
			
					<span class="separator"></span>
					<?php include('include/userbox.php'); 
					
					?>
				
				</div>
				<!-- end: search & user box -->
			</header>
			<!-- end: header -->

			<div class="inner-wrapper">
				<!-- start: sidebar -->
				<?php include('include/nav.php');
				if ($stationid==0){$stationname="Central";} 
				else{
		$sqlstat = $db2->query("SELECT * FROM jostj_vikrentcar_stations WHERE jostj_vikrentcar_stations.station_id='$stationid' ") or die(mysql_error());
		$rowstat = mysqli_fetch_array( $sqlstat );
				$stationname=$rowstat['station_name'];}
				  $sqlstlo = "SELECT * FROM jostj_vikrentcar_places WHERE jostj_vikrentcar_places.station='$stationid' ";
		
				$result = mysqli_query($db2,$sqlstlo);
		
				?>
				<!-- end: sidebar -->

				<section role="main" class="content-body">
					<header class="page-header">
						<h2>Dashboard</h2>
					
						<div class="right-wrapper text-right">
							<ol class="breadcrumbs">
								<li>
									<a href="index.php">
										<i class="fas fa-home"></i>
									</a>
								</li>
								<li><span>WV Admin</span></li>
								<li><span>Dashboard</span></li>
							</ol>
					
							<a class="sidebar-right-toggle" data-open="sidebar-right"><i class="fas fa-chevron-left"></i></a>
						</div>
					</header>
					  
			<!-- start: page -->
				<?php
// Default dashboard file
$dashboardFile = 'dash-res.php';

// Check if the user role is 1 and allow dashboard switching
if ($userrole == 1) {
    
    ?>
    <div class="row justify-content-end">
					 <div class="col-md-3">
					     <div class="row">
					         <div class="col-6 text-right pt-2">
					     <label>Change Dashboard</label>
					     </div>
					     <div class="col-6">
                        <select data-plugin-selectTwo class="form-control populate"
                            onChange="window.location.href=this.value">
                            <option value="?<?php echo http_build_query(array_merge($_GET, array("dash"=>'res')))?>"
                                <?php if($dash=='res') { echo "selected";} ?>>
                                Reservations</option>
                            <option value="?<?php echo http_build_query(array_merge($_GET, array("dash"=>'account')))?>"
                                <?php if($dash=='account') { echo "selected";} ?>>
                                Backoffice</option>
                                <option value="?<?php echo http_build_query(array_merge($_GET, array("dash"=>'mech')))?>"
                                <?php if($dash=='mech') { echo "selected";} ?>>
                                Garage</option>
                        </select>
                          </div>
                        </div>
                    </div>
                    </div>
                    <?php
    if (isset($_GET['dash'])) {
        if ($_GET['dash'] == "account") {
            $dashboardFile = 'dash-account.php';
        } elseif ($_GET['dash'] == "mech") {
            $dashboardFile = 'dash-mech.php';
        } else {
            $dashboardFile = 'dash-res.php';
        }
    }

   } elseif ($userrole == 2 || $userrole == 3) {
    $dashboardFile = 'dash-res.php';
} elseif ($userrole == 4) {
    $dashboardFile = 'dash-account.php';
} elseif ($userrole >= 5 && $userrole <= 7) {
    $dashboardFile = 'dash-mech.php';
}
?>

<!-- Dashboard Content -->
<div id="dashboardContainer">
    <?php include($dashboardFile); ?>
</div>

						<!-- end: page -->
				</section>
			</div>

			<?php include('include/aside.php');?>

		</section>

    <!-- Vendor -->
    <script src="vendor/jquery/jquery.js"></script>
    <script src="vendor/jquery-browser-mobile/jquery.browser.mobile.js"></script>
    <script src="vendor/popper/umd/popper.min.js"></script>
    <script src="vendor/bootstrap/js/bootstrap.js"></script>
    <script src="vendor/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
    <script src="vendor/common/common.js"></script>
    <script src="vendor/nanoscroller/nanoscroller.js"></script>
    <script src="vendor/magnific-popup/jquery.magnific-popup.js"></script>
    <script src="vendor/jquery-placeholder/jquery.placeholder.js"></script>

    <!-- Specific Page Vendor -->
    <script src="vendor/select2/js/select2.js"></script>
    <script src="vendor/datatables/media/js/jquery.dataTables.min.js"></script>
    <script src="vendor/datatables/media/js/dataTables.bootstrap4.min.js"></script>
    <script src="vendor/datatables/extras/TableTools/Buttons-1.4.2/js/dataTables.buttons.min.js"></script>
    <script src="vendor/datatables/extras/TableTools/Buttons-1.4.2/js/buttons.bootstrap4.min.js"></script>
    <script src="vendor/datatables/extras/TableTools/Buttons-1.4.2/js/buttons.html5.min.js"></script>
    <script src="vendor/datatables/extras/TableTools/Buttons-1.4.2/js/buttons.print.min.js"></script>
    <script src="vendor/datatables/extras/TableTools/JSZip-2.5.0/jszip.min.js"></script>
    <script src="vendor/datatables/extras/TableTools/pdfmake-0.1.32/pdfmake.min.js"></script>
    <script src="vendor/datatables/extras/TableTools/pdfmake-0.1.32/vfs_fonts.js"></script>


    <!--(remove-empty-lines-end)-->

    <!-- Theme Base, Components and Settings -->
    <script src="js/theme.js"></script>

    <!-- Theme Custom -->
    <script src="js/custom.js"></script>

    <!-- Theme Initialization Files -->
    <script src="js/theme.init.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-modal/0.9.1/jquery.modal.min.js"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-modal/0.9.1/jquery.modal.min.css" />
    <!-- Examples -->
    <script src="js/examples/examples.datatables.default.js"></script>
    <script>
            
   $(document).ready(function () {
    $('#datatable-tabletools3').DataTable({
        
        order: [[13, 'desc']],
        "paging": true,
        "lengthChange": false,
        "bFilter": false,
        "ordering": true,
        "columnDefs": [
    { "visible": false, "targets": 13 }
  ],
    });

    $('#datatable-tabletools').DataTable({
        
        
        "paging": true,
        "lengthChange": false,
        "bFilter": false,
        "ordering": true,
    
    });
    $('#datatable-tabletools2').DataTable({
        
        "order": [[11, 'desc']],
        "paging": true,
        "lengthChange": false,
        "bFilter": false,
        "ordering": true,
    
    });
});
    </script>
	</body>
</html>
<?php include('include/footer.php');?>