<?php
 	session_start(); 

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

	include("connect.php");
date_default_timezone_set("Asia/Kolkata");
$mdate1= date('Y-m-d H:i:s');
$mdate= date('d-m-Y');
$mdate2= date('d-m-Y H:i');
	$usermid = $_SESSION['umid'];
	
	//$cmname=$_POST['cmname'];
	if(isset($_POST['imid1']))
	{
	$imid1=$_POST['imid1'];
	}
	
	$stiqmid=$_POST['stiqmid'];
	$clgamid=$_POST['clgamid'];
	$eve2 = "select imid from res_studentinquiry_detail where stiqmid=$stiqmid";
	$re2 = mysqli_query($conn, $eve2);
	while($rt2 = mysqli_fetch_assoc($re2))

	{
		$imid1 = $rt2['imid'];
	}
	$coursemid=$_POST['coursemid'];
	$eve2 = "select collegemid,countrymid from res_course_master where coursemid=$coursemid";
	$re2 = mysqli_query($conn, $eve2);
	while($rt2 = mysqli_fetch_assoc($re2))

	{
		$collegemid = $rt2['collegemid'];
		$countrymid = $rt2['countrymid'];
	}
	
	$coremarks=$_POST['coremarks'];
	$coursefees=$_POST['coursefees'];
	$doapplication=date("Y-m-d", strtotime($_POST['doapplication']));
	$capstatus=$_POST['capstatus'];
	
	$cintakeyear='';
	$cintekmonth='';
	
			$cintakeyear=$_POST['cintakeyear'];
			
			$cintekmonth=$_POST['cintakemonth'];
			
			
		  $eve1 = "INSERT INTO res_clgdefapp_master (imid,stiqmid, coursemid,collegemid,countrymid,cdfremarks,applicationfess,cdapstatus,cdoapplication,cdaddedon,cdaddedby,cdupdatedon,cdupdatedby,cdintakemonth,cdintakeyear,clgamid,cdastatus) VALUES('$imid1','$stiqmid','$coursemid','$collegemid','$countrymid','$coremarks','$coursefees','$capstatus','$doapplication','$mdate1','$usermid','$mdate1','$usermid','$cintekmonth','$cintakeyear','$clgamid','Pending for Approval')";
	
			
		if ($conn->query($eve1) === TRUE)
			{
				
				$eve23 = "update res_collegeappman_master set clgstatus='Approved' where clgamid=$clgamid";
				$re23 = mysqli_query($conn, $eve23);
				
				
			}
			else
			{
				$_SESSION['msg1'] = "Error";
			}
			
			if($_SESSION['frompage']=='aplicationInquirydetailpage')
			{
				header("Location: applicationinquirydetail.php?id=$stiqmid");
			}else{
	header("Location: inquirydetail.php?id=$imid1&tab=student_application");
			}
			
	
?>