<?php
require_once ('../include/tc_calendar.php');
	$start = strtotime($_SESSION['inspection_date']);
	$d = date("d", $start );
	$m = date("m", $start );
	$y = date("Y", $start );
	
$table_name = $_SESSION['db_prefix']."_list_names_authorise";
$position_query = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
$arrId1 = array ();
$arrName1 = array ();
$position_result = execsql($position_query);
if ($position_result!="") {
$position_num = mysql_num_rows($position_result);
$b = 0;
while ($b < $position_num) {
		$arrId1[$b] = mysql_result($position_result, $b, "item_name");
		$arrName1[$b] = mysql_result($position_result, $b, "item_name");
		$b++;
}
}		

$table_name = $_SESSION['db_prefix']."_mworks_job_components";
$component_query = "SELECT component, quantity, produced_quantity, 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);

?>
<script type="text/javascript" src="../jscript/jquery.1.4.2.js"></script>
<script language="JavaScript" src="../jscript/gen_validatorv4.js"  type="text/javascript" xml:space="preserve"></script>
<script language="javascript" src="../jscript/calendar.js"></script>
</head>

<?php include('../include/wait.php') ?>
<link href="../css/wait.css" rel="stylesheet" type="text/css">
<body onLoad="MM_showHideLayers('wait','','hide')" onFocus="MM_showHideLayers('wait','','hide');"  onBlur="MM_showHideLayers('wait','','hide');">

<div class="wizard_page_middle_frame">
<form action="producedJobWiz5.php" method="get" name="form1" id="form1" >
     <div class="wizard_frame">Produced:
        <table width="600" id="table_details_display">
          <tr>
            <td width="129">Item</td>
            <td width="158">Notes</td>
            <td width="55">Quantity</td>
            <td width="65">Produced</td>
            <td width="65">Balance</td>
            <td width="102">Now Produced</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");
	  if ($produced_quantity=='') {$produced_quantity=0;}
	  $notes = mysql_result($component_result, $i, "notes");
	  $balance =$quantity-$produced_quantity;
	  
	?>
          <tr>
            <td><?php echo $component ?></td>
            <td><?php echo $notes ?></td>
            <td align="center"><?php echo $quantity ?>
              <input type="hidden" name="quantity_text<?php echo $i?>" id="quantity_text<?php echo $i?>" value="<?php echo $quantity ?>"></td>
            <td align="center"><?php echo $produced_quantity ?>
              <input type="hidden" name="produced_text<?php echo $i?>" id="produced_text<?php echo $i?>" value="<?php echo $produced_quantity ?>"></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_produced'.$i] ?></td>
            <?php
	$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">
        <table width="600" id="table_details_display">
  <tr>
    <td width="196" valign="top">Job was inspected by:</td>
    <td width="392"><?php echo $_SESSION['inspect']?>
      </td>
  </tr>
  <tr>
    <td valign="top">Inspection date:</td>
    <td><?php echo date("d-m-Y", strtotime($_SESSION['inspection_date']))?></td>
  </tr>
  <tr>
    <td valign="top">Produced for:</td>
    <td><?php if ($_SESSION['mworks']=='only') { ?>
      <img src="../images/M_only.png" width="16" height="16"> M-works
      <?php } else { ?>
Manase
<?php } ?></td>
  </tr>
        </table>
    </div>
    <div class="wizard_frame">
    <table width="600" id="table_details_display">
  <tr>
    <td width="296">Job approved?</td>
    <td><?php echo $_SESSION['approved'] ?></td>
  </tr>
</table>
</div>
   
    
    <div class="wizard_frame">
    <table width="600" id="table_details_display">
  <tr>
    <td width="166" valign="top">Inspection report notes:</td>
    <td width="422"><?php echo $_SESSION['inspection_notes'] ?></td>
  </tr>
</table>

    </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','producedJobWizbase.php?s=&amp;p=2');return document.MM_returnValue" /></td>
          <td width="115">&nbsp;</td>
          <td width="99"><input name="p" type="hidden" id="p" value="3" />
            <input name="s" type="hidden" id="s" value="3" />
            </span></td>
          <td width="125" align="right"><input name="cancelbutton" type="button" class="imagebutton" id="cancelbutton"  onClick="needToConfirm = false; cancel_confirmation(1, '../production/production_main.php');" value="Cancel" /></td>
          <td width="110" align="right"><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>

</body>      