<?php
 	session_start(); 

	if(!isset($_SESSION['tulsilogin']))
	{
		header('Location: index.php');
		return;
	}


date_default_timezone_set("Asia/Kolkata");
$mdate1= date('Y-m-d H:i:s');
$mdate= date('d-m-Y');
$_SESSION['_token']=bin2hex(openssl_random_pseudo_bytes(16));
	
	$umid = $_SESSION['umid'];
	include("connect.php");

	
	//$cmname=$_POST['cmname'];
	
	
	
	
	$visatmid=$_POST['visatmid'];
	$subservicemid=$_POST['subservicemid'];
	$countrymid=$_POST['countrymid'];
	$blockname=$_POST['blockname'];
	
	

	if(!in_array('All',$subservicemid))
{
	$subservicemid = $_POST['subservicemid'];
}
else{
	
	if($visatmid == 'All')
	{
		$eve = "select subservicemid from res_subservice_master ";
	}else{
	 $eve = "select subservicemid from res_subservice_master where visatmid=$visatmid";
	}
		$re = mysqli_query($conn, $eve);
			$subservicemid = array();																
		while($rt = mysqli_fetch_assoc($re))

		{
			$subservicemid1 = $rt['subservicemid'];
			array_push($subservicemid,$subservicemid1);
		}

}
	
	
	foreach ($subservicemid as $one_by_one_sid) 
					{
						foreach ($blockname as $one_by_one_sid1) 
					{
						 $eve1 = "INSERT INTO res_inquirymoduleallocation_detail (countrymid,visatmid,subservicemid,blockname,imatype) VALUES('$countrymid','$visatmid','$one_by_one_sid','$one_by_one_sid1','Visa')";
		$re1 = mysqli_query($conn, $eve1);
					}
					
					}
		 

	header("Location: servicewisevisainquiryblockallocation.php");
			
	
?>