<? 

ob_start();

require("wp-config.php");

require("class.phpmailer.php");

global $wpdb;

$actions=$_REQUEST["actions"];

if($actions=='addedit_leads'){	

	$from_nameM='Limousine Sacramento';	

	$from_emailM='info@sacramentolimousineservice.net';

	$website='sacramentolimousineservice.net';

	

	$session_id=session_id();

	$_SESSION["svSessionId"]=$session_id;

	$checkRow=$wpdb->get_row("SELECT leads_id FROM leads WHERE session_id='".$session_id."'");

	$leads_id=$checkRow->leads_id;

	if($leads_id == ''){

		$sql="insert into leads(session_id,status,c_date ,guid)values('".$wpdb->_real_escape($session_id)."',0,NOW(),UUID())";

		$wpdb->query($sql);

		//$leads_id=mysql_insert_id();

		$leads_id=$wpdb->insert_id;

		//echo $sql;

	}

	//echo $leads_id;

	//echo $session_id;

	//exit();

	$isFrom=$_REQUEST["isFrom"];

	$cst_name_MO=$wpdb->_real_escape($_REQUEST["cst_name_MO"]);

	if($cst_name_MO!=''){

		$cst_name=$cst_name_MO;		

		$cst_email=$wpdb->_real_escape($_REQUEST["cst_email_MO"]);

		$cst_phone=$wpdb->_real_escape($_REQUEST["cst_phone_MO"]);

	}else{

		$f_name=$wpdb->_real_escape($_REQUEST["cst_name"]);

		$l_name=$wpdb->_real_escape($_REQUEST["cst_name_1"]);

		$cst_name=$f_name.' '.$l_name;

		

		$cst_email=$wpdb->_real_escape($_REQUEST["cst_email"]);

		$cst_phone=$wpdb->_real_escape($_REQUEST["cst_phone"]);	

	}

	//$cst_mobile=$wpdb->_real_escape($_REQUEST["cst_mobile"]);

	$cst_remark=$wpdb->_real_escape($_REQUEST["cst_remark"]);

	$cst_mobile=$cst_phone;

	if($isFrom=='Web'){

		$services_id=$wpdb->_real_escape($_REQUEST["services_id"]);

		$pickup_date=$wpdb->_real_escape($_REQUEST["pickup_date"]);

		if($pickup_date!=''){

			if($pickup_date!='0000-00-00'){

				$pickup_dateA=explode("-",$pickup_date);

				$pickup_date=$pickup_dateA[2].'-'.$pickup_dateA[0].'-'.$pickup_dateA[1];

				$leads_limos=1;

			}else{

				$leads_limos=0;

			}

		}else{

			$leads_limos=0;		

		}

		$no_of_passengers=$wpdb->_real_escape($_REQUEST["no_of_passengers"]);

		$type_of_vehicle=$wpdb->_real_escape($_REQUEST["type_of_vehicle"]);

		$pickup_time_hour=$wpdb->_real_escape($_REQUEST["pickup_time_hour"]);

		$pickup_time_minute=$wpdb->_real_escape($_REQUEST["pickup_time_minute"]);

		$no_of_hrs=$wpdb->_real_escape($_REQUEST["no_of_hrs"]);

		$pa_address=$wpdb->_real_escape($_REQUEST["pa_address"]);

		

		$street_number=$wpdb->_real_escape($_REQUEST["street_number"]);

		$route=$wpdb->_real_escape($_REQUEST["route"]);

		if($route!=''){

			$pa_address=$street_number.' '.$route;

		}

		$pa_city=$wpdb->_real_escape($_REQUEST["locality"]);

		$pa_state=$wpdb->_real_escape($_REQUEST["administrative_area_level_1"]);

		$pa_zipcode=$wpdb->_real_escape($_REQUEST["postal_code"]);

		$pa_country=$wpdb->_real_escape($_REQUEST["country"]);

		

		

		$pickup_date_boat=$wpdb->_real_escape($_REQUEST["pickup_date_boat"]);

		if($pickup_date_boat!=''){

			if($pickup_date_boat!='0000-00-00'){

				$pickup_date_boatA=explode("-",$pickup_date_boat);

				$pickup_date_boat=$pickup_date_boatA[2].'-'.$pickup_date_boatA[0].'-'.$pickup_date_boatA[1];

				$leads_boat=1;

			}else{

				$leads_boat=0;

			}

		}else{

			$leads_boat=0;

		}

		$pickup_time_hour_boat=$wpdb->_real_escape($_REQUEST["pickup_time_hour_boat"]);

		$no_of_hrs_boat=$wpdb->_real_escape($_REQUEST["no_of_hrs_boat"]);

		$services_boat=$wpdb->_real_escape($_REQUEST["services_boat"]);

		$no_of_passengers_boat=$wpdb->_real_escape($_REQUEST["no_of_passengers_boat"]);

		

		

		$pickup_date_yatch=$wpdb->_real_escape($_REQUEST["pickup_date_yatch"]);

		if($pickup_date_yatch!=''){

			if($pickup_date_yatch!='0000-00-00'){

				$pickup_date_yatchA=explode("-",$pickup_date_yatch);

				$pickup_date_yatch=$pickup_date_yatchA[2].'-'.$pickup_date_yatchA[0].'-'.$pickup_date_yatchA[1];

				$leads_yatch=1;

			}else{

				$leads_yatch=0;

			}

		}else{

			$leads_yatch=0;

		}		

		$pickup_time_hour_yatch=$wpdb->_real_escape($_REQUEST["pickup_time_hour_yatch"]);

		$no_of_hrs_yatch=$wpdb->_real_escape($_REQUEST["no_of_hrs_yatch"]);

		$locations_yatch=$wpdb->_real_escape($_REQUEST["locations_yatch"]);

		

		

		$pickup_date_dj=$wpdb->_real_escape($_REQUEST["pickup_date_dj"]);

		if($pickup_date_dj!=''){

			if($pickup_date_dj!='0000-00-00'){

				$pickup_date_djA=explode("-",$pickup_date_dj);

				$pickup_date_dj=$pickup_date_djA[2].'-'.$pickup_date_djA[0].'-'.$pickup_date_djA[1];

				$leads_dj=1;

			}else{

				$leads_dj=0;

			}

		}else{

			$leads_dj=0;

		}

		$pickup_time_hour_dj=$wpdb->_real_escape($_REQUEST["pickup_time_hour_dj"]);

		$no_of_hrs_dj=$wpdb->_real_escape($_REQUEST["no_of_hrs_dj"]);

		$services_dj=$wpdb->_real_escape($_REQUEST["services_dj"]);

		$guests_dj=$wpdb->_real_escape($_REQUEST["guests_dj"]);

		$address_dj=$wpdb->_real_escape($_REQUEST["address_dj"]);

		$city_dj=$wpdb->_real_escape($_REQUEST["city_dj"]);

		$state_dj=$wpdb->_real_escape($_REQUEST["state_dj"]);

		$zip_dj=$wpdb->_real_escape($_REQUEST["zip_dj"]);

		$nameofhall_dj=$wpdb->_real_escape($_REQUEST["nameofhall_dj"]);

		

		$street_number_DJ=$wpdb->_real_escape($_REQUEST["street_number_DJ"]);

		$route_DJ=$wpdb->_real_escape($_REQUEST["route_DJ"]);

		if($route_DJ!=''){

			$address_dj=$street_number_DJ.' '.$route_DJ;

		}

		$country_dj=$wpdb->_real_escape($_REQUEST["country_DJ"]);

		

		$pickup_date_ph=$wpdb->_real_escape($_REQUEST["pickup_date_ph"]);

		if($pickup_date_ph!=''){

			if($pickup_date_ph!='0000-00-00'){

				$pickup_date_phA=explode("-",$pickup_date_ph);

				$pickup_date_ph=$pickup_date_phA[2].'-'.$pickup_date_phA[0].'-'.$pickup_date_phA[1];

				$leads_ph=1;

			}else{

				$leads_ph=0;

			}

		}else{

			$leads_ph=0;

		}

		$pickup_time_hour_ph=$wpdb->_real_escape($_REQUEST["pickup_time_hour_ph"]);

		$no_of_hrs_ph=$wpdb->_real_escape($_REQUEST["no_of_hrs_ph"]);

		$services_ph=$wpdb->_real_escape($_REQUEST["services_ph"]);

		$adn_ph=$wpdb->_real_escape($_REQUEST["adn_ph"]);

		$no_photographers_ph=$wpdb->_real_escape($_REQUEST["no_photographers_ph"]);

		$photosdp_ph=$wpdb->_real_escape($_REQUEST["photosdp_ph"]);

		$nophoto_ph=$wpdb->_real_escape($_REQUEST["nophoto_ph"]);

		$no_videographers_ph=$wpdb->_real_escape($_REQUEST["no_videographers_ph"]);

		$address_ph=$wpdb->_real_escape($_REQUEST["address_ph"]);

		$city_ph=$wpdb->_real_escape($_REQUEST["city_ph"]);

		$state_ph=$wpdb->_real_escape($_REQUEST["state_ph"]);

		$zip_ph=$wpdb->_real_escape($_REQUEST["zip_ph"]);

		$nameofhall_ph=$wpdb->_real_escape($_REQUEST["nameofhall_ph"]);

		

		$street_number_PH=$wpdb->_real_escape($_REQUEST["street_number_PH"]);

		$route_PH=$wpdb->_real_escape($_REQUEST["route_PH"]);

		if($route_PH!=''){

			$address_ph=$street_number_PH.' '.$route_PH;

		}

		$country_ph=$wpdb->_real_escape($_REQUEST["country_PH"]);

		

		

		$custom_c1=$wpdb->_real_escape($_REQUEST["custom_c1"]);

		$custom_c2=$wpdb->_real_escape($_REQUEST["custom_c2"]);

		$custom_c3=$wpdb->_real_escape($_REQUEST["custom_c3"]);

		$custom_c4=$wpdb->_real_escape($_REQUEST["custom_c4"]);		

		

		$pickup_date_ep=$wpdb->_real_escape($_REQUEST["pickup_date_ep"]);

		if($pickup_date_ep!=''){

			if($pickup_date_ep!='0000-00-00'){

				$pickup_date_epA=explode("-",$pickup_date_ep);

				$pickup_date_ep=$pickup_date_epA[2].'-'.$pickup_date_epA[0].'-'.$pickup_date_epA[1];

				$leads_ep=1;

			}else{

				$leads_ep=0;

			}

		}else{

			$leads_ep=0;

		}

		$typeofevent_ep=$wpdb->_real_escape($_REQUEST["typeofevent_ep"]);

		$timeofevent_ep=$wpdb->_real_escape($_REQUEST["timeofevent_ep"]);

		$noofhours_ep=$wpdb->_real_escape($_REQUEST["noofhours_ep"]);

		$city_ep=$wpdb->_real_escape($_REQUEST["city_ep"]);

		$state_ep=$wpdb->_real_escape($_REQUEST["state_ep"]);

		$zip_ep=$wpdb->_real_escape($_REQUEST["zip_ep"]);

		$country_ep=$wpdb->_real_escape($_REQUEST["country_ep"]);		

		$street_number_PH=$wpdb->_real_escape($_REQUEST["street_number_ep"]);

		$route_PH=$wpdb->_real_escape($_REQUEST["route_ep"]);

		if($route_PH!=''){

			$address_ep=$street_number_PH.' '.$route_PH;

		}	

	}else{

		$services_id=$wpdb->_real_escape($_REQUEST["services_id_Mob"]);

		$pickup_date=$wpdb->_real_escape($_REQUEST["pickup_date_Mob"]);

		if($pickup_date!=''){

			if($pickup_date!='0000-00-00'){

				$pickup_dateA=explode("-",$pickup_date);

				$pickup_date=$pickup_dateA[2].'-'.$pickup_dateA[0].'-'.$pickup_dateA[1];

				$leads_limos=1;

			}else{

				$leads_limos=0;

			}

		}else{

			$leads_limos=0;		

		}

		$no_of_passengers=$wpdb->_real_escape($_REQUEST["no_of_passengers_Mob"]);

		$type_of_vehicle=$wpdb->_real_escape($_REQUEST["type_of_vehicle_Mob"]);

		$pickup_time_hour=$wpdb->_real_escape($_REQUEST["pickup_time_hour_Mob"]);

		$pickup_time_minute=$wpdb->_real_escape($_REQUEST["pickup_time_minute_Mob"]);

		$no_of_hrs=$wpdb->_real_escape($_REQUEST["no_of_hrs_Mob"]);

		$pa_address=$wpdb->_real_escape($_REQUEST["pa_address_Mob"]);

		

		$street_number=$wpdb->_real_escape($_REQUEST["street_number_Mob"]);

		$route=$wpdb->_real_escape($_REQUEST["route_Mob"]);

		if($route!=''){

			$pa_address=$street_number.' '.$route;

		}

		$pa_city=$wpdb->_real_escape($_REQUEST["locality_Mob"]);

		$pa_state=$wpdb->_real_escape($_REQUEST["administrative_area_level_1_Mob"]);

		$pa_zipcode=$wpdb->_real_escape($_REQUEST["postal_code_Mob"]);

		$pa_country=$wpdb->_real_escape($_REQUEST["country_Mob"]);

		

		

		$pickup_date_boat=$wpdb->_real_escape($_REQUEST["pickup_date_boat_Mob"]);

		if($pickup_date_boat!=''){

			if($pickup_date_boat!='0000-00-00'){

				$pickup_date_boatA=explode("-",$pickup_date_boat);

				$pickup_date_boat=$pickup_date_boatA[2].'-'.$pickup_date_boatA[0].'-'.$pickup_date_boatA[1];

				$leads_boat=1;

			}else{

				$leads_boat=0;

			}

		}else{

			$leads_boat=0;

		}

		$pickup_time_hour_boat=$wpdb->_real_escape($_REQUEST["pickup_time_hour_boat_Mob"]);

		$no_of_hrs_boat=$wpdb->_real_escape($_REQUEST["no_of_hrs_boat_Mob"]);

		$services_boat=$wpdb->_real_escape($_REQUEST["services_boat_Mob"]);

		$no_of_passengers_boat=$wpdb->_real_escape($_REQUEST["no_of_passengers_boat_Mob"]);

		

		

		$pickup_date_yatch=$wpdb->_real_escape($_REQUEST["pickup_date_yatch_Mob"]);

		if($pickup_date_yatch!=''){

			if($pickup_date_yatch!='0000-00-00'){

				$pickup_date_yatchA=explode("-",$pickup_date_yatch);

				$pickup_date_yatch=$pickup_date_yatchA[2].'-'.$pickup_date_yatchA[0].'-'.$pickup_date_yatchA[1];

				$leads_yatch=1;

			}else{

				$leads_yatch=0;

			}

		}else{

			$leads_yatch=0;

		}		

		$pickup_time_hour_yatch=$wpdb->_real_escape($_REQUEST["pickup_time_hour_yatch_Mob"]);

		$no_of_hrs_yatch=$wpdb->_real_escape($_REQUEST["no_of_hrs_yatch_Mob"]);

		$locations_yatch=$wpdb->_real_escape($_REQUEST["locations_yatch_Mob"]);

		

		

		$pickup_date_dj=$wpdb->_real_escape($_REQUEST["pickup_date_dj_Mob"]);

		if($pickup_date_dj!=''){

			if($pickup_date_dj!='0000-00-00'){

				$pickup_date_djA=explode("-",$pickup_date_dj);

				$pickup_date_dj=$pickup_date_djA[2].'-'.$pickup_date_djA[0].'-'.$pickup_date_djA[1];			

				$leads_dj=1;

			}else{

				$leads_dj=0;

			}

		}else{

			$leads_dj=0;

		}

		$pickup_time_hour_dj=$wpdb->_real_escape($_REQUEST["pickup_time_hour_dj_Mob"]);

		$no_of_hrs_dj=$wpdb->_real_escape($_REQUEST["no_of_hrs_dj_Mob"]);

		$services_dj=$wpdb->_real_escape($_REQUEST["services_dj_Mob"]);

		$guests_dj=$wpdb->_real_escape($_REQUEST["guests_dj_Mob"]);

		$address_dj=$wpdb->_real_escape($_REQUEST["address_dj_Mob"]);

		$city_dj=$wpdb->_real_escape($_REQUEST["city_dj_Mob"]);

		$state_dj=$wpdb->_real_escape($_REQUEST["state_dj_Mob"]);

		$zip_dj=$wpdb->_real_escape($_REQUEST["zip_dj_Mob"]);

		$nameofhall_dj=$wpdb->_real_escape($_REQUEST["nameofhall_dj_Mob"]);

		

		$street_number_DJ=$wpdb->_real_escape($_REQUEST["street_number_DJ_Mob"]);

		$route_DJ=$wpdb->_real_escape($_REQUEST["route_DJ_Mob"]);

		if($route_DJ!=''){

			$address_dj=$street_number_DJ.' '.$route_DJ;

		}

		$country_dj=$wpdb->_real_escape($_REQUEST["country_DJ_Mob"]);

		

				

		$pickup_date_ph=$wpdb->_real_escape($_REQUEST["pickup_date_ph_Mob"]);

		if($pickup_date_ph!=''){

			if($pickup_date_ph!='0000-00-00'){

				$pickup_date_phA=explode("-",$pickup_date_ph);

				$pickup_date_ph=$pickup_date_phA[2].'-'.$pickup_date_phA[0].'-'.$pickup_date_phA[1];

				$leads_ph=1;

			}else{

				$leads_ph=0;

			}

		}else{

			$leads_ph=0;

		}

		$pickup_time_hour_ph=$wpdb->_real_escape($_REQUEST["pickup_time_hour_ph_Mob"]);

		$no_of_hrs_ph=$wpdb->_real_escape($_REQUEST["no_of_hrs_ph_Mob"]);

		$services_ph=$wpdb->_real_escape($_REQUEST["services_ph_Mob"]);

		$adn_ph=$wpdb->_real_escape($_REQUEST["adn_ph_Mob"]);

		$no_photographers_ph=$wpdb->_real_escape($_REQUEST["no_photographers_ph_Mob"]);

		$photosdp_ph=$wpdb->_real_escape($_REQUEST["photosdp_ph_Mob"]);

		$nophoto_ph=$wpdb->_real_escape($_REQUEST["nophoto_ph_Mob"]);

		$no_videographers_ph=$wpdb->_real_escape($_REQUEST["no_videographers_ph_Mob"]);

		$address_ph=$wpdb->_real_escape($_REQUEST["address_ph_Mob"]);

		$city_ph=$wpdb->_real_escape($_REQUEST["city_ph_Mob"]);

		$state_ph=$wpdb->_real_escape($_REQUEST["state_ph_Mob"]);

		$zip_ph=$wpdb->_real_escape($_REQUEST["zip_ph_Mob"]);

		$nameofhall_ph=$wpdb->_real_escape($_REQUEST["nameofhall_ph_Mob"]);		

		$street_number_PH=$wpdb->_real_escape($_REQUEST["street_number_PH_Mob"]);

		$route_PH=$wpdb->_real_escape($_REQUEST["route_PH_Mob"]);

		if($route_PH!=''){

			$address_ph=$street_number_PH.' '.$route_PH;

		}

		$country_ph=$wpdb->_real_escape($_REQUEST["country_PH_Mob"]);

		

		

		$custom_c1=$wpdb->_real_escape($_REQUEST["custom_c1_Mob"]);

		$custom_c2=$wpdb->_real_escape($_REQUEST["custom_c2_Mob"]);

		$custom_c3=$wpdb->_real_escape($_REQUEST["custom_c3_Mob"]);

		$custom_c4=$wpdb->_real_escape($_REQUEST["custom_c4_Mob"]);		

		

		$pickup_date_ep=$wpdb->_real_escape($_REQUEST["pickup_date_ep_Mob"]);

		if($pickup_date_ep!=''){

			if($pickup_date_ep!='0000-00-00'){

				$pickup_date_epA=explode("-",$pickup_date_ep);

				$pickup_date_ep=$pickup_date_epA[2].'-'.$pickup_date_epA[0].'-'.$pickup_date_epA[1];

				$leads_ep=1;

			}else{

				$leads_ep=0;

			}

		}else{

			$leads_ep=0;

		}

		$typeofevent_ep=$wpdb->_real_escape($_REQUEST["typeofevent_ep_Mob"]);

		$timeofevent_ep=$wpdb->_real_escape($_REQUEST["timeofevent_ep_Mob"]);

		$noofhours_ep=$wpdb->_real_escape($_REQUEST["noofhours_ep_Mob"]);

		$city_ep=$wpdb->_real_escape($_REQUEST["city_ep_Mob"]);

		$state_ep=$wpdb->_real_escape($_REQUEST["state_ep_Mob"]);

		$zip_ep=$wpdb->_real_escape($_REQUEST["zip_ep_Mob"]);

		$country_ep=$wpdb->_real_escape($_REQUEST["country_ep_Mob"]);		

		$street_number_PH=$wpdb->_real_escape($_REQUEST["street_number_ep_Mob"]);

		$route_PH=$wpdb->_real_escape($_REQUEST["route_ep_Mob"]);

		if($route_PH!=''){

			$address_ep=$street_number_PH.' '.$route_PH;

		}

	}

	

	$country_ph_12=$wpdb->_real_escape($_REQUEST["country_ph"]);

	$country_dj_12=$wpdb->_real_escape($_REQUEST["country_dj"]);

	$pa_country_12=$wpdb->_real_escape($_REQUEST["pa_country"]);

	$pa_zipcode_12=$wpdb->_real_escape($_REQUEST["pa_zipcode"]);

	$pa_state_12=$wpdb->_real_escape($_REQUEST["pa_state"]);

	$pa_city_12=$wpdb->_real_escape($_REQUEST["pa_city"]);		

	if($country_ph_12!=''){

		$country_ph=$country_ph_12;

	}	

	if($country_dj_12!=''){

		$country_dj=$country_dj_12;

	}	

	if($pa_country_12!=''){

		$pa_country=$pa_country_12;

	}	

	if($pa_zipcode_12!=''){

		$pa_zipcode=$pa_zipcode_12;

	}	

	if($pa_state_12!=''){

		$pa_state=$pa_state_12;

	}	

	if($pa_city_12!=''){

		$pa_city=$pa_city_12;

	}	

	

	$sql_update="update leads set cst_name='".$cst_name."',cst_email='".$cst_email."',cst_phone='".$cst_phone."',cst_mobile='".$cst_mobile."',cst_remark='".$cst_remark."',leads_limos='".$leads_limos."',services_id='".$services_id."',pickup_date='".$pickup_date."',no_of_passengers='".$no_of_passengers."',type_of_vehicle='".$type_of_vehicle."',pickup_time_hour='".$pickup_time_hour."',pickup_time_minute='".$pickup_time_minute."',no_of_hrs='".$no_of_hrs."',pa_address='".$pa_address."',leads_boat='".$leads_boat."',pickup_date_boat='".$pickup_date_boat."',pickup_time_hour_boat='".$pickup_time_hour_boat."',no_of_hrs_boat='".$no_of_hrs_boat."',services_boat='".$services_boat."',no_of_passengers_boat='".$no_of_passengers_boat."',leads_yatch='".$leads_yatch."',pickup_date_yatch='".$pickup_date_yatch."',pickup_time_hour_yatch='".$pickup_time_hour_yatch."',no_of_hrs_yatch='".$no_of_hrs_yatch."',locations_yatch='".$locations_yatch."',leads_dj='".$leads_dj."',pickup_date_dj='".$pickup_date_dj."',pickup_time_hour_dj='".$pickup_time_hour_dj."',no_of_hrs_dj='".$no_of_hrs_dj."',services_dj='".$services_dj."',guests_dj='".$guests_dj."',address_dj='".$address_dj."',city_dj='".$city_dj."',state_dj='".$state_dj."',zip_dj='".$zip_dj."',nameofhall_dj='".$nameofhall_dj."',leads_ph='".$leads_ph."',pickup_date_ph='".$pickup_date_ph."',pickup_time_hour_ph='".$pickup_time_hour_ph."',no_of_hrs_ph='".$no_of_hrs_ph."',services_ph='".$services_ph."',adn_ph='".$adn_ph."',no_photographers_ph='".$no_photographers_ph."',photosdp_ph='".$photosdp_ph."',nophoto_ph='".$nophoto_ph."',no_videographers_ph='".$no_videographers_ph."',address_ph='".$address_ph."',city_ph='".$city_ph."',state_ph='".$state_ph."',zip_ph='".$zip_ph."',nameofhall_ph='".$nameofhall_ph."',custom_c1='".$custom_c1."',custom_c2='".$custom_c2."',custom_c3='".$custom_c3."',custom_c4='".$custom_c4."',isFrom='".$isFrom."',website='".$website."',country_ph='".$country_ph."',country_dj='".$country_dj."',pa_city='".$pa_city."',pa_state='".$pa_state."',pa_zipcode='".$pa_zipcode."',pa_country='".$pa_country."',leads_ep='".$leads_ep."',pickup_date_ep='".$pickup_date_ep."',typeofevent_ep='".$typeofevent_ep."',timeofevent_ep='".$timeofevent_ep."',noofhours_ep='".$noofhours_ep."',address_ep='".$address_ep."',city_ep='".$city_ep."',state_ep='".$state_ep."',zip_ep='".$zip_ep."',country_ep='".$country_ep."' where leads_id='".$leads_id."'";

	$wpdb->query($sql_update);	

	//echo $sql_update;

	//exit();

	$isFinal=$_REQUEST["isFinal"];

	if($isFinal==1){	

		if($leads_limos==0 && $leads_boat==0 && $leads_yatch==0 && $leads_dj==0 && $leads_ph==0 && $leads_ep==0){

			header("location: /leads.php");

			exit();	

		}		

		////////////////////////////////////Send Email//////////////////////////////

		$details='<table width="100%" border="0" cellspacing="1" cellpadding="2"><tr><td colspan="2" valign="top"><strong>Inquiry Details:</strong></td></tr>';

		$details=$details.'<tr><td colspan="2" valign="top"><h4>Customer Details:</h4></td></tr>';

		$details=$details.'<tr><td width="40%" valign="top"><strong>Customer Name:</strong></td><td width="60%" valign="top">'.$cst_name.'</td></tr>';

		$details=$details.'<tr><td width="40%" valign="top"><strong>Customer Email:</strong></td><td width="60%" valign="top">'.$cst_email.'</td></tr>';

		$details=$details.'<tr><td width="40%" valign="top"><strong>Customer Phone:</strong></td><td width="60%" valign="top">'.$cst_phone.'</td></tr>';

		$details=$details.'<tr><td width="40%" valign="top"><strong>Customer Mobile:</strong></td><td width="60%" valign="top">'.$cst_mobile.'</td></tr>';

		$details=$details.'<tr><td width="40%" valign="top"><strong>Customer Remark:</strong></td><td width="60%" valign="top">'.$cst_remark.'</td></tr>';

		if($leads_limos==1){

			if($services_id=='1000'){

				$services_name='To Airport';

			}elseif($services_id=='1001'){

				$services_name='From Airport';

			}elseif($services_id=='1002'){

				$services_name='Point-to-Point (one-way)';

			}elseif($services_id=='1003'){

				$services_name='Hourly Service';

			}elseif($services_id=='27'){

				$services_name='Prom / School Event';

			}elseif($services_id=='25'){

				$services_name='Wedding';

			}elseif($services_id=='24'){

				$services_name='Birthday and Anniversary';

			}elseif($services_id=='3'){

				$services_name='Night On The Town';

			}elseif($services_id=='12'){

				$services_name='Concert / Sporting Events';

			}elseif($services_id=='11'){

				$services_name='Bachelor (ette) Party';

			}elseif($services_id=='10'){

				$services_name='Executive & Corporate';

			}elseif($services_id=='7'){

				$services_name='Wine Tours';

			}elseif($services_id=='30'){

				$services_name='To & From Sea-Port';

			}elseif($services_id=='31'){

				$services_name='Funeral';

			}

			if($type_of_vehicle=='1'){

				$type_of_vehicle_name='Sedans and SUVs';

			}elseif($type_of_vehicle=='2'){

				$type_of_vehicle_name='Limos and SUV Limos';

			}elseif($type_of_vehicle=='4'){

				$type_of_vehicle_name='Buses and Party Buses';

			}elseif($type_of_vehicle=='6'){

				$type_of_vehicle_name='Exotic Cars';

			}

						

			$details=$details.'<tr><td colspan="2" valign="top"><h4>Limos Details:</h4></td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Where do you want to go?:</strong></td><td width="60%" valign="top">'.$services_name.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>What Date?:</strong></td><td width="60%" valign="top">'.$pickup_date.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Type of Vehicle:</strong></td><td width="60%" valign="top">'.$type_of_vehicle_name.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Number of people?:</strong></td><td width="60%" valign="top">'.$no_of_passengers.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Pickup Hour:</strong></td><td width="60%" valign="top">'.$pickup_time_hour.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Pickup Minute:</strong></td><td width="60%" valign="top">'.$pickup_time_minute.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Number of Hour?:</strong></td><td width="60%" valign="top">'.$no_of_hrs.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Pickup Address:</strong></td><td width="60%" valign="top">'.$pa_address.'</td></tr>';			

			$details=$details.'<tr><td width="40%" valign="top"><strong>City:</strong></td><td width="60%" valign="top">'.$pa_city.'</td></tr>';			

			$details=$details.'<tr><td width="40%" valign="top"><strong>State:</strong></td><td width="60%" valign="top">'.$pa_state.'</td></tr>';			

			$details=$details.'<tr><td width="40%" valign="top"><strong>Zipcode:</strong></td><td width="60%" valign="top">'.$pa_zipcode.'</td></tr>';			

			$details=$details.'<tr><td width="40%" valign="top"><strong>Country:</strong></td><td width="60%" valign="top">'.$pa_country.'</td></tr>';			

		}

		

		if($leads_boat==1){						

			$details=$details.'<tr><td colspan="2" valign="top"><h4>Boat Details:</h4></td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Date You are interested in?:</strong></td><td width="60%" valign="top">'.$pickup_date_boat.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Time for Boat Pickup?:</strong></td><td width="60%" valign="top">'.$pickup_time_hour_boat.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Number of hours needed:</strong></td><td width="60%" valign="top">'.$no_of_hrs_boat.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Lake Youre intrested?:</strong></td><td width="60%" valign="top">'.$services_boat.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Aproximate number of people:</strong></td><td width="60%" valign="top">'.$no_of_passengers_boat.'</td></tr>';

		}

		

		if($leads_yatch==1){						

			$details=$details.'<tr><td colspan="2" valign="top"><h4>Yatch Details:</h4></td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Date You are interested in?:</strong></td><td width="60%" valign="top">'.$pickup_date_yatch.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Time for Yatch Pickup?:</strong></td><td width="60%" valign="top">'.$pickup_time_hour_yatch.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Number of hours needed:</strong></td><td width="60%" valign="top">'.$no_of_hrs_yatch.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Location of Port:</strong></td><td width="60%" valign="top">'.$locations_yatch.'</td></tr>';

		}

		

		if($leads_dj==1){						

			$details=$details.'<tr><td colspan="2" valign="top"><h4>DJ Details:</h4></td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Date of Event?:</strong></td><td width="60%" valign="top">'.$pickup_date_dj.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Time of Event?:</strong></td><td width="60%" valign="top">'.$pickup_time_hour_dj.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Number of hours?:</strong></td><td width="60%" valign="top">'.$no_of_hrs_dj.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Type of Event:</strong></td><td width="60%" valign="top">'.$services_dj.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Aprrox. no. of guests in party:</strong></td><td width="60%" valign="top">'.$guests_dj.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Address of the event:</strong></td><td width="60%" valign="top">'.$address_dj.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>City:</strong></td><td width="60%" valign="top">'.$city_dj.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>State:</strong></td><td width="60%" valign="top">'.$state_dj.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Zipcode:</strong></td><td width="60%" valign="top">'.$zip_dj.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Country:</strong></td><td width="60%" valign="top">'.$country_dj.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Name of Venue/Hall:</strong></td><td width="60%" valign="top">'.$nameofhall_dj.'</td></tr>';

		}		

		

		if($leads_ph==1){						

			$details=$details.'<tr><td colspan="2" valign="top"><h4>Photography And Videography Details:</h4></td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Date of Event?:</strong></td><td width="60%" valign="top">'.$pickup_date_ph.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Time of Event?:</strong></td><td width="60%" valign="top">'.$pickup_time_hour_ph.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Number of hours?:</strong></td><td width="60%" valign="top">'.$no_of_hrs_ph.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Type of Event:</strong></td><td width="60%" valign="top">'.$services_ph.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Additional days needed:</strong></td><td width="60%" valign="top">'.$adn_ph.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>No. of photographers you need:</strong></td><td width="60%" valign="top">'.$no_photographers_ph.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Digital Photos or Printed:</strong></td><td width="60%" valign="top">'.$photosdp_ph.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>No. of photos:</strong></td><td width="60%" valign="top">'.$nophoto_ph.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>No. of videographers you need:</strong></td><td width="60%" valign="top">'.$no_videographers_ph.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Address to the event:</strong></td><td width="60%" valign="top">'.$address_ph.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>City:</strong></td><td width="60%" valign="top">'.$city_ph.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>State:</strong></td><td width="60%" valign="top">'.$state_ph.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Country:</strong></td><td width="60%" valign="top">'.$country_ph.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Zipcode:</strong></td><td width="60%" valign="top">'.$zip_ph.'</td></tr>';

		}

		

		if($leads_ep==1){						

			$details=$details.'<tr><td colspan="2" valign="top"><h4>Event Planning Details:</h4></td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Date of Event?:</strong></td><td width="60%" valign="top">'.$pickup_date_ep.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Time of Event?:</strong></td><td width="60%" valign="top">'.$timeofevent_ep.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Type Of Event?:</strong></td><td width="60%" valign="top">'.$typeofevent_ep.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>No Of Hours:</strong></td><td width="60%" valign="top">'.$noofhours_ep.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Address to the event:</strong></td><td width="60%" valign="top">'.$address_ep.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>City:</strong></td><td width="60%" valign="top">'.$city_ep.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>State:</strong></td><td width="60%" valign="top">'.$state_ep.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Country:</strong></td><td width="60%" valign="top">'.$country_ep.'</td></tr>';

			$details=$details.'<tr><td width="40%" valign="top"><strong>Zipcode:</strong></td><td width="60%" valign="top">'.$zip_ep.'</td></tr>';

		}		

		$details=$details.'</table>';

		if($cst_name!='' && $cst_email!=''){

			////////////////////////////////////Send Email//////////////////////////////				

			$sql_us="update leads set session_id='Done' where leads_id='".$leads_id."'";

			$wpdb->query($sql_us);	

			

			/////////////////////Store In Global Limos Start//////////////////////////////////////

			$apiKey="6db15233898b1175232492e13259e594";

			$time=date('Ymdhis');

			$apiUrl="https://www.globallimos.com/api/leads/add.php?apikey=".$apiKey."&time=".$time;

			$postdata=$postdata.'&website='.$website.'';

			$postdata=$postdata.'&isFrom='.$isFrom.'';

			$postdata=$postdata.'&cst_name='.$f_name.'';

			$postdata=$postdata.'&cst_name_1='.$l_name.'';

			$postdata=$postdata.'&cst_email='.$cst_email.'';

			$postdata=$postdata.'&cst_phone='.$cst_phone.'';

			$postdata=$postdata.'&cst_mobile='.$cst_mobile.'';

			$postdata=$postdata.'&cst_remark='.$cst_remark.'';

			$postdata=$postdata.'&services_id='.$services_id.'';

			$postdata=$postdata.'&pickup_date='.$pickup_date.'';

			$postdata=$postdata.'&leads_limos='.$leads_limos.'';

			$postdata=$postdata.'&no_of_passengers='.$no_of_passengers.'';

			$postdata=$postdata.'&type_of_vehicle='.$type_of_vehicle.'';

			$postdata=$postdata.'&pickup_time_hour='.$pickup_time_hour.'';

			$postdata=$postdata.'&pickup_time_minute='.$pickup_time_minute.'';

			$postdata=$postdata.'&no_of_hrs='.$no_of_hrs.'';

			$postdata=$postdata.'&pa_address='.$pa_address.'';

			$postdata=$postdata.'&locality='.$pa_city.'';

			$postdata=$postdata.'&administrative_area_level_1='.$pa_state.'';

			$postdata=$postdata.'&postal_code='.$pa_zipcode.'';

			$postdata=$postdata.'&country='.$pa_country.'';

			$postdata=$postdata.'&pickup_date_boat='.$pickup_date_boat.'';

			$postdata=$postdata.'&leads_boat='.$leads_boat.'';

			$postdata=$postdata.'&pickup_time_hour_boat='.$pickup_time_hour_boat.'';

			$postdata=$postdata.'&no_of_hrs_boat='.$no_of_hrs_boat.'';

			$postdata=$postdata.'&services_boat='.$services_boat.'';

			$postdata=$postdata.'&no_of_passengers_boat='.$no_of_passengers_boat.'';

			$postdata=$postdata.'&pickup_date_yatch='.$pickup_date_yatch.'';

			$postdata=$postdata.'&leads_yatch='.$leads_yatch.'';

			$postdata=$postdata.'&pickup_time_hour_yatch='.$pickup_time_hour_yatch.'';

			$postdata=$postdata.'&no_of_hrs_yatch='.$no_of_hrs_yatch.'';

			$postdata=$postdata.'&locations_yatch='.$locations_yatch.'';

			$postdata=$postdata.'&pickup_date_dj='.$pickup_date_dj.'';

			$postdata=$postdata.'&leads_dj='.$leads_dj.'';

			$postdata=$postdata.'&pickup_time_hour_dj='.$pickup_time_hour_dj.'';

			$postdata=$postdata.'&no_of_hrs_dj='.$no_of_hrs_dj.'';

			$postdata=$postdata.'&services_dj='.$services_dj.'';

			$postdata=$postdata.'&guests_dj='.$guests_dj.'';

			$postdata=$postdata.'&address_dj='.$address_dj.'';

			$postdata=$postdata.'&city_dj='.$city_dj.'';

			$postdata=$postdata.'&state_dj='.$state_dj.'';

			$postdata=$postdata.'&zip_dj='.$zip_dj.'';

			$postdata=$postdata.'&nameofhall_dj='.$nameofhall_dj.'';

			$postdata=$postdata.'&street_number_DJ='.$street_number_DJ.'';

			$postdata=$postdata.'&route_DJ='.$route_DJ.'';

			$postdata=$postdata.'&country_DJ='.$country_dj.'';

			$postdata=$postdata.'&pickup_date_ph='.$pickup_date_ph.'';

			$postdata=$postdata.'&leads_ph='.$leads_ph.'';

			$postdata=$postdata.'&pickup_time_hour_ph='.$pickup_time_hour_ph.'';

			$postdata=$postdata.'&no_of_hrs_ph='.$no_of_hrs_ph.'';

			$postdata=$postdata.'&services_ph='.$services_ph.'';

			$postdata=$postdata.'&adn_ph='.$adn_ph.'';

			$postdata=$postdata.'&no_photographers_ph='.$no_photographers_ph.'';

			$postdata=$postdata.'&photosdp_ph='.$photosdp_ph.'';

			$postdata=$postdata.'&nophoto_ph='.$nophoto_ph.'';

			$postdata=$postdata.'&no_videographers_ph='.$no_videographers_ph.'';

			$postdata=$postdata.'&address_ph='.$address_ph.'';

			$postdata=$postdata.'&city_ph='.$city_ph.'';

			$postdata=$postdata.'&state_ph='.$state_ph.'';

			$postdata=$postdata.'&zip_ph='.$zip_ph.'';

			$postdata=$postdata.'&nameofhall_ph='.$nameofhall_ph.'';

			$postdata=$postdata.'&street_number_PH='.$street_number_PH.'';

			$postdata=$postdata.'&route_PH='.$route_PH.'';

			$postdata=$postdata.'&country_PH='.$country_ph.'';

			$postdata=$postdata.'&custom_c1='.$custom_c1.'';

			$postdata=$postdata.'&custom_c2='.$custom_c2.'';

			$postdata=$postdata.'&custom_c3='.$custom_c3.'';

			$postdata=$postdata.'&custom_c4='.$custom_c4.'';

			$postdata=$postdata.'&pickup_date_ep='.$pickup_date_ep.'';

			$postdata=$postdata.'&leads_ep='.$leads_ep.'';

			$postdata=$postdata.'&typeofevent_ep='.$typeofevent_ep.'';

			$postdata=$postdata.'&timeofevent_ep='.$timeofevent_ep.'';

			$postdata=$postdata.'&noofhours_ep='.$noofhours_ep.'';

			$postdata=$postdata.'&city_ep='.$city_ep.'';

			$postdata=$postdata.'&state_ep='.$state_ep.'';

			$postdata=$postdata.'&zip_ep='.$zip_ep.'';

			$postdata=$postdata.'&country_ep='.$country_ep.'';

			$postdata=$postdata.'&street_number_ep='.$street_number_PH.'';

			$postdata=$postdata.'&route_ep='.$route_PH.'';

			

			$ch = curl_init($apiUrl);

			curl_setopt($ch, CURLOPT_VERBOSE, 1);//standard i/o streams 

			curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);// Turn off the server and peer verification 

			curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); 

			curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//Set to return data to string ($response) 

			curl_setopt($ch, CURLOPT_POST, 1);//Regular post 

			curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);// Set the request as a POST FIELD for curl. 

			$response = curl_exec($ch); 

			curl_close($ch);

			$responseJO=json_decode($response);

			$leads_id_GL=$responseJO->leadid;

			/////////////////////Store In Global Limos End//////////////////////////////////////		

			

			/////////////////////////Send Email/////////////////////

			$subject="Inquiry details for ".$website;

			$mail_body="Dear Sir/Mem,<br><br>Your Inquiry Details are as follows.<br><br> <strong>Inquiry ID: ".$leads_id_GL."</strong><br><br>#details#<br><br>Thanks";	

			$mail_body=str_replace("#details#",$details,$mail_body);		

	

			$mail = new PHPMailer();

			$mail->IsMail(); // telling the class to use SMTP

			$mail->Host="localhost"; // SMTP server

			$mail->IsHTML(true); 

			$mail->From = $from_emailM;

			$mail->FromName = $from_nameM;

			$mail->AddAddress("exoticlimocal@yahoo.com");

			$mail->AddAddress("david@globallimos.com");

			$mail->Subject=$subject;

			$mail->Body=$mail_body;

			if(!$mail->Send()){}

			/////////////////////////Send Email/////////////////////

						

			header("location: /thank-you?revid=".$leads_id_GL);

			exit();

		}else{		

			header("location: /leads.php");

			exit();

		}

	}else{		

		header("location: /leads.php");

		exit();

	}

}?>