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

<?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";


$line_query = "SELECT *  FROM $table_name WHERE  maintenance_card_no =  '".$maintenance_card_no."' ";
$line_result = mySQL_query($line_query);
$line_num = mysql_num_rows($line_result);




?>

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

<title>Manase maintenance card <?php echo $maintenance_card_no ?></title>
<link rel="shortcut icon" type="image/x-icon" href="../images/favicon.ico">


<style>
body {
	font-family:Arial, Helvetica, sans-serif;
	font-size:12px;
}
</style>

</head>

<body  onload="window.print(); window.close();" >


<div id="page_1" style="page-break-after:always;">
<?php include('../include/print_header.php'); ?>
<div class="print_main_frame" style="height:auto;"><br>
<br>

  <div class="print_standard_frame">
          <table width="650" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="479"><label class="label_page_head">Maintenance card</label><br>
<b>&nbsp;&nbsp;Customer Copy</b></td>
              <td width="171">Maintenance card no: <?php echo $maintenance_card_no;  ?>
             </td>
            </tr>
          </table>
          </div>
          <br><br>


         
<div class="print_standard_frame">
<?php 
include('../include/customer_block.php');
?>
</div>  
<br>
  
<div class="print_standard_frame">
<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>
</div>  
<br>

<div class="print_standard_frame">
<b>Spares</b>
<table width="648" id="table_display" >
          <tr>
            <td height="26" colspan="2" align="left" valign="top">Item</td>
            <td width="95" align="left" valign="top">Group</td>
            <td width="63" align="center" valign="top">Unit</td>
            <td width="73" align="center" valign="top">Quantity<br>
              supplied</td>
            <td width="149" align="center" valign="top">Remarks</td>
        </tr>
          <?php
				$i=0;
				$sub_total_2=0;
				while ($i<$line_num){
					 $a0 = mysql_result($line_result, $i, "order_line_id");
					 $a1 = mysql_result($line_result, $i, "store_item_id");
					 
					 
					 $table_name = $_SESSION['db_prefix']."_store_items";
						$item_query = "SELECT item_name, unit, subCategory, register FROM $table_name WHERE store_item_id = '".$a1."' ";
						$item_result = mySQL_query($item_query);
						$a1a = mysql_result($item_result, 0, "item_name");
						$a3a = mysql_result($item_result, 0, "unit");
						$a4a = mysql_result($item_result, 0, "subCategory");
						$register = mysql_result($item_result, 0, "register");
					 
					 $a2 = mysql_result($line_result, $i, "quantity");
					 $a3 = mysql_result($line_result, $i, "delivered");
					 
					 
					$a8 = mysql_result($line_result, $i, "misc");
					
					if ($register=='yes') {
				  	$table_name = $_SESSION['db_prefix']."_store_register";
					$register_query = "SELECT serial_number FROM $table_name WHERE job_card = '".$maintenance_card_no."'  AND store_item_id = '".$a1."'  ";
					$register_result = mySQL_query($register_query);
					$serial = mysql_result($register_result, 0, "serial_number");
			}	
					 
				 ?>
          <tr>
            <td colspan="2" valign="top"><?php echo $a1a ?>&nbsp;
            <?php if ($register=='yes') { echo 'serial no: '.$serial ; }?></td>
            <td valign="top"><?php echo $a4a ?></td>
            <td align="center" valign="top"><?php echo $a3a ?></td>
            <td align="center" valign="top"><?php if (($a3!='') AND ($a3!='0.00')) { if ($a3a!='no') {echo number_format($a3, 2, '.', ',');} else { echo number_format($a3, 0, '.', ','); } }?></td>
            <td align="center" valign="top"><?php echo $a8 ?></td>
        </tr>
          <?php 
			  $i++;
				 }
				 ?>
         <?php
		 $j=0;
		 while ($j<(10-$line_num)) {
		 ?>       
          <tr>
            <td colspan="2" align="left" valign="top">&nbsp;</td>
            <td align="left" valign="top">&nbsp;</td>
            <td align="left" valign="top">&nbsp;</td>
            <td align="left" valign="top">&nbsp;</td>
            <td align="right" valign="top">&nbsp;</td>
        </tr>
		<?php
		$j++;
		 }
		?>
      </table>
        <br>
    <table width="650" id="table_display">
          <tr>
            <td height="87" colspan="4" valign="top">Details of work done:</td>
          </tr>
          <tr>
            <td colspan="4">&nbsp;</td>
          </tr>
          <tr>
            <td colspan="4">Undersigned accepts in good order the above mentioned works:</td>
          </tr>
          <tr>
            <td width="128" height="30">Customer Name:</td>
            <td width="196">&nbsp;</td>
            <td width="46">Date:</td>
            <td width="260">&nbsp;</td>
          </tr>
          <tr>
            <td height="30">Customer signature:</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td height="30">Site forman signature:</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
    </table>
    <br>

