<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<link rel="stylesheet" type="text/css" href="../css/main.css" />

<?php
include('../include/session.php');	

$table_name = $_SESSION['db_prefix']."_authorised_timber";
$bracing_query = "SELECT auth_timber_group, auth_timber_name, store_item_id, reserved, de_authorised, delivered  FROM $table_name WHERE job_no = '".$_SESSION['job_no']."' AND $table_name.store_item_id>0 AND $table_name.reserved>0 AND  auth_timber_group='bracing' ORDER BY auth_timber_name ";
$bracing_result = mySQL_query($bracing_query);
$bracing_num = mysql_num_rows($bracing_result);

$sundries_query = "SELECT auth_timber_group, auth_timber_name, store_item_id, reserved, de_authorised, delivered FROM $table_name WHERE job_no = '".$_SESSION['job_no']."' AND  store_item_id>0 AND reserved>0 AND  auth_timber_group='sundries' ORDER BY auth_timber_name ";
$sundries_result = mySQL_query($sundries_query);
$sundries_num = mysql_num_rows($sundries_result);

$table_name = $_SESSION['db_prefix']."_supply_customer_temp";
$check_query = "SELECT supply_id FROM $table_name WHERE truss_type = 'Mitek' AND job_no = '".$_SESSION['job_no']."' AND user =  '".$_SESSION['username']."' "; 
$check_result = mySQL_query($check_query);
$check_num = mysql_num_rows($check_result);

$i=0;
while ($i<$check_num) {
	$table_name = $_SESSION['db_prefix']."_supply_customer_temp";
	$delete_query = "DELETE FROM $table_name WHERE truss_type = 'Mitek' AND job_no = '".$_SESSION['job_no']."' AND user =  '".$_SESSION['username']."' AND extra IS NULL ";
	execsql($delete_query);
	$i++;
}

$table_name = $_SESSION['db_prefix']."_supply_customer_temp";
$extra_bracing_query = "SELECT store_item_id, timber_type, quantity, notes_text  FROM $table_name WHERE truss_type = 'Bracing' AND job_no = '".$_SESSION['job_no']."' AND user =  '".$_SESSION['username']."' AND extra = 'yes' ";
$extra_bracing_result = mySQL_query($extra_bracing_query);
$extra_bracing_num = mysql_num_rows($extra_bracing_result);

$table_name = $_SESSION['db_prefix']."_supply_customer_temp";
$extra_query = "SELECT store_item_id, timber_type, quantity, notes_text  FROM $table_name WHERE truss_type = 'Sundries' AND job_no = '".$_SESSION['job_no']."' AND user =  '".$_SESSION['username']."' AND extra = 'yes' ";
$extra_result = mySQL_query($extra_query);
$extra_num = mysql_num_rows($extra_result);


$table_name = $_SESSION['db_prefix']."_list_sundries";
$dropDownQuery = "SELECT item_name FROM $table_name ORDER BY item_name ASC";
$dropDownResult = execsql($dropDownQuery);
	$num = mysql_num_rows($dropDownResult);
	$a = 0;
	$arrId = array ();
	$arrName = array ();
	while ($a < $num) {
		$arrId[$a] = mysql_result($dropDownResult, $a, "item_name");
		$arrName[$a] = mysql_result($dropDownResult, $a, "item_name");
		$a++;
	}
?>



<link rel="stylesheet" href="../window/dhtmlwindow.css" type="text/css" />
<link rel="stylesheet" href="../window/modal.css" type="text/css" />
<script type="text/javascript" src="../window/dhtmlwindow.js"></script>
<script type="text/javascript" src="../window/modal.js"></script>

<script language="JavaScript" src="../jscript/gen_validatorv4_2.js"  type="text/javascript" xml:space="preserve"></script>
<script language="JavaScript" src="../jscript/alert_message.js"  type="text/javascript"></script> 
<script language="JavaScript" src="../jscript/go_to_url.js"  type="text/javascript"></script> 
<script language="JavaScript" src="../jscript/numbers_only.js"  type="text/javascript"></script>   
<script language="JavaScript" src="../jscript/go_to_url.js"  type="text/javascript"></script> 
<script language="javascript" src="../jscript/chainedselects.js"></script>

