<?php
session_start();

	if(!isset($_SESSION['linkarisecrm']))
	{
		header('Location: index.php');
		return;
	}
	date_default_timezone_set("Asia/Singapore");
	 $mdate1= date('Y-m-d');
	 $mdatetime= date('Y-m-d H:i:s');
	 $cdatetime= date('Y-m-d H:i:s');

	$brmid=$_SESSION['linkarisebranchid'];
	$umid = $_SESSION['linkariseumid'];


	include("connect.php");

	 //$imid=$_POST['imid'];
	 $partymid=$_POST['partymid'];
	
	
	//  $from=$_POST['from'];
	  $inqfremarks=$_POST['inqfremarks'];
	  $newinqdate=date("Y-m-d", strtotime($_POST['inqfdate']));
	 //$istatus=$_POST['istatus'];
    $followup=$_POST['followup'];
    $inqstage=$_POST['istage'];
    $stageremark=$_POST['stageremark'];
	//for current date
	
	/*  $eve = "INSERT INTO res_followup_detail ( ftype,fdate, imid, fremarks, fstatus, brmid, faddedby, fupdatedby, faddedon, fupdatedon) VALUES ('Inquiry','$newinqdate', '$imid', '$inqfremarks', 'Open', $brmid, '$umid', '$umid', '$cdatetime', '$cdatetime')"; */
	 
	$eve31 = "update res_party_master set partystage='$inqstage',stageremark='$stageremark',followup='Yes',followupdate='$newinqdate',followupremark='$inqfremarks' where partymid='$partymid'";
	$re31 = mysqli_query($conn, $eve31);
		
	if($followup=='Yes')
	{
		 $eve1 = "INSERT INTO res_followup_detail (ftype,fdate, partymid, fremarks, fstatus, faddedby, fupdatedby, faddedon, fupdatedon,inquirystage,stageremark) VALUES ('Inquiry','$newinqdate', '$partymid', '$inqfremarks', 'Open', '$umid', '$umid', '$cdatetime', '$cdatetime','$inqstage','$stageremark')";
		 if ($conn->query($eve1) === TRUE)
		{
			$last_id = $conn->insert_id;
				
			$_SESSION['msg'] = "Follow-Up Addded";
			

		}
		else
		{
			$_SESSION['msg1'] = "Follow-Up Not Addded";
			
		}
	}
	
	 
	header("Location: inquiryfollowup.php"); 

?>
