<?php

if(!empty($_POST['details']) && !empty($_POST['name']) && !empty($_POST['mobile']) && !empty($_POST['email'])){
	
	$products = implode(", ", $_POST['tech2_mscheck']);
	if(substr($products, 0, 2) == ", "){
		$products = substr($products, 2);
	}
	
	$channels = implode(", ", $_POST['tech_mscheck']);
	if(substr($channels, 0, 2) == ", "){
		$channels = substr($channels, 2);
	}
	
	$to = "callcenter.socialmedia@cibeg.com, cib.socialmedia@vm.com.eg";
	// $to = "ahmed.adel.atta@gmail.com";
	$reply = "socialmedia.support@cibeg.com";
	$subject = '[FB Talk-to-Us] '.$_POST['feedbackType'].' - '.$products;
    
    if(!empty($_POST['account']))
    $message = '<html>'.
                '<b>Name:</b> '.$_POST['name']."<br/>".
                '<b>Mobile:</b> '.$_POST['mobile']."<br/>".
                '<b>Email:</b> '.$_POST['email']."<br/>".
                '<b>Current CIB Client:</b> '.$_POST['client']."<br/>".
                '<b>Account Number:</b> '.$_POST['account']."<br/>".
                '<b>Feedback Type:</b> '.$_POST['feedbackType']."<br/>".
                '<b>Product/Service:</b> '.$products."<br/>".
                '<b>Channel:</b> '.$channels."<br/>".
                '<b>Details:</b> '.$_POST['details'].'</html>';
    else                            
	$message = '<html>'.
				'<b>Name:</b> '.$_POST['name']."<br/>".
				'<b>Mobile:</b> '.$_POST['mobile']."<br/>".
				'<b>Email:</b> '.$_POST['email']."<br/>".
				'<b>Current CIB Client:</b> '.$_POST['client']."<br/>".
				'<b>Feedback Type:</b> '.$_POST['feedbackType']."<br/>".
				'<b>Product/Service:</b> '.$products."<br/>".
				'<b>Channel:</b> '.$channels."<br/>".
				'<b>Details:</b> '.$_POST['details'].'</html>';
	$headers = "";
	if(!empty($_POST['email'])){
		$headers = 'From: '.$_POST['email']. "\r\n" .
	    'Reply-To: '.$reply. "\r\n";
	}
	$headers = $headers . 'X-Mailer: PHP/' . phpversion();
	$headers .= 'MIME-Version: 1.0' . "\r\n";
	$headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
	mail($to, $subject, $message, $headers);	
	
	echo 1;
}

?>