<script type="text/javascript">
function validate_required(input,alerttxt,maxvalue)
{
with (input)
  {
  if (value>maxvalue)
    {
	alertMessage(2, 'variation_mitek.php', 'The quantity to de-authorise is higher than the outstanding authorised quantity.<br><br> Enter a quantity lower than the outstanding authorised quantity.');
	input.value = maxvalue;
	return false;
	}
  else
    {
    return true;
    }
  }
}
</script>



<script>
var disable_empty_list=true; //uncomment this line to disable empty selection lists

//===============BRACING=============
addListGroup("TimberB type", "bracing_type", "new_length_sel_bracing", "items");
//addListGroup("Direct materials", "timber", "sub_category", "items");

addOption("bracing_type", "-", "-", "-", 1); //Empty starter option

<?php
$table_name = $_SESSION['db_prefix']."_list_bracing";
$dropDownQuery = "SELECT item_name, width, depth, class FROM $table_name ORDER BY item_name ASC";
$dropDownResult = execsql($dropDownQuery);
$dropDown_num = mysql_num_rows($dropDownResult);
$i=0;
while ($i<$dropDown_num) {
	$line = mysql_result($dropDownResult, $i, "item_name");
	?>
	addList("bracing_type", "<?php echo $line ?>", "<?php echo $line ?>", "<?php echo $line ?>");
	<?php
	$i++;
}
	?>

addOption("<?php echo $line ?>", "-", "-", "-", 1); //Empty starter option
<?php
$k=0;
while ($k<$dropDown_num) {
	$line = mysql_result($dropDownResult, $k, "item_name");
	$width = mysql_result($dropDownResult, $k, "width");
	$depth = mysql_result($dropDownResult, $k, "depth");
	$class = mysql_result($dropDownResult, $k, "class");
	
	$table_name = $_SESSION['db_prefix']."_store_items";
	$length_query = "SELECT length FROM $table_name WHERE width = '".$width."' AND  depth = '".$depth."' AND class = '".$class."' ORDER BY length";
	$length_result = mySQL_query($length_query);
	$length_num = mysql_num_rows($length_result);
	
	$m=0;
	while ($m<$length_num) {
		$length = mysql_result($length_result, $m, "length");
	?>
	addList("<?php echo $line ?>", "<?php echo $length ?>", "<?php echo $length ?>", "");
	<?php 
		$m++;
	}
		?>
	<?php
	$k++;
}
?>
</script>

<SCRIPT>
var disable_empty_list=true; //uncomment this line to disable empty selection lists

//===============SUNDRIES=============
addListGroup("Timber type", "sundries_type", "new_length_sel", "items");
//addListGroup("Direct materials", "timber", "sub_category", "items");

addOption("sundries_type", "-", "-", "-", 1); //Empty starter option

<?php
$table_name = $_SESSION['db_prefix']."_list_sundries";
$dropDownQuery = "SELECT item_name, width, depth, class FROM $table_name ORDER BY item_name ASC";
$dropDownResult = execsql($dropDownQuery);
$dropDown_num = mysql_num_rows($dropDownResult);
$i=0;
while ($i<$dropDown_num) {
	$line = mysql_result($dropDownResult, $i, "item_name");
	?>
	addList("sundries_type", "<?php echo $line ?>", "<?php echo $line ?>", "<?php echo $line ?>");
	<?php
	$i++;
}
	?>

addOption("<?php echo $line ?>", "-", "-", "-", 1); //Empty starter option
<?php
$k=0;
while ($k<$dropDown_num) {
	$line = mysql_result($dropDownResult, $k, "item_name");
	$width = mysql_result($dropDownResult, $k, "width");
	$depth = mysql_result($dropDownResult, $k, "depth");
	$class = mysql_result($dropDownResult, $k, "class");
	
	$table_name = $_SESSION['db_prefix']."_store_items";
	$length_query = "SELECT length FROM $table_name WHERE width = '".$width."' AND  depth = '".$depth."' AND class = '".$class."' ORDER BY length";
	$length_result = mySQL_query($length_query);
	$length_num = mysql_num_rows($length_result);
	
	$m=0;
	while ($m<$length_num) {
		$length = mysql_result($length_result, $m, "length");
	?>
	addList("<?php echo $line ?>", "<?php echo $length ?>", "<?php echo $length ?>", "");
	<?php 
		$m++;
	}
		?>
	<?php
	$k++;
}
?>
</script>


</head>


