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

$maintenance_card_no=$_GET['maintenance_card_no'];
$table_name = $_SESSION['db_prefix']."_maintenance_jobs";
$job_query = "SELECT * FROM $table_name WHERE maintenance_card_no = '".$maintenance_card_no."' ";
$job_result = mySQL_query($job_query);
$maintenance_no = mysql_result($job_result, 0, "maintenance_no");
$cycle_no = mysql_result($job_result, 0, "cycle_no");
$cust_id = mysql_result($job_result, 0, "cust_id");
$quote_note = mysql_result($job_result, 0, "quote_note");
$value = mysql_result($job_result, 0, "value");
$order_date = mysql_result($job_result, 0, "date");
$start_date = mysql_result($job_result, 0, "start_date");
$end_date = mysql_result($job_result, 0, "end_date");
$project_description = mysql_result($job_result, 0, "project_description");
$project = mysql_result($job_result, 0, "project");

$project_no = mysql_result($job_result, 0, "project_no");
$project_place = mysql_result($job_result, 0, "project_place");
$project_area = mysql_result($job_result, 0, "project_area");
$deliver_date = mysql_result($job_result, 0, "start_date");
$team = mysql_result($job_result, 0, "team");
			
		
			
$table_name = $_SESSION['db_prefix']."_maintenance_job_lines";
$item_query = "SELECT store_item_id, item_name, delivered, store_reg_id FROM $table_name WHERE  maintenance_card_no = '".$maintenance_card_no."' ";
$item_result = mySQL_query($item_query);
$item_num = mysql_num_rows($item_result);

$report_name = 'Maintenance supply sheet';
?>

<!--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_report_header.php'); ?>
<div class="print_main_frame" style="height:auto; margin:20px;">
 
<div class="print_standard_frame"> 
  <p>
    <?php 
		include ('../include/customer_block.php');
		echo '<br>';
		
		
		
		
		?>
  </p>
  <table width="650" id="table_details_display">
    <tr>
      <td align="left" valign="top">Project:</td>
      <td align="left" valign="top"><?php  echo $project;  ?></td>
      <td align="left" valign="top"><?php echo 'Maintenance_card_no:'; ?></td>
      <td align="left" valign="top"><?php echo $maintenance_card_no;  ?></td>
    </tr>
    <?php if ($project=='Monthly maintenance') { ?>
    <tr>
      <td align="left" valign="top">Cycle number:</td>
      <td align="left" valign="top"><?php echo $cycle_no ?></td>
      <td align="left" valign="top">Maintenance contract no:</td>
      <td align="left" valign="top"><?php echo $maintenance_no ?></td>
    </tr>
    <?php } ?>
    <tr>
      <td align="left" valign="top">Team:</td>
      <td align="left" valign="top"><?php echo $team ?></td>
      <td align="left" valign="top">&nbsp;</td>
      <td align="left" valign="top">&nbsp;</td>
    </tr>
    <tr>
      <td align="left" valign="top"><?php  echo 'Order date:';?></td>
      <td width="173" align="left" valign="top"><?php  echo date("d-m-Y", strtotime($order_date));  ?></td>
      <td width="166" align="left" valign="top"><?php  echo 'Job value'; ?></td>
      <td width="170" align="left" valign="top"><?php   echo number_format($value, 2, '.', ','); ?></td>
    </tr>
    <tr>
      <td align="left" valign="top">Project period:</td>
      <td colspan="3" align="left" valign="top"><?php if ($deliver_date!='') {?>
        from: <?php echo date("d-m-Y", strtotime($deliver_date));  ?> to: <?php echo date("d-m-Y", strtotime($end_date));  ?>
        <?php } ?></td>
    </tr>
    <tr>
      <td width="121" align="left" valign="top">Project place:</td>
      <td colspan="3" align="left" valign="top"><?php echo $project_no?>&nbsp;&nbsp;<?php echo $project_area?>&nbsp;&nbsp;<?php echo $project_place?></td>
    </tr>
    <tr>
      <td align="left" valign="top">Notes:</td>
      <td colspan="3" align="left" valign="top"><?php echo $quote_note ?></td>
    </tr>
  </table>
  <p>&nbsp;</p>
</div>

<div class="print_standard_frame">
<font size=+1;>Supply to: <?php echo $team ?></font><br>
Supply no: <?php echo $maintenance_card_no ?>&nbsp;&nbsp;&nbsp;&nbsp;Supply date: <?php echo date("d-m-Y", strtotime($start_date)) ?><br>
<br>

<table width="650" id="table_details_display">
  <tr>
    <td width="448">Item</td>
    <td width="89" align="center">Supplied</td>
    <td width="89" align="center">Unit</td>
    <td width="92" align="center">Received</td>
  </tr>
  <?php
  $i=0;
  
  while ($i<$item_num) {
	  	$register='';
  		$unit='';
	  
	  $store_item_id = mysql_result($item_result, $i, "store_item_id");
	  $spec_name = mysql_result($item_result, $i, "item_name");
	  
	       		
	       		$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");
				
		$store_reg_id = mysql_result($item_result, $i, "store_reg_id");
	       			
						
			if ($register=='yes') {
				  	$table_name = $_SESSION['db_prefix']."_store_register";
					$register_query = "SELECT serial_number FROM $table_name WHERE store_register_id = '".$store_reg_id."' ";
					$register_result = mySQL_query($register_query);
					$serial = mysql_result($register_result, 0, "serial_number");
			}		 
					 
					 
	  $delivered = mysql_result($item_result, $i, "delivered");
	  ?>
  <tr>
    <td><?php echo $store_item_name ?>&nbsp;&nbsp;<?php if ($register=='yes') { echo 'serial no: '.$serial ; }?></td>
    <td align="center"><?php if ($unit!='no') {echo number_format($delivered, 2, '.', ',');} else { echo number_format($delivered, 0, '.', ','); } ?></td>
    <td align="center"><?php echo $unit ?></td>
    <td align="center">&nbsp;</td>
  </tr>
  <?php
  $i++;
  }
  ?>
</table>
</div>

<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>