<?php
session_start();
$user_id = $_SESSION["user_id"];
$type= $_SESSION["type"];
include '../connection/includecon.php';
$sqlempl_id = "SELECT * FROM `tbl_user_mstr` where id = '$user_id'";
$result_emp = $objhr->viewdata($sqlempl_id);
		$row_emp = $result_emp->fetch_assoc();
		
		$sqlempl_li = "SELECT * FROM `tbl_emp_desg_dept` where emp_id = '".$row_emp['emp_id']."'";
$result_li = $objhr->viewdata($sqlempl_li);
		$row_li = $result_li->fetch_assoc();
?>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="description" content="">
    <meta name="author" content="">
    <!-- Favicon icon -->
    <link rel="icon" type="image/png" sizes="16x16" href="images/favicon.png">
    <title></title>
    <!-- Bootstrap Core CSS -->
    <link href="../css/lib/bootstrap/bootstrap.min.css" rel="stylesheet">
    <!-- Custom CSS -->
    <link href="../css/helper.css" rel="stylesheet">
    <link href="../css/style.css" rel="stylesheet">
   <style>
   .sidebar-nav ul li a {
    color:#fff!important;
	font-weight:bold;
	}
	
	.collapse > li > a.active {
    font-weight: 400;
    background: #fff;
    color: #1976d2;
}   

