<?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	=	$_POST['hdes_name']; 
	if($hdes_name=='')
	{
		$cad_sts = 'cad';
	}
	else
	{
		$cad_sts = 'emp';
	}
	$lob	=	$_POST['lob']; 
	$lob 	= str_replace("/", "-", $lob);
	
	$ot	=	$_POST['ot']; 
	if($ot==''){$ot=1; }

	foreach($_POST['category'] as $cat_id)
	{
		$INSRT		= "INSERT INTO cad_loading(`design_det_id`,`emp_det_id`, `loading_date`,`emp_load`,`cad_load`,`post_dt`,`operation_type`) VALUES ('$cat_id','$hdes_name','$lob','$cad_sts','$cad_sts','$cur_time','$ot')";	
		 //echo $INSRT;	
		$QURY		= mysqli_query($connect,$INSRT);

		$UPDATE = "UPDATE design_det SET design_status = 'In CAD Loading',update_dt = '$cur_time',operation_type='1' WHERE design_det_id = '$cat_id'";
		$QRY    = mysqli_query($connect,$UPDATE);
	}
}
if($page_id==2) //this is for basic details add page
{
	$hdes_name	=	$_POST['hdes_name']; 
	$cad_sts = 'emp';

	foreach($_POST['category'] as $cat_id)
	{
		$INSRT		= "UPDATE cad_loading SET `emp_det_id`='$hdes_name', `emp_load`='$cad_sts', `cad_load`='$cad_sts', update_dt ='$cur_time',operation_type='1' WHERE `design_det_id` = '$cat_id';";	
		 //echo $INSRT;	
		$QURY		= mysqli_query($connect,$INSRT);	
	}

	/*$UPDATE_cd = "UPDATE cad_loading SET cad_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='../cad_loading_list.php';
    </script>

