<head>
<?php
$screen = $_GET['screen'];

$table_name = $_SESSION['db_prefix']."_captured_mitek";
$table_name2 = $_SESSION['db_prefix']."_captured_mitek_temp";
$mitek_query = "SELECT cap_mitek_id, cap_item_id, cap_quantity, auth_quantity FROM $table_name WHERE cap_job = '".$_SESSION['job_no']."' UNION  SELECT cap_mitek_id, cap_item_id, cap_quantity, auth_quantity  FROM $table_name2 WHERE cap_job = '".$_SESSION['job_no']."' AND user =  '".$_SESSION['username']."'";

$mitek_result = mySQL_query($mitek_query);
$mitek_num = mysql_num_rows($mitek_result);

?>
<!--style sheets-->
<link rel="stylesheet" href="../window/dhtmlwindow.css" type="text/css" />
<link rel="stylesheet" href="../window/modal.css" type="text/css" />

<!--jscript-->
<script language="JavaScript" src="../jscript/numbers_only.js"  type="text/javascript"></script>  
<script type="text/javascript" src="../window/dhtmlwindow.js"></script>
<script type="text/javascript" src="../window/modal.js"></script>
<script language="JavaScript" src="../jscript/alert_message.js"  type="text/javascript"></script>
<script type="text/javascript" src="../jscript/jquery.1.4.2.js"></script>



</head>
<?php include('../include/wait.php') ?>
<link href="../css/wait.css" rel="stylesheet" type="text/css">
<body onLoad="MM_showHideLayers('wait','','hide'); <?php if ($screen==1) { ?>editwindow=dhtmlmodal.open('editBox', 'iframe', '../edit_windows/authorisation_add.php?category=Direct materials&sub_category=Mitek', 'Add item', 'width=500px,height=220px,center=1,resize=0,scrolling=0')
needToConfirm = false;
editwindow.onclose=function(){return window}; return false; <?php } ?> <?php if ($_SESSION['error_2']==1) {?>alertMessage(2, 'authorisationWizbase.php?p=2&s=', 'This item is already in the list and will not be added to the list.<br><br>If you require additional quantity, you should <br>edit the quantity in the list.');<?php }; $_SESSION['error_2']=0 ?>" onFocus="MM_showHideLayers('wait','','hide'); " onBlur="MM_showHideLayers('wait','','hide');  <?php if ($_SESSION['s']=='10') { ?> needToConfirm = false; <?php } ?> " >
<div class="page_middle_frame">
<form action="authorisationWizbase.php" method="get" name="form1" id="form1">
<table id="tableMain" width="595">
    <!--begin of tableMain-->
    <tr>
      <td><!--center of tableMain-->

        <div class="scroll_frame_medium" style="height:340px; width:640px;">
          <table width="599">
               <tr>
               <td colspan="5"><label class="label_std" style="font-size:14px;">eCoProducts:</label></td>
             </tr>
               <tr>
                 <td>&nbsp;</td>
                 <td>&nbsp;</td>
                 <td colspan="2"><label class="label_std">Captured</label></td>
                 <td><label class="label_std">Authorise</label></td>
               </tr>
             <?php 
				  $i=0;
				  $_SESSION['list_3'] = $mitek_num;
				  while ($i<$mitek_num) { 
				        $_SESSION['mitek_line'.$i] = mysql_result($mitek_result, $i, "cap_mitek_id");
					    $_SESSION['item_id'.$i] = mysql_result($mitek_result, $i, "cap_item_id");
						
						
						if ($_SESSION['start2']==0) {
							
						if ($_SESSION['quantity_'.$i]=='') {
						       $_SESSION['quantity_'.$i] = mysql_result($mitek_result, $i, "cap_quantity");
						}
						
						if ($_SESSION['quantity_'.$i]=='0') {
						       $_SESSION['quantity_'.$i] = mysql_result($mitek_result, $i, "auth_quantity");
						}
						}
						
						if ($_SESSION['mitek_line'.$i]=='0') {
							  
							     $_SESSION['quantity_'.$i] = mysql_result($mitek_result, $i, "auth_quantity");
						}
						
						$quantity = mysql_result($mitek_result, $i, "cap_quantity");
						$table_name = $_SESSION['db_prefix']."_store_items";
						$item_name_query = "SELECT item_name, unit FROM $table_name WHERE store_item_id = '".$_SESSION['item_id'.$i]."' ";
						$item_name_result = mySQL_query($item_name_query);
						$item_name = mysql_result($item_name_result, 0, "item_name"); 
						$unit = mysql_result($item_name_result, 0, "unit"); 
								
				 ?>
             <tr>
               <td colspan="2"><label class="label_std" ><?php echo $item_name ?>
                 <input type="hidden" name="mitek_line_<?php echo $i?>" id="mitek_line_<?php echo $i?>" value="<?php echo $_SESSION['mitek_line'.$i] ?>">
                 <input type="hidden" name="mitek_num" id="mitek_num" value="<?php echo $mitek_num?>">
               </label></td>
               <td width="37" align="right"><label for="textfield"><?php echo $quantity?></label></td>
               <td width="58">&nbsp;&nbsp;<?php echo $unit ?></td>
               <td width="231"><input name="quantity_text_<?php echo $i?>" type="text" class="text60" id="quantity_text_<?php echo $i?>" style="text-align:right" onKeyPress="return numbersonly(this, event)"  value="<?php echo $_SESSION['quantity_'.$i] ?>" autocomplete="off" autofocus tabindex="<?php echo $i+1 ?>">
&nbsp;&nbsp;<?php echo $unit ?></td>
             </tr>
             <?php
			  $i++;
             }
             ?>
             <tr>
               <td colspan="2">
                 <input type="submit" name="Submit" id="button"  class="imagebutton" value="Add"  onClick="needToConfirm=false; this.form.action='authorisationWiz2_save.php';  MM_showHideLayers('wait','','show');"></td>
               <td align="right">&nbsp;</td>
               <td>&nbsp;</td>
               <td>&nbsp;</td>
             </tr>
           </table>
         </div>
      </td>
      </tr>
      <tr>
      <td><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','authorisationWizbase.php?s=&amp;p=1');return document.MM_returnValue"  tabindex="<?php echo $i+3 ?>"/></td>
          <td width="115">&nbsp;</td>
          <td width="99"><input name="p" type="hidden" id="p" value="2" />
            <input name="s" type="hidden" id="s" value="2" />
            </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" tabindex="<?php echo $i+4 ?>" /></td>
          <td width="110" align="right"><input type="submit" name="next_button" class="imagebutton" value="Next" onClick="needToConfirm = false;  MM_showHideLayers('wait','','show');" tabindex="<?php echo $i+2 ?>"/></td>
        </tr>
      </table></td>
      </tr>
      </table>
</form>
</div>
</body>      