<?php
if(basename($_SERVER['PHP_SELF']) == 'status.php') 
  $nv=" class='current'";
include'header.php';
$custo='';
$pr=0;


    if(isset($_POST['search']))
		{
			$custo=$_POST['custo'];
		}
		
		
		if($custo)
			$conde="AND (`Plate` LIKE '%$custo%')";
   
        ?>


<script>
$(document).ready(function() {
$('input[type="checkbox"]').change(function(){
var total_checked=  $("input[type='checkbox']:checked").length 
$("#d1").html("Selected Vehicles: <b> " + total_checked );
});
/////////////
var total_checked=  $("input[type='checkbox']:checked").length 
$("#d1").html("Selected Vehicles: <b> " + total_checked );
///////
});


   function check_uncheck_checkbox(isChecked) {
	if(isChecked) {
		$('input[type="checkbox"]').each(function() { 
			this.checked = true; 
		});
	} else {
		$('input[type="checkbox"]').each(function() {
			this.checked = false;
		});
	}
}	
</script>

<div class="container-fluid main-content">
        <div class="page-title hidden-xs hidden-print">
          <h2 style='margin-top:-20px; margin-bottom: 5px; color:#ffcc33'>
         Vehicles
          </h2>
                 </div>
     
        <div class="row">
  <div class="col-lg-2 hidden-print">
   
   <ul class="list-group">

	   <li class="list-group-item active">
              <a href="locate.php">
                <p>
                <i class="lnr lnr-menu-circle"></i>&nbsp;Allocated Vehicles
                </p>
              </a></li> 
                  
			  <li class="list-group-item">
              <a href="ment.php">
                <p>
                <i class="lnr lnr-plus-circle"></i>&nbsp;Repair & Services
                </p>
              </a></li>

    <li class="list-group-item">
	  <a href="mainsto.php">
                <p>
                <i class="lnr lnr-menu-circle"></i>&nbsp;List of Vehicles
                </p>
              </a></li>
                       
            </ul><br><br>

			<li class="list-group-item" style="border:1px dashed #cccccc; border-radius:5px; margin:0px 0px 4px 0px;">
	  <a href="createa.php">
                <p>
                <i class="lnr lnr-plus-circle"></i>&nbsp;Create Customers
                </p>
              </a></li>	
              
            <li class="list-group-item" style="border:1px dashed #cccccc; border-radius:5px; margin:0px 0px 4px 0px;">
	  <a href="dispatch.php">
                <p>
                <i class="lnr lnr-plus-circle"></i>&nbsp;Create Vehicle Trip
                </p>
              </a></li>	
              
            <li class="list-group-item" style="border:1px dashed #cccccc; border-radius:5px; margin:0px 0px 4px 0px;">
	  <a href="addinco.php">
                <p>
                <i class="lnr lnr-plus-circle"></i>&nbsp;Additional Services
                </p>
              </a></li>	  
			 
                <?php
              if($_SESSION['Cpo']){
                  ?>
			  <li class="list-group-item" style="border:1px dashed #cccccc; border-radius:5px; margin:0px 0px 4px 0px;">
              <a href="purcha.php">
                <p>
                <i class="lnr lnr-plus-circle"></i>&nbsp;Purchase Orders
                </p>
              </a></li>
              <?php
              }
              if($_SESSION['Cpi']){
                  ?>
            <li class="list-group-item" style="border:1px dashed #cccccc; border-radius:5px; margin:0px 0px 4px 0px;">
	  <a href="profo.php">
                <p>
                <i class="lnr lnr-plus-circle"></i>&nbsp;Create Proforma
                </p>
              </a></li>	
              <?php
              }
              ?>
              
            <li class="list-group-item" style="border:1px dashed #cccccc; border-radius:5px; margin:0px 0px 4px 0px;">
	  <a href="payslip.php">
                <p>
                <i class="lnr lnr-plus-circle"></i>&nbsp;Payment Vouchers
                </p>
              </a></li>	
              
            <li class="list-group-item" style="border:1px dashed #cccccc; border-radius:5px; margin:0px 0px 4px 0px;">
	  <a href="conterepo.php">
                <p>
                <i class="lnr lnr-plus-circle"></i>&nbsp;Container Dispatch
                </p>
              </a></li>	
              
            <li class="list-group-item" style="border:1px dashed #cccccc; border-radius:5px; margin:0px 0px 4px 0px;">
	  <a href="ddlist.php">
                <p>
                <i class="lnr lnr-plus-circle"></i>&nbsp;Mileage Deduction
                </p>
              </a></li>	
  </div>
                    
          
       
        <div class="col-lg-10">
    <div class="row"><div class="col-lg-4" style="margin-left:40px;">
           
         <form action="tmile.php" method="post" class="form-horizontal" enctype="multipart/form-data" name='myform'> 
           <div class="col-lg-4 hidden-print"> <button class="btn btn-info btn-block" type="submit"> Trip Report </button> </div></form> 
           
         <form action="milerepo.php" method="post" class="form-horizontal" enctype="multipart/form-data" name='myform'> 
           <div class="col-lg-4 hidden-print"> <button class="btn btn-success btn-block" type="submit"> Mileage Report </button> </div></form> 
						
           <form action="status.php" method="post" class="form-horizontal" enctype="multipart/form-data" name='myform'> 
           <div class="col-lg-4 hidden-print"> <button class="btn btn-warning btn-block" type="submit"> Status Report </button> </div></form> 
						
        </div>  
           
            
        <div class="col-lg-7">   
           <div class="col-lg-4"> </div>
           

        <form action="" method="post" class="form-horizontal ">                  
                       
            <div class="col-lg-5 hidden-xs hidden-print"> 
      <input class="form-control"  name="custo" type="text" id="searchu" autofocus="autofocus">
			</div>                      
                       
                       <div class="col-lg-3 hidden-xs hidden-print">
                        <button class="btn  btn-primary btn-block" type="submit" name="search"><i class="lnr lnr-magnifier"></i> Search</button>
                   
					  </div>
                         
                      
                     
                  
            </form> </div>
             
               
            </div>
             <div class="row">
            <div class="col-lg-12" style='margin-top:-20px;'>
             <span> &nbsp;&nbsp; </span>
             <?php
             if($pr){
                 echo"<span class='pull-right text-right'>
             <a href='#' onclick='return window.print()' class='hidden-print' title='Print' data-toggle='tooltip' data-placement='top'><i class='lnr lnr-printer'></i></a>&nbsp;&nbsp;&nbsp;</span>";
             }
             ?>
            <div class="widget-container fluid-height clearfix">
            <div class="widget-content padded clearfix">
               
                                
					<?php
		    	$stl="style='font-size:10px; padding:1px; text-align:center;'";
		    	    $all=0;
					
		// *********************** Garage ****************************
		
	$do=mysqli_query($conn, "SELECT *FROM `vehicles` WHERE `Status`='0' AND `Locate`='GARAGE' AND `Trip`='1' $conde ORDER BY `Number` ASC LIMIT 1000");
	        if($fo=mysqli_num_rows($do)){
            echo"<div class='panel panel-default' style='border:1px solid powderblue;'><form action='' method='post'>
			<div class='panel-heading' style='background-color:powderblue; padding-left:30px; font-weight:bold; font-size:12px;'> GARAGE &nbsp;&nbsp; [$fo VEHICLE(S)] <input type='hidden' name='loko' value='$loke'>
			
	<button type='submit' name='openi' class='btn btn-xs btn-success pull-right hidden-print' style='height:16px; padding:1px 10px 1px 10px; margin:0px; margin-right:30px; font-size:10px;'><i class='lnr lnr-download'></i> OPEN </button></div></form>";
		
		
			echo"<div class='panel-body' style='padding:0px;'>
			 <table class='table table-striped table-hover'>     
                <tr role='row'><th $stl class='hidden-xs'> No </th>
                        <th $stl><div align='center'> DATE </th>
                        <th $stl><div align='center'> TRUCK&nbsp;ID </th>
                        <th $stl><div align='center'> TRAILER&nbsp;ID </th>
                       <th $stl><div align='center'> MAKE </th>
                       <th $stl><div align='center'> CHASSIS TRUCK </th>
					   <th $stl><div align='center'> DRIVER'S NAME </th>
					   <th $stl><div align='center'> DRIVING LICENSE </th>
						<th $stl><div align='center'> PC/LP </th>
						 <th $stl><div align='center'> TELEPHONE </th>
                     </tr><tbody>";
	
	            $n=1;				$to=0;
		while($ro=mysqli_fetch_assoc($do)){
			$code=$ro['Number'];
			$make=$ro['Make'];
			$mode=$ro['Chassis1'];
			$chassis=$ro['Chassis2'];
			$year=$ro['Year'];

			$fuel=$ro['Fuel'];
			$vid=$ro['Plate'];
			$source=$ro['Driver'];
			$tre=$ro['Trailer'];
			$all++;
			
		$sete=mysqli_query($conn, "SELECT `Idno`, `Contact1`, `Contact2` FROM `employees` WHERE `Fullname`='$source' AND `Fullname`!='' ORDER BY `Eid` DESC LIMIT 1");
		    if($fete=mysqli_num_rows($sete)){
			    $rete=mysqli_fetch_assoc($sete);
			        $tle=$rete['Contact1'];
			        $pcl=$rete['Contact2'];
			        $idno=$rete['Idno'];
		    }
		    else
		        $tle=$pcl=$idno="";
		        
	$seted=mysqli_query($conn, "SELECT `Date` FROM `trage` WHERE `Plate`='$vid' AND `Descri` LIKE '%Added vehicle to GARAGE%' ORDER BY `Number` DESC LIMIT 1");
			    $reted=mysqli_fetch_assoc($seted);
			        $date=$reted['Date'];
	

                if(!$tle OR !$pcl OR !$idno)
					$stn="style='padding:0px; font-size:11px; color:blue;'";
				else
					$stn="style='padding:0px; font-size:11px;'";
		 
		print("<tr><td class='hidden-xs' $stn><div align='right'>$n&nbsp;&nbsp;</td><td $stn><div align='center'> $date </td><td $stn><div align='center'> $vid </td><td $stn><div align='center'> $tre </td><td $stn> $make </td><td $stn> $mode </td><td $stn> $source </td>
			  <td class='text-center' $stn> $idno </td>
			  <td $stn><div align='left'> $pcl </td>
		<td $stn><div align='right'> $tle &nbsp;</td></tr>");
							$n++;                   $b++;
						}
			echo" </tbody>
                  </table>
        <div class='clearfix'></div>
            </div>
                
        </div>";
	        }
        
        
        
        // *********************** ALLOCATED **************************
		
	$do=mysqli_query($conn, "SELECT *FROM `vehicles` WHERE `Status`='0' AND `Locate`='ALLOCATED' AND `Trip`='1' $conde ORDER BY `Number` ASC LIMIT 1000");
	        if($fo=mysqli_num_rows($do)){
            echo"<div class='panel panel-default' style='border:1px solid powderblue;'><form action='' method='post'>
			<div class='panel-heading' style='background-color:powderblue; padding-left:30px; font-weight:bold; font-size:12px;'> ALLOCATED &nbsp;&nbsp; [$fo VEHICLE(S)] <input type='hidden' name='loko' value='$loke'>
			
	<button type='submit' name='openi' class='btn btn-xs btn-success pull-right hidden-print' style='height:15px; padding:1px 10px 1px 10px; margin:0px; margin-right:30px; font-size:10px;'><i class='lnr lnr-download'></i> OPEN </button></div></form>";
		
		
			echo"<div class='panel-body' style='padding:0px;'>
			 <table class='table table-striped table-hover'>    
                <tr role='row'><th $stl class='hidden-xs'> No </th>
                        <th $stl><div align='center'> DATE </th>
                        <th $stl><div align='center'> TRUCK&nbsp;ID </th>
                        <th $stl><div align='center'> TRAILER&nbsp;ID </th>
                       <th $stl><div align='center'> MAKE </th>
                       <th $stl><div align='center'> CHASSIS TRUCK </th>
					   <th $stl><div align='center'> DRIVER'S NAME </th>
					   <th $stl><div align='center'> DRIVING LICENSE </th>
						<th $stl><div align='center'> PC/LP </th>
						 <th $stl><div align='center'> TELEPHONE </th>
                     </tr><tbody>";
	
	            $n=1;				$to=0;
		while($ro=mysqli_fetch_assoc($do)){
			$code=$ro['Number'];
			$make=$ro['Make'];
			$mode=$ro['Chassis1'];
			$chassis=$ro['Chassis2'];
			$year=$ro['Year'];

			$fuel=$ro['Fuel'];
			$vid=$ro['Plate'];
			$source=$ro['Driver'];
			$tre=$ro['Trailer'];
			$all++;
			
		$sete=mysqli_query($conn, "SELECT `Idno`, `Contact1`, `Contact2` FROM `employees` WHERE `Fullname`='$source' AND `Fullname`!='' ORDER BY `Eid` DESC LIMIT 1");
		    if($fete=mysqli_num_rows($sete)){
			    $rete=mysqli_fetch_assoc($sete);
			        $tle=$rete['Contact1'];
			        $pcl=$rete['Contact2'];
			        $idno=$rete['Idno'];
		    }
		    else
		        $tle=$pcl=$idno="";
		        
	$seted=mysqli_query($conn, "SELECT `Date` FROM `trage` WHERE `Plate`='$vid' AND `Descri` LIKE '%Added vehicle to GARAGE%' ORDER BY `Number` DESC LIMIT 1");
			    $reted=mysqli_fetch_assoc($seted);
			        $date=$reted['Date'];
	

                if(!$tle OR !$pcl OR !$idno)
					$stn="style='padding:0px; font-size:11px; color:blue;'";
				else
					$stn="style='padding:0px; font-size:11px;'";
		 
		print("<tr><td class='hidden-xs' $stn><div align='right'>$n&nbsp;&nbsp;</td><td $stn><div align='center'> $date </td><td $stn><div align='center'> $vid </td><td $stn><div align='center'> $tre </td><td $stn> $make </td><td $stn> $mode </td><td $stn> $source </td>
			  <td class='text-center' $stn> $idno </td>
			  <td $stn><div align='left'> $pcl </td>
		<td $stn><div align='right'> $tle &nbsp;</td></tr>");
							$n++;                   $b++;
						}
			echo" </tbody>
                  </table>
        <div class='clearfix'></div>
            </div>
                
        </div>";
	        }
	        
	        
	 // ************************ WAITING *********************************
		
	$do=mysqli_query($conn, "SELECT *FROM `vehicles` WHERE `Status`='0' AND `Custo`='WAITING CARGO' AND `Trip`='1' $conde ORDER BY `Number` ASC LIMIT 1000");
	        if($fo=mysqli_num_rows($do)){
            echo"<div class='panel panel-default' style='border:1px solid powderblue;'><form action='' method='post'>
			<div class='panel-heading' style='background-color:powderblue; padding-left:30px; font-weight:bold; font-size:12px;'> WAITING CARGO &nbsp;&nbsp; [$fo VEHICLE(S)] <input type='hidden' name='loko' value='$loke'>
			
	<button type='submit' name='openi' class='btn btn-xs btn-success pull-right hidden-print' style='height:15px; padding:1px 10px 1px 10px; margin:0px; margin-right:30px; font-size:10px;'><i class='lnr lnr-download'></i> OPEN </button></div></form>";
		
		
			echo"<div class='panel-body' style='padding:0px;'>
			 <table class='table table-striped table-hover'>    
                <tr role='row'><th $stl class='hidden-xs'> No </th>
                        <th $stl><div align='center'> DATE </th>
                        <th $stl><div align='center'> TRUCK&nbsp;ID </th>
                        <th $stl><div align='center'> TRAILER&nbsp;ID </th>
                       <th $stl><div align='center'> MAKE </th>
                       <th $stl><div align='center'> CHASSIS TRUCK </th>
					   <th $stl><div align='center'> DRIVER'S NAME </th>
					   <th $stl><div align='center'> DRIVING LICENSE </th>
						<th $stl><div align='center'> PC/LP </th>
						 <th $stl><div align='center'> TELEPHONE </th>
                     </tr><tbody>";
	
	            $n=1;				$to=0;
		while($ro=mysqli_fetch_assoc($do)){
			$code=$ro['Number'];
			$make=$ro['Make'];
			$mode=$ro['Chassis1'];
			$chassis=$ro['Chassis2'];
			$year=$ro['Year'];

			$fuel=$ro['Fuel'];
			$vid=$ro['Plate'];
			$source=$ro['Driver'];
			$tre=$ro['Trailer'];
			$all++;
			
		$sete=mysqli_query($conn, "SELECT `Idno`, `Contact1`, `Contact2` FROM `employees` WHERE `Fullname`='$source' AND `Fullname`!='' ORDER BY `Eid` DESC LIMIT 1");
		    if($fete=mysqli_num_rows($sete)){
			    $rete=mysqli_fetch_assoc($sete);
			        $tle=$rete['Contact1'];
			        $pcl=$rete['Contact2'];
			        $idno=$rete['Idno'];
		    }
		    else
		        $tle=$pcl=$idno="";
		        
	$seted=mysqli_query($conn, "SELECT `Date` FROM `trage` WHERE `Plate`='$vid' AND `Descri` LIKE '%Added to %' ORDER BY `Number` DESC LIMIT 1");
			    $reted=mysqli_fetch_assoc($seted);
			        $date=$reted['Date'];
	

                if(!$tle OR !$pcl OR !$idno)
					$stn="style='padding:0px; font-size:11px; color:blue;'";
				else
					$stn="style='padding:0px; font-size:11px;'";
		 
		print("<tr><td class='hidden-xs' $stn><div align='right'>$n&nbsp;&nbsp;</td><td $stn><div align='center'> $date </td><td $stn><div align='center'> $vid </td><td $stn><div align='center'> $tre </td><td $stn> $make </td><td $stn> $mode </td><td $stn> $source </td>
			  <td class='text-center' $stn> $idno </td>
			  <td $stn><div align='left'> $pcl </td>
						<td $stn><div align='right'> $tle &nbsp;</td></tr>");
							$n++;                   $b++;
						}
			echo" </tbody>
                  </table>
        <div class='clearfix'></div>
            </div>
                
        </div>";
	        }
	        
	        
	        
	        
	        
	// ************************ CUSTOMERS *********************************
	$doi=mysqli_query($conn, "SELECT `Custo` FROM `vehicles` WHERE `Status`='0' AND `Custo`!='WAITING CARGO' AND `Custo`!='' AND `Locate`='' AND `Loading`='0' AND `Trip`='1' $conde GROUP BY `Custo` ORDER BY `Number` ASC LIMIT 1000");
	        if($foi=mysqli_num_rows($doi)){
	            while($roi=mysqli_fetch_assoc($doi)){
	                $loke=$roi['Custo'];
		
	$do=mysqli_query($conn, "SELECT *FROM `vehicles` WHERE `Status`='0' AND `Custo`='$loke' AND `Locate`='' AND `Loading`='0' AND `Trip`='1' $conde ORDER BY `Number` ASC LIMIT 1000");
	        if($fo=mysqli_num_rows($do)){
            echo"<div class='panel panel-default' style='border:1px solid powderblue;'><form action='' method='post'>
			<div class='panel-heading' style='background-color:powderblue; padding-left:30px; font-weight:bold; font-size:12px;'> $loke &nbsp;&nbsp; [$fo VEHICLE(S)] <input type='hidden' name='loko' value='$loke'>
			
	<button type='submit' name='openi' class='btn btn-xs btn-success pull-right hidden-print' style='height:15px; padding:1px 10px 1px 10px; margin:0px; margin-right:30px; font-size:10px;'><i class='lnr lnr-download'></i> OPEN </button></div></form>";
		
		
			echo"<div class='panel-body' style='padding:0px;'>
			 <table class='table table-striped table-hover'>    
                <tr role='row'><th $stl class='hidden-xs'> No </th>
                        <th $stl><div align='center'> DATE </th>
                        <th $stl><div align='center'> TRUCK&nbsp;ID </th>
                        <th $stl><div align='center'> TRAILER&nbsp;ID </th>
                       <th $stl><div align='center'> MAKE </th>
                       <th $stl><div align='center'> CHASSIS TRUCK </th>
					   <th $stl><div align='center'> DRIVER'S NAME </th>
					   <th $stl><div align='center'> DRIVING LICENSE </th>
						<th $stl><div align='center'> PC/LP </th>
						 <th $stl><div align='center'> TELEPHONE </th>
                     </tr><tbody>";
	
	            $n=1;				$to=0;
		while($ro=mysqli_fetch_assoc($do)){
			$code=$ro['Number'];
			$make=$ro['Make'];
			$mode=$ro['Chassis1'];
			$chassis=$ro['Chassis2'];
			$year=$ro['Year'];

			$fuel=$ro['Fuel'];
			$vid=$ro['Plate'];
			$source=$ro['Driver'];
			$tre=$ro['Trailer'];
			$all++;
			
		$sete=mysqli_query($conn, "SELECT `Idno`, `Contact1`, `Contact2` FROM `employees` WHERE `Fullname`='$source' AND `Fullname`!='' ORDER BY `Eid` DESC LIMIT 1");
		    if($fete=mysqli_num_rows($sete)){
			    $rete=mysqli_fetch_assoc($sete);
			        $tle=$rete['Contact1'];
			        $pcl=$rete['Contact2'];
			        $idno=$rete['Idno'];
		    }
		    else
		        $tle=$pcl=$idno="";
		        
	$seted=mysqli_query($conn, "SELECT `Date` FROM `trage` WHERE `Plate`='$vid' AND `Descri` LIKE '%Added to %' ORDER BY `Number` DESC LIMIT 1");
			    $reted=mysqli_fetch_assoc($seted);
			        $date=$reted['Date'];
	

                if(!$tle OR !$pcl OR !$idno)
					$stn="style='padding:0px; font-size:11px; color:blue;'";
				else
					$stn="style='padding:0px; font-size:11px;'";
		 
		print("<tr><td class='hidden-xs' $stn><div align='right'>$n&nbsp;&nbsp;</td><td $stn><div align='center'> $date </td><td $stn><div align='center'> $vid </td><td $stn><div align='center'> $tre </td><td $stn> $make </td><td $stn> $mode </td><td $stn> $source </td>
			  <td class='text-center' $stn> $idno </td>
			  <td $stn><div align='left'> $pcl </td>
						<td $stn><div align='right'> $tle &nbsp;</td></tr>");
							$n++;                   $b++;
						}
			echo" </tbody>
                  </table>
        <div class='clearfix'></div>
            </div>
                
        </div>";
	        }
	        }
	        }
	        
	        
	        // *********************** Offloading ****************************
		
	$do=mysqli_query($conn, "SELECT *FROM `vehicles` WHERE `Status`='0' AND `Locate`='' AND `Loading`='1' AND `Trip`='1' $conde ORDER BY `Number` ASC LIMIT 1000");
	        if($fo=mysqli_num_rows($do)){
            echo"<div class='panel panel-default' style='border:1px solid powderblue;'><form action='' method='post'>
			<div class='panel-heading' style='background-color:powderblue; padding-left:30px; font-weight:bold; font-size:12px;'> OFFLOADED &nbsp;&nbsp; [$fo VEHICLE(S)] <input type='hidden' name='loko' value='$loke'>
			
	<button type='submit' name='openi' class='btn btn-xs btn-success pull-right hidden-print' style='height:16px; padding:1px 10px 1px 10px; margin:0px; margin-right:30px; font-size:10px;'><i class='lnr lnr-download'></i> OPEN </button></div></form>";
		
		
			echo"<div class='panel-body' style='padding:0px;'>
			 <table class='table table-striped table-hover'>     
                <tr role='row'><th $stl class='hidden-xs'> No </th>
                        <th $stl><div align='center'> DATE </th>
                        <th $stl><div align='center'> TRUCK&nbsp;ID </th>
                        <th $stl><div align='center'> TRAILER&nbsp;ID </th>
                       <th $stl><div align='center'> MAKE </th>
                       <th $stl><div align='center'> CHASSIS TRUCK </th>
					   <th $stl><div align='center'> DRIVER'S NAME </th>
					   <th $stl><div align='center'> DRIVING LICENSE </th>
						<th $stl><div align='center'> PC/LP </th>
						 <th $stl><div align='center'> TELEPHONE </th>
                     </tr><tbody>";
	
	            $n=1;				$to=0;
		while($ro=mysqli_fetch_assoc($do)){
			$code=$ro['Number'];
			$make=$ro['Make'];
			$mode=$ro['Chassis1'];
			$chassis=$ro['Chassis2'];
			$year=$ro['Year'];

			$fuel=$ro['Fuel'];
			$vid=$ro['Plate'];
			$source=$ro['Driver'];
			$tre=$ro['Trailer'];
			$all++;
			
		$sete=mysqli_query($conn, "SELECT `Idno`, `Contact1`, `Contact2` FROM `employees` WHERE `Fullname`='$source' AND `Fullname`!='' ORDER BY `Eid` DESC LIMIT 1");
		    if($fete=mysqli_num_rows($sete)){
			    $rete=mysqli_fetch_assoc($sete);
			        $tle=$rete['Contact1'];
			        $pcl=$rete['Contact2'];
			        $idno=$rete['Idno'];
		    }
		    else
		        $tle=$pcl=$idno="";
		        
	$seted=mysqli_query($conn, "SELECT `Date` FROM `trage` WHERE `Plate`='$vid' AND `Descri` LIKE '%Offload vehicle from trip%' ORDER BY `Number` DESC LIMIT 1");
			    $reted=mysqli_fetch_assoc($seted);
			        $date=$reted['Date'];
	

                if(!$tle OR !$pcl OR !$idno)
					$stn="style='padding:0px; font-size:11px; color:blue;'";
				else
					$stn="style='padding:0px; font-size:11px;'";
		 
		print("<tr><td class='hidden-xs' $stn><div align='right'>$n&nbsp;&nbsp;</td><td $stn><div align='center'> $date </td><td $stn><div align='center'> $vid </td><td $stn><div align='center'> $tre </td><td $stn> $make </td><td $stn> $mode </td><td $stn> $source </td>
			  <td class='text-center' $stn> $idno </td>
			  <td $stn><div align='left'> $pcl </td>
						<td $stn><div align='right'> $tle &nbsp;</td></tr>");
							$n++;                   $b++;
						}
			echo" </tbody>
                  </table>
        <div class='clearfix'></div>
            </div>
                
        </div>";
	        }
	        
	        
	       echo" &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TOTAL VEHICLES: $all";
		?>
            
            </div></div>
                </div>
                  
            
             <?php
             if($pr){
                 echo"<span class='pull-right text-right'>
             <a href='#' onclick='return window.print()' class='hidden-print' title='Print' data-toggle='tooltip' data-placement='top'><i class='lnr lnr-printer'></i></a> &nbsp;&nbsp;&nbsp;&nbsp; </span>";
             }
             ?>
      
   </div></div></div>  
   <?php
   include'footer.php';
   ?>