</div>      

   
</div>  
</div>

<div id="page_2" >
<?php include('../include/print_header.php'); ?>
<div class="print_main_frame" style="height:auto;"><br>
<br>

  <div class="print_standard_frame">
          <table width="650" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="479"><label class="label_page_head">Maintenance card</label><br>
<b>&nbsp;&nbsp;Manase copy</b></td>
              <td width="171">Maintenance card no: <?php echo $maintenance_card_no;  ?>
             </td>
            </tr>
          </table>
          </div>
          <br><br>


         
<div class="print_standard_frame">
<?php 
include('../include/customer_block.php');
?>
</div>  
<br>
  
<div class="print_standard_frame">
<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>
    <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="131" align="left" valign="top"><?php  echo date("d-m-Y", strtotime($order_date));  ?></td>
      <td width="101" align="left" valign="top"><?php  echo 'Job value'; ?></td>
      <td width="277" 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_area?>&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>
</div>  
<br>

<div class="print_standard_frame">
<b>Spares</b>
<table width="648" id="table_display" >
          <tr>
            <td height="26" colspan="2" align="left" valign="top">Item</td>
            <td width="95" align="left" valign="top">Group</td>
            <td width="63" align="center" valign="top">Unit</td>
            <td width="73" align="center" valign="top">Quantity<br>
              supplied</td>
            <td width="149" align="center" valign="top">Remarks</td>
        </tr>
          <?php
				$i=0;
				$sub_total_2=0;
				while ($i<$line_num){
					 $a0 = mysql_result($line_result, $i, "order_line_id");
					 $a1 = mysql_result($line_result, $i, "store_item_id");
					 
					 
					 $table_name = $_SESSION['db_prefix']."_store_items";
						$item_query = "SELECT item_name, unit, subCategory, register FROM $table_name WHERE store_item_id = '".$a1."' ";
						$item_result = mySQL_query($item_query);
						$a1a = mysql_result($item_result, 0, "item_name");
						$a3a = mysql_result($item_result, 0, "unit");
						$a4a = mysql_result($item_result, 0, "subCategory");
						$register = mysql_result($item_result, 0, "register");
					 
					 $a2 = mysql_result($line_result, $i, "quantity");
					 $a3 = mysql_result($line_result, $i, "delivered");
					 
					 
					$a8 = mysql_result($line_result, $i, "misc");
					
					if ($register=='yes') {
				  	$table_name = $_SESSION['db_prefix']."_store_register";
					$register_query = "SELECT serial_number FROM $table_name WHERE job_card = '".$maintenance_card_no."'  AND store_item_id = '".$a1."'  ";
					$register_result = mySQL_query($register_query);
					$serial = mysql_result($register_result, 0, "serial_number");
			}	
					 
				 ?>
          <tr>
            <td colspan="2" valign="top"><?php echo $a1a ?>&nbsp;
            <?php if ($register=='yes') { echo 'serial no: '.$serial ; }?></td>
            <td valign="top"><?php echo $a4a ?></td>
            <td align="center" valign="top"><?php echo $a3a ?></td>
            <td align="center" valign="top"><?php if (($a3!='') AND ($a3!='0.00')) { if ($a3a!='no') {echo number_format($a3, 2, '.', ',');} else { echo number_format($a3, 0, '.', ','); } }?></td>
            <td align="center" valign="top"><?php echo $a8 ?></td>
        </tr>
          <?php 
			  $i++;
				 }
				 ?>
         <?php
		 $j=0;
		 while ($j<(10-$line_num)) {
		 ?>       
          <tr>
            <td colspan="2" align="left" valign="top">&nbsp;</td>
            <td align="left" valign="top">&nbsp;</td>
            <td align="left" valign="top">&nbsp;</td>
            <td align="left" valign="top">&nbsp;</td>
            <td align="right" valign="top">&nbsp;</td>
        </tr>
		<?php
		$j++;
		 }
		?>
      </table>
        <br>
    <table width="650" id="table_display">
          <tr>
            <td height="87" colspan="4" valign="top">Details of work done:</td>
          </tr>
          <tr>
            <td colspan="4">&nbsp;</td>
          </tr>
          <tr>
            <td colspan="4">Undersigned accepts in good order the above mentioned works:</td>
          </tr>
          <tr>
            <td width="128" height="30">Customer Name:</td>
            <td width="196">&nbsp;</td>
            <td width="46">Date:</td>
            <td width="260">&nbsp;</td>
          </tr>
          <tr>
            <td height="30">Customer signature:</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr>
            <td height="30">Site forman signature:</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
    </table>
    <br>

</div>      

   
</div>  
</div>


</body>
</html>