<?php
 	session_start(); 
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
	if(!isset($_SESSION['linkarisecrm']))
	{
		header('Location: index.php');
		return;
	}
	
	/* if($_SESSION['utype']!='admin')
	{
		header('Location: index.php');
		return;
	} */
$cmpmid=$_SESSION['linkarisecmpmid'];

	$brmid = $_SESSION['linkarisebranchid'];
	$umid = $_SESSION['linkariseumid'];
	
	if($_SERVER['REQUEST_METHOD'] === 'POST')
	{
		if(!isset($_POST['_token']) || ($_POST['_token']!==$_SESSION['_token'] ) )
		{
			header('Location: index.php');
			return;
		}
	}
	else
	{
		header('Location: index.php');
		return;
	}
	$_SESSION['_token']=bin2hex(openssl_random_pseudo_bytes(16));
	
	
	include("connect.php");
	include("connectp.php");
	include("removespecial.php");
	
	date_default_timezone_set("Asia/Kolkata");
	$mdate= date('Y-m-d H:i:s');
	$mdate1= date('Y-m-d');
	
	$umid=$_SESSION['linkariseumid'];
	$umid1=$_POST['umid'];
	$taskname=removespecialchar($_POST['taskname']);
	$taskdescription=removespecialchar($_POST['taskdescription']);
	$taskduedate=date("Y-m-d", strtotime($_POST['taskduedate']));
	$iftime=date("H:i:s", strtotime($_POST['ftime']));
	$taskstatus="Open";
	//$taskremark=removespecialchar($_POST['taskremark']);
	$taskstage="New";
	$pmid=$_POST['pmid'];
	


	
	
	
		$eve2 = "INSERT INTO res_task_master (pmid,cmpmid,taskname,taskdescription,taskduedatetime,taskstatus,taskstage,taskallocatedto,taskaddedby,taskaddedon) VALUES('$pmid','$cmpmid','$taskname','$taskdescription','$taskduedate $iftime','$taskstatus','$taskstage','$umid1','$umid','$mdate')";
		if ($conn->query($eve2) === TRUE)
		{
			$last_id = $conn->insert_id;
			
			
    }

			
			
			
		
		/* generate_followup_sms(); */
		
		$_SESSION['msg'] = "Record saved successfully";
	
			header("Location: task.php");
		

?>