<body style="width:675px;" onload="alertMessage(1, '', 'Variations need to be applied before delivering. Any values for delivery entered already are cleared.'); initListGroup('Timber type', document.forms[0].sundries_type, document.forms[0].new_length_select);  initListGroup('TimberB type', document.forms[0].bracing_type, document.forms[0].new_length_select_bracing);">
<form action="../store/deliverJobWizbase.php" method="get" name="form1" id="form1" target="_parent">


<!--===================BRACING====================--> 
  <div class="scroll_frame_medium" style="height:250px; width:630px;">
    <label class="label_std">De-authorise bracing items:</label>
    <br />
    <table width="609" id="table_details_display" >
      <tr>
        <td align="left" valign="top"><label class="label_std">Bracing Timber:</label></td>
        <td align="left" valign="top"><label class="label_std">Stock:</label></td>
        <td colspan="2" align="center" valign="top"><label class="label_std">de-Authorise to</label>
          <input name="edit_job_no" type="hidden" value="<?php echo $_SESSION['job_no']?>" /></td>
        <td align="center" valign="top"><label class="label_std">
          <label class="label_std">Reason to de-Authorise </label>
          </label></td>
      </tr>
      <?php 
				  $i=0;
				  
				  while ($i<$bracing_num) { 
				        $reason_text = '-';
					    $store_item_id = mysql_result($bracing_result, $i, "store_item_id");	
						$bracing_name = mysql_result($bracing_result, $i, "auth_timber_name");									
						$bracing_auth_quantity = mysql_result($bracing_result, $i, "reserved")-mysql_result($bracing_result, $i, "de_authorised");
						
						$table_name = $_SESSION['db_prefix']."_variations_temp";
						$variations_query = "SELECT de_auth_quantity, notes_text FROM $table_name WHERE job_no = '".$_SESSION['job_no']."' AND store_item_id = '".$store_item_id."' AND timber_name = '".$bracing_name."' AND user =  '".$_SESSION['username']."'  ";
						$variations_result = mySQL_query($variations_query);
						$variations_num = mysql_num_rows($variations_result);
						if ($variations_num>0){
						$bracing_de_auth = mysql_result($variations_result, 0, "de_auth_quantity");	
						$bracing_reason_text = mysql_result($variations_result, 0, "notes_text");
						}
						else {
						$bracing_de_auth=0;
						$bracing_reason_text='-';
						}
						$bracing_to_auth_quantity = $bracing_auth_quantity-$bracing_de_auth;
												
						$table_name = $_SESSION['db_prefix']."_store_items";
						$item_name_query = "SELECT item_name, unit, quantity FROM $table_name WHERE store_item_id = '".$store_item_id."' ";
						$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"); 
						$quantity = mysql_result($item_name_result, 0, "quantity"); 
						$_SESSION['bracing_auth_item_name'.$i] = $item_name;
				 ?>
      <tr>
        <td width="155"><?php echo $bracing_name?>
          <input name="bracing_name<?php echo $i?>" id="bracing_name<?php echo $i?>" type="hidden" value="<?php echo $bracing_name ?>" />
          <br />
          <?php echo $_SESSION['bracing_auth_item_name'.$i] ?>
          <input name="bracing_store_item_id<?php echo $i?>" id="bracing_store_item_id<?php echo $i?>" type="hidden" value="<?php echo $store_item_id ?>" /></td>
        <td width="64"><?php echo $quantity ?>&nbsp;</td>
        <td width="84" align="right"><input name="bracing_edit<?php echo $i?>" type="text" class="text60" id="bracing_edit<?php echo $i?>"  onfocus = "this.select();" style="text-align:right;" onkeyup="validate_required(bracing_edit<?php echo $i?>, 'The entered amount exceeds the outstanding authorised quantity, the entry will be cleared. ' +'\n'+ 'Please enter a valid amount.', <?php echo $bracing_auth_quantity ?>)" onkeypress="return numbersonly(this, event)" autocomplete="off"  value="<?php echo $bracing_to_auth_quantity ?>" onchange=" document.getElementById('bracing_reason_text<?php echo $i?>').value = '';"/></td>
        <td width="61" align="center"><?php echo $unit?></td>
        <td width="221" align="center"><input name="bracing_reason_text<?php echo $i?>" type="text" class="text200" id="bracing_reason_text<?php echo $i?>" maxlength="50" value="<?php echo $bracing_reason_text?>" /></td>
      </tr>
      <?php
						
			  $i++;
             }
			 $_SESSION['list_bracing'] = $i;
			 ?>
    </table>
    <label class="label_std">Authorise new bracing items:</label>
    <table width="609" id="table_details_display" >
      <?php
  
  $k=0;
  while ($k<$extra_num) { 
    $bracing_quantity='-';
	$bracing_notes_text='-';

	

	$store_item_id =mysql_result($extra_bracing_result, $k, "store_item_id");
	$timber_type =mysql_result($extra_bracing_result, $k, "timber_type");
		$table_name = $_SESSION['db_prefix']."_store_items";
		$name_query = "SELECT item_name FROM $table_name WHERE store_item_id = '".$store_item_id."'  ";
		$name_result = mySQL_query($name_query);
		$name_num = mysql_num_rows($name_result);
		if ($name_num!=0) {
		$item_name = mysql_result($name_result, 0, "item_name");
		}
		else {
			$item_name='';
		}
    $bracing_quantity =mysql_result($extra_bracing_result, $k, "quantity");
	$bracing_notes_text =mysql_result($extra_bracing_result, $k, "notes_text");
	
	$table_name = $_SESSION['db_prefix']."_store_items";
	$length_query = "SELECT length FROM $table_name WHERE store_item_id = '".$store_item_id."' ";
	$length_result = mySQL_query($length_query);
	$length = mysql_result($length_result, 0, "length");
	?>
      <tr>
        <td width="317" colspan="2"><?php echo $timber_type.'  '.$length; ?>
          <input name="bracing_store_item_select_<?php echo $k?>" type="hidden" value="<?php echo $timber_type?>" />
          <input name="bracing_length_select_<?php echo $k?>" type="hidden" value="<?php echo $length?>" /></td>
        <td width="59"><input name="bracing_new_qty_text_<?php echo $k?>" type="text" class="text50" id="bracing_new_qty_text_<?php echo $k?>" value="<?php echo $bracing_quantity ?>" onkeypress="return numbersonly(this, event)"/></td>
        <td width="235"><input name="bracing_new_reason_text_<?php echo $k?>" type="text" class="text200" id="bracing_new_reason_text_<?php echo $k?>"  value="<?php echo $bracing_notes_text ?>"/></td>
      </tr>
      <?php
	$k++;
  }?>
      <?php
  $store_item_id = '-';
  $quantity ='-';
  $notes_text ='-';
  while ($k<(1+$extra_num)) {
	  ?>
      <tr>
        <td><select name="bracing_store_item_select_<?php echo $k ?>" class="select200" id="bracing_type"   onblur=" document.getElementById('bracing_new_reason_text').value = ''; document.getElementById('bracing_new_qty_text').value = ''; "/>
        </select>
          </select></td>
        <td><select name="bracing_length_select_<?php echo $k ?>" class="select80" id="new_length_select_bracing" ; >
          <option value="-" selected="selected">-</option>
        </select></td>
        <td><input name="bracing_new_qty_text_<?php echo $k ?>" id="bracing_new_qty_text"  class="text60"  value="-" /></td>
        <td><input name="bracing_new_reason_text_<?php echo $k ?>" type="text" class="text200" id="bracing_new_reason_text"  value="-"/></td>
      </tr>
      <?php 
  $k++;
  $bracing_list2 = $k+$extra_num;
		}
		?>
      <input name="bracing_list2" type="hidden" value="<?php echo $k ?>" />
    </table>
  </div>
  
  
