<?php
	//Connects to your Database
	include "../db_connection/db_connection.php";
	include "../config/config.php";		
	$page_id	=	base64_decode(base64_decode(base64_decode($_GET['page_id']))); //THIS IS PAGE ID  
	                  
	//cat_name,d_no,hdes_name,imgInp
if($page_id==1) //this is for basic details add page	
{ 		
		$hdes_name	=	base64_decode(base64_decode(base64_decode(base64_decode($_POST['hdes_name']))));
		//$hdes_name	=	$_POST['hdes_name'];
		$lob		=	$_POST['lob'];
		$lob		= 	str_replace("/", "-", $lob);
		
		$st_tim		=	$_POST['st_tim'];
		
		$kdm_wt = $_POST['kdm_wgt'];
		$dus_wt = $_POST['dust_wgt'];
		
		$INSRT		= "INSERT INTO sol_finishing(`emp_det_id`, `finishing_date`, `finishing_time`, `kdm_return_weight`, `dust_weight`, `post_dt`) VALUES('$hdes_name','$lob','$st_tim	','$kdm_wt','$dus_wt','$cur_time')";		
		$QURY		= mysqli_query($connect,$INSRT);
		
		$SLCT_sk = "SELECT  MAX(sol_finishing_id) as max_ids FROM sol_finishing ORDER BY sol_finishing_id ASC";
		$QURY_sk = mysqli_query($connect,$SLCT_sk);  
		$FTCH_sk = mysqli_fetch_object($QURY_sk);
		$max_id = $FTCH_sk->max_ids;
		
		foreach($_POST['category'] as $cat_id)
		{
			$no_mas = $_POST['no_mas'][$cat_id];
			$sol_wt = $_POST['sol_wt'][$cat_id];
			$sil_wt = $_POST['sil_wt'][$cat_id];
			$run_wt = $_POST['run_wt'][$cat_id];
			$tot_wt = $_POST['tot_wt'][$cat_id];
			$wst_wt = $_POST['wst_wt'][$cat_id];
			
			
					
		$INSRT_d	= "INSERT INTO sol_finishing_des(`sol_finishing_id`, `design_det_id`, `master_pice`, `sol_weight`,`sil_weight`,`run_weight`,`tot_weight`,`wastage`, `post_dt`) VALUES('$max_id','$cat_id','$no_mas','$sol_wt','$sil_wt','$run_wt','$tot_wt','$wst_wt','$cur_time')";		
		$QURY_d		= mysqli_query($connect,$INSRT_d);
		
		//THI IS FOR UPDATING THE DESIGN STATUS
		$UPDATE = "UPDATE design_det SET master_pieces='$no_mas', design_status = 'In Soldering Finishing',update_dt = '$cur_time' WHERE design_det_id = '$cat_id'";
		$QRY    = mysqli_query($connect,$UPDATE); 
		
		//THI IS FOR UPDATING THE SOLDERING LOADING STATUS
		$UPDATE_cd = "UPDATE soldering_loading SET soldering_status = 'yes',update_dt = '$cur_time' WHERE design_det_id = '$cat_id'";
		$QRY_cd    = mysqli_query($connect,$UPDATE_cd); 	
		
		}
		
?>
		<script type="text/javascript">
            //alert("Data inserted successfully");
            //history.back();
            window.location='../sol_finishing_list.php';
        </script>
<?php
}
?>
	
