<?php
if(basename($_SERVER['PHP_SELF']) == 'garage.php') 
$co=" class='current'";
include'header.php';
$custo='';
		
			
		// ******************** Release vehicles **********************
    if(isset($_POST['savalled']))
		{
			$lokete=str_replace("'", "`", $_POST['lokete']);
			$a=$_POST['a'];
			
			for($t=1; $t<=$a; $t++){
			$pla=$_POST["plate$t"];
			$fna=$_POST["fna$t"];
	if($pla){
$doi=mysqli_query($conn, "UPDATE `vehicles` SET `Loading`='1', `Bulk`='0', `Custo`='', `Locate`='', `Gara`='1' WHERE `Number`='$pla' ORDER BY `Number` ASC LIMIT 1");

	$tgd=mysqli_query($conn, "INSERT INTO `trage` (`Date`, `Time`, `User`, `Plate`, `Action`, `Descri`) VALUES ('$Date', '$Time', '$loge', '$fna', 'RELEASE', 'Released from garage')");
		    }
		        }
		    }
		
		
	// ******************** Release single vehicle **********************
    if(isset($_POST['leased']))
		{
			$code=$_POST['code'];
			$pla=$_POST['plate'];
$doi=mysqli_query($conn, "UPDATE `vehicles` SET `Loading`='1', `Bulk`='0', `Custo`='', `Locate`='', `Gara`='1' WHERE `Number`='$code' ORDER BY `Number` ASC LIMIT 1");

	$tgd=mysqli_query($conn, "INSERT INTO `trage` (`Date`, `Time`, `User`, `Plate`, `Action`, `Descri`) VALUES ('$Date', '$Time', '$loge', '$pla', 'RELEASE', 'Released from garage.')");
		    }
		    
    // ******************** Lock/Unlock single vehicle **********************
    if(isset($_POST['locked']))
		{
			$code=$_POST['code'];
			$pla=$_POST['plate'];
			$lock=$_POST['lock'];
			
			if($lock=='1')
$doi=mysqli_query($conn, "UPDATE `vehicles` SET `Locked`='0' WHERE `Number`='$code' ORDER BY `Number` ASC LIMIT 1");
			else
$doi=mysqli_query($conn, "UPDATE `vehicles` SET `Locked`='1' WHERE `Number`='$code' ORDER BY `Number` ASC LIMIT 1");

//	$tgd=mysqli_query($conn, "INSERT INTO `trage` (`Date`, `Time`, `User`, `Plate`, `Action`, `Descri`) VALUES ('$Date', '$Time', '$loge', '$pla', 'RELEASE', 'Released from garage')");
		    }
		
		
		
		// ******************************* Repair & Services ******************************
	if(isset($_POST['savege']))
		{
			$dato=$_POST['dato'];
			$garage=$_POST['garage'];
			$plate=$_POST['plate'];
			$driver=$_POST['driver'];
			$purcha=$_POST['purcha'];
			$next=$_POST['next'];
			$issue=str_replace("'", "`", $_POST['issue']);
			$repair=str_replace("'", "`", $_POST['repair']);
			$amo=preg_replace('/,/', '', $_POST['amo']);
			if($type=='OTHER EXPENSE')
			    $ty=1;
			else
			    $ty=0;

			$temp1 = explode(".", $_FILES["file1"]["name"]);
$newfilename1 = round(microtime(true)) . '.' . end($temp1);
move_uploaded_file($_FILES["file1"]["tmp_name"], "repair/" . $newfilename1);
	if(!end($temp1))
	$newfilename1='';
	
	$tripe=mysqli_query($conn, "SELECT `Number`, `Plate` FROM `trips` WHERE `Vehicle`='$plate' AND `Date`<= '$dato' ORDER BY `ETD` DESC LIMIT 1");
			if($fripe=mysqli_num_rows($tripe)){
			$ripe=mysqli_fetch_assoc($tripe);
				$trip=$ripe['Number'];
				$plat=$ripe['Plate'];
	        }
	        else
	            $trip=0;
				
	$doz=mysqli_query($conn, "SELECT `Rate` FROM `currency` WHERE `Code`='USD' ORDER BY `Number` DESC");
		    $roz=mysqli_fetch_assoc($doz);
			     $rate=$roz['Rate'];
			    
	$dozi=mysqli_query($conn, "SELECT `Plate`, `Driver` FROM `vehicles` WHERE `Number`='$plate' ORDER BY `Number` DESC");
		    $rozi=mysqli_fetch_assoc($dozi); 
			     if(!$driver)
			     $driver=$rozi['Driver'];
			     if(!$plat)
			     $plat=$rozi['Plate'];
			     
	$so=mysqli_query($conn, "INSERT INTO `repair` (`Vehicle`, `Amount`, `Garage`, `Items`, `Issue`, `Date`, `Repair`, `Driver`, `File`, `Purchase`, `Next`, `User`, `Time`, `Trip`, `Plate`, `Type`, `Rate`) VALUES ('$plate', '$amo', '$garage', '0', '$issue', '$dato', '$repair', '$driver', '$newfilename1', '$purcha', '$next', '$loge', '$Time', '$trip', '$plat', '$ty', '$rate')");
	
    //	$dozi=mysqli_query($conn, "UPDATE `vehicles` SET `Locate`='GARAGE' WHERE `Number`='$plate' ORDER BY `Number` DESC");
			$pto=50;
		}
		
		
			if(isset($_POST['eddoge']))
		{
			
			$num=$_POST['num'];
			$veh=$_POST['veh'];
			$i=$_POST['i'];

			$rece=mysqli_query($conn, "SELECT `Voucher` FROM `stouse` WHERE `Voucher`!='0' ORDER BY `Voucher` DESC LIMIT 1");
				$re=mysqli_fetch_assoc($rece);
					$vou=$re['Voucher']+1;

			while($i>0){
			$pri=$_POST["pri$i"];
			$item=$_POST["item$i"];
			$pieces = explode(" @ ", $item);
					$item=$pieces[0]; // piece1
					if(!$pri)
					$pri=$pieces[1]; // piece2
			$qty=$_POST["qty$i"];
				$qty=preg_replace('/,/', '', $qty);
			$store=$_POST["store$i"];
				$pri=preg_replace('/,/', '', $pri);
			
			if($qty>0){
	$doz=mysqli_query($conn, "SELECT `Number`, `Price` FROM `items` WHERE `Item`='$item' ORDER BY `Number` DESC");
		if(!$foz=mysqli_num_rows($doz)){
$then=mysqli_query($conn, "INSERT INTO `items` (`Type`, `Item`, `Price`, `Quantity`, `Label`, `Descri`, `Status`) VALUES ('Repair Part', '$item', '$pri', '0', 'Variable Asset', 'From repair', '1')");
	$doz=mysqli_query($conn, "SELECT `Number`, `Price` FROM `items` WHERE `Item`='$item' ORDER BY `Number` DESC");
		    }
		$roz=mysqli_fetch_assoc($doz);
			$ite=$roz['Number'];

	if($store){
		if(!$pri)
			$pri=$roz['Price'];
	$doin=mysqli_query($conn, "UPDATE `items` SET `Quantity`=`Quantity`-'$qty' WHERE `Number`='$ite' ORDER BY `Number` DESC LIMIT 1");
$so=mysqli_query($conn, "INSERT INTO `stouse` (`Date`, `User`, `Item`, `Quantity`, `Price`, `Destin`, `Action`, `Voucher`, `Status`, `Invoice`, `Vehicles`, `Repair`, `Store`) VALUES ('$Date', '$loge', '$ite', '$qty', '$pri', 'Used for repair', 'USED', '$vou', '0', '0', '$veh', '$num', '$store')");
	}
	else{
$so=mysqli_query($conn, "INSERT INTO `stouse` (`Date`, `User`, `Item`, `Quantity`, `Price`, `Destin`, `Action`, `Voucher`, `Status`, `Invoice`, `Vehicles`, `Repair`, `Store`) VALUES ('$Date', '$loge', '$ite', '$qty', '$pri', 'Used for repair', 'USED', '$vou', '2', '0', '$veh', '$num', '$store')");
	}
			}
					$i--;
			}
			$pto=60;
		}

		
		
		if($custo)
			$conde="AND (`Plate` LIKE '%$custo%' OR `Driver` LIKE '%$custo%' OR `Locate` LIKE '%$custo%')";
		else
		    $conde="AND `Loading`='1'";
		    
		    if(isset($_POST['openi']))
		        {
			    $loko=$_POST['loko'];
			    $conde="AND `Locate`='$loko'";
			    $pr=1;
		        }
