<?php
 	session_start();

	if(!isset($_SESSION['linkarisecrm']))
	{
		header('Location: index.php');
		return;
	}
	date_default_timezone_set("Asia/Kolkata");
		$mdate= 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'];
	$cmpmid = $_SESSION['linkarisecmpmid'];

      $from=$_POST['from'];
	include("connect.php");
   $qmid=$_POST['qmid'];
	
	 $partymid=$_POST['partymid'];
	 
     $inqfdate=date("Y-m-d", strtotime($_POST['inqfdate']));  
	 $inqfremarks=$_POST['inqfremarks'];

	  $followup=$_POST['followup'];
	
	//for current date
	
     if($followup=='Yes')
	 {
				 $evefup = "INSERT INTO res_followup_detail (partymid, ftype,fdate,cmpmid, qmid, fremarks,  faddedby, fupdatedby, faddedon, fupdatedon) VALUES ('$partymid','Quotation','$inqfdate', '$cmpmid','$qmid', '$inqfremarks','$umid', '$umid', '$cdatetime', '$cdatetime')";
				

				  
				if ($conn->query($evefup) === TRUE)
				{
					$last_id = $conn->insert_id;
					
					$eve4 = "update res_quotation_master set followup='$followup',followdate='$inqfdate',followremarks='$inqfremarks' where qmid='$qmid' and cmpmid='$cmpmid'";
		            $re4 = mysqli_query($conn, $eve4);
					
					$_SESSION['msg'] = "Follow-Up Addded";
					

				}
				else
				{
					$_SESSION['msg'] = "Follow-Up Not Addded";
				
				}
	 }
	$eve2 = "update res_quotation_master set followup='$followup' where qmid=$qmid";
	$re2 = mysqli_query($conn, $eve2);
	if($from=='dashboard')
	{
	
		 header("Location: dashboard.php"); 
	}	
	else{
		
	header("Location: quotationfollowup.php");
	
	}
?>
