<?php
 session_start(); 

	if(!isset($_SESSION['tulsilogin']))
	{
		header('Location: index.php');
		return;
	}
	
	include("connect.php");
	date_default_timezone_set("Asia/Kolkata");
	$mdate= date('Y-m-d H:i:s');
	
	$nextfup=$_POST['nextfup'];
	if($nextfup == 1)
	{
		  $fdate=date("Y-m-d H:i:s", strtotime($_POST['fdate']));
		  $ifnote=$_POST['ifnote'];
	}else{
		$fdate = '';
		$ifnote = '';
	}
	
	
	
	$fremarks=$_POST['fremarks'];
	$imid=$_POST['imid'];
	$ifstatus=$_POST['ifstatus'];
	$ifaddedby=$_SESSION['umid'];
	$ifaddedtype=$_SESSION['utype'];
	$iftype=$_POST['iftype'];
	
	  $stiqmid=$_POST['stiqmid'];
	
	
	
	$eve2 = "insert into res_inquiryfollowup_detail (imid, fdate, fremarks,ifstatus,ifaddedby,ifaddedtype,ifaddedon,ifstatusnew,iftype,ifnote,stiqmid) values ($imid,'$fdate','$fremarks','$ifstatus',$ifaddedby,'$ifaddedtype','$mdate','Open','$iftype','$ifnote','$stiqmid')";
	if ($conn->query($eve2) === TRUE)
	{
		$last_id = $conn->insert_id;
		if($nextfup == 1)
	{
		$eve4 = "insert into res_upcomingfollowup_master (imid, ufdate, ufremark,ufaddedby,ufaddedon,stiqmid) values ($imid,'$fdate','$ifnote',$ifaddedby,'$mdate','$stiqmid')";
	$re4 = mysqli_query($conn, $eve4);
	}
		
		$eve3 = "update res_studentinquiry_detail set status='$ifstatus' where  stiqmid='$stiqmid' ";
		$re3 = mysqli_query($conn, $eve3);
		
		
		$_SESSION['msg'] = "Record has been added successfully";
	}
	else
	{
		$_SESSION['msg1'] = "Error";
	}
	
	if($_SESSION['frompage']=='followupadd')
	{
		header("Location: followup.php");
	}
	else
	{
		header("Location: inquirydetail.php?id=$imid#student_inquires");
	}
?>	