<?php		
	include'expohead.php';
	?>
	<script>
function goBack() {
  window.history.back();
}
</script>

<?php
	if(isset($_POST['opens']))
		{
			$rowid=$_POST['rowid'];
			$date=$_POST['date'];
			$dato=$_POST['dato'];
			$datos=$_POST['datos'];
			$pago=$_POST['pago'];
			$user=$_POST['user'];
			$p=$_POST['p'];
			$t=1;
		}
			$due=date('l jS M Y', strtotime($date)); 

	echo"<div class='DONTPrint'><table width=80% border=0><tr>
	<td><a href='$pago'><font face='Agency FB' color='blue' size='3'> BACK </a></td>
<td><div align=right><a href='#' onclick='javascript:printpage();window.close()'>
<font face='Agency FB' color='blue' size='3'> PRINT </a></td></tr></table><br></div>";

echo"<div style='float:right; text-align:right; padding-right:40px;'><b> $due </b><br><br></div>";

	echo"<table width='98%' border='1' cellpadding='0' cellspacing='0' STYLE='font-family: verdana,arial,sans-serif;
	font-size: 12px; color: #333333z; border-width: 1px; border-color: #999999; border-collapse: collapse;'>
    <tr style='height:30px;'><th> REQUISITION FROM No: 0$rowid </th>
    </tr></table><br>";

	print("<table width='98%' border='1' cellpadding='0' cellspacing='0' STYLE='font-family: verdana,arial,sans-serif; font-size: 12px; color: #333333z; border-width: 1px; border-color: #999999; border-collapse: collapse;'><tr style='height:20px;'>
			<th width='5%' style='font-size:12px;'> No </th>
			<th style='font-size:12px;'> Description </th>
			<th width='10%' style='font-size:12px;'> Store </th>
			<th width='10%' style='font-size:12px;'> Quantity </th>
			<th width='10%' style='font-size:12px;'> Price/Unit </th>
			<th width='12%' style='font-size:12px;'> Amount </th>
			<th width='10%' style='font-size:12px;'> Approved </th>
			<th width='12%' style='font-size:12px;'> Amount </th>");

		$n=1;			$tot=$top=0;
$roome=mysqli_query($conn, "SELECT `items`.`Item`, `stouse`.`Quantity`, `stouse`.`Price`, `stouse`.`Person`, `stouse`.`Comment`, `stouse`.`Otype`, `stouse`.`User`, `stouse`.`Approved`, `stouse`.`Approby`, `stouse`.`Closing` FROM `stouse` INNER JOIN `items` ON `stouse`.`Item`=`items`.`Number` WHERE `stouse`.`Status`='0' AND `stouse`.`Voucher`='$rowid' AND `stouse`.`Action`='REQUISE' ORDER BY `stouse`.`Number` ASC");
if(!$foome=mysqli_num_rows($roome))
$roome=mysqli_query($conn, "SELECT `Invoice` AS `Item`, `Quantity`, `Price`, `Person`, `Comment`, `Otype`, `stouse`.`Approved`, `stouse`.`Approby`, `stouse`.`Closing` FROM `stouse` WHERE `Status`='0' AND `Voucher`='$rowid' AND `Action`='REQUISE' ORDER BY `Number` ASC");
					while($rom=mysqli_fetch_assoc($roome)){	
						$item=$rom['Item'];				
						$qty=$rom['Quantity'];
						$pri=$rom['Price'];
						$app=$rom['Approved'];
						$aby=$rom['Approby'];
						$clo=$rom['Closing'];
						
						if(!$aby)
						    $aby="............................";
						
				    $pers=$rom['Person'];
				    if(!$pers)
				    $pers=$rom['User'];
				    $coome=$rom['Comment'];
				    $phon=$rom['Otype'];
					$to=$pri*$qty;
					$po=$pri*$app;
					
	$too=number_format($to, 2);			
	$prio=number_format($pri, 2);			
	$qto=number_format($qty, 2);
	$appo=number_format($app, 2);				
	$poo=number_format($po, 2);	
echo"<tr><td style='font-size:12px; text-align:right'> $n &nbsp;</td>
<td style='font-size:12px; text-align:left'>&nbsp; $item </td>
<td style='font-size:12px; text-align:right;'> $clo </td>
<td style='font-size:12px; text-align:right;'> $qto </td>
<td style='font-size:12px; text-align:right;'> $prio </td>
<td style='font-size:12px; text-align:right;'> $too </td>
<td style='font-size:12px; text-align:right;'> $appo </td>
<td style='font-size:12px; text-align:right;'> $poo </td></tr>";
		$n++;				$tot+=$to;                  $top+=$po;
					}
		while($n<=10){
			echo"<tr><td style='font-size:12px;'> &nbsp; </td>
		<td style='font-size:12px; text-align:left'> &nbsp; </td>
<td style='font-size:12px; text-align:right;'> &nbsp; </td>
<td style='font-size:12px; text-align:right;'> &nbsp; </td>
<td style='font-size:12px; text-align:right;'> &nbsp; </td>
<td style='font-size:12px; text-align:right;'> &nbsp; </td>
<td style='font-size:12px; text-align:right;'> &nbsp; </td>
<td style='font-size:12px; text-align:right;'> &nbsp; </td></tr>";
		$n++;
		}
	$toto=number_format($tot, 2);                  $topo=number_format($top, 2);
?>			
<tr style='height:20px;'><th style='font-size:12px; text-align:center;' colspan='4'><b> Total Amount </th>
<th style='font-size:12px; text-align:right;' colspan='2'><b><?php echo $toto ?>&nbsp;&nbsp;</th>
<th style='font-size:12px; text-align:right;' colspan='2'><b><?php echo $topo ?>&nbsp;&nbsp;</th></tr>
	</table><BR><BR>
    <?php    
    print("<table WIDTH='94%' border='1' cellpadding='0' cellspacing='0' STYLE='font-family: verdana,arial,sans-serif;
	font-size: 12px; color: #333333z; border-width: 1px; border-color: #999999; border-collapse: collapse;'>");
	if($coome)
echo"<tr style='height:30px;'>
<td colspan='2'> &nbsp; Purpose: $coome </td><tr>";
	
	  print("<tr style='height:40px;'><td width='75%'> &nbsp; Requested By: $pers ");
	  if($phon)
	  echo" ($phon)";
	  print("<label style='float:right; text-align:right'> Signature: .................. ...... &nbsp;&nbsp;&nbsp; </label></td>
	     <td align='center'> On: ....../ ....../ ...... </td><tr>
	     
	     <tr style='height:40px;'><td> &nbsp; Checked By: ............................ 
	     	<div style='float:right; text-align:right'> Signature: .................. ...... &nbsp;&nbsp;&nbsp;</td>
	     <td align='center'> On: ....../ ....../ ...... </td><tr>
	     
	     <tr style='height:40px;'><td> &nbsp; Approved By: $aby 
	<div style='float:right; text-align:right'> Signature: .................. ...... &nbsp;&nbsp;&nbsp;</td>
	     <td align='center'> On: ....../ ....../ ...... </td><tr></table>");
	     
	print("<div class='DONTPrint'><BR><HR WIDTH=90%><table width='80%' border=0><tr><td align='left'><a href='$pago'><font face='Agency FB' color='blue' size='3'> BACK </a></td>
<td border='0' align='right' width='50%'><div align=right><a href='#' onclick='javascript:printpage();window.close()'><font face='Agency FB' color='blue' size='3'> PRINT </a></td></tr></table></div><br><br>");
		
				?>
				
		<div class="divFooter" style="position:fixed; left: 0px; bottom: 0px; right:0px; width: 100%;
text-align: center;"><IMG SRC="imgs/footer.jpg" WIDTH="100%" HEIGHT="60" BORDER="0" ALT=""></div>
      </body>
</html>
