<?php
session_start();
include'connection.php';
?>
<html>
<head><title>iMS</title>
<style>
@media print{
   .noprint{
       display:none;
   }
}
@media screen{
   .noshow{
       display:none;
   }
}


@media print {
  .DONTPrint{ display:none }
  .DOCheck{ display:table}
			}
			
			
    @media screen {
        div.divFooter {
            display: none;
        }
    }


      table,
      th,
      td {
        padding: 2px 2px 2px 10px;
        border: 1px solid black;
        border-collapse: collapse;
        font-size: 12px;
      }

</style><link rel="shortcut icon" type="image/png" href="imgs/logo.png"/></head>
<body bgcolor="#COCOCO">
<center>
		<?php
		$loge=$_SESSION['Loge'];
		$hed=mysqli_query($conn, "SELECT *FROM company");
			$rd=mysqli_fetch_assoc($hed);{
				$N1x=$rd['Cname'];
				$N3x=$rd['Address'];
				$N5x=$rd['Tax'];
				$N6x=$rd['Phone1'];
				$N7x=$rd['Phone2'];
				$N8x=$rd['Email'];
				$N9x=$rd['Email'];
				$N10x=$rd['Website'];
				$Date=$rd['Date'];
			}
?><div class='divFooter' style="top: 0px;">
<IMG SRC="imgs/header.jpg" WIDTH="100%" HEIGHT="90" BORDER="0" ALT=""></div>
<br><script>
function goBack() {
  window.history.back();
}
</script>

<?php
	$due=date('l, jS M Y', strtotime($dte)); 
	
	echo"<table width='98%' class='gridtable' style='border:0px;'>
	<tr style='height:20px;'><th style='border: 0px;' width='20%'><div class='DONTPrint'><a href='$pago'><font face='Agency FB' color='blue' size='3'> BACK </a></th>
	<th style='border: 0px dotted #99cccc; font-size:20px; background-color:#F3EF53; border-radius:5px; height:30px;'><b><u> MILEAGE PAYMENT VOUCHER </u></b></th><th style='border: 0px;' width='20%'><div class='DONTPrint'>
	<a href='#' onclick='window.print();return false;'/>
<font face='Agency FB' color='blue' size='3'> PRINT </a></th></tr></table>

	<table width='98%' style='border: 0px;'><tr>
 <td align='right' style='font-size:18px; border:0px;'> $due <br>
 Voucher No:<b> &nbsp; 0$invo &nbsp; </b></td>
 </tr></table>";
 
 echo"<table width='99%' class='gridtable'>
			<tr style='height:20px;'>
			<th width='5%' style='font-size:12px;'> No </th>
			<th width='10%' style='font-size:12px;'> Vehicle&nbsp;ID </th>
			<th width='10%' style='font-size:12px;'> Trailer&nbsp;ID </th>
			<th style='font-size:12px;'> Driver`s&nbsp;Name </th>
			<th style='font-size:12px;'> Destination </th>
			<th width='10%' style='font-size:12px;'> Date </th>
			<th width='10%' style='font-size:12px;'> Mileage </th>
			<th width='10%' style='font-size:12px;'> Signature </th></tr>";
		
		
	             $to=0;                 $i=1;  
		        // ******************* Road Toll & Mileage ******************
		$dois=mysqli_query($conn, "SELECT *FROM `repair` WHERE `Status`='0' AND `Trip`!='0' AND `Printed`='1' AND `Invoice`='$invo' ORDER BY `Number` ASC");
			    while($rois=mysqli_fetch_assoc($dois)){
			        $nuo=$rois['Number'];
			        $trip=$rois['Trip'];
			        $drive=$rois['Driver'];
			        $amo=$rois['Mileage'];
				$amoo=number_format($amo, 2);
				    $veh=$rois['Vehicle'];
				    $dte=$rois['Pdate'];
				    $user=$rois['Done'];
				    
		$doi=mysqli_query($conn, "SELECT `Plate`, `Trailer` FROM `vehicles` WHERE `Number`='$veh' ORDER BY `Number` ASC");
			$roi=mysqli_fetch_assoc($doi);
				$pla=$roi['Plate'];
				$tra=$roi['Trailer'];
				
	$doic=mysqli_query($conn, "SELECT `Destination`, `Location` FROM `trips` WHERE `Number`='$trip' ORDER BY `Number` ASC LIMIT 1");
			$roic=mysqli_fetch_assoc($doic);
				$des=$roic['Destination'];
				$loc=$roic['Location'];
						    
echo"<tr><td align='center'> $i </td><td align='right'> $pla &nbsp;</td>
<td align='right'> $tra &nbsp;</td><td> $drive </td><td> $des/$loc </td>
<td align='center'> $dte </td><td align='right'> $amoo &nbsp;</td><td> </td>
</tr>";
        $i++;                   $to+=$amo;
			    }

        $too=number_format($to, 2);
echo"<tr style='height:20px;'><th colspan='6'>Total Amount</th>
<th align='right'> $too </th><th> </th></table>


<center><table width='99%' style='border: 0px;'><tr>
 <td align='center' width='33%'>Prepared by <br><br><br>
 $user <br>Cashier</td>
 <td align='center'>Checked by <br><br><br>
 ----------------- <br>Director of Finance</td>
 <td align='center' width='33%'>Approved by <br><br><br>
 ----------------- <br>Managing Director</td>
 </tr></table>";
 
 	echo"<div class='DONTPrint'><br>
 	<table width='98%' class='gridtable' style='border:0px;'>
	<tr style='height:20px;'><th style='border: 0px;' width='20%'>
	<a href='$pago'><font face='Agency FB' color='blue' size='3'> BACK </a></th>
	<th style='border:0px;'> </th><th style='border: 0px;' width='20%'><a href='#' onclick='window.print();return false;'/><font face='Agency FB' color='blue' size='3'> PRINT </a></th></tr></table>
        </div>";
    ?>
<div class="divFooter" style="left: 0px; bottom: 0px; right:0px; width: 100%; text-align: center; position:fixed;"><IMG SRC="imgs/footer.jpg" WIDTH="100%" HEIGHT="60" BORDER="0" ALT=""></div>
    <?php
    exit();
    ?>
      </body>
</body>


