 <?php
	   // *************** Create a single trip record **********************
	    echo"<div class='modal fade' id='Modaldis' tabindex='-1' role='dialog' aria-labelledby='exampleModalLabel' aria-hidden='true'>
  <div class='modal-dialog' role='document'><div class='modal-content'><div class='modal-header text-left'>
        <h5 class='modal-title' id='exampleModalLabel'>CREATE NEW TRIP 
        <span class='pull-right'>  </span></h5>

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

        <div class='form-group'>
			<div class='col-md-5' align='right'> 
            <label class='control-label'>Vehicle&nbsp;ID</label></div>
            <div class='col-md-6'>
<select class='form-control' name='plate' required><option value=''> </option>";

$doci=mysqli_query($conn, "SELECT `Locate` FROM `vehicles` WHERE `Status`='0' AND `Trip`='1' AND `Locate`!='' GROUP BY `Locate` ORDER BY `Plate` ASC");
           while($roci=mysqli_fetch_assoc($doci)){
               $lco=$roci['Locate'];
	echo"<option value='' style='color:blue;' disabled> $lco </option>";
$dov=mysqli_query($conn, "SELECT `Number`, `Plate` FROM `vehicles` WHERE `Status`='0' AND `Trip`='1' AND `Locate`='$lco' ORDER BY `Plate` ASC");
		while($rov=mysqli_fetch_assoc($dov)){
			$numb=$rov['Number'];
			$plate=$rov['Plate'];
			echo"<option value='$numb'> &nbsp; &raquo; $plate </option>";
		}
           }
		
		echo"</select>
            </div>          
		</div>
			
			 	
		 <div class='form-group'>	 
			  <div class='col-md-5' align='right'>
			  <label class='control-label'>Trip Destination</label></div>	

	 <div class='col-md-6'>
          <input name='desti' class='form-control' type='text'>
            </div>
		</div>

		<div class='form-group'>	 
			  <div class='col-md-5' align='right'>
			  <label class='control-label'>Package Location</label></div>	

	 <div class='col-md-6'>
          <input name='loca' class='form-control' type='text'>
            </div>
		</div>


		 <div class='form-group'>
			<div class='col-md-5' align='right'> 
            <label class='control-label'>Final Destination</label></div>
            <div class='col-md-6'>
           <input name='final' class='form-control' type='text'>
            </div>
		</div>


		 <div class='form-group'>
			<div class='col-md-5' align='right'> 
            <label class='control-label'>Weight / Distance</label></div>
            <div class='col-md-3'><div class='input-group'>
           <input name='capa' class='form-control' type='text' style='text-align:center;' onkeyup='format(this);' onkeypress='return isNumberKey(event)'><span class='input-group-addon text-info'>TON</span>
            </div></div>
            <div class='col-md-3'><div class='input-group'>
           <input name='dista' class='form-control' type='text' style='text-align:center;' onkeyup='format(this);' onkeypress='return isNumberKey(event)'><span class='input-group-addon text-info'>KM</span>
            </div></div>
		</div>
		
		<div class='form-group'>
			<div class='col-md-5' align='right'> 
            <label class='control-label'>
            <br class='hidden-xs'>ETD / ETA</label></div>
            <div class='col-md-3' style='padding-right:0px;'><br class='hidden-xs'><div class='input-group date' data-provide='datepicker'><input class='form-control form-center' name='etd' type='text' value='$Date' onkeypress='return isNumberKey(event)' style='padding-left:2px; padding-right:2px;' required><div class='input-group-addon'><span class='lnr lnr-calendar-full'></span></div></div>
            </div>
            
             <div class='col-md-3' style='padding-left:0px;'><br class='hidden-xs'><div class='input-group date' data-provide='datepicker'><input class='form-control form-center' name='eta' type='text' value='$Date' onkeypress='return isNumberKey(event)' style='padding-left:2px; padding-right:2px;' required><div class='input-group-addon'><span class='lnr lnr-calendar-full'></span></div></div>
             </div>
		</div>


		<div class='form-group'>
   <div class='col-md-5' align='right'><br class='hidden-xs'>
			  <label class='control-label'>Description</label></div>

 <div class='col-md-6'>
