<?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'];
	 if(isset($_POST['imid1']))
	{
	$imid1=$_POST['imid1'];
	}
	
	$stiqmid=$_POST['stiqmid'];
	$eve2 = "select imid from res_studentinquiry_detail where stiqmid=$stiqmid";
	$re2 = mysqli_query($conn, $eve2);
	while($rt2 = mysqli_fetch_assoc($re2))

	{
		$imid1 = $rt2['imid'];
	}
	
	$gicbankname=$_POST['gicbankname'];
	
	$gusername=$_POST['gusername'];
	$gpassword=$_POST['gpassword'];
	$gcreatedate=date("Y-m-d",strtotime($_POST['gcreatedate']));
	$gwiretransferrecevieddate=date("Y-m-d",strtotime($_POST['gwiretransferrecevieddate']));
	$gpaydate=date("Y-m-d",strtotime($_POST['gpaydate']));
	$gcertificatereceiveddate=date("Y-m-d",strtotime($_POST['gcertificatereceiveddate']));
	$gwiretransfer=$_POST['gwiretransfer'];
	$gmodeofpayment=$_POST['gmodeofpayment'];
	$gpaymentvalue=$_POST['gpaymentvalue'];
	$gtranscationcharges=$_POST['gtranscationcharges'];
	$gpaystatus=$_POST['gpaystatus'];
	$gcertificatestatus=$_POST['gcertificatestatus'];
	$gcertificatedocument=$_POST['gcertificatedocument'];
	$gcurrency=$_POST['gcurrency'];
	$grate=$_POST['grate'];
	
	
	
	$gcertificatedocument="";
	
	if(empty($_FILES['gcertificatedocument']['name']) == false  )
	{
		$simplephoto11=$_FILES['gcertificatedocument']['name'];
		$ext = pathinfo($simplephoto11, PATHINFO_EXTENSION);
		$fileexplode1 = explode(".",$simplephoto11);
		$fileend1 = end($fileexplode1);

		 $gcertificatedocument= date("YmdHis").rand(100,999).".".$fileend1;
		
		
		$path = "docs";
		move_uploaded_file( $_FILES['gcertificatedocument']['tmp_name'], $path ."/". $gcertificatedocument );
	}
	$gwiretransferdocument="";
	
	if(empty($_FILES['gwiretransferdocument']['name']) == false  )
	{
		$simplephoto11=$_FILES['gwiretransferdocument']['name'];
		$ext = pathinfo($simplephoto11, PATHINFO_EXTENSION);
		$fileexplode1 = explode(".",$simplephoto11);
		$fileend1 = end($fileexplode1);

		 $gwiretransferdocument= date("YmdHis").rand(100,999).".".$fileend1;
		
		
		$path = "docs";
		move_uploaded_file( $_FILES['gwiretransferdocument']['tmp_name'], $path ."/". $gwiretransferdocument );
	}
	
		 $eve1 = "INSERT INTO res_gicprocess_master (imid,gicbankname, gusername,gpassword,stiqmid,gcreatedate,gaddedon,gaddedby,gupdatedon,gupdatedby,gwiretransfer,gwiretransferrecevieddate,gmodeofpayment,gpaymentvalue,gtranscationcharges,gpaystatus,gpaydate,gcertificatestatus,gcertificatereceiveddate,gcertificatedocument,gcurrency,grate,gwiretransferdocument) VALUES('$imid1','$gicbankname','$gusername','$gpassword','$stiqmid','$gcreatedate','$mdate1','$umid','$mdate1','$umid','$gwiretransfer','$gwiretransferrecevieddate','$gmodeofpayment','$gpaymentvalue','$gtranscationcharges','$gpaystatus','$gpaydate','$gcertificatestatus','$gcertificatereceiveddate','$gcertificatedocument','$gcurrency','$grate','$gwiretransferdocument')";
		
		if ($conn->query($eve1) === TRUE)
		{
			
			$_SESSION['msg'] = "Record has been added successfully";
		}
		else
		{
			$_SESSION['msg1'] = "Error";
		}

	if($_SESSION['frompage']=='aplicationInquirydetailpage')
			{
				header("Location: applicationinquirydetail.php?id=$stiqmid");
			}else{
	header("Location: inquirydetail.php?id=$imid1&tab=student_application");
			}
			
	
?>