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

$class5_num = $_POST['class5_num'];
$class7_num = $_POST['class7_num'];
$mitek_num = $_POST['mitek_num'];
$bracing_num = $_POST['bracing_num'];
$sundries_num = $_POST['sundries_num'];
$additional_num = $_POST['additional_num'];
$job_no = $_POST['job_no'];

$_SESSION['press_points'] = $_POST['press_points_edit'];
$_SESSION['plate_area'] = $_POST['plate_area_edit'];


$i=0;
while ($i<$class5_num) {
	//$bracing_name = $_SESSION['s5_cap_timber'.$i];
	$edit_value = $_POST['class5_edit'.$i];
	$_SESSION['edit_class5_quantity_'.$i] = $edit_value;
	
	//if ($_SESSION['edit_bracing_line'.$i]=='0') {
//	$table_name = $_SESSION['db_prefix']."_captured_timber_edit_temp";
//	$bracing_query = "UPDATE $table_name SET cap_timber_length = '".$edit_value."' WHERE cap_timber_name = '".$bracing_name."' AND cap_job = '".$job_no."' ";
//	//echo '<br>'.$bracing_query;
//	execsql($bracing_query);
//	}
	$i++;
}

$i=0;
while ($i<$class7_num) {
	//$bracing_name = $_SESSION['s7_cap_timber'.$i];
	$edit_value = $_POST['class7_edit'.$i];
	$_SESSION['edit_class7_quantity_'.$i] = $edit_value;
	
	//if ($_SESSION['edit_bracing_line'.$i]=='0') {
//	$table_name = $_SESSION['db_prefix']."_captured_timber_edit_temp";
//	$bracing_query = "UPDATE $table_name SET cap_timber_length = '".$edit_value."' WHERE cap_timber_name = '".$bracing_name."' AND cap_job = '".$job_no."' ";
//	//echo '<br>'.$bracing_query;
//	execsql($bracing_query);
//	}
	$i++;
}




$i=0;
while ($i<$mitek_num) {
	$mitek_item_id = $_SESSION['edit_mitek_item_id'.$i];
	$edit_value = $_POST['mitek_edit'.$i];
	$_SESSION['edit_mitek_quantity_'.$i] = $edit_value;
	
	if ($_SESSION['edit_mitek_line'.$i]=='0') {
	$table_name = $_SESSION['db_prefix']."_captured_mitek_edit_temp";
	$mitek_query = "UPDATE $table_name SET cap_quantity = '".$edit_value."' WHERE cap_item_id = '".$mitek_item_id."' AND cap_job = '".$job_no."' ";
	//echo '<br>'.$mitek_query;
	execsql($mitek_query);	
	}
	$i++;
}

$i=0;
while ($i<$bracing_num) {
	$bracing_name = $_SESSION['edit_bracing_name'.$i];
	$edit_value = $_POST['bracing_edit'.$i];
	$_SESSION['edit_bracing_quantity_'.$i] = $edit_value;
	
	if ($_SESSION['edit_bracing_line'.$i]=='0') {
	$table_name = $_SESSION['db_prefix']."_captured_timber_edit_temp";
	$bracing_query = "UPDATE $table_name SET cap_timber_length = '".$edit_value."' WHERE cap_timber_name = '".$bracing_name."' AND cap_job = '".$job_no."' ";
	//echo '<br>'.$bracing_query;
	execsql($bracing_query);
	}
	$i++;
}

$i=0;
while ($i<$sundries_num) {
	$bracing_name = $_SESSION['edit_sundries_name'.$i];
	$edit_value = $_POST['sundries_edit'.$i];
	$_SESSION['edit_sundries_quantity_'.$i] = $edit_value;
	
	if ($_SESSION['edit_sundries_line'.$i]=='0') {
	$table_name = $_SESSION['db_prefix']."_captured_timber_edit_temp";
	$sundries_query = "UPDATE $table_name SET cap_timber_length = '".$edit_value."' WHERE cap_timber_name = '".$bracing_name."' AND cap_job = '".$job_no."' ";
	//echo '<br>'.$sundries_query;
	execsql($sundries_query);
	}
	$i++;
}

$m=0;
while ($m<$additional_num) {
	$additional_item_id = $_SESSION['edit_additional_item_id'.$m];
	$edit_value = $_POST['additional_edit'.$m];
	$_SESSION['edit_additional_quantity_'.$m] = $edit_value;
		
	
	if ($_SESSION['edit_additional_line'.$m]=='0') {
	$table_name = $_SESSION['db_prefix']."_captured_sundries_edit_temp";
	$additional_query = "UPDATE $table_name SET cap_quantity = '".$edit_value."' WHERE cap_item_id = '".$additional_item_id."' AND cap_job = '".$job_no."' ";
	execsql($additional_query);	
	}
	$m++;
}


$_SESSION['edit_start']=1;

if (isset($_POST['timber_button']))  {
		$sub_category = 'Timber';
		
}

if (isset($_POST['mitek_button']))  {
		$sub_category = 'Mitek';
		
		
}

if (isset($_POST['bracing_button']))  {
		$sub_category = 'Bracing';
		
}

if (isset($_POST['sundries_button']))  {
		$sub_category = 'Sundries2';
		
}

if (isset($_POST['additional_button']))  {
		$sub_category = 'Sundries';
		
}
		  
?>		  

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



