<?php
include('common/connection.php');

$check_lead_master=mysqli_query($con,"select Phone from lead_master where Phone='".$_REQUEST['mob']."'");

		

		$seq_sln_sql="select max(SLN) as total_leads from lead_master ";

	    $seq_sln_qry=mysqli_query($con,$seq_sln_sql);

	    $seq_sln=mysqli_fetch_array($seq_sln_qry);

        $Max_Sln=$seq_sln['total_leads']; 



		if($seq_sln['total_leads']!='')

		{			 

		    

			$Sql_PrjId="Select * From lead_master Where SLN='".$Max_Sln."'";

			$Qry_PrjId=mysqli_query($con,$Sql_PrjId);

			$Result_PrjId=mysqli_fetch_array($Qry_PrjId);

			$Max_PrjId=$Result_PrjId['Lead_ID'];

			$Id=explode("LMS",$Max_PrjId);

			$New_PrjId=$Id[1]+1;								

			$Cln_Id="LMS".$New_PrjId; 

		}

		else

		{

			$Cln_Id="LMS10001";

		}
		
		    $insert_lead=mysqli_query($con,"insert into lead_master (Lead_ID,Lead_Creation_Date,Lead_Name,Phone,Email,Form_Source,Source,Status,Active,City,Course_Name,Coupon)values('".$Cln_Id."','".date('Y-m-d')."','".$_REQUEST['name']."','".$_REQUEST['mob']."','".$_REQUEST['email']."','Enquiry','Website','Yet to be Called','Yes','".$_REQUEST['location']."','".$_REQUEST['service']."','".$_REQUEST['coupon']."')");

		    $insert_details=mysqli_query($con,"insert into lead_details (Lead_ID,Lead_Name,Datetime_of_Enquiry,Form_Source,Comments,Status,Active)values('".$Cln_Id."','".$_REQUEST['name']."','".date('Y-m-d H:i:s')."','Enquiry','".mysqli_real_escape_string($con,$_REQUEST['message'])."','Yet to be Called','Yes')");

		

		/* else

		{

		    $insert_details=mysqli_query($con,"insert into lead_details (Lead_ID,Lead_Name,Datetime_of_Enquiry,Form_Source,Comments,Status,Active)values('".$Cln_Id."','".$_REQUEST['name']."','".date('Y-m-d H:i:s')."','Enquiry','".mysqli_real_escape_string($con,$_REQUEST['message'])."','Yet to be Called','Yes')");

		} */

?>		