<?php
 	session_start(); 

	if(!isset($_SESSION['tulsilogin']))
	{
		header('Location: index.php');
		return;
	}

	date_default_timezone_set("Asia/Kolkata");
	$mdate1= date('Y-m-d H:i:s');
	$mdate2= date('Y-m-d');
	
	$_SESSION['_token']=bin2hex(openssl_random_pseudo_bytes(16));
	
	
	include("connect.php");
	$umid=$_SESSION['umid'];
	//$umid=$_SESSION['umid'];
	$logisticname=$_POST['logisticname'];
	$logisticfaxnumber=$_POST['logisticfaxnumber'];
	$logisticwebsite=$_POST['logisticwebsite'];
	$logisticmastercode=$_POST['logisticmastercode'];
	
	$contactname=str_replace ("'","\'",$_POST['contactname']);
	$contactname=str_replace ('"','\"',$contactname);
	
	$cmiddlename=str_replace ("'","\'",$_POST['cmiddlename']);
	$cmiddlename=str_replace ('"','\"',$cmiddlename);
	
	$csurname=str_replace ("'","\'",$_POST['csurname']);
	$csurname=str_replace ('"','\"',$csurname);
	
		$contactnumber=str_replace ("'","\'",$_POST['contactnumber']);
	$contactnumber=str_replace ('"','\"',$contactnumber);
	$mobilecode=$_POST['mobilecode'];
	$contactnumber=$mobilecode."".$contactnumber;
	$cmobilenumber=str_replace ("'","\'",$_POST['cmobilenumber']);
	$cmobilenumber=str_replace ('"','\"',$cmobilenumber);
	$homemobilecode=$_POST['homemobilecode'];
	$cmobilenumber=$homemobilecode."".$cmobilenumber;
	$contactemail=str_replace ("'","\'",$_POST['contactemail']);
	$contactemail=str_replace ('"','\"',$contactemail);
	$caltenateemail=str_replace ("'","\'",$_POST['caltenateemail']);
	$caltenateemail=str_replace ('"','\"',$caltenateemail);
	$contactdepartmnet='Head';
	
	$cposition='Head';
	
	$cremarks=str_replace ("'","\'",$_POST['cremarks']);
	$cremarks=str_replace ('"','\"',$cremarks);
	
	$caddress1=str_replace ("'","\'",$_POST['caddress1']);
	$caddress1=str_replace ('"','\"',$caddress1);
	
	$caddress2=str_replace ("'","\'",$_POST['caddress2']);
	$caddress2=str_replace ('"','\"',$caddress2);
	
	$ccountry=str_replace ("'","\'",$_POST['ccountry']);
	$ccountry=str_replace ('"','\"',$ccountry);
	$cpostalcode=str_replace ("'","\'",$_POST['cpostalcode']);
	$cpostalcode=str_replace ('"','\"',$cpostalcode);
	
	$cmsgappname=str_replace ("'","\'",$_POST['cmsgappname']);
	$cmsgappname=str_replace ('"','\"',$cmsgappname);
	
	$csubcategory='Direct';
	
	
	$cmsgappid=$_POST['cmsgappid'];
	
	
	$cvideoappname=str_replace ("'","\'",$_POST['cvideoappname']);
	$cvideoappname=str_replace ('"','\"',$cvideoappname);
	
	$cvideoappid=$_POST['cvideoappid'];
	
	$ccity=$_POST['ccity'];
	
	
	
	$cstate=str_replace ("'","\'",$_POST['cstate']);
	$cstate=str_replace ('"','\"',$cstate);
	
	
		  $eve2 = "INSERT INTO res_logistics_master (logisticname,logisticfaxnumber,logisticwebsite,logisticmastercode,laddedby,laddedon,lupdatedby,lupdatedon) VALUES('$logisticname','$logisticfaxnumber','$logisticwebsite','$logisticmastercode','$umid','$mdate1','$umid','$mdate1')";
		
		
		if ($conn->query($eve2) === TRUE)

	{	
	$last_id = $conn->insert_id;
		 $eve1 = "INSERT INTO res_contact_master (contactname, contactemail,contactnumber,cmobilenumber,contactdepartmnet,cposition,cremarks,caltenateemail,caddress1,caddress2,ccountry,cstate,ccity,cpostalcode,cmiddlename,csurname,cmsgappname,cmsgappid,cvideoappname,cvideoappid,ccompanyname,csubcategory,clinktype,clinkid) VALUES('$contactname','$contactemail','$contactnumber','$cmobilenumber','$contactdepartmnet','$cposition','$cremarks','$caltenateemail','$caddress1','$caddress2','$ccountry','$cstate','$ccity','$cpostalcode','$cmiddlename','$csurname','$cmsgappname','$cmsgappid','$cvideoappname','$cvideoappid','$logisticname','$csubcategory','Logistics','$last_id')";
		
		$re1 = mysqli_query($conn, $eve1);
			
		$_SESSION['msg'] = "Record Saved successfully";
	}else{
		$_SESSION['msg1'] = "Error";
	}
	header('Location: logistics.php');
?>