<?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'];
			$dest=$_POST['dest'];
			$user=$_POST['user'];
			$p=$_POST['p'];
			$t=1;
		}
			$due=date('l jS M Y', strtotime($date)); 

	echo"<div class='DONTPrint'><table width='90%' border=0><tr>
	<td width='50%' align='left'><a href='$pago'><font face='Agency FB' color='blue' size='3'> BACK </a></td>
    <td 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"<table width='98%' border='1' cellpadding='0' cellspacing='0' STYLE='font-family: verdana,arial,sans-serif; background-color:powderblue;
	font-size: 12px; color: #333333z; border-width: 1px; border-color: #999999; border-collapse: collapse;'>
    <tr style='height:30px;'><th> PURCHASE ORDER No: 0$rowid </th>
    </tr></table><br>";

echo"<table width='90%' style='float:center; padding-right:20px; border:0px;'>
<tr><td border='0' align='left'> Supplier`s Name: <b> $dest </b><br></td><td border='0' align='right'> &nbsp; <br><b> $due </b></td></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='8%' style='font-size:12px;'> No </th>
			<th style='font-size:12px;'> Description </th>
			<th width='10%' style='font-size:12px;'>&nbsp;Quantity&nbsp;</th>
			<th width='12%' style='font-size:12px;'>&nbsp;Price/Unit&nbsp;</th>
			<th width='12%' style='font-size:12px;'>&nbsp;Amount&nbsp;(RWF)&nbsp;</th></tr>");

		$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` 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` 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'];
						
						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;'> $appo&nbsp;</td>
<td style='font-size:12px; text-align:right;'> $prio&nbsp;</td>
<td style='font-size:12px; text-align:right;'> $poo&nbsp;</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></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='2'><b> Total Amount (VAT 18% Included) </th>
<th style='font-size:12px; text-align:right;' colspan='3'><b><?php echo $topo ?>&nbsp;&nbsp;</th></tr>
	</table><BR><BR>
	    
	    	<div class="divFooter">
	<table width='99%' style='font-size:11px;'>
	    <tr><td width='33%'> Prepared by: <br><br><br>
	<hr style='width:90%; float:left;'><br> ............... ........ <br><br>
	Procurement
	</td>
	
	<td>Verified by: <br><br><br>
	<hr style='width:90%; float:left;'><br> ................. ......... <br><br> Director of Finance </td>
	
	<td width='33%'> Approved by: <br><br><br>
	<hr style='width:90%; float:left;'><br> ............ ............ <br><br> Managing Director</td>
	</tr></table><br><br><br> Thanks for putting your Trust in Us!!!</div>
	
	 <?php
	echo"<div class='DONTPrint'><HR WIDTH='98%'>
	<table width='90%' border=0><tr>
	<td width='33%' align='left'><a href='$pago'><font face='Agency FB' color='blue' size='3'> BACK </a></td>
	
	<form action='sition.php' method='post'><td align='center'>
                <input type='hidden' name='rowid' value='$rowid'>
                <input type='hidden' name='date' value='$date'>
				<input type='hidden' name='dest' value='$dest'>
				<input type='hidden' name='p' value='0'>
				<input type='hidden' name='user' value='$user'>
		<input type='hidden' name='pago' value='requit.php'>
	    <button type='submit' name='opens' style='font-face:Agency FB; color:red; font-size:14px; border:0px; cursor:pointer; background-color:transparent;'> PRINT REQUISITION </button></td></form>
	<td width='33%' align=right><a href='#' onclick='javascript:printpage();window.close()'><font face='Agency FB' color='blue' size='3'> PRINT </a></td></tr></table><br><br></div>";
	?>
				
		<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>
