<?php
header("Access-Control-Allow-Origin: *");
// echo "string";
// print_r($_POST) exit;
error_reporting(0);
@session_start();
define('SITE_URL','/');
define('SITE_URL1','');
$sitename="Mantha Insurance";
		//mail("vishnukk@techwyseintl.com", "in cond", "message");

// echo "status".$status = mail("vishnukk.techintl@gmail.com","test mail","<pre>".print_r($_REQUEST,true)."</pre>");	
// echo "status".$status = mail("sujeesh.techintl@gmail.com","test mail","<pre>".print_r($_REQUEST,true)."</pre>");	
// echo "status".$status = mail("vishnukk@techwyseintl.com","test mail","<pre>".print_r($_REQUEST,true)."</pre>");	
include('mailsendclass.php');
$email_to="";
################################################################
if($_POST['aname']!='')// Inner form
{
	  $name=stripslashes($_POST['aname']);
	  $phone=stripslashes($_POST['aphone']);
      $email=stripslashes($_POST['aemail']);
	  $comments=stripslashes(nl2br($_POST['acommnents']));
	
	//$hcbt=stripslashes(nl2br($_POST['scomments']));

	$email_fieldname='aemail';
	$phone_fieldname='aphone';

	//$captcha_fieldname='captcha_hid_home';
	//$session_fieldname = 'captcha_field';
	
	$array=array(
			'aname' 	=> "Full Name",
			'aphone'  	=> "Number",
			'aemail'    => "Email",
			'acommnents' => "Comments",
			
	);
	$subject="Request a live demo at one of our
showrooms or test kitchens- " .$sitename;
}

$con_subject="Confirmation - " .$sitename;

//Replacing the to, cc and bcc email address if @techwyseintl.com is found STARTS HERE
	$email=stripslashes($email);
	$email_string = strstr($email, "@techwyseintl.com"); //Checking whether email string contains @techwyseintl.com
	$to = ($email_string=="@techwyseintl.com")? stripslashes($email) : $email_to;
	$bcc_email = ($email_string=="@techwyseintl.com")? "" : $email_bcc;
	$cc_email = ($email_string=="@techwyseintl.com")? "" : $email_cc;
//Replacing the to, cc and bcc email address if @techwyseintl.com is found ENDS HERE


if($name!='')
{ 
		//mail("vishnukk@techwyseintl.com", "abc", "message");

$obj = new formTempclass();
$obj->name 		            = $name; // This is mantatory- Field name of name
$obj->email_fieldname 		= $email_fieldname; // This is mantatory- Field name of Email which send to user 
$obj->phone_fieldname 		= $phone_fieldname; // This is mantatory- Field name of Phone  which send to user
//$obj->captcha_fieldname 	= $captcha_fieldname; // This is mantatory- Field name of Captcha  which send to user
//$obj->session_fieldname 	= $session_fieldname; // This is mantatory- Field name of Session  which send to user
$obj->postval_array	        = $array;

$obj->sitename 				= $sitename; //Site Name
$obj->siteurl 				= SITE_URL;  // Site Url 
$obj->mail_banner 			= "http://manthainsurance.wysework.com/mails/images/mail-template.jpg"; // path of mail image 
$obj->rowbgcolor   			= "#fff"; // Bg color of each row
$obj->rowsubtitlebgcolor	= "#b5cfe0"; // Bg color of titles like persoonal Details
$obj->footerbgcolor			= "#b5cfe0";
$obj->footer_txtcolor		= "#000";
$obj->bordercolor 			= "#000";

$obj->admin_mailto 			= $to;
$obj->admin_bcc_mail		= $bcc_email;
$obj->admin_cc_mail 		= $cc_email;
$obj->admin_subject 		= $subject;
$obj->con_subject			= $con_subject; // Confirmation mail Sublect
$obj->send_to_user          = true;
$obj->AdminmailSend(); 
//--- uncomment for view the tempahtes in browser

$body = $obj->UserTemplate($array);
$bodyadmin = $obj->adminTemplate($array);
/*
echo $body;
echo "<br>";
echo $bodyadmin;exit;
*/

//--- uncomment for view the tempahtes in browser
// //--------------------------------------adluge code--------------------------------------
	require_once("clientcenter-api-library.php"); 
	$lead = new clientcenter();
	$lead->client_code="cqzndzryzh16246"; // Mandatory. Unique identification code.

	$lead->fname=$name; //post  Value of first name  
	$lead->lname=$lname; //post  Value of first name
	$lead->phone=$phone;//post Value of Phone Number 
	$lead->email=$email;//post  Value of Email addess  
	//$lead->state=$state;//post  Value of Email addess  
	$lead->city=$city;//post  Value of City 
	$lead->postalcode=$postalcode;
	$lead->comments=$comments;//post Value of Comments 
	
	$lead->status=1; // No need to change this
	
	//No need to modify any of the below code
	$lead->useragent = $_SERVER['HTTP_USER_AGENT']; //browser properties
	$lead->remote_ip=$_SERVER['REMOTE_ADDR']; //ip address
	$lead->referrer=$_SERVER['HTTP_REFERER'];// page source
	$lead->contact_date=date("Y-m-d h:i:s");
	$lead->search_engine=$_COOKIE['adl_durl'];
	$lead->keyword=$_COOKIE['adl_key'];
	$lead->source=$_COOKIE['adl_camp'];
	$lead->randomnum=$_COOKIE['adl_rand'];
	$lead->adl_ref=$_COOKIE['adl_ref'];
		
	$lead->send_to_adluge=true; // Set to true If you are sending leads to adluge //default true
	$leads_sent = $lead->send();
// 	//echo "thank-you";exit;

// //--------------------------------------------------------------------------------------------------
		//	mail("vishnukk@techwyseintl.com", "hi", "message");

// if($leads_sent == 1){

	echo "yes";
// }

// header("location:".SITE_URL."thank-you/");
}

?>
