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

	{
		$imid = $rt2['imid'];
	}
	}
	
	
	
	$gicmid=$_POST['gicmid'];
	$grreason=$_POST['grreason'];
	$grefundstatus=$_POST['grefundstatus'];
	$grefunddocument='';
	
	if(empty($_FILES['grefunddocument']['name']) == false  )
	{
		$simplephoto11=$_FILES['grefunddocument']['name'];
		$ext = pathinfo($simplephoto11, PATHINFO_EXTENSION);
		$fileexplode1 = explode(".",$simplephoto11);
		$fileend1 = end($fileexplode1);

		 $grefunddocument= date("YmdHis").rand(100,999).".".$fileend1;
		
		
		$path = "docs";
		move_uploaded_file( $_FILES['grefunddocument']['tmp_name'], $path ."/". $grefunddocument );
	
	}
	
		 $eve1 = "INSERT INTO res_gicrefund_detail (gicmid,grefundfate,grreason,grefundstatus,grefunddocument) VALUES('$gicmid','$mdate1','$grreason','$grefundstatus','$grefunddocument')";
		
		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=$imid&tab=student_application");
			}
			
	
?>