<?php
 	session_start(); 

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



$_SESSION['_token']=bin2hex(openssl_random_pseudo_bytes(16));
	
	
	include("connect.php");
include("mylibrary.php");
	
	//$packagename=$_POST['packagename'];
	$packagename=checkvalidstring ($_POST['packagename']);
	
	$pdescription=checkvalidstring ($_POST['pdescription']);
	
	$pcurrency=checkvalidstring ($_POST['pcurrency']);
	
	$pcurrencyrate=checkvalidstring($_POST['pcurrencyrate']);
	
	 $pcurrencyinr=checkvalidstring($_POST['pcurrencyinr']);
	
	if($_SESSION['utype']=="admin")
	{ 
	$branchmid=checkvalidstring ($_POST['branchmid']);
	}
	else
	{
		$branchmid= $_SESSION['branchid'];
	}
		
	$delete_checkbox_array = $_POST['subservicemid'];
		$n=0;
			foreach ($delete_checkbox_array as $one_by_one_sid) 
			{
				$subservicemid=$one_by_one_sid;
				if($subservicemid==0)
				{
				}
				else
				{		
		 $eve1 = "INSERT INTO res_package_master (packagename,pdescription,pcurrency,pcurrencyrate,pcurrencyinr,branchmid,ptype,subservicemid) VALUES('$packagename','$pdescription','$pcurrency','$pcurrencyrate','$pcurrencyinr','$branchmid','Branch','$subservicemid')";
		
		
		$re1 = mysqli_query($conn, $eve1);
			

			
	}
			}
				$_SESSION['msg'] = "Record saved successfully";
	header('Location: package.php');
?>