<?php
          if($_SESSION['Ovt']=='1' OR $_SESSION['Alt']=='1'){
          // *************** Offload vehicles **********************
	    echo"<div class='modal fade' id='Modaldixi' tabindex='-1' role='dialog' aria-labelledby='exampleModalLabel' aria-hidden='true'>
  <div class='modal-dialog' role='document' style='width:70%;'>
  <div class='modal-content'><div class='modal-header text-left'>
        <h5 class='modal-title' id='exampleModalLabel'>LOADED VEHICLES 
        <span class='pull-right'>  </span></h5>

      </div><form action='' method='post'>
      <div class='modal-body text-left'><div class='row'>

    <div class='col-md-12 text-center' style='height:380px; overflow-x:auto;'>";
        
        $a=1;
    $dos=mysqli_query($conn, "SELECT `Number`, `Plate`, `Locate`, `Depane`, `Custo`, `Loaded` FROM `vehicles` WHERE `Status`='0' AND `Trip`='1' AND `Locate`='' AND `Loading`='0' AND `Custo`!='WAITING CARGO' ORDER BY `Plate` ASC LIMIT 420");
		while($ros=mysqli_fetch_assoc($dos)){
			$numb=$ros['Number'];
			$plate=$ros['Plate'];
			$bd=$ros['Locate'];
			$tle=$ros['Custo'];
			if($ros['Loaded']){
			$bor="border:1px solid blue;";
			$tle="Loaded from $tle";
			}
			if($bd)
			$bor="border:1px solid red;";
			
			if($ros['Depane']){
			$bor="border:1px solid red;";
			$tle="Vehicle in depanage from $tle";
			}
			
	echo"<label class='btn btn-default active' for='my$a' style='width:110px; $bor' title='$tle' data-toggle='tooltip' data-placement='top'>
	<input type='hidden' name='fna$a' value='$plate'>
          <input id='my$a' type='checkbox' value='$numb' name='plate$a' style='border:0px; height:12px;'> $plate </label>";
                 $a++;
		}
	
	echo"<div class='row'><hr style='margin:20px; border:1px solid #c8c7c6;'></div>";
    
    
    $dos=mysqli_query($conn, "SELECT `Number`, `Plate`, `Locate`, `Depane` FROM `vehicles` WHERE (`Status`='0' AND `Trip`='1' AND `Loading`='1') OR (`Status`='0' AND `Trip`='1' AND `Locate`='' AND `Loading`='0' AND `Custo`='WAITING CARGO') ORDER BY `Plate` ASC LIMIT 420");
		while($ros=mysqli_fetch_assoc($dos)){
			$numb=$ros['Number'];
			$plate=$ros['Plate'];
			$bd=$ros['Locate'];
			if($bd)
			$bor="border:1px solid red;";
			else
			$bor="border:1px solid blue;";
			
			if($ros['Depane']){
			$bor="border:1px solid red;";
			}
			if(!$bd)
			$bd="ALLOCATED";
			
	echo"<label class='btn btn-default active' for='my$a' style='width:110px; $bor' title='$bd' data-toggle='tooltip' data-placement='top'>
	<input type='hidden' name='fna$a' value='$plate'>
          <input id='my$a' type='checkbox' value='$numb' name='plate$a' style='border:0px; height:12px;'> $plate </label>";
                 $a++;
		}
    
    echo"</div></div></div><div class='row'> </div>
	    
	   <input type='hidden' name='a' value='$a'>	
	<div class='modal-header' style='padding-top:15px; height:50px;'>
	
	<div class='col-md-4' style='padding-left:40px;'>
	<input type='checkbox' name='checkall' id='checkall' style='height:22px; width:24px; margin-top:0px;' onClick='check_uncheck_checkbox(this.checked);'> &nbsp; <button type='button' class='btn btn-secondary' id='d1'></button></div><div class='col-md-1'> </div>
    
    <div class='col-md-2'><select class='form-control' name='lokete' style='height:35px; width:220px; font-size:16px; margin-top:-10px;' required><option value='' selected='selected'>Select Option</option>";
    if($_SESSION['Ovt']=='1')
    echo"<option value='OFFLOADING' style='color: blue;'>OFFLOADED</option>";
    if($_SESSION['Avt']=='1')
    echo"<option value='DEPANNAGE' style='color: red;'>ADDITIONAL FUEL</option>";
    
    echo"</select></div>
    
        <div class='col-md-1'> </div><div class='col-md-4 text-right'>
	<button type='button' class='btn btn-xs btn-danger' data-dismiss='modal' style='width:80px; height:28px;'> CANCEL </button>
        <button type='submit' name='savall' class='btn btn-xs btn-success' style='width:80px; height:28px;'> SAVE </button></div>
        </div></form>
    </div></div>
    </div>";
          }
          ?>