<?php  include_once('config/db.php'); 
       include_once('config/homecheck.php'); 

          // if ( $_POST['storeid'] == "")
          //   {
                $_SESSION['storeid'] =  1 ; 
                $_SESSION['guard']   =  1 ;
            // }
            // else
            // {

                 $_SESSION['storeid'] =   $Abranch ; //$_POST['storeid'] ;
                 $_SESSION['guard'] =    1 ;  //$_POST['guard'] ;
            // }
        
          $storeID = $_SESSION['storeid'];
          $storeGD = $_SESSION['guard'];
     
        
         if ( $_SESSION['storeid'] ==''){

            header("location:dashboard.php");
         }
       //  echo  $_SESSION['storeid'] ;

           $Analytics = $conn->prepare("  SELECT a.id,menu,p.id pid,p.name pname,p.icon picon,p.url purl,p.active pactive,p.displayno pdisplayno,
                                        R.role Rrole,h.dashboard hdashboard,h.name,u.id myuid FROM sys_module a
                                        join sys_page p ON a.id=p.module
                                        JOIN sys_rights R ON p.id=R.page
                                        JOIN sys_roles   h ON R.role=h.id
                                        JOIN sys_user u ON R.role=u.role
                                        WHERE menu=1 AND   p.active=1  AND u.id=1
                                  ");
           $Analytics->execute(); 
           $Activetabs = $Analytics->fetchAll(); 

     
?>
<!DOCTYPE html>

<html>
<head>
  <?php include('inc/link.php');   ?> 
</head>
<body class="hold-transition skin-black sidebar-mini">
<div class="wrapper"  >

  <!-- Main Header -->
    <header class="main-header">

    <!-- Logo -->
     <?php include_once('inc/brand.php');   ?>    

    <!-- Header Navbar -->
      <?php include_once('inc/navbar.php');   ?>
    
  </header>
  
  <!-- Left side column. contains the logo and sidebar -->
  <aside class="main-sidebar ">

    <!-- sidebar: style can be found in sidebar.less -->
    <?php  include_once('inc/shome.php');   ?>
   
    <!-- /.sidebar -->
  </aside>

<!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper" style="background-color:aliceblue;" >
     
    <section class="content-header  ">
      <h4 class="" style="color:lightblack;font-weight:700; font-size:20px; font-family:Arial, Helvetica, sans-serif ">
          Welcome back <?php echo "$fname".' '."$lname".''.","; ?> 
      </h4> 
      <!-- <p style="color:green;font-size:16px;"> Here's what's happening with your dashboard today. </p> -->
    </section> 

  
    <!-- <section class="content" style="padding-top: 10px;" ></section> -->
          <section class="content container-fluid"   > 
            
            <!-- Start Tabs -->
            <!-- <h2 class="page-header text-centre"> <i class="fa fa-dashboard"></i>Dashboard</h2> -->
        
              
              <div class="nav-tabs-custom"   >
                                <ul class="nav nav-tabs"   >
                                <?php foreach($Activetabs  as $Atab){  ?>
                                    
                                      <?php if($Atab["pid"] == $Atab["hdashboard"]){ ?>
                                        <li class="active" ><a href="#<?php echo $Atab["pid"]  ?>" data-toggle="tab"> <?php echo $Atab["picon"] .' '. $Atab["pname"]  ?> </a></li>
                                              
                    
                                    <?php }else{ ?>
                                      <!-- <li><a style=""  href="#<?php echo $Atab["pid"]  ?>" data-toggle="tab"> <?php echo $Atab["picon"] .' '. $Atab["pname"]  ?> </a></li> -->
                                                            
                                    <?php } ?>
                                <?php } ?>

                                </ul>
                              
                                <div class="tab-content" style=""  >
                                  <?php foreach($Activetabs  as $Atab ){ $A = $Atab["pid"]  ?>
                                      <?php if($Atab["pid"] == $Atab["hdashboard"]){ ?>

                                        <div id="<?php echo $Atab["pid"]; ?>" class="tab-pane fade in active"   >
                                        
                                        <?php  
                                                             if ($A==312)     { include_once('zdash/sadmin.php'); }
                                                             elseif ($A==313) { include_once('zdash/zadmin'); }
                                                             elseif ($A==314) { include_once('zdash/zmanager');  }
                                                             elseif ($A==315) { include_once('zdash/zprocurement');}
                                                             elseif ($A==316) { include_once('zdash/zcredit.php');}
                                                           // elseif ($A==313) { include_once('zafosa.php'); }
                                                          //  elseif ($A==314) { include_once('zaloan.php');  }
                                                           // elseif ($A==315) { include_once('zainventory.php');}
                                                           // elseif ($A==316) { include_once('zahr.php');}
                                                            // elseif ($A==317) {include_once('zapayroll.php');}
                                                            // elseif ($A==318) {include_once('zproduction.php');}
                                                            // elseif ($A==319) {include_once('zpackaging.php');}
                                                            // elseif ($A==320) {include_once('zsystem.php');}
                                                            else  {include_once('zdash//sall.php');}
                                                            ;
                                                            
                                                            ?>
                                              </div>
                                          
                                      <?php }else{ ?>

                                              <div id="<?php echo $Atab["pid"]; ?>" class="tab-pane fade in" style="background-color:aliceblue;"  >
                                                    <?php  
                                                             if ($A==312)     { include_once('zdash/sadmin'); }
                                                             elseif ($A==313) { include_once('zdash/zadmin'); }
                                                             elseif ($A==314) { include_once('zdash/zmanager');  }
                                                             elseif ($A==315) { include_once('zdash/zprocurement');}
                                                             elseif ($A==316) { include_once('zdash/zcredit.php');}
                                                            // elseif ($A==317) {include_once('zapayroll.php');}
                                                            // elseif ($A==318) {include_once('zproduction.php');}
                                                            // elseif ($A==319) {include_once('zpackaging.php');}
                                                            // elseif ($A==320) {include_once('zsystem.php');}
                                                            else  {include_once('zdash/sall.php');}
                                                            ;
                                                            
                                                            ?>
                                                  
                                              </div>
                                      <?php } ?>
                                  <?php } ?>   
                                </div>

              </div>
            <!-- Start Tabs -->  
            
            
      </section>

     </div>
    <!-- /.content-wrapper -->



  <!-- Main Footer -->
  <footer class="main-footer">
    <!-- To the right -->
     <?php  include_once('inc/footer.php'); ?>
  </footer>

</div>

<!-- REQUIRED JS SCRIPTS -->

<?php include('inc/linkjs.php') ?>
<?php include('inc/linkjs3.php') ?>


 <script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
    
</body>
</html>

<?php include('zdash/load.php') ?>



  