<textarea class='form-control' name='descri' style='height:60px; font-size:14px;'></textarea>
	</div>
	
	</div></div>
		
	</div><div class='modal-header text-right' style='height:50px; padding-top:15px;'><a href='' class='pull-left text-left' data-toggle='modal' data-target='#Modaldisc' data-dismiss='modal' style='padding-top:3px; margin-left:40px;'>Trip Bulk Record</a>	
		<button type='button' class='btn btn-xs btn-danger' data-dismiss='modal' style='width:80px;'> CANCEL </button>
        <button type='submit' name='savedi' class='btn btn-xs btn-success' style='width:80px;'> SAVE </button></div>
      </form>
  </div></div>
</div>";









	   // *************** Create a bulk trip record **********************
	    echo"<div class='modal fade' id='Modaldisc' 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'>CREATE TRIP (ALLOCATED VEHICLES) 
        <span class='pull-right'>  </span></h5>

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

    <div class='col-md-6 text-center' style='height:380px; overflow-x:auto;'>";
        
        $a=1;
    $doc=mysqli_query($conn, "SELECT `Locate` FROM `vehicles` WHERE `Status`='0' AND `Trip`='1' AND `Locate`!='' GROUP BY `Locate` ORDER BY `Plate` ASC");
           while($roc=mysqli_fetch_assoc($doc)){
               $lco=$roc['Locate'];
    
    $dov=mysqli_query($conn, "SELECT `Number`, `Plate`, `Locate` FROM `vehicles` WHERE `Status`='0' AND `Trip`='1' AND `Locate`='$lco' ORDER BY `Plate` ASC");
            $fov=mysqli_num_rows($dov);
    
    echo"<div class='panel panel-default' style='border:1px solid #d8d7d6; background-color:transparent; border-radius:5px;'><div class='panel-heading' style='background-color:#d8d7d6; padding-left:30px; text-align:left; font-weight:bold;'> $lco 
	<label class='pull-right text-info' style='font-weight:bold; padding-right:30px;'> $fov VEHICLES </label></div>";
	
		while($rov=mysqli_fetch_assoc($dov)){
			$numb=$rov['Number'];
			$plate=$rov['Plate'];
			$bd=$rov['Locate'];
			if($lco=='GARAGE'){
			$bor="border:1px solid red;";
			$tle="$bor";
			$bdo="disabled";
			}
			else{
			$bor="";
			$tle="$plate";
			$bdo="";
			}
	echo"<label class='btn btn-default active' for='my$a' style='width:105px; margin:5px; $bor' title='$tle' data-toggle='tooltip' data-placement='top' $bdo>
          <input id='my$a' type='checkbox' value='$numb' name='plate$a' style='border:0px; height:12px;'> $plate </label>";
                 $a++;
		}
		 echo"<div class='clearfix'></div>
            </div>";
           }
    
    
    
    echo"</div><div class='col-md-6'>
    
        	 	
		 <div class='form-group'>	 
			  <div class='col-md-4' align='right'>
			  Trip Destination</div>	

	 <div class='col-md-8'>
          <input name='desti' class='form-control' type='text'>
            </div>
		</div>

		<div class='form-group'>	 
			  <div class='col-md-4' align='right'>
			  Package Location</div>	

	 <div class='col-md-8'>
          <input name='loca' class='form-control' type='text'>
            </div>
		</div>


		 <div class='form-group'>
			<div class='col-md-4' align='right'> 
            Final Destination</div>
            <div class='col-md-8'>
           <input name='final' class='form-control' type='text'>
            </div>
		</div>


		 <div class='form-group'>
			<div class='col-md-4' align='right'> 
            Weight / Distance</div>
            <div class='col-md-4'><div class='input-group'>
           <input name='capa' class='form-control' type='text' style='text-align:center;' onkeyup='format(this);' onkeypress='return isNumberKey(event)'><span class='input-group-addon text-info'>TON</span>
            </div></div>
            <div class='col-md-4'><div class='input-group'>
           <input name='dista' class='form-control' type='text' style='text-align:center;' onkeyup='format(this);' onkeypress='return isNumberKey(event)'><span class='input-group-addon text-info'>KM</span></div></div>
		</div>
		
		<div class='form-group'>
			<div class='col-md-4' align='right'> 
            <br class='hidden-xs'>ETD / ETA</div>
        <div class='col-md-4' style='padding-right:0px;'><br class='hidden-xs'><div class='input-group date' data-provide='datepicker'><input class='form-control form-center' name='etd' type='text' value='$Date' onkeypress='return isNumberKey(event)' style='padding-left:2px; padding-right:2px;' required><div class='input-group-addon'><span class='lnr lnr-calendar-full'></span></div></div>
        </div>
            
        <div class='col-md-4' style='padding-left:0px;'><br class='hidden-xs'><div class='input-group date' data-provide='datepicker'><input class='form-control form-center' name='eta' type='text' value='$Date' onkeypress='return isNumberKey(event)' style='padding-left:2px; padding-right:2px;' required><div class='input-group-addon'><span class='lnr lnr-calendar-full'></span></div></div>
             </div></div>
		

		<div class='form-group'>
   <div class='col-md-4' align='right'><br class='hidden-xs'>
		Description</div>

 <div class='col-md-8'>
