<!--
 * this file is to be used in combination with special_item_select_header.php
 *
-->

<script language="JavaScript" src="../jscript/numbers_only.js"  type="text/javascript"></script>  
<script language="JavaScript" src="../jscript/numbers_only_decimal.js"  type="text/javascript"></script>  

<div class="wizard_frame"><br>
    <table id="dataTable2" width="635" border="1" style="border-collapse:collapse;">
    <?php
	
/* 
 *
 */
	   if ($line2_num==0) {
	       
		   $a21='-';
		   $a22='-';
		   $a23='-';
		   $a24='';
		   
	   }
	   else {
		   
		   $a21 = mysql_result($line2_result, 0, "order_no").' - '.mysql_result($line2_result, 0, "item_name");
		   $a22 = mysql_result($line2_result, 0, "quantity");
		   $a23 = mysql_result($line2_result, 0, "price");
		   $a24 = mysql_result($line2_result, 0, "special_order_id");
		   
	   }
		?>
    <thead> 
        <tr>
          <td>&nbsp;</td>
          <td>Special orders (order no - item)</td>
          <td>Quantity</td>
          <td>Unit price</td>
        </tr>
        </thead>
        <script>
			 function check_it2() {
				 if (document.getElementById('line_checkbox20').checked) {
					     <?php if ($page=='purchase') { ?>
                         document.getElementById('line_checkbox20').hidden = true;
                         <?php } ?>
                         document.getElementById('item_select20').style.background = '#F0F0F0';
						 document.getElementById('quantity_text20').style.background = '#F0F0F0';
						 document.getElementById('amount_text20').style.background = '#F0F0F0';
						 document.getElementById('item_select20').selectedIndex=-1;
						 document.getElementById('item_select20').value = '.';
						 document.getElementById('quantity_text20').value = '.';
						 document.getElementById('amount_text20').value = '.';
						 document.getElementById('item_select20').disabled = true;
						 document.getElementById('item_text20').disabled = true;
						 document.getElementById('quantity_text20').disabled = true;
						 document.getElementById('amount_text20').disabled = true;
						 
                } else {
                        document.getElementById('item_select20').style.background = '#FFF';
						document.getElementById('quantity_text20').style.background = '#FFF';
						 document.getElementById('amount_text20').style.background = '#FFF';
						 document.getElementById('item_select20').selectedIndex=-1;
						 document.getElementById('quantity_text20').value = '';
						 document.getElementById('amount_text20').value = '';
						 document.getElementById('item_select20').disabled = false;
						 document.getElementById('quantity_text20').disabled = false;
						 document.getElementById('amount_text20').disabled = false;
                }
				}
		     </script>
        <tr>
            <td width="20"><input type="checkbox" name="line_checkbox20" id="line_checkbox20" onMouseUp="check_it2()" <?php if ($a21!='-') {?>checked <?php } ?> /></td>
          <td width="299"><select name="item_select20" id="item_select20" class="select300"  <?php if ($page=='purchase') { ?> disabled="disabled" <?php } ?> onChange="document.getElementById('line_checkbox20').checked=true; document.getElementById('quantity_text20').disabled = false; document.getElementById('amount_text20').disabled = false; document.getElementById('quantity_text20').value = ''; document.getElementById('amount_text20').value = ''; document.getElementById('special_order_id20').value = document.getElementById('item_select20').value;"  >
            <option value="<?php echo $a24 ?>" selected="selected"><?php echo $a21 ?></option>
            <?php 
    	for ($w = 0; $w < count($arrId200); $w++) {
		echo "<option value=".$arrId200[$w].">" . $arrName200[$w] . "</option>";	
	    }
     ?>
     
          </select>
          <input type="hidden" name="special_order_id20" id="special_order_id20"  value="<?php echo $a24 ?>"/></td>
          <td width="144" align="right"><input  name="quantity_text20" type="text" class="text60" id="quantity_text20" value="<?php echo $a22 ?>" style="text-align:right;" onKeyPress="return numbersonly(this, event)" <?php if ($a22=='-') {?>disabled="true" <?php } ?> autocomplete="off"/></td>
            <td width="144" align="right"><input  name="amount_text20" type="text" class="text60" id="amount_text20" value="<?php if ($a23!=0) {echo number_format($a23, 2, '.', ',');} else {echo '-'; } ?>" onKeyPress="return isNumberKey(event)" onKeyUp=" this.value = this.value.replace (/(\...).*/, '$1')" style="text-align:right"  <?php if ($a23=='-') {?>disabled="true" <?php } ?> autocomplete="off"/><input type="hidden" name="line_num2" id="line_num2" value="1"/><input type="hidden" name="line_num2" id="line_num2" value="1" >
        
        <?php
		$i=1;
		while ($i<$line2_num) {

		   $a21 = mysql_result($line2_result, $i, "order_no").' - '.mysql_result($line2_result, $i, "item_name");
		   $a22 = mysql_result($line2_result, $i, "quantity");
		   $a23 = mysql_result($line2_result, $i, "price");
		   $a24 = mysql_result($line2_result, $i, "special_order_id");
		   
		?>
        <tr>
            <td width="20"><input type="checkbox" name="line_checkbox2<?php echo $i ?>" id="line_checkbox2<?php echo $i ?>"  <?php if ($a21!='') { ?> checked="checked" <?php } ?> onMouseUp="{
				 if (document.getElementById('line_checkbox2<?php echo $i ?>').checked) {
                		 <?php if ($page=='purchase') { ?>
                         document.getElementById('line_checkbox2<?php echo $i ?>').hidden = true;
                         <?php } ?>
                         document.getElementById('item_select2<?php echo $i ?>').style.background = '#F0F0F0';
						 document.getElementById('quantity_text2<?php echo $i ?>').style.background = '#F0F0F0';
						 document.getElementById('amount_text2<?php echo $i ?>').style.background = '#F0F0F0';
						 document.getElementById('item_select2<?php echo $i ?>').selectedIndex=-1;
						 document.getElementById('item_select2<?php echo $i ?>').value = '.';
						 document.getElementById('quantity_text2<?php echo $i ?>').value = '.';
						 document.getElementById('amount_text2<?php echo $i ?>').value = '.';
						 document.getElementById('item_select2<?php echo $i ?>').disabled = true;
						 document.getElementById('item_text2<?php echo $i ?>').disabled = true;
						 document.getElementById('quantity_text2<?php echo $i ?>').disabled = true;
						 document.getElementById('amount_text2<?php echo $i ?>').disabled = true;
						 
                } else {
                        document.getElementById('item_select2<?php echo $i ?>').style.background = '#FFF';
						document.getElementById('quantity_text2<?php echo $i ?>').style.background = '#FFF';
						 document.getElementById('amount_text2<?php echo $i ?>').style.background = '#FFF';
						 document.getElementById('item_select2<?php echo $i ?>').selectedIndex=-1;
						 document.getElementById('quantity_text2<?php echo $i ?>').value = '';
						 document.getElementById('amount_text2<?php echo $i ?>').value = '';
						 document.getElementById('item_select2<?php echo $i ?>').disabled = false;
						 document.getElementById('quantity_text2<?php echo $i ?>').disabled = false;
						 document.getElementById('amount_text2<?php echo $i ?>').disabled = false;
                }
				}
                "/></td>
          <td width="299"><select name="item_select2<?php echo $i ?>" id="item_select2<?php echo $i ?>" class="select300"  <?php if ($page=='purchase') { ?> disabled="disabled" <?php } ?> onchange="document.getElementById('special_order_id2<?php echo $i ?>').value = document.getElementById('item_select2<?php echo $i ?>'.value;"> <option value="<?php echo $a24 ?>" selected="selected"><?php echo $a21 ?> </option>
            <?php 
    	for ($w = 0; $w < count($arrId200); $w++) {
		echo "<option value=".$arrId200[$w] . " " . ">" . $arrName200[$w] . "</option>";	
	    }
     ?>
          </select> &nbsp;
          <input type="hidden" name="special_order_id2<?php echo $i ?>" id="special_order_id2<?php echo $i ?>"  value="<?php echo $a24 ?>"/></td>
          <td width="144" align="right"><input  name="quantity_text2<?php echo $i ?>" type="text" class="text60" id="quantity_text2<?php echo $i ?>" value="<?php echo $a22 ?>" onKeyPress="return numbersonly(this, event)" style="text-align:right" autocomplete="off"/></td>
            <td width="144" align="right"><input  name="amount_text2<?php echo $i ?>" type="text" class="text60" id="amount_text2<?php echo $i ?>" value="<?php echo number_format($a23, 2, '.', ',') ?>" onKeyPress="return isNumberKey(event)" onKeyUp=" this.value = this.value.replace (/(\...).*/, '$1')" style="text-align:right" autocomplete="off"/>              <input type="hidden" name="line_num2" id="line_num2" value="<?php echo $line2_num?>"></td>
        </tr>
        <?php
		$i++;
		}
		?>
        
  </table>
  
    <input type="button" class="imagebutton" onClick="addRow2('dataTable2')" value="Add line" />
    <div align="right">
      <label class="label_small">To delete a line: uncheck line box.</label></div>
		
  </div>