<?php
	include "../db_connection/db_connection.php";
	include "../config/config.php";	
	$cat ='';
	$page_id	=	base64_decode(base64_decode(base64_decode(base64_decode($_POST['page_id']))));
	$guest_id 	= 	base64_decode(base64_decode(base64_decode(base64_decode($_POST['guest_id']))));
	$gg_id = "gu".$guest_id;
	if($page_id==1)
	{
		$SELECT="SELECT * FROM guest_user WHERE guest_id='$guest_id'";
		$QUERY=mysqli_query($connect,$SELECT);
		$FTCH=mysqli_fetch_object($QUERY);
		
		/*$SLCT_pos = "SELECT * FROM des_sel_temp_des WHERE party_det_id = '$gg_id'"; 
		$QURY_pos = mysqli_query($connect,$SLCT_pos);					
		while($FTCH_pos = mysqli_fetch_object($QURY_pos))*/
		foreach($_POST['category'] as $cat_id)
		{	
			$spl_id=explode(",",$cat_id);
			
			$catego_id	=	$spl_id[0];
			$design_id	=	$spl_id[1];		
			
			$SLCT_check_des = "SELECT * FROM  `guest_user_details` WHERE  `guest_user_id` ='$guest_id' AND `design_det_id` ='$design_id'"; 
			$QURY_check_des = mysqli_query($connect,$SLCT_check_des);
			if(mysqli_num_rows($QURY_check_des)>0)
			{
			}
			else
			{
				$INSRT		= "INSERT INTO guest_user_details(`guest_user_id`, `design_det_id`, `master_cat_id`,`post_dt`) VALUES ('$guest_id','$design_id','$catego_id','$cur_time')";	
				//echo $INSRT."<br>";
				$QURY		= mysqli_query($connect,$INSRT);	
			}
			$DELT1 = "DELETE FROM des_sel_temp_des WHERE party_det_id = '$gg_id' AND `design_det_id` ='$design_id'";
			//echo $DELT1."<br>";
			$QRY1    = mysqli_query($connect,$DELT1);
		}				
	}
	else if($page_id==2)
	{
		$DELT1 = "DELETE FROM des_sel_temp_des WHERE party_det_id = '$gg_id'";
		//echo $DELT1;
		$QRY1    = mysqli_query($connect,$DELT1);		
	}
?>

<script type="text/javascript">
    window.location='../guest_ord_req_pend_view.php';
</script>