<!--===================SUNDRIES====================--> 
  
  <div class="scroll_frame_medium" style="height:250px; width:630px;">


<label class="label_std">De-authorise sundries items:</label>
<br />
<table width="609" id="table_details_display" >
  <tr>
    <td align="left" valign="top"><label class="label_std">Sundries Timber:</label></td>
    <td align="left" valign="top"><label class="label_std">Stock:</label></td>
    <td colspan="2" align="center" valign="top"><label class="label_std">de-Authorise to</label>
      <input name="edit_job_no2" type="hidden" value="<?php echo $_SESSION['job_no']?>" /></td>
    <td align="center" valign="top"><label class="label_std">
      <label class="label_std">Reason to de-Authorise </label>
      </label></td>
  </tr>
  <?php 
				  $i=0;
				  
				  while ($i<$sundries_num) { 
				        $reason_text = '-';
					    $store_item_id = mysql_result($sundries_result, $i, "store_item_id");	
						$sundries_name = mysql_result($sundries_result, $i, "auth_timber_name");									
						$sundries_auth_quantity = mysql_result($sundries_result, $i, "reserved")-mysql_result($sundries_result, $i, "de_authorised");
						
						$table_name = $_SESSION['db_prefix']."_variations_temp";
						$variations_query = "SELECT de_auth_quantity, notes_text FROM $table_name WHERE job_no = '".$_SESSION['job_no']."' AND store_item_id = '".$store_item_id."' AND timber_name = '".$sundries_name."' AND user =  '".$_SESSION['username']."'  ";
						$variations_result = mySQL_query($variations_query);
						$variations_num = mysql_num_rows($variations_result);
						if ($variations_num>0){
						$sundries_de_auth = mysql_result($variations_result, 0, "de_auth_quantity");	
						$sundries_reason_text = mysql_result($variations_result, 0, "notes_text");
						}
						else {
						$sundries_de_auth=0;
						$sundries_reason_text='-';
						}
						$sundries_to_auth_quantity = $sundries_auth_quantity-$sundries_de_auth;
						
						
						
						$table_name = $_SESSION['db_prefix']."_store_items";
						$item_name_query = "SELECT item_name, unit, quantity FROM $table_name WHERE store_item_id = '".$store_item_id."' ";
						$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"); 
						$quantity = mysql_result($item_name_result, 0, "quantity"); 
						$_SESSION['sundries_auth_item_name'.$i] = $item_name;
				 ?>
  <tr>
    <td width="155"><?php echo $sundries_name?>
      <input name="sundries_name<?php echo $i?>" id="sundries_name<?php echo $i?>" type="hidden" value="<?php echo $sundries_name ?>" />
      <br />
      <?php echo $_SESSION['sundries_auth_item_name'.$i] ?>
      <input name="sundries_store_item_id<?php echo $i?>" id="sundries_store_item_id<?php echo $i?>" type="hidden" value="<?php echo $store_item_id ?>" /></td>
    <td width="64"><?php echo $quantity ?>&nbsp;</td>
    <td width="84" align="right"><input name="sundries_edit<?php echo $i?>" type="text" class="text60" id="sundries_edit<?php echo $i?>"  onfocus = "this.select();" style="text-align:right;" onkeyup="validate_required(sundries_edit<?php echo $i?>, 'The entered amount exceeds the outstanding authorised quantity, the entry will be cleared. ' +'\n'+ 'Please enter a valid amount.', <?php echo $sundries_auth_quantity ?>)" onkeypress="return numbersonly(this, event)" autocomplete="off"  value="<?php echo $sundries_to_auth_quantity ?>" onchange=" document.getElementById('sundries_reason_text<?php echo $i?>').value = '';"/></td>
    <td width="61" align="center"><?php echo $unit?></td>
    <td width="221" align="center"><input name="sundries_reason_text<?php echo $i?>" type="text" class="text200" id="sundries_reason_text<?php echo $i?>" maxlength="50" value="<?php echo $sundries_reason_text?>" /></td>
  </tr>
  <?php
						
			  $i++;
             }
			 $_SESSION['list_sundries'] = $i;
			 ?>