.sidebar-nav > ul > li.active > a {
    color: #000!important;
	}
	.collapse > li > a.active {
    color: #000!important;
	}
	.fa{ color:#000!important;}
	.mdi {color:#FFFFFF!important; }
	.sidebar-nav .has-arrow:after {
   
    
    border-color: #FFFFFF;
	}
	.ti-menu, .ti-search{color:#FFFFFF!important; }
</style>
</head>

<body class="fix-header fix-sidebar">
    <!-- Preloader - style you can find in spinners.css -->
    <div class="preloader">
        <svg class="circular" viewBox="25 25 50 50">
			<circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10" /> </svg>
    </div>
    <!-- Main wrapper  -->
    <div id="main-wrapper">
        <!-- header header  -->
        <div class="header">
            <nav class="navbar top-navbar navbar-expand-md navbar-light">
                <!-- Logo -->
                <div class="navbar-header">
                    <a class="navbar-brand" href="index.php">
                        <!-- Logo icon -->
                       <!-- <b><img src="../images/logo.png" alt="homepage" class="dark-logo" /></b>-->
                        <!--End Logo icon -->
                        <!-- Logo text -->
                        <span><img src="../images/Logo.jpg" style="width:210px; height:60px;" alt="homepage" class="dark-logo" /></span>
                    </a>
                </div>
                <!-- End Logo -->
                <div class="navbar-collapse" style="background:#1873A2">
                    <!-- toggle and nav items -->
                    <ul class="navbar-nav mr-auto mt-md-0">
                        <!-- This is  -->
                        <li class="nav-item"> <a class="nav-link nav-toggler hidden-md-up text-muted  " href="javascript:void(0)"><i class="mdi mdi-menu"></i></a> </li>
                        <li class="nav-item m-l-10"> <a class="nav-link sidebartoggler hidden-sm-down text-muted  " href="javascript:void(0)"><i class="ti-menu"></i></a> </li>
                        <!-- Messages -->
                        
                        <!-- End Messages -->
                    </ul>
                    <!-- User profile and search -->
                    <ul class="navbar-nav my-lg-0">

                        <!-- Search -->
                        <li class="nav-item hidden-sm-down search-box"> <a class="nav-link hidden-sm-down text-muted  " href="javascript:void(0)"><i class="ti-search"></i></a>
                            <form class="app-search">
                                <input type="text" class="form-control" placeholder="Search here"> <a class="srh-btn"><i class="ti-close"></i></a> </form>
                        </li>
                       
                       
                        <!-- Profile -->
                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle text-muted  " href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><img src="../images/users/default.png" alt="user" class="profile-pic" /></a>
                            <div class="dropdown-menu dropdown-menu-right animated zoomIn">
                                <ul class="dropdown-user">
                                    <li><a href="profile.php"><i class="ti-user"></i> Profile</a></li>
                                   
                                    <li><a href="#"><i class="ti-settings"></i> Setting</a></li>
                                    <li><a href="../logout.php"><i class="fa fa-power-off"></i> Logout</a></li>
                                </ul>
                            </div>
                        </li>
                    </ul>
                </div>
            </nav>
        </div>
        <!-- End header header -->
        <!-- Left Sidebar  -->
        <div class="left-sidebar">
            <!-- Sidebar scroll-->
            <div class="scroll-sidebar" style="background:#1873A2">
                <!-- Sidebar navigation-->
                <nav class="sidebar-nav">
                    <ul id="sidebarnav" style="background:#1873A2">
                        <li class="nav-devider"></li>
                        <li class="nav-label" style="color:#FFFFFF; font-weight:bold;">Home</li>
                        <li> <a class=" has-arrow " href="index.php" aria-expanded="false"><i class="fa fa-tachometer"></i><span class="hide-menu">Dashboard </span></a>
                           <!-- <ul aria-expanded="false" class="collapse">
                                <li><a href="index.html">Ecommerce </a></li>
                                <li><a href="index1.html">Analytics </a></li>
                            </ul>-->
                        </li>
						
						<?php
						if($type=='1'){
						?>
						 <li> <a class="has-arrow  " href="#" aria-expanded="false"><i class="fa fa-envelope"></i><span class="hide-menu">Master</span></a>
                            <ul aria-expanded="false" class="collapse">
                                <li><a href="add_identity_type.php">Add Identity Type</a></li>
								 <li><a href="add_user_type.php">Add User Type</a></li>
								 <li><a href="create_user.php">Create User</a></li>
								 <li><a href="menu_details2.php">Menu Permission</a></li>
                              
                            </ul>
                        </li>
							<?php }?>
						
                      	<?php 
							$sqlw = "select *from tbl_menu_mtr where under_menu_id = '0' and id in (select under_menu_id from tbl_menu_mtr where under_menu_id <> '0' and id in (select menu_id from tbl_menu_permission where user_type_id = '$type')) order by menu_order asc";
						$result = $objhr->viewdata($sqlw);
							if($result->num_rows > 0){
									while($rows = $result->fetch_assoc()){
									$id= $rows['id'];
									?>
									 <li> <a class="has-arrow  " href="#" aria-expanded="false"><i class="fa fa-envelope"></i><span class="hide-menu"><?php echo $rows['menu_name']; ?></span></a>
                            <ul aria-expanded="false" class="collapse">
                            
                         
          
		  <?php
		  error_reporting(0);
		  $sqlp = "select *from tbl_menu_permission where user_type_id = '$type' and status = '1'";
						$resultp = $objhr->viewdata($sqlp);
							if($resultp->num_rows > 0){
								while(	$rowsp = $resultp->fetch_assoc()){
									
								$menu_id=$rowsp['menu_id'];
									
 $sqlme = "select *from tbl_menu_mtr where id = '$menu_id' and under_menu_id = '$id' order by menu_order asc";
						$resultme = $objhr->viewdata($sqlme);
							if($resultme->num_rows > 0){
									while($rowsme = $resultme->fetch_assoc()){?>
									    <li><a href="<?php echo $rowsme['file_path']; ?>"><?php echo $rowsme['menu_name']; ?></a></li>
									
																		
								<?php }}}}
									?>
		  	

          </ul>
        </li>
								
								<?php }} ?>
                            
                            </ul>
                        </li>
                    </ul>
                </nav>
                <!-- End Sidebar navigation -->
            </div>
            <!-- End Sidebar scroll-->
        </div>
        <!-- End Left Sidebar  -->