<?php
include 'session.php';
date_default_timezone_set("Asia/Kolkata");
require_once 'web_constant.php';
$bdd=new DB();
$row=$bdd->getOne("SELECT user_id,type,name FROM user WHERE user_id=".$_SESSION['admin_id']);
$type=$row['type'];
$UId=$row['user_id'];
$Uname=$row['name'];
$current_datetime=date("Y-m-d H:i:s");

$userPermissions = [];
$permissionResult = $bdd->getAll("SELECT Tabs FROM permissions WHERE UId =" . $_SESSION['admin_id']);

// Check if the query was successful and $permissionResult is a valid result object
if ($permissionResult) {
    foreach ($permissionResult as $permission) {
        $userPermissions[] = $permission['Tabs'];
    }
}else if($type=='admin') {
    //$nothing = "You do not have any permission";
} else {
    $nothing = "You do not have any permission";
}
$bdd->disconnect();

?>
<!DOCTYPE html>
<!-- Template Name: Clip-One - Responsive Admin Template build with Twitter Bootstrap 3.x Version: 1.3 Author: ClipTheme -->
<!--[if IE 8]><html class="ie8 no-js" lang="en"><![endif]-->
<!--[if IE 9]><html class="ie9 no-js" lang="en"><![endif]-->
<!--[if !IE]><!-->
<html lang="en" class="no-js">
	<!--<![endif]-->
	<!-- start: HEAD -->
	<head>
		<title>Scanner System Admin</title>
		<!-- start: META -->
		<meta charset="utf-8" />
		<!--[if IE]><meta http-equiv='X-UA-Compatible' content="IE=edge,IE=9,IE=8,chrome=1" /><![endif]-->
		<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0, minimum-scale=1.0, maximum-scale=1.0">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<meta content="" name="description" />
		<meta content="" name="author" />
		<!-- end: META -->
		<!-- start: MAIN CSS -->
		<link rel="stylesheet" href="assets/plugins/bootstrap/css/bootstrap.min.css">
		<link rel="stylesheet" href="assets/plugins/font-awesome/css/font-awesome.min.css">
		<link rel="stylesheet" href="assets/fonts/style.css">
		<link rel="stylesheet" href="assets/css/main.css">
		<link rel="stylesheet" href="assets/css/main-responsive.css">
		<!--<link rel="stylesheet" href="assets/plugins/bootstrap-colorpalette/css/bootstrap-colorpalette.css"> 
		<link rel="stylesheet" href="assets/plugins/bootstrap-datepicker/css/datepicker.css">-->
		<link rel="stylesheet" href="assets/css/theme_light.css" type="text/css" id="skin_color">
		<link rel="stylesheet" href="assets/css/print.css" type="text/css" media="print"/>
		<link rel="stylesheet" type="text/css" href="assets/lip/lightpick.css">
		<!-- jqury ui css
		<link rel="stylesheet" href="assets/css/jquery-ui.css"/>-->
		
		<!--[if IE 7]>
		<link rel="stylesheet" href="assets/plugins/font-awesome/css/font-awesome-ie7.min.css">
		<![endif]-->
		<!-- end: MAIN CSS -->
		<!-- start: CSS REQUIRED FOR THIS PAGE ONLY 
		<link rel="stylesheet" href="assets/plugins/fullcalendar/fullcalendar/fullcalendar.css">-->
		<!-- end: CSS REQUIRED FOR THIS PAGE ONLY -->
		<link rel="shortcut icon" href="favicon.ico" />
		<style>
		/* Style the sidenav links and the dropdown button */
		.dropdown-btn {
		    display: block;
		    width: 100%;
		}
		/*.main-navigation-menu li{
			border-style: groove !important;
  border-width: 3px !important;
  border-color: #9BB5F4 !important;
		}*/
		</style>
	</head>
	<!-- end: HEAD -->
	<!-- start: BODY -->
	<body class="navigation-small">
		<!-- start: HEADER -->
		<div class="navbar navbar-inverse navbar-fixed-top">
			<!-- start: TOP NAVIGATION CONTAINER -->
			<div class="container">
				<div class="navbar-header">
					<!-- start: RESPONSIVE MENU TOGGLER -->
					<button data-target=".navbar-collapse" data-toggle="collapse" class="navbar-toggle" type="button">
						<span class="clip-list-2"></span>
					</button>
					<!-- end: RESPONSIVE MENU TOGGLER -->
					<!-- start: LOGO -->
					<a class="navbar-brand" href="home">
						Scanner System
					</a>
					<!-- end: LOGO -->
				</div>
				<div class="navbar-tools">
					<!-- start: TOP NAVIGATION MENU -->
					<ul class="nav navbar-right">
						<!-- start: USER DROPDOWN -->
						<li class="dropdown current-user">
							<a data-toggle="dropdown" data-hover="dropdown" class="dropdown-toggle" data-close-others="true" href="#">
								<img src="assets/images/admin.png" class="circle-img" alt="">
								<span class="username"><?php echo $_SESSION['login_admin'] ?></span>
								<i class="clip-chevron-down"></i>
							</a>
							<ul class="dropdown-menu">
								<li>
									<a href="user">
										<i class="fa fa-user"></i>
										&nbsp;Profile
									</a>
								</li>
								<li>
									<a href="logout">
										<i class="clip-exit"></i>
										&nbsp;Log Out
									</a>
								</li>
							</ul>
						</li>
						<!-- end: USER DROPDOWN -->
					</ul>
					<!-- end: TOP NAVIGATION MENU -->
				</div>
			</div>
			<!-- end: TOP NAVIGATION CONTAINER -->
		</div>
		<!-- end: HEADER -->
		<!-- start: MAIN CONTAINER -->
		<div class="main-container">
			<div class="navbar-content">
				<!-- start: SIDEBAR -->
				<div class="main-navigation navbar-collapse collapse">
					<div class="navigation-toggler" onClick="toggleCustSidebar()" style="width: 100% !important; margin-left: 0px;">
						<button class="btn btn-blue btn-block"><i class="clip-arrow-right-2" id="toggleSidebarBtn"></i></button>
					</div>
					<!-- start: MAIN NAVIGATION MENU -->
					<ul class="main-navigation-menu">
						<li>
							<a href="home"><i class="clip-home-3"></i>
								<span class="title"> Dashboard </span>
							</a>
						</li>
						<?php
						if($type=='admin'){
						?>
						<li>
							<a href="menu">
								<i class="fa fa-list" style="color:#d58630"></i>
								<span class="title"> Menu </span>
							</a>
						</li>
						
						<li>
							<a href="javascript:void(0)" class="dropdown-btn">
								<i class="fa fa-book" style="color:#2b6835"></i>
								<span class="title"> Master </span><i class="icon-arrow"></i>
								<span class="selected"></span>
							</a>
							<ul class="sub-menu">
								<li><a href="meter_make"><span class="title"> Meter Make </span></a></li>
								<li><a href="rto"><span class="title"> RTO </span></a></li>
								<li><a href="product"><span class="title"> Product </span></a></li>
								<li><a href="salesman"><span class="title"> Salesman </span></a></li>
								<?php
if($type=="admin"){
	echo '<li><a href="security_password"><span class="title"> Security Password </span></a></li>';
}
?>
							</ul>
							
						</li>
						<?php } ?>
						
						<li>
							<a href="javascript:void(0)" class="dropdown-btn">
								<i class="fa fa-users" style="color:#2b6835"></i>
								<span class="title"> Customer </span><i class="icon-arrow"></i>
								<span class="selected"></span>
							</a>
							<ul class="sub-menu">
							<?php
				if($type!='restricted_user'){
				?>
								<li>
									<a href="customer?status=Pending">
										<span class="title"> Pending </span>
									</a>
								</li>
								<li>
									<a href="customer?status=Completed">
										<span class="title"> Completed </span>
									</a>
								</li>
								<li>
									<a href="customer?status=Uploaded">
										<span class="title"> Uploaded </span>
									</a>
								</li>
							<?php } ?>
								<li>
									<a href="customer?status=SemiSuccessfull">
										<span class="title"> Semi-Successfull </span>
									</a>
								</li>
								<li>
									<a href="customer?status=hsrp">
										<span class="title"> HSRP </span>
									</a>
								</li>
								<li>
									<a href="customer?status=Fitment">
										<span class="title"> Fitment </span>
									</a>
								</li>
								<li>
									<a href="customer?status=Register">
										<span class="title"> Register </span>
									</a>
								</li>
								<li>
									<a href="customer?status=FullSuccessfull">
										<span class="title"> Full-Successfull </span>
									</a>
								</li>
								<li>
									<a href="customer?status=Reject">
										<span class="title"> Rejected </span>
									</a>
								</li>
							<?php
				if($type!='restricted_user'){
				?>
								<li>
									<a href="customer?status=All">
										<span class="title"> All </span>
									</a>
								</li>
							<?php } ?>

							</ul>
						</li>
						<?php
				if($type!='restricted_user'){
				?>
						<li>
							<a href="update-registration-no">
								<i class="fa fa-edit" style="color:#2b61f5"></i>
								<span class="title"> Update Registration No </span>
							</a>
						</li>
						<?php } ?>
						
						<?php
						if($type=='admin'){
						?>
						<li>
							<a href="user_update_report">
								<i class="fa fa-check-square" style="color:#2b61f5"></i>
								<span class="title"> User Update Report </span>
							</a>
						</li>
						<li>
							<a href="smc_report">
								<i class="fa fa-truck" style="color:#6a2bf5"></i>
								<span class="title"> SMC Report </span>
							</a>
						</li>
						<li>
							<a href="user">
								<i class="fa fa-users" style="color:#2b61f5"></i>
								<span class="title"> Users </span>
							</a>
						</li>
						
						<li>
							<a href="restore.php">
								<i class="fa fa-share" style="color:#cc6111"></i>
								<span class="title"> Restore </span>
							</a>
						</li>
						
						<li>
							<a href="javascript:void(0)" class="dropdown-btn">
								<i class="fa fa-file-text-o" style="color:#2b6835"></i>
								<span class="title"> Report </span><i class="icon-arrow"></i>
								<span class="selected"></span>
							</a>
							<ul class="sub-menu">
								<li><a href="report?type=tat"><span class="title"> TAT </span></a></li>
							</ul>
							
						</li>
						
						<?php } ?>
						
						<?php
						if (in_array('RTO-Data', $userPermissions)) {
						?>
						<li>
							<a href="rto_data">
								<i class="fa fa-list-ol" style="color:#2b61f5"></i>
								<span class="title"> RTO DATA </span>
							</a>
						</li>
						<?php
						}
						?>
						<li>
							<a href="backup.php">
								<i class="fa fa-lock" style="color:#cc6111"></i>
								<span class="title"> Backup </span>
							</a>
						</li>
						<li>
							<a href="sync_backup.php">
								<i class="fa fa-file" style="color:#cc6111"></i>
								<span class="title"> Documents Backup </span>
							</a>
						</li>
						<li>
							<a href="http://<?php echo web_constant::$ip_ticl; ?>" target="_blank">
								<i class="fa fa-truck" style="color:#cc6111"></i>
								<span class="title"> TICL </span>
							</a>
						</li>
						
					</ul>
					<!-- end: MAIN NAVIGATION MENU -->
				</div>
				<!-- end: SIDEBAR -->
			</div>
			<!-- start: PAGE -->
			<div class="main-content">
				<!-- end: SPANEL CONFIGURATION MODAL FORM -->
				<div class="container">
					<!-- end: PAGE HEADER -->