?>


<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-print">
          <h3 style='margin-top:-20px; margin-bottom: 5px; color:#ffcc33'>
         Garage
          </h3>
                 </div>
     
        <div class="row">
  <div class="col-lg-2 hidden-print">
   
  <ul class="list-group">   

    <li class="list-group-item active">
	  <a href="garage.php">
                <p>
                <i class="lnr lnr-menu-circle"></i>&nbsp;Vehicles in Garage
                </p>
              </a></li>

    <li class="list-group-item">
	  <a href="garepo.php">
                <p>
                <i class="lnr lnr-menu-circle"></i>&nbsp;Repair/Service Report
                </p>
              </a></li>
              
            </ul>
  </div>
                    
    
    
            <?php
 // *************** release vehicles **********************
	    echo"<div class='modal fade' id='release' tabindex='-1' role='dialog' aria-labelledby='exampleModalLabel' aria-hidden='true'>
  <div class='modal-dialog' role='document' style='width:50%;'>
  <div class='modal-content'><div class='modal-header text-left'>
        <h5 class='modal-title' id='exampleModalLabel'> VEHICLES IN GARAGE 
        <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-left' style='height:180px; overflow-x:auto;'>";
        
        $a=1;
    $dos=mysqli_query($conn, "SELECT `Number`, `Plate`, `Locate` FROM `vehicles` WHERE `Status`='0' AND `Trip`='1' AND `Locate`='GARAGE' ORDER BY `Plate` ASC LIMIT 200");
		while($ros=mysqli_fetch_assoc($dos)){
			$numb=$ros['Number'];
			$plate=$ros['Plate'];
			$bd=$ros['Locate'];
			$bor="";
	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; <label style='margin-top:-10px; color:#f9f9f9;' for='checkall'>Check/Uncheck All</label>  </div><div class='col-md-1'> </div>
    
    <div class='col-md-2'> </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;'> RELEASE </button></div>
        </div></form>
    </div></div>
    </div>";
    ?>
    
    
    
    
    
    
    
<!-- For Repair & Services -->
<div id="repair" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true" style="display: none;">

    <div class="modal-dialog">

        <div class="modal-content" style="border-radius:5px;">

            <div class="modal-header" style="border-radius:5px;">

                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times-circle" aria-hidden="true"></i></button>

                <h4 class="modal-title" id="myModalLabel">&nbsp;&nbsp;&nbsp;<i class="fa fa-bars"></i> Repair & Services </h4>

            </div>

            <div class="modal-body">

                
                <!-- Email Logins-->

                

                <form action="" method="post" enctype='multipart/form-data'>

                     <div class="row"> 

                        <div class="col-sm-6" style="padding-top:7px;">

                           &nbsp; <i class="fa fa-calendar"></i> Due Date
                        </div><div class="col-sm-6" style="padding-top:7px;">

                           &nbsp; <i class="fa fa-truck"></i> Vehicle ID
                        </div>

                        <label class="control-label col-sm-6">

    <input class="form-control form-center date" data-provide="datepicker" name="dato" type="text" value="<?php echo $Date ?>" onkeypress='return isNumberKey(event)' id='to' required>

</label>
                       

						<div class="col-sm-6">

       <select class="form-control" name="plate" style="font-size:16px; height:34px;" required>
	 <option value=''> </option>
<?php
$do=mysqli_query($conn, "SELECT `Number`, `Plate`, `Trip` FROM `vehicles` WHERE `Status`='0' AND `Locate`='GARAGE' ORDER BY `Plate` ASC");
		while($ro=mysqli_fetch_assoc($do)){
			$numb=$ro['Number'];
			$plate=$ro['Plate'];
			echo"<option value='$numb'> $plate </option>";
		}
		?>
		</select>

                        </div>
</div>


 <div class="row"> 


 <div class="col-sm-6" style="padding-top:0px;">

                           &nbsp; <i class="fa fa-bars"></i> Repair/Service Type
                        </div><div class="col-sm-6" style="padding-top:0px;">

                           &nbsp; <i class="fa fa-user"></i> Driver`s Name
                        </div>

                        <label class="control-label col-sm-6">
 <select class="form-control" name="garage" style="font-size:16px; height:34px;" required>
	 <option value=''> Select Type </option>
<?php
$doz=mysqli_query($conn, "SELECT `Name` FROM `garage` WHERE `Name`='INTERNAL REPAIRING' ORDER BY `Name` ASC");
		while($roz=mysqli_fetch_assoc($doz)){
			$name=$roz['Name'];
			echo"<option value='$name'> $name </option>";
		}
		?>
		</select>
					</label>
                       

						<div class="col-sm-6">
		 <input type="text" class="form-control" name="driver" OnKeyup='return cUpper(this);' style="font-size:16px; height:34px;" list='dive'>
	 <datalist id="dive">
<?php
$doe=mysqli_query($conn, "SELECT `Fname`, `Lname` FROM `employees` WHERE `Currentp`='7' AND `Status`='0' ORDER BY `Fname` ASC");
		while($roe=mysqli_fetch_assoc($doe)){
			$fna=$roe['Fname'];
			$lna=$roe['Lname'];
			$name="$fna $lna";
			echo"<option value='$name'>";
		}
		?>
		</datalist>
                        </div>

</div>

 <div class="row">  <div class="col-sm-12" style="padding-top:0px;">

                           &nbsp; <i class="fa fa-question-circle"></i> Issue
                        </div>
				
		 <label class="control-label col-sm-12">

    <textarea placeholder="Write here..." class="form-control" rows="3" name="issue"></textarea>
					</label>

</div>

						<div class="row"> 
						

                   <div class="col-sm-6" style="padding-top:0px;">

				    &nbsp; <i class="fa fa-briefcase"></i> Total Amount
    
                        </div>
						
						<div class="col-sm-6" style="padding-top:0px; padding-left:60px;">

                           &nbsp; <i class="fa fa-file-text"></i> Document File
                        </div>

   
                        <label class="control-label col-sm-6">

	<input class="form-control form-center" name="amo" type="text" onkeyup="format(this);" onkeypress="return isNumberKey(event)"><br>
						<b>&nbsp;&nbsp; <i class="fa fa-spinner"></i> Mileage Count </b> &nbsp;&nbsp; 
			<b>&nbsp; <i class="fa fa-spinner"></i> Next Count<br></b><div class="col-sm-6">
	<input class="form-control form-center" name="purcha" type="text" onkeypress="return isNumberKey(event)" title='Mileage Count' data-toggle='tooltip' data-placement='top' style="width:120px;"></div><div class="col-sm-6 form-center"><input class="form-control form-center" name="next" type="text" onkeypress="return isNumberKey(event)" title='Next Count' data-toggle='tooltip' data-placement='top' style="width:120px;"></div>

					</label>
                       

						<div class="col-sm-6 form-center"><br>

      <div class="fileupload fileupload-new" data-provides="fileupload"><input value="<?php echo $rowid ?>" name="rowid" type="hidden">
                <span class="btn btn-default btn-file"><span class="fileupload-new">Select</span><span class="fileupload-exists">Change</span><input name="file1" id="app_file" type="file" readonly='readonly'></span><span class="fileupload-preview"></span><button class="close fileupload-exists" data-dismiss="fileupload" style="float:none" type="button">×</button>
		<?php echo $dfile ?>
				
                     
              </div>     <small>Zip, txt, jpeg, png, pdf, doc (Max : 2M)</small>

                        </div>

</div>

                        <div class="col-sm-12" style="text-align:center"><hr>

                           
                     <button class="view-listing-button" type="submit" name="savege" style="border:1px solid #99ccff; width:240px; float:center; height:30px; border-radius:5px; font-size:18px;"><i class="fa fa-check-square-o"></i> &nbsp; Save  </button>
                        </div>

                     </div>

                </form>

            </div>


        </div>

        <!-- /.modal-content -->

    </div>

    <!-- /.modal-dialog -->














    
        <div class="col-lg-10">
    <div class="row"><div class="col-lg-4" style="margin-left:40px;">
           <div class="col-lg-4 hidden-print">  </div>
           
        <div class="col-lg-4 hidden-print">  </div></form> 
           
        <div class="col-lg-4 hidden-print"> </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
	            $b=1;
            echo"<div class='panel panel-default' style='border:1px solid powderblue;'><div class='panel-heading' style='background-color:powderblue; padding-left:30px; font-weight:bold;'> VEHICLES IN GARAGE </div>";
		
		echo"<div class='panel-body' style='padding:0px;'>
			 <table class='table table-striped table-hover'>
			 <thead><tr role='row'><th class='hidden-xs'> No </th>
                        <th><div align='center'> DATE </th>
                        <th><div align='center'> TRUCK&nbsp;ID </th>
                        <th><div align='center'> TRAILER&nbsp;ID </th>
                       <th><div align='center'> MAKE </th>
                       <th><div align='center'> CHASSIS TRUCK </th>
						 <th><div align='center'> DRIVER'S NAME </th>
					   <th><div align='center'> DRIVING LICENSE </th>
						 <th><div align='center'> PC/LP </th>
						 <th><div align='center'> TELEPHONE </th>
						 <th colspan='2'><div align='center'> OPTIONS </th>
                     </tr><t/head><tbody>";
		
	$do=mysqli_query($conn, "SELECT *FROM `vehicles` WHERE `Status`='0' AND `Locate`='GARAGE' ORDER BY `Gdate` ASC LIMIT 450");	
	            $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'];
			$gda=$ro['Date'];

			$fuel=$ro['Fuel'];
			$vid=$ro['Plate'];
			$source=$ro['Driver'];
			$tre=$ro['Trailer'];
			$lock=$ro['Locked'];
			
		$seti=mysqli_query($conn, "SELECT `Number` FROM `trips` WHERE `Vehicle`='$code' ORDER BY `Number` DESC LIMIT 1");
			    $reti=mysqli_fetch_assoc($seti);
			    $trino=$reti['Number'];
			
		$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="";
	

                if($lock){
					$stn="style='padding:0px; color:red;'";
					$til="UNLOCK";
					$tile="unlock";
                }
				else{
					$stn="style='padding:0px;'";
					$til="LOCK";
					$tile="lock";
				}
		 
	print("<tr><td class='hidden-xs' $stn><div align='right'>$n&nbsp;&nbsp;</td>
	<td $stn><div align='center'> $gda </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;");
						
						
						
		
		if($lock=='0'){
	echo"<div class='modal fade' id='lease$n' tabindex='-1' role='dialog' aria-labelledby='exampleModalLabel' aria-hidden='true' style='top:120px;'>
  <div class='modal-dialog' role='document'>
    <div class='modal-content'><div class='modal-header text-left'>
        <h5 class='modal-title' id='exampleModalLabel'>RELEASE CONFIRMATION 
<label class='pull-right text-right'><b> $vid </b></label></h5>

      </div>
      <div class='modal-body text-left' style='height:60px;'>
<h5 style='color:#ff0033'>Are you sure you want to release this vehicle?</h5>
      </div><form method='post' action=''><input type='hidden' name='rowid' value='$code'><input type='hidden' name='code' value='$code'>
      <input type='hidden' name='plate' value='$vid'>
      <div class='modal-footer' style='margin-top:-10px; height:50px; padding-top:5px; border:0px solid blue;'>
        <button type='button' class='btn btn-sm btn-danger' data-dismiss='modal'>&nbsp;NO&nbsp;</button>
        <button type='submit' name='leased' class='btn btn-sm btn-success'>YES</button></div></form>
    </div></div>
  </div>";
		}
			





	print("<div class='modal fade' id='locki$n' tabindex='-1' role='dialog' aria-labelledby='exampleModalLabel' aria-hidden='true' style='top:120px;'>
  <div class='modal-dialog' role='document'>
    <div class='modal-content'><div class='modal-header text-left'>
        <h5 class='modal-title' id='exampleModalLabel'>$til CONFIRMATION 
<label class='pull-right text-right'><b> $vid </b></label></h5>

      </div>
      <div class='modal-body text-left' style='height:60px;'>
<h5 style='color:#ff0033'>Are you sure you want to $tile this vehicle?</h5>
      </div><form method='post' action=''><input type='hidden' name='rowid' value='$code'><input type='hidden' name='code' value='$code'>
      <input type='hidden' name='plate' value='$vid'>
      <input type='hidden' name='lock' value='$lock'>
      <div class='modal-footer' style='margin-top:-10px; height:50px; padding-top:5px; border:0px solid blue;'>
        <button type='button' class='btn btn-sm btn-danger' data-dismiss='modal'>&nbsp;NO&nbsp;</button>
        <button type='submit' name='locked' class='btn btn-sm btn-success'>YES</button></div></form>
    </div></div>
  </div>
			
						
						
						
						
						</td>
						
					  
		
	<td class='hidden-print' align='right' style='width:20px; padding:0px;' title='$til' data-toggle='tooltip' data-placement='top'>
    <button type='button' class='btn btn-xs btn-warning hidden-print' style='height:18px; padding:0px; margin:3px;' data-placement='top' data-toggle='modal' data-target='#locki$n'>&nbsp;&nbsp;<i class='lnr lnr-lock'></i>&nbsp;&nbsp;</button></td>
    
	<td class='hidden-print' align='right' style='width:20px; padding:0px;' title='RELEASE' data-toggle='tooltip' data-placement='top'>");
	if($lock==0)
        echo"<button type='button' class='btn btn-xs btn-success hidden-print' style='height:18px; padding:0px; margin:3px;' data-placement='top' data-toggle='modal' data-target='#lease$n'>&nbsp;&nbsp;<i class='lnr lnr-upload'></i>&nbsp;&nbsp;</button>";
    else
        echo"<center>&nbsp;--&nbsp;</center>";
        
        print("</td></tr>");
							$n++;                   $b++;
						}
			echo" </tbody>
                  </table>
        <div class='clearfix'></div>
            </div>
                
        </div>";
    
    
    
    
    
    
					$stn="style='padding:0px;'";
    
    
    
    
    
    
    
    
    
 	$repa=mysqli_query($conn, "SELECT `vehicles`.`Plate`, `vehicles`.`Driver`, `repair`.* FROM `repair` INNER JOIN `vehicles` ON `repair`.`Vehicle`=`vehicles`.`Number` WHERE `repair`.`Vehicle`>'0' AND `repair`.`Garage` LIKE '%REPAIRING%' AND `vehicles`.`Locate`='GARAGE' AND `repair`.`Date` >= `vehicles`.`Gdate` ORDER BY `repair`.`Number` DESC");	
 	
			if($fepa=mysqli_num_rows($repa)){
    
     echo"<br><br><div class='panel panel-default' style='border:1px solid powderblue;'>
     <table class='table table-striped table-hover' style='font-size:10px;'>
							<thead><tr>
                     <th colspan='2' width='1%' $stn>&nbsp;&nbsp;&nbsp;No </th><th $stn><div align='center'> DATE </th>
					 <th $stn><div align='center'> USER </th>
					 <th $stn><div align='center'> VEHICLE </th>
					 <th $stn><div align='center'> DRIVER </th>
					 <th $stn><div align='center'> ISSUE </th>
					 <th $stn><div align='center'> ITEMS </th>
					 <th $stn><div align='center'> AMOUNT </th>
							</tr> </thead>
                                        <tbody>";
					
					$n=1;
			while($rif=mysqli_fetch_assoc($repa)){
				$num=$rif['Number'];
				$veh=$rif['Plate'];
				$sta=$rif['Date'];
				$file=$rif['File'];
				$vei=$rif['Vehicle'];
				$driv=$rif['Driver'];
				$user=$rif['User'];
                $desi=$rif['Issue'];

				echo"<style>
tr img { display:none; }
tr:hover img { display:block; }
	</style>";


				echo"<tr>";

				if($file)
	echo"<td $stn style='width:1px;'><img src='repair/$file' style='margin-left:5px; margin-top:-280px; position:absolute;' width='310' height='240' /></td>";
				else
			echo"<td $stn style='width:1px;'> </td>";
				
				echo"<td class='text-right' $stn>$n&nbsp;";
				
				include"itmodal.php";
				$end=number_format($rif['Amount']+$to);
				
				echo"</td><td class='text-center' $stn> $sta </td>
				<td $stn> $user </td><td $stn> $veh </td><td $stn> $driv </td>
				<td $stn> $desi </td><td class='text-right' $stn> $fob&nbsp;<button type='button' class='btn btn-xs btn-warning hidden-print' style='height:18px; width:20px; padding:0px; margin:-2px 0px 0px 0px;' title='Add Item' data-placement='top' data-toggle='modal' data-target='#mode$n'>
				<i class='lnr lnr-plus-circle'></i></button></td><td class='text-right' $stn> $end&nbsp;</td></tr>";
                     $n++;          $driv='';
			}
                        
						  echo"</tbody></table></div>";
						  }
						      
						    
		?>
            
            </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';
   ?>
