<?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');
	$usermid = $_SESSION['umid'];
	
	//$cmname=$_POST['cmname'];
	
	$stiqmid=$_POST['stiqmid'];
	$citdid=$_POST['citdid'];
	$intekyear='';
	$intekmonth='';
	 $eve1="SELECT * FROM res_courseintaketerm_detail where  citdid = $citdid 	 ";
	$re1 = mysqli_query($conn, $eve1);

    if(mysqli_num_rows($re1) > 0)
	{
		
        while($rt1 = mysqli_fetch_assoc($re1))
		{
			$intekmonth=$rt1['ctermmonth'];
			$intekmonth = date('m',strtotime($intekmonth));
			
			$intekyear=$rt1['ctermyear'];
		}
	}
	
	 $eve1="SELECT * FROM res_admission_master where  stiqmid = $stiqmid 	 ";
	$re1 = mysqli_query($conn, $eve1);

    if(mysqli_num_rows($re1) > 0)
	{
		
        while($rt1 = mysqli_fetch_assoc($re1))
		{
			$admid=$rt1['admid'];
			
			
		}
	}
	
	$eve1="SELECT max(adintaketerm)  as tt1 FROM res_admission_master where  stiqmid = $stiqmid 	 ";
	$re1 = mysqli_query($conn, $eve1);

    if(mysqli_num_rows($re1) > 0)
	{
		
        while($rt1 = mysqli_fetch_assoc($re1))
		{
			$adintaketerm1=$rt1['tt1'];
			
			
		}
	}
	$adintaketerm = $adintaketerm1+1
	
		
						 $eve3 = "INSERT INTO res_admissionintake_detail (admid,adintakeyear, adintakemonth,adintaketerm,adaddedon,adaddedby) VALUES('$admid','$intekyear','$intekmonth','$adintaketerm','$mdate1','$usermid')";
		
		$re3 = mysqli_query($conn, $eve3);
						
				header("Location: applicationinquirydetail.php?id=$stiqmid");
			
			
	
?>