
<?php
$table_name = $_SESSION['db_prefix']."_mworks_job_components";
$component_query = "SELECT component, quantity, produced_quantity, quantity_delivered, notes FROM $table_name WHERE job_card_no = '".$_SESSION['job_card_no']."' ";
$component_result = mySQL_query($component_query);
$component_num = mysql_num_rows($component_result);

$cust_id = $_SESSION['cust_id'];
?>

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

<!--jscript-->
<script language="JavaScript" src="../jscript/tooltip.js"  type="text/javascript"></script> 

</head>
<?php include('../include/wait.php') ?>

<body onLoad="MM_showHideLayers('wait','','hide')" onFocus="MM_showHideLayers('wait','','hide');"  onBlur="MM_showHideLayers('wait','','hide');">

<div class="wizard_page_middle_frame">
<form id="feedbackform" method="get" action="deliverJobWiz5.php" >
<div class="wizard_frame">
<?php 
include('../include/customer_block.php');
?>
</div> 
<div class="wizard_frame">
<table width="650" id="table_details_display">
    <tr>
      <td align="left" valign="top">Project:</td>
      <td colspan="2" align="left" valign="top"><?php  echo $_SESSION['project'];  ?></td>
      <td align="left" valign="top"><?php echo 'Job card no:&nbsp;&nbsp;'.$_SESSION['job_card_no'];  ?></td>
    </tr>
    <tr>
      <td align="left" valign="top">Project description:</td>
      <td colspan="3" align="left" valign="top"><?php  echo $_SESSION['project_description'];  ?></td>
      </tr>
    <tr>
      <td align="left" valign="top">Forman:</td>
      <td colspan="3" align="left" valign="top">&nbsp;</td>
      </tr>
    <tr>
      <td align="left" valign="top">Order date:</td>
      <td width="186" align="left" valign="top"><?php  echo date("d-m-Y", strtotime($_SESSION['order_date']));  ?></td>
      <td width="86" align="left" valign="top"></td>
      <td width="232" align="left" valign="top"></td>
    </tr>
    <tr>
      <td align="left" valign="top">Deliver date:</td>
      <td align="left" valign="top"><?php  echo date("d-m-Y", strtotime($_SESSION['deliver_date']));  ?></td>
      <td align="left" valign="top">&nbsp;</td>
      <td align="left" valign="top"></td>
      </tr>
    <tr>
      <td align="left" valign="top">Vehicle:</td>
      <td colspan="3" align="left" valign="top"><?php  echo $_SESSION['vehicle_name'];  ?></td>
    </tr>
    <tr>
      <td width="126" align="left" valign="top">Project place:</td>
      <td colspan="3" align="left" valign="top"><?php echo $_SESSION['project_no'] ?>&nbsp;&nbsp;<?php echo $_SESSION['project_area']?>&nbsp;&nbsp;<?php echo $_SESSION['project_place']?></td>
      </tr>
  </table>
</div>    
<div class="wizard_frame">Deliver:
        <table width="650" id="table_details_display">
          <tr>
            <td width="186">Item</td>
            <td width="216">Notes</td>
            <td width="66">Delivered</td>
            <td width="66">Balance</td>
            <td width="92">Deliver now</td>
          </tr>
          <?php 
  $i=0;
  while ($i<$component_num) {
	  $component = mysql_result($component_result, $i, "component");
	  $quantity = mysql_result($component_result, $i, "quantity");
	  $produced_quantity = mysql_result($component_result, $i, "produced_quantity");
	  $quantity_delivered = mysql_result($component_result, $i, "quantity_delivered");
	  
	  if ($produced_quantity=='') {$produced_quantity=0;}
	  $notes = mysql_result($component_result, $i, "notes");
	  $balance =$produced_quantity-$quantity_delivered;
	  
	?>
          <tr>
            <td><?php echo $component ?>
              <input type="hidden" name="component_text<?php echo $i?>" id="component_text<?php echo $i?>" value="<?php echo $component ?>"></td>
            <td><?php echo $notes ?></td>
            <td align="center"><?php echo $quantity_delivered ?>
              <input type="hidden" name="delivered_text<?php echo $i?>2" id="delivered_text<?php echo $i?>2" value="<?php echo $quantity_delivered ?>"></td>
            <td align="center"><?php echo $balance ?>
              <input type="hidden" name="balance_text<?php echo $i?>" id="balance_text<?php echo $i?>" value="<?php echo $balance ?>"></td>
            <td align="center"><?php echo $_SESSION['new_delivered'.$i] ?></td>
            <?php
	$i++;
  }
  $_SESSION['line_num'] = $i;
	?>
            <input name="line_num_text" id="line_num_text" type="hidden" value="<?php echo $_SESSION['line_num'] ?>">
          </tr>
        </table>
</div>       
    <div class="wizard_frame">
          <input name="s" type="hidden" id="s" value="3" />
          <input name="p" type="hidden" id="p" value="3" />
          <label class="label_std">If you want to make changes use the 'Prev' button to go back. <br />
            To finish the wizard click 'Finish'.</label>
    </div>
        <div class="wizard_frame">
      <table width="590" height="50" align="center" id="table_button_bar">
          <tr>
            <td width="117"><input type="button" name="lastprev_button" class="imagebutton" value="Prev" onClick="needToConfirm = false;   MM_showHideLayers('wait','','show'); MM_goToURL('parent','deliverJobWizbase.php?s=&p=2');return document.MM_returnValue" /></td>
            <td width="115">&nbsp;</td>
            <td width="99">&nbsp;</td>
            <td width="125"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton" onClick="javascript:cancel_confirmation(1, '../production/production_main.php'); needToConfirm = false;" value="Cancel" /></td>
            <td width="110"><input  name="finish_button" type="submit" class="imagebutton" id="finish_button" value="Finish" onClick="needToConfirm = false; MM_showHideLayers('wait','','show');"  /></td>
          </tr>
        </table>
        </div>

</form>
</div>