<textarea class='form-control' name='descri' style='height:60px; font-size:14px;'></textarea>
	</div></div>
	
	
            
		<div class='form-group'>	 
			  <div class='col-md-4' align='right'><br class='hidden-xs'><br class='hidden-xs'> Customer Name</div>	

	 <div class='col-md-8'><br class='hidden-xs'><br class='hidden-xs'>
          <select class='form-control' name='customer' style='font-size:16px; height:34px;' required><option value=''> Select a Customer </option>
    <option value='290009399190' style='color:blue;'> WAITING CARGO </option>";

$doz=mysqli_query($conn, "SELECT `Number`, `Customer` FROM `account` WHERE `Status`='0' ORDER BY `Customer` ASC");
		while($roz=mysqli_fetch_assoc($doz)){
			$cust=$roz['Customer'];
			$cods=$roz['Number'];
	echo"<option value='$cods'> $cust </option>";
		}
		
		echo"</select>
            </div>
		</div>
		
			<div class='form-group'>	 
		<div class='col-md-4' align='right'><br class='hidden-xs'> Amount / Vehicle </div>	

	 <div class='col-md-5'><br class='hidden-xs'>
    <input class='form-control form-center' name='amo' type='text' onkeyup='format(this);' onkeypress='return isNumberKey(event)' required></div>
        
    <div class='col-md-3'><br class='hidden-xs'>
    <select class='form-control' name='currency' required>
				<option value='' selected='selected'>Currency</option>";
			 
			$doix=mysqli_query($conn, "SELECT `Code`, `Rate` FROM `currency` WHERE `Code`!='' AND `Status`='0' ORDER BY `Code` ASC");
			while($roix=mysqli_fetch_assoc($doix)){
				$fna=$roix['Code'];
				$rate=$roix['Rate'];
				$rte=number_format($rate, 2);
			echo"<option value='$rate'> $fna @ $rte </option>";
			}
	
		  echo"</select>
            </div>
		</div>
		
		
		</div>
	
	</div></div>
	    
	            <input type='hidden' name='a' value='$a'>	
	<div class='modal-header text-right' style='height:50px; padding-top:15px;'>
	
	<label class='pull-left text-left' style='margin-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' style='margin-top:-10px;'></button></label>
    
		<button type='button' class='btn btn-xs btn-danger' data-dismiss='modal' style='width:80px;'> CANCEL </button>
        <button type='submit' name='tridis' class='btn btn-xs btn-success' style='width:80px;'> SAVE </button></div>
      </form>
  </div></div>
</div>";
?>