<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php
include('../include/session.php');

$direct_delivery_no = $_GET['direct_delivery_no'];

$table_name = $_SESSION['db_prefix']."_direct_delivery";
$cash_query = "SELECT cust_id  FROM $table_name WHERE direct_delivery_no = '".$direct_delivery_no."' ";
$cash_result = mySQL_query($cash_query);
$cash_num = mysql_num_rows($cash_result);
$cust_id = mysql_result($cash_result, 0, "cust_id");

$quote='no';

$table_name2 = $_SESSION['db_prefix']."_customer";
		$customer_query = "SELECT * FROM $table_name2 WHERE cust_id ='".$cust_id."' ";
		$customer_result = mySQL_query($customer_query);
		$customer_num = mysql_num_rows($customer_result);	
		$a1 = mysql_result($customer_result, 0, "account_type");
			if ($a1=="corporate") { 
				$name = mysql_result($customer_result, 0, "comp_name"); 
			} 
			else {
				$name = mysql_result($customer_result, 0, "title")." ".mysql_result($customer_result, 0, "name_2")." ".mysql_result($customer_result, 0, "comp_name");
 			}
			
$table_name = $_SESSION['db_prefix']."_direct_delivery";
$supply_id_query = "SELECT direct_delivery_id, direct_delivery_no, issue_date  FROM $table_name WHERE  direct_delivery_no = '".$direct_delivery_no."' ";
$supply_id_result = mySQL_query($supply_id_query);
$supply_id_num = mysql_num_rows($supply_id_result);
$supply_date = mysql_result($supply_id_result, 0, "issue_date");
	
			
$table_name = $_SESSION['db_prefix']."_direct_delivery_lines";
$item_query = "SELECT store_item_id, item_name, quantity FROM $table_name WHERE  direct_delivery_no = '".$direct_delivery_no."' ";
$item_result = mySQL_query($item_query);
$item_num = mysql_num_rows($item_result);


$report_name = 'Delivery note';
?>

<!--style sheets-->
<link href="../css/main.css" rel="stylesheet" type="text/css" />

<style>
body {
	font-family:Arial, Helvetica, sans-serif;
	font-size:12px;
}
</style>
</head>
<body  onload="window.print(); window.close();" >
<?php include('../include/print_header.php'); ?>
<div class="print_main_frame" style="height:auto;">
<br>
<br>
<br>
 
 
<div class="print_standard_frame"> 
<?php 
		include ('../include/customer_block.php');
		echo '<br>';
		
		?>
</div>
<br>

<div class="print_standard_frame"><b>
<font size=+1;>Delivery<br>
</font> Deliver note no: <?php echo $direct_delivery_no ?>&nbsp;&nbsp;&nbsp;&nbsp;Delivery  date: <?php echo date("d-m-Y", strtotime($supply_date)) ?></b><br>
<br>

<table width="648" id="table_details_display">
  <tr>
    <td width="344">Item</td>
    <td width="40" align="center">Unit</td>
    <td width="76" align="center">Supplied</td>
    <td width="168" align="center">Received</td>
  </tr>
  <?php
  $i=0;
  while ($i<$item_num) {
	  $store_item_id = mysql_result($item_result, $i, "store_item_id");
	  $spec_name = mysql_result($item_result, $i, "item_name");
	  
	       		if (($store_item_id!=0) AND ($store_item_id<100000)) {
	       		$table_name = $_SESSION['db_prefix']."_store_items";
				$name_query = "SELECT item_name, register, unit FROM $table_name WHERE store_item_id = '".$store_item_id."'  ";
				$name_result = mySQL_query($name_query);
				$store_item_name = mysql_result($name_result, 0, "item_name");
				$register = mysql_result($name_result, 0, "register");
				$unit = mysql_result($name_result, 0, "unit");
			}
					
			if ($register=='yes') {
				  	$table_name = $_SESSION['db_prefix']."_store_register";
					$register_query = "SELECT serial_number FROM $table_name WHERE job_card = '".$job_card_no."'  AND store_item_id = '".$store_item_id."'  ";
					$register_result = mySQL_query($register_query);
					$serial = mysql_result($register_result, 0, "serial_number");
			}		 
					 
					 
	  $delivered = mysql_result($item_result, $i, "quantity");
	  ?>
  <tr>
    <td><?php echo $store_item_name ?>&nbsp;&nbsp;<?php if ($register=='yes') { echo 'serial no: '.$serial ; }?></td>
    <td align="center"><?php echo $unit ?>&nbsp;</td>
    <td align="center"><?php if ($unit!='no') {echo number_format($delivered, 2, '.', ',');} else { echo number_format($delivered, 0, '.', ','); } ?></td>
    <td align="center">&nbsp;</td>
  </tr>
  <?php
  $i++;
  }
  ?>
</table>
</div>
<br>
<br>
<div class="print_standard_frame">
Above items received by:<br>


  <br>
  <table width="650" id="table_details_display">
    <tr>
      <td width="47" height="58">Sign:</td>
      <td width="287" align="center">&nbsp;</td>
      <td width="56" align="left">Date:</td>
      <td width="240" align="center">&nbsp;</td>
    </tr>
   
  </table>
</div>
</div>
</body>

</html>