<?php 
   error_reporting(0);
   include("config.php");
   checkLogin();
   $company = "SELECT * FROM `company_mst` WHERE `id` = '".$_SESSION['company_id']."'";
   $com_res = mysqli_query($conn,$company);
   $com_row = mysqli_fetch_array($com_res);

   $branch = "SELECT * FROM `branch_mst` WHERE `id` = '".$_SESSION['branch_id']."'";
   $bra_res = mysqli_query($conn,$branch);
   $bra_row = mysqli_fetch_array($bra_res);
   
   if($_SESSION['branch_id'] != ''){
      $branch_id = $_SESSION['branch_id'];
   }else{
      $branch_id = '';
   }

   if($_SESSION['from_year'] != ''){
      $from_year = $_SESSION['from_year'];
   }else{
      $from_year = '';
   }
   if($_SESSION['to_year'] != ''){
      $to_year = $_SESSION['to_year'];
   }else{
      $to_year = '';
   }

   $url = 'index.php?page=dashboard.php';
?>
<!DOCTYPE html>
<html>
   <head>
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <title>ATTRANS</title>
      <link rel="shortcut icon" type="image/x-icon" href="assets/upload/favicon.png" />
      <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
      <link rel="stylesheet" href="assets/bower_components/bootstrap/dist/css/bootstrap.min.css">
      <link rel="stylesheet" href="assets/bower_components/bootstrap/dist/css/bootstrap.css">
      <link rel="stylesheet" href="assets/bower_components/font-awesome/css/font-awesome.min.css">
      <link rel="stylesheet" href="assets/plugins/Ionicons/css/ionicons.min.css">
      <link rel="stylesheet" href="assets/bower_components/bootstrap-datepicker/dist/css/bootstrap-datepicker.min.css">
      <link rel="stylesheet" href="assets/sweet-alert/sweetalert.css" />
      <link href="assets/bower_components/select2/dist/css/select2.min.css" rel="stylesheet" />
      <link rel="stylesheet" href="assets/dist/css/skins/_all-skins.min.css">
      <link rel="stylesheet" href="assets/dist/css/AdminLTE.css">
      <link rel="stylesheet" href="assets/custome.css">
      <link rel="stylesheet" href="assets/plugins/iCheck/all.css">
      <link rel="stylesheet" href="assets/plugins/jQueryUI/jquery-ui.min.css">
      <link href="assets/plugins/chosen/chosen.min.css" rel="stylesheet" type="text/css" />

      <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,600,700,300italic,400italic,600italic">
      <link rel="stylesheet" href="assets/bower_components/datatables.net-bs/css/dataTables.bootstrap.min.css">

      <link rel="stylesheet" href="assets/print.css" type="text/css" media="print">
      <link rel="stylesheet" href="assets/plugins/bootstrap-toastr/toastr.min.css">

      <script src="assets/jquery-2.2.4.min.js"></script>
      <!-- <script src="assets/plugins/jquery/dist/jquery.min.js"></script> -->
      <script src="assets/bower_components/datatables.net/js/jquery.dataTables.min.js"></script>
      <script src="assets/bower_components/datatables.net-bs/js/dataTables.bootstrap.min.js"></script>
      <script src="assets/plugins/jquery-form/jquery.form.js"></script>
      <script type="text/javascript" src="assets/sweet-alert/sweetalert.min.js"></script>
      <script src="assets/plugins/bootstrap-toastr/toastr.js"></script>
      <script type="text/javascript">
         var http_host = '<?php echo $root;?>index.php';
         var ajax_host = '<?php echo $root;?>';
         $(document).ready( function () {
            $('#table_id').DataTable();
         } );
         $(document).ready(function(){
           $('[data-toggle="tooltip"]').tooltip();   
         });
      </script>
   </head>
   <body class="hold-transition skin-blue layout-top-nav">
      <div class="wrapper">
      <header class="main-header">
         <nav class="navbar navbar-static-top">
            <div class="">
               <div class="navbar-header">
                  <a href="<?php echo $url;?>"><img src="assets/upload/white_logo.png" class="header-logo"></a>
                  <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-collapse">
                  <i class="fa fa-bars"></i>
                  </button>
               </div>
               <div class="collapse navbar-collapse pull-left" id="navbar-collapse">   
                  <ul class="nav navbar-nav">
                        <li class="dropdown">
                           <a href="#" class="dropdown-toggle" data-toggle="dropdown">MASTER <span class="caret"></span></a>
                           <ul class="dropdown-menu" role="menu">
                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'vendor_show') ) { ?>
                              <li><a href="index.php?page=vendor/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> VENDOR</a></li>
                              <?php } ?>

                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'account_show') ) { ?>
                              <li><a href="index.php?page=account_group/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> ACCOUNT GROUP</a></li>
                              <?php } ?>                           

                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'accountm_show') ) { ?>
                              <li><a href="index.php?page=account_mst/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> ACCOUNT</a></li>
                              <?php } ?>

                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'ac_show') ) { ?>
                              <li><a href="index.php?page=account_control/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> ACCOUNTING CONTROL</a></li>
                              <?php } ?>

                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'truck_show') ) { ?>
                              <li><a href="index.php?page=truck_mst/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> TRUCK</a></li>
                              <?php } ?>

                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'driver_show') ) { ?>
                              <li><a href="index.php?page=driver/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> DRIVER</a></li>
                              <?php } ?>

                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'tax_show') ) { ?>
                              <li><a href="index.php?page=tax_mst/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> TAX</a></li>
                              <?php } ?>

                              <?php if($_SESSION['name'] == 'DEVELOPER'){ ?>
                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'company_show') ) { ?>
                              <li><a href="index.php?page=company_mst/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> COMPANY</a></li>
                              <?php } ?>
                              
                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'branch_show') ) { ?>
                              <li><a href="index.php?page=branch_mst/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> BRANCH</a></li>
                              <?php } ?>
                              
                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'doc_show') ) { ?>
                              <li><a href="index.php?page=document_mst/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> DOCUMENT</a></li>
                              <?php } ?>

                              <?php } ?>
                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'emp_show') ) { ?>
                              <li><a href="index.php?page=emp_mst/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> EMPLOYEE</a></li>
                              <?php } ?>

                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'maintance_type_show') ) { ?>
                              <li><a href="index.php?page=maintance_type/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> MAINTANCE TYPE</a></li>
                              <?php } ?>
                           </ul>
                        </li>
                        
                        <li class="dropdown">
                           <a href="#" class="dropdown-toggle" data-toggle="dropdown">TRANSACTION <span class="caret"></span></a>
                           <ul class="dropdown-menu" role="menu">
                             
                                 <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'lr_show') ) { ?>
                                 <li><a href="index.php?page=lr/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> LR</a></li>
                                 <?php } ?>

                                 <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'lro_show') ) { ?>
                                 <li><a href="index.php?page=lr_opeing/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> LR OPENING</a></li>
                                 <?php } ?>

                                 <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'lhc_show') ) { ?>
                                 <li><a href="index.php?page=lhc/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> LHC</a></li>
                                 <?php } ?>
                                    
                                    
                                 <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'lhc_balance_payment_show') ) { ?>
                                 <li><a href="index.php?page=lhc_balance_payment/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> LHC PAYMENT</a></li>
                                 <?php } ?>

                                 
                                 <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'bill_show') ) { ?>
                                 <li><a href="index.php?page=bill/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> BILL</a></li>
                                 <?php } ?>

                                 <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'mr_show') ) { ?>
                                 <li><a href="index.php?page=mr/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> MR</a></li>
                                 <?php } ?>
                                 
                                 <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'commission_show') ) { ?>
                                 <li><a href="index.php?page=commission_Flag/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> COMMISSION FLAG</a></li>
                                 <?php } ?>
                                 

                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'bank_receipt_show') ) { ?>
                              <li><a href="index.php?page=bank_receipt/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> BANK RECEIPT</a></li>
                              <?php } ?>

                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'bank_payment_show') ) { ?>
                              <li><a href="index.php?page=bank_payment/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> BANK PAYMENT</a></li>
                              <?php } ?>

                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'cash_receipt_show') ) { ?>
                              <li><a href="index.php?page=cash_receipt/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> CASH RECEIPT</a></li>
                              <?php } ?>

                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'cash_payment_show') ) { ?>
                              <li><a href="index.php?page=cash_payment/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> CASH PAYMENT</a></li>
                              <?php } ?>

                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'ob_show') ) { ?>
                              <li><a href="index.php?page=opening_balance/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> OPENING BALANCE</a></li>
                              <?php } ?>

                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'jv_show') ) { ?>
                              <li><a href="index.php?page=journal_voucher/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> JOURNAL VOUCHER</a></li>
                              <?php } ?>

                              
                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'tr_show') ) { ?>
                              <li><a href="index.php?page=tracking/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> TRACKING</a></li>
                              <?php } ?>
                              
                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'general_purchase_show') ) { ?>
                              <li><a href="index.php?page=general_purchase/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> GENERAL PURCHASE</a></li>
                              <?php } ?>

                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'general_sales_show') ) { ?>
                              <li><a href="index.php?page=general_sales/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> GENERAL SALES</a></li>
                              <?php } ?>
                              
                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'credit_note_show') ) { ?>
                              <li><a href="index.php?page=credit_note/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> CREDIT NOTE</a></li>
                              <?php } ?>

                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'debit_note_show') ) { ?>
                              <li><a href="index.php?page=debit_note/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> DEBIT NOTE</a></li>
                              <?php } ?>
                              
                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'trip_list') ) { ?>
                        <li><a href="index.php?page=trip/list.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> TRIP</a></li>
                        <?php } ?>
                        
                           </ul>
                        </li>
                        <li class="dropdown">
                           <a href="#" class="dropdown-toggle" data-toggle="dropdown">REPORT <span class="caret"></span></a>
                           <ul class="dropdown-menu" role="menu">
                              
                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'lr_query_show') ) { ?>
                              <li><a href="index.php?page=report/lr_query.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> LR QUERY</a></li>
                              <?php } ?>
                              
                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'general_ledger_show') ) { ?>
                              <li><a href="index.php?page=report/general_ledger.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> GENERAL LEDGER</a></li>
                              <?php } ?>

                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'booking_register_show') ) { ?>
                              <li><a href="index.php?page=report/booking_register.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i>BOOKING REGISTER</a></li>
                              <?php } ?>

                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'booking_register_show') ) { ?>
                              <li><a href="index.php?page=report/pending_pod_register.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i>PENDING POD REGISTER</a></li>
                              <?php } ?>

                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'pending_lr_for_lhc_show') ) { ?>
                              <li><a href="index.php?page=report/pending_lr_for_lhc.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i>PENDING LR FOR LHC</a></li>
                              <?php } ?>

                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'pending_lr_for_billing_show') ) { ?>
                              <li><a href="index.php?page=report/pending_lr_for_billing.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i>PENDING LR FOR BILLING</a></li>
                              <?php } ?>

                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'billing_register_show') ) { ?>
                              <li><a href="index.php?page=report/billing_register.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i>BILLING REGISTER</a></li>
                              <?php } ?>

                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'billing_summery_show') ) { ?>
                              <li><a href="index.php?page=report/billing_summery.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> BILLING SUMMERY</a></li>
                              <?php } ?>

                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'lhc_register_show') ) { ?>
                              <li><a href="index.php?page=report/lhc_register.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> LHC REGISTER</a></li>
                              <?php } ?>

                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'pending_lhc_register_show') ) { ?>
                              <li><a href="index.php?page=report/pending_lhc_register.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> PENDING LHC REGISTER</a></li>
                              <?php } ?>
                              
                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'tds_payable_show') ) { ?>
                              <li><a href="index.php?page=report/tds_payable.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> TDS PAYABLE</a></li>
                              <?php } ?>
                              
                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'tds_receivable_show') ) { ?>
                              <li><a href="index.php?page=report/tds_receivable.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> TDS RECEIVABLE</a></li>
                              <?php } ?>

                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'pending_lhc_balance_payment_show') ) { ?>
                              <li><a href="index.php?page=report/pending_lhc_balance_payment.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i>PENDING LHC FOR BALANCE PAYMENT</a></li>
                              <?php } ?>

                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'mr_register_show') ) { ?>
                              <li><a href="index.php?page=report/mr_register.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> MR REGISTER</a></li>
                              <?php } ?>

                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'outstanding_report_show') ) { ?>
                              <li><a href="index.php?page=report/outstanding_report.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> OUTSTANDING REPORT</a></li>
                              <?php } ?>

                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'tracking_report_show') ) { ?>
                              <li><a href="index.php?page=report/tracking_report.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> TRACKING REPORT</a></li>
                              <?php } ?>

                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'gst_register_show') ) { ?>
                              <li><a href="index.php?page=report/gst_register.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i>GST REGISTER</a></li>
                              <?php } ?>
                              
                              <?php if( hasPermission($_SESSION['user_detail']['role_id'], 'trip_wise_show') ) { ?>
                              <li><a href="index.php?page=report/trip_wise_profit/trip_wise_profit.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i>TRIP WISE PROFIT</a></li>
                              <?php } ?>
                           </ul>
                        </li>
                        <li>
                           <a href="index.php?page=phone_book/add.php" aria-expanded="false">PHONE BOOK</a>
                        </li>
                        <?php if($backup_type == 1){?>
                        <li class="dropdown">
                           <a href="#" class="dropdown-toggle" data-toggle="dropdown">UTILITY <span class="caret"></span></a>
                              <ul class="dropdown-menu" role="menu">
                                 <li><a href="index.php?page=common/backup.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> BACKUP</a></li>
                              </ul>
                        </li>
                        <?php } ?>
                        <?php 
                        if($_SESSION['name'] == 'DEVELOPER'){ ?>
                           <li class="dropdown">
                              <a href="#" class="dropdown-toggle" data-toggle="dropdown">SETTINGS <span class="caret"></span></a>
                              <ul class="dropdown-menu" role="menu">
                                 <li><a href="index.php?page=user_management/grid.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> USER MANAGEMENT</a></li>
                                 <li><a href="index.php?page=role_management/grid.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> ROLE MANAGEMENT</a></li>

                                 <li><a href="index.php?page=common/report_setting.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> REPORT SETTING</a></li>

                                 <li><a href="index.php?page=common/general_setting.php"><i class="fa fa-hand-o-right" aria-hidden="true"></i> GENERAL SETTING</a></li>

                              

                              </ul>
                           </li>
                        <?php } ?>
                     </ul>
               </div>
               <div class="navbar-custom-menu">
                  <ul class="nav navbar-nav">
                     <li class="messages-menu">
                        <a href="<?php echo $root;?>get_financial_year_modal.php" class="hidden-print" data-toggle="modal" id="trigger-year-modal" data-target="#emptymodal"><i class="fa fa-toggle-on"></i></a>
                     </li>
                     <li class="dropdown">
                        <a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false"><span class="hidden-xs">WELCOME : <?php echo $_SESSION['name'];?></span> <span class="caret"></span></a>
                        <ul class="dropdown-menu header-setting" role="menu">
                           <li><a href="index.php?page=user_management/user-profile.php" class="capital"><i class="fa fa-user" aria-hidden="true"></i> MY Profile</a></li>

                           <li><a href="index.php?page=user_management/change-password.php" class="capital"><i class="fa fa-key" aria-hidden="true"></i> CHANGE PASSWORD</a></li>
                           
                           <li><a href="index.php?page=logout.php" class="capital"><i class="fa fa-sign-out" aria-hidden="true"></i> LOGOUT</a></li>
                        </ul>
                     </li>
                     
                  </ul>
               </div>
            </div>
         </nav>
      </header>