</table>
<label class="label_std">Authorise new sundries items:</label>
<table width="609" id="table_details_display" >
  <?php
  
  $k=0;
  while ($k<$extra_num) { 
    $sundries_quantity='-';
	$sundries_notes_text='-';

	

	$store_item_id =mysql_result($extra_result, $k, "store_item_id");
	$timber_type =mysql_result($extra_result, $k, "timber_type");
		$table_name = $_SESSION['db_prefix']."_store_items";
		$name_query = "SELECT item_name FROM $table_name WHERE store_item_id = '".$store_item_id."'  ";
		$name_result = mySQL_query($name_query);
		$name_num = mysql_num_rows($name_result);
		if ($name_num!=0) {
		$item_name = mysql_result($name_result, 0, "item_name");
		}
		else {
			$item_name='';
		}
    $sundries_quantity =mysql_result($extra_result, $k, "quantity");
	$sundries_notes_text =mysql_result($extra_result, $k, "notes_text");
	
	$table_name = $_SESSION['db_prefix']."_store_items";
	$length_query = "SELECT length FROM $table_name WHERE store_item_id = '".$store_item_id."' ";
	$length_result = mySQL_query($length_query);
	$length = mysql_result($length_result, 0, "length");
	?>
  <tr>
    <td width="317" colspan="2"><?php echo $timber_type.'  '.$length; ?><input name="sundries_store_item_select_<?php echo $k?>" type="hidden" value="<?php echo $timber_type?>" /><input name="sundries_length_select_<?php echo $k?>" type="hidden" value="<?php echo $length?>" /></td>
    <td width="59"><input name="sundries_new_qty_text_<?php echo $k?>" type="text" class="text50" id="sundries_new_qty_text_<?php echo $k?>" value="<?php echo $sundries_quantity ?>" onkeypress="return numbersonly(this, event)"/></td>
    <td width="235"><input name="sundries_new_reason_text_<?php echo $k?>" type="text" class="text200" id="sundries_new_reason_text_<?php echo $k?>"  value="<?php echo $sundries_notes_text ?>"/></td>
    </tr>
    <?php
	$k++;
  }?>
  <?php
  $store_item_id = '-';
  $quantity ='-';
  $notes_text ='-';
  while ($k<(1+$extra_num)) {
	  ?>
      <tr>
    <td><select name="sundries_store_item_select_<?php echo $k ?>" class="select200" id="sundries_type"   onblur=" document.getElementById('sundries_new_reason_text').value = ''; document.getElementById('sundries_new_qty_text').value = ''; "/>
      </select></td>
    <td><select name="sundries_length_select_<?php echo $k ?>" class="select80" id="new_length_select" ; >
      <option value="-" selected="selected">-</option>
    </select></td>
    <td><input name="sundries_new_qty_text_<?php echo $k ?>" id="sundries_new_qty_text"  class="text60"  value="-">
    <td><input name="sundries_new_reason_text_<?php echo $k ?>" type="text" class="text200" id="sundries_new_reason_text"  value="-"/></td>
    </tr>
  <?php 
  $k++;
  $sundries_list2 = $k+$extra_num;
		}
		?>
   <input name="sundries_list2" type="hidden" value="<?php echo $k ?>" /> 
    
      
