<script language="javascript" type="text/javascript">
   needToConfirm=false;
</script>

<?php 
include('../include/session.php');
$truss_num = $_POST['truss_num'];
$t5_num = $_POST['t5_num'];
$t7_num = $_POST['t7_num'];
$plates_num = $_POST['plates_num'];

$job_no = $_POST['job_no'];
$bill_id = $_POST['bill_id'];

$i=0;
while ($i<$truss_num) {
	$truss_type = $_SESSION['edit_truss_type_'.$i];
	$edit_value = $_POST['truss_edit'.$i];
	$_SESSION['edit_truss_quantity_'.$i] = $edit_value;
	$span_value = $_POST['truss_edit_span'.$i];
	$_SESSION['edit_truss_span_'.$i] = $span_value;
	$press_value = $_POST['truss_edit_press'.$i];
	$_SESSION['edit_truss_press_'.$i] = $press_value;
	
	
	if ($_SESSION['edit_truss_line'.$i]=='0') {
	$table_name = $_SESSION['db_prefix']."_cutting_bill_lines_edit_temp";
	$truss_query = "UPDATE $table_name SET quantity = '".$edit_value."', span = '".$span_value."', press_points = '".$press_value."' WHERE truss_type = '".$truss_type."' AND job_no = '".$job_no."' ";
	execsql($truss_query);	
	}
	$i++;
}

$j=0;
while ($j<$t5_num) {
	$store_item_id = $_SESSION['edit_t5_store_item_id_'.$j];
	
	$edit_value = $_POST['t5_edit'.$j];
	$_SESSION['edit_t5_quantity_'.$j] = $edit_value;
	if ($_SESSION['edit_t5_line'.$j]=='0') {
	$table_name = $_SESSION['db_prefix']."_cutting_bill_lines_edit_temp";
	$t5_query = "UPDATE $table_name SET quantity = '".$edit_value."' WHERE store_item_id = '".$store_item_id."' AND job_no = '".$job_no."' ";
	execsql($t5_query);	
	}
	$j++;
}

$j=0;
while ($j<$t7_num) {
	$store_item_id = $_SESSION['edit_t7_store_item_id_'.$j];
	
	$edit_value = $_POST['t7_edit'.$j];
	$_SESSION['edit_t7_quantity_'.$j] = $edit_value;
	if ($_SESSION['edit_t7_line'.$j]=='0') {
	$table_name = $_SESSION['db_prefix']."_cutting_bill_lines_edit_temp";
	$t7_query = "UPDATE $table_name SET quantity = '".$edit_value."' WHERE store_item_id = '".$store_item_id."' AND job_no = '".$job_no."' ";
	execsql($t7_query);	
	}
	$j++;
}

$j=0;
while ($j<$plates_num) {
	$store_item_id = $_SESSION['edit_plates_store_item_id'.$j];
	
	$edit_value = $_POST['plates_edit'.$j];
	$_SESSION['edit_plates_quantity_'.$j] = $edit_value;
	if ($_SESSION['edit_plates_line'.$j]=='0') {
	$table_name = $_SESSION['db_prefix']."_cutting_bill_lines_edit_temp";
	$t7_query = "UPDATE $table_name SET quantity = '".$edit_value."' WHERE store_item_id = '".$store_item_id."' AND job_no = '".$job_no."'  ";
	execsql($t7_query);	
	}
	$j++;
}

$_SESSION['edit_start']=1;

if (isset($_POST['truss_button']))  {
		$sub_category = 'Truss';
		$anchor = 'truss';		
}

if (isset($_POST['t5_button']))  {
		$sub_category = 't5';
		$anchor = 'class5';
}

if (isset($_POST['t7_button']))  {
		$sub_category = 't7';
		$anchor = 'class7';
}

if (isset($_POST['plates_button']))  {
		$sub_category = 'Plates';
		$anchor = 'plates';
}
		  
?>		  

<script language="javascript" type="text/javascript">
   window.location="cutting_bill_edit.php?screen=1&job_no=<?php echo $job_no?>&edit=1&sub_category=<?php echo $sub_category?>#<?php echo $anchor?>; ";
</script>



