<?php
 	session_start();

	if(!isset($_SESSION['linkarisecrm']))
	{
		header('Location: index.php');
		return;
	}
		$brmid=$_SESSION['linkarisebranchid'];
		$umid = $_SESSION['linkariseumid'];
$cmpmid = $_SESSION['linkarisecmpmid'];

	include("connect.php");
	include("removespecial.php");
	date_default_timezone_set("Asia/Kolkata");
				$cdatetime= date('Y-m-d H:i:s');

	$partymid=$_POST['partymid'];
	$fdate=date("Y-m-d", strtotime($_POST['fdate'])); 

	$inqfremarks=removespecialchar($_POST['remarks']);
	$stagename=$_POST['inquirystagename'];
	$stageremark="";;


	$eve = "INSERT INTO res_followup_detail ( ftype,fdate,partymid,fremarks, fstatus, cmpmid, faddedby, fupdatedby, faddedon, fupdatedon,inquirystage,stageremark) VALUES ('Inquiry','$fdate','$partymid','$inqfremarks', 'Open', $cmpmid, '$umid', '$umid', '$cdatetime', '$cdatetime','$stagename','$stageremark')";

	if ($conn->query($eve) === TRUE)
	{
		$last_id = $conn->insert_id;
		$eve3 = "update res_party_master set followup='Yes',followupdate='$fdate',partyupdatedby=$umid,cmpmid=$cmpmid,partyupdatedon='$cdatetime',partystage='$stagename',stageremark='$stageremark',followupremark='$inqfremarks' where  partymid=$partymid ";
		$re3 = mysqli_query($conn, $eve3);
		
		$_SESSION['msg'] = "Follow-Up Addded";

	}
	else
	{
		$_SESSION['msg'] = "Follow-Up Not Addded";

	}
	header("Location: inquiryfollowup.php");

?>