</table>

</div>

<div class="page_inside_frame" style="width:630px;">
<input name="save_button" type="submit" class="imagebutton" value="Save &amp; close" />&nbsp;&nbsp;&nbsp;&nbsp;
<input name="cancel_button" type="button" class="imagebutton" onclick="MM_goToURL('parent','../store/deliverJobWizbase.php?p=3&s=&all=');return document.MM_returnValue" value="Cancel" />
<input type="hidden" name="p" id="p" value="3"/>
<input type="hidden" name="s" id="s" value="12"/>
<input type="hidden" name="all" id="all" value=""/>
</div>
</form>
<!--form validation-->
<script language="JavaScript" type="text/javascript" xml:space="preserve">
  var frmvalidator  = new Validator("form1");
  frmvalidator.EnableMsgsTogether();
  </script>
  <?php 
  $j=0;
  while ($j<$_SESSION['list_bracing']) { 
  ?> 
  <script language="JavaScript" type="text/javascript" xml:space="preserve">
  frmvalidator.addValidation("bracing_reason_text<?php echo $j?>","req","Please enter a reason for changing authorisation for <?php echo $_SESSION['bracing_auth_item_name'.$j]?>");
  </script>
  <?php 
  $j++;
  }
  ?> 
  <?php 
  $j=0;
  while ($j<$_SESSION['list_sundries']) { 
  ?> 
  <script language="JavaScript" type="text/javascript" xml:space="preserve">
  frmvalidator.addValidation("sundries_reason_text<?php echo $j?>","req","Please enter a reason for changing authorisation for <?php echo $_SESSION['sundries_auth_item_name'.$j]?>");
  </script>
  <?php 
  $j++;
  }
  ?> 

  
<script language="JavaScript" type="text/javascript" xml:space="preserve">
  frmvalidator.addValidation("bracing_new_qty_text","req","Please enter a quantity for extra bracing authorisation");
  frmvalidator.addValidation("bracing_new_reason_text","req","Please enter a reason for extra bracing authorisation");
  frmvalidator.addValidation("sundries_new_qty_text","req","Please enter a quantity for extra sundries authorisation");
  frmvalidator.addValidation("sundries_new_reason_text","req","Please enter a reason for extra sundries authorisation");
  </script>
  

</body>
</html>