<?php include('common/header.php'); ?>
  <!-- Main Sidebar Container -->
<?php include('common/sidenav.php'); ?>

  <!-- Content Wrapper. Contains page content -->
  <div class="content-wrapper">
    <!-- Content Header (Page header) -->
    <div class="content-header">
      <div class="container-fluid">
        <div class="row mb-2">
          <div class="col-sm-6">
            <h1 class="m-0 text-dark">Dashboard</h1>
          </div><!-- /.col -->
          <div class="col-sm-6">
            <ol class="breadcrumb float-sm-right">
            <!--  <li class="breadcrumb-item"><a href="#">Home</a></li>-->
              <li class="breadcrumb-item active">Dashboard</li>
            </ol>
          </div><!-- /.col -->
        </div><!-- /.row -->
      </div><!-- /.container-fluid -->
    </div>
    <!-- /.content-header -->

    <!-- Main content -->
    <section class="content">
      <div class="container-fluid">
          
        <!-- Small boxes (Stat box) -->
        <?php $role =  $_SESSION['sess_role'];  ?>
        <?php  if($role =='Admin') {?>
        <div class="row">
        
                   <div class="col-lg-4 col-6">
            <!-- small box -->
           <?php
       include('includes/config.php');
          
          
  $no=0;
  $result = mysqli_query($con, "SELECT COUNT(vehicle_id) as vehicle FROM vehicles");
   while($row = mysqli_fetch_assoc($result)) {
   $no++  
        
      ?>
            <div class="small-box bg-danger">
              <div class="inner">
                <h3><?php echo $row['vehicle']; ?></h3>

                <p>Vehicle</p>
              </div>
             <?php } ?>
              <div class="icon">
                <i class="fas fa-truck"></i>
              </div>
              <a href="vehicle.php" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
            </div>
          </div>
           
            
            
            
            
            
            <div class="col-lg-4 col-6">
            <!-- small box -->
           <?php
       include('includes/config.php');
          
          
  $no=0;
  $result = mysqli_query($con, "SELECT COUNT(v_id) as vendor FROM vendors");
   while($row = mysqli_fetch_assoc($result)) {
   $no++     
        
      ?>
            <div class="small-box bg-danger">
              <div class="inner">
                <h3><?php echo $row['vendor']; ?></h3>

                <p>Vendors</p>
              </div>
             <?php } ?>
              <div class="icon">
                <i class="fa fa-industry"></i>
              </div>
              <a href="vendor.php" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
            </div>
          </div>
          
        
       
          <!-- ./col -->
             <div class="col-lg-4 col-6">
            <!-- small box -->
           <?php
       include('includes/config.php');
          
          
  $no=0;
  $result = mysqli_query($con, "SELECT COUNT(m_id) as material FROM materials");
   while($row = mysqli_fetch_assoc($result)) {
   $no++    
        
      ?>
            <div class="small-box bg-danger">
              <div class="inner">
                <h3><?php echo $row['material']; ?></h3>

                <p>Materials</p>
              </div>
             <?php } ?>
              <div class="icon">
                <i class="fa fa-tree"></i>
              </div>
              <a href="material.php" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
            </div>
          </div>
   
          <!-- ./col -->
         
        </div>
        <!-- /.row -->
            
          
          
          <!-- sec row -->
          <div class="row">
                 
            <div class="col-lg-4 col-6">
            <!-- small box -->
           <?php
       include('includes/config.php');
          
          
  $no=0;
  $result = mysqli_query($con, "SELECT COUNT(sh_id) as totalship FROM shipment where s_status!=2");
   while($row = mysqli_fetch_assoc($result)) {
   $no++     
        
      ?>
            <div class="small-box bg-danger">
              <div class="inner">
                <h3><?php echo $row['totalship']; ?></h3>

                <p>Shipment</p>
              </div>
             <?php } ?>
              <div class="icon">
                <i class="fas fa-shopping-cart"></i>
              </div>
              <a href="shipment.php" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
            </div>
          </div>
          <!-- ./col -->
          
          
            <div class="col-lg-4 col-6">
            <!-- small box -->
           <?php
       include('includes/config.php');
          
          
  $no=0;
  $result = mysqli_query($con, "SELECT COUNT(sh_id) as totalship FROM shipment WHERE s_status ='0'");
   while($row = mysqli_fetch_assoc($result)) {
   $no++     
        
      ?>
            <div class="small-box bg-danger">
              <div class="inner">
                <h3><?php echo $row['totalship']; ?></h3>

                <p>Pending Shipment</p>
              </div>
             <?php } ?>
              <div class="icon">
                <i class="fas fa-shopping-cart"></i>
              </div>
              <a href="shipment.php" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
            </div>
          </div>
          <!-- ./col -->
          
          
            <div class="col-lg-4 col-6">
            <!-- small box -->
           <?php
       include('includes/config.php');
          
          
  $no=0;
  $result = mysqli_query($con, "SELECT COUNT(sh_id) as totalship FROM shipment WHERE  s_status='1'");
   while($row = mysqli_fetch_assoc($result)) {
   $no++     
        
      ?>
            <div class="small-box bg-danger">
              <div class="inner">
                <h3><?php echo $row['totalship']; ?></h3>

                <p>Delivered Shipment</p>
              </div>
             <?php } ?>
              <div class="icon">
                <i class="fas fa-shopping-cart"></i>
              </div>
              <a href="shipment.php" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
            </div>
          </div>
          <!-- ./col -->
          
              
          </div>
          <!-- end admin check -->
            <?php } ?>
        
        <!-- end sec row -->
        
        
        <!-- User Dashboard -->
         <!-- sec row -->
         <?php $username = $_SESSION['sess_user_id'];  $user = $_SESSION['sess_user']; ?>
         <?php if($role =='User') { ?>
          <div class="row">
                 
            <div class="col-lg-4 col-6">
            <!-- small box -->
           <?php
       include('includes/config.php');
          
          
  $no=0;
  $result = mysqli_query($con, "SELECT COUNT(sh_id) as totalship FROM shipment Where user_id='$user' AND s_status!=2");
   while($row = mysqli_fetch_assoc($result)) {
   $no++     
        
      ?>
            <div class="small-box bg-danger">
              <div class="inner">
                <h3><?php echo $row['totalship']; ?></h3>

                <p>Shipment</p>
              </div>
             <?php } ?>
              <div class="icon">
                <i class="fas fa-shopping-cart"></i>
              </div>
              <a href="shipment.php" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
            </div>
          </div>
          <!-- ./col -->
          
          
            <div class="col-lg-4 col-6">
            <!-- small box -->
           <?php
       include('includes/config.php');
          
          
  $no=0;
  $result = mysqli_query($con, "SELECT COUNT(sh_id) as totalship FROM shipment WHERE  user_id='$user' AND s_status ='0'");
   while($row = mysqli_fetch_assoc($result)) {
   $no++     
        
      ?>
            <div class="small-box bg-danger">
              <div class="inner">
                <h3><?php echo $row['totalship']; ?></h3>

                <p>Pending Shipment</p>
              </div>
             <?php } ?>
              <div class="icon">
                <i class="fas fa-shopping-cart"></i>
              </div>
              <a href="shipment.php" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
            </div>
          </div>
          <!-- ./col -->
          
          
            <div class="col-lg-4 col-6">
            <!-- small box -->
           <?php
       include('includes/config.php');
          
          
  $no=0;
  $result = mysqli_query($con, "SELECT COUNT(sh_id) as totalship FROM shipment WHERE  user_id='$user' AND s_status ='1' ");
   while($row = mysqli_fetch_assoc($result)) {
   $no++     
        
      ?>
            <div class="small-box bg-danger">
              <div class="inner">
                <h3><?php echo $row['totalship']; ?></h3>

                <p>Delivered Shipment</p>
              </div>
             <?php } ?>
              <div class="icon">
                <i class="fas fa-shopping-cart"></i>
              </div>
              <a href="shipment.php" class="small-box-footer">More info <i class="fas fa-arrow-circle-right"></i></a>
            </div>
          </div>
          <!-- ./col -->
          
              
          </div>
        
        <?php }
         ?>
        <!-- User Dasboard -->
        
   
          <!-- ./col -->
        </div>
  
        
        
        <!-- Main row -->
     
        <!-- /.row (main row) -->
      </div><!-- /.container-fluid -->
    </section>
    <!-- /.content -->
  </div>
  <!-- /.content-wrapper -->


<?php include('common/footer.php'); ?>