<?php 

//$to   = "alex@pixel-air.co.uk";
$to   = "a.jones@audpro.com";

// $bcc  = "forms@audpro.com";
// $to = "firozmohammedmi@gmail.com";
//$to = "gazhealey@gmail.com";
$prodType = $_REQUEST['prod-type'];

session_start();

/********** Your Details******************/
$companyName    = $_REQUEST['compName'];
$contactName    = $_REQUEST['contName'];
$phone          = $_REQUEST['phone'];
$email          = $_REQUEST['cemail'];
$web            = $_REQUEST['cwebsite'];

if ($prodType == "prod-own") {

            /*************Production Details*************/

            $voiceover=$_REQUEST['voiceover-main'];
            $music=$_REQUEST['music-main'];
            $format=$_REQUEST['format-main'];
            $comments=$_REQUEST['comments-main'];

            /*************Scripts*************/

            $scriptA=$_REQUEST['scriptA'];
            $remLenA=$_REQUEST['remLenA'];

            $scriptB=$_REQUEST['scriptB'];
            $remLenB=$_REQUEST['remLenB'];

            /*************Extra Scripts*************/

            $extrascript1=$_REQUEST['extrascript1'];
            $scriptD=$_REQUEST['scriptD'];
            $remLenD=$_REQUEST['remLenD'];

            $extrascript2=$_REQUEST['extrascript2'];
            $scriptE=$_REQUEST['scriptE'];
            $remLenE=$_REQUEST['remLenE'];

            $extrascript3=$_REQUEST['extrascript3'];
            $scriptF=$_REQUEST['scriptF'];
            $remLenF=$_REQUEST['remLenF'];

            $extrascript4=$_REQUEST['extrascript4'];
            $scriptG=$_REQUEST['scriptG'];
            $remLenG=$_REQUEST['remLenG'];

            $extrascript5=$_REQUEST['extrascript5'];
            $scriptH=$_REQUEST['scriptH'];
            $remLenH=$_REQUEST['remLenH'];

            $extrascript6=$_REQUEST['extrascript6'];
            $scriptI=$_REQUEST['scriptI'];
            $remLenI=$_REQUEST['remLenI'];

            $extrascript7=$_REQUEST['extrascript7'];
            $scriptJ=$_REQUEST['scriptJ'];
            $remLenJ=$_REQUEST['remLenJ'];
			
		    /*************Cost*************/
		    
		    $totalCost=$_REQUEST['cost'];

            $subject='SF Test Music On Hold';

            $headers  = 'MIME-Version: 1.0' . "\r\n";
            $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
            $headers .= "From: SF Test Music On Hold <noreply@telephonemessage.co.uk>" . "\r\n" .
            "Reply-To: orders@audpro.com" . "\r\n" .
			"Bcc: forms@audpro.com" . "\r\n" .	
            "X-Mailer: PHP/" . phpversion();


            $message = '<html><body>';
//            $message = "<div><p>You have received an order from your MOH Portal. Please check the script and details below are correct, and also advise us of any special pronunciations, especially the company name.  The script will be read exactly as written below. Once you are happy with the order, please reply or forward this email to orders@audpro.com for processing.<br /></p></div>";

            $message .= '<table  width="100%"; rules="all" style="border:1px solid #3A5896;">';

			/**************Reseller Detail*******************************/
	
	        $message .= "<tr class='cost'><td class='heading' colspan='2' style='background: #6a2e92;color: #fff;text-align: center;font-weight: 700;font-size: 16px;'>Reseller Detail</td></tr>";
            $message .= "<tr class='cost'><td class='title'>Reseller Account: </td><td>0011n00002FFEZhAAP</td></tr>";
            $message .= "<tr class='cost'><td class='title'>Reseller Email: </td><td>a.jones@audpro.com</td></tr>";
			$message .= "<tr class='cost'><td class='title'>Quote Email: </td><td>a.jones@audpro.com</td></tr>";
	
            /**************Client Detail*******************************/

            $message .= "<tr><td class='heading' colspan='2' style='background: #6a2e92;color: #fff;text-align: center;font-weight: 700;font-size: 16px;'>Personal Detail</td></tr>";
            $message .= "<tr><td class='title'>Client Company Name: </td><td>$companyName</td></tr>";
            $message .= "<tr><td class='title'>Client Contact Name: </td><td>$contactName</td></tr>";
            $message .= "<tr><td class='title'>Client Phone Number: </td><td>$phone</td></tr>";
            $message .= "<tr><td class='title'>Client Email: </td><td>$email</td></tr>";

            /**************Production Details*******************************/

            $message .= "<tr><td class='heading' colspan='2' style='background: #6a2e92;color: #fff;text-align: center;font-weight: 700;font-size: 16px;'>Production Details</td></tr>";
            $message .= "<tr><td class='title'>Voice Over: </td><td>$voiceover</td></tr>";
            $message .= "<tr><td class='title'>Music: </td><td>$music</td></tr>";
            $message .= "<tr><td class='title'>Format: </td><td>$format</td></tr>";
            $message .= "<tr><td class='title'>Comments: </td><td>$comments</td></tr>";
	
	        /**************Costs*******************************/

            $message .= "<tr class='cost'><td class='heading' colspan='2' style='background: #6a2e92;color: #fff;text-align: center;font-weight: 700;font-size: 16px;'>Cost</td></tr>";
            $message .= "<tr class='cost'><td class='title'>Total Cost: </td><td>$totalCost</td></tr>";
            

            /**************Scrips Details*******************************/

            $message .= "<tr><td class='heading' colspan='2' style='background: #6a2e92;color: #fff;text-align: center;font-weight: 700;font-size: 16px;'>Scripts Details</td></tr>";
            $message .= "<tr><td class='title'>Script Paragraph 1: </td><td>$scriptA</td></tr>";
            $message .= "<tr><td class='title'>Characters Remaining 1: </td><td>$remLenA</td></tr>";

            $message .= "<tr><td class='title'>Script Paragraph 2: </td><td>$scriptB</td></tr>";
            $message .= "<tr><td class='title'>Characters Remaining 2: </td><td>$remLenB</td></tr>";

            if($extrascript1 || $extrascript2 || $extrascript3 || $extrascript4 || $extrascript5 || $extrascript6 || $extrascript7){

                /**************Extra Scrips Details*******************************/

                $message .= "<tr><td class='heading' colspan='2' style='background: #6a2e92;color: #fff;text-align: center;font-weight: 700;font-size: 16px;'>Extra Scripts Details</td></tr>";
                if($extrascript1){
                    $message .= "<tr ><td class='heading-inner' colspan='2' style='background: #777;color: #fff;text-align: center;font-weight: 700;font-size: 14px;'>Extra Script 1</td></tr>";
                    $message .= "<tr><td class='title'>Script 3: </td><td>$extrascript1</td></tr>";
                    $message .= "<tr><td class='title'>Paragraph 3: </td><td>$scriptD</td></tr>";
                    $message .= "<tr><td class='title'>Paragraph 3 Characters Count: </td><td>$remLenD</td></tr>";
                }
                if($extrascript2){
                    $message .= "<tr><td class='heading-inner' colspan='2' style='background: #777;color: #fff;text-align: center;font-weight: 700;font-size: 14px;'>Extra Script 2</td></tr>";
                    $message .= "<tr><td class='title'>Script 4 : </td><td>$extrascript2</td></tr>";
                    $message .= "<tr><td class='title'>Paragraph 4: </td><td>$scriptE</td></tr>";
                    $message .= "<tr><td class='title'>Paragraph 4 Characters Count: </td><td>$remLenE</td></tr>";
                }
                if($extrascript3){
                    $message .= "<tr><td class='heading-inner' colspan='2' style='background: #777;color: #fff;text-align: center;font-weight: 700;font-size: 14px;'>Extra Script 3</td></tr>";
                    $message .= "<tr><td class='title'>Script 5: </td><td>$extrascript3</td></tr>";
                    $message .= "<tr><td class='title'>Paragraph 5: </td><td>$scriptF</td></tr>";
                    $message .= "<tr><td class='title'>Paragraph 5 Characters Count: </td><td>$remLenF</td></tr>";
                }
                if($extrascript4){
                    $message .= "<tr><td class='heading-inner' colspan='2' style='background: #777;color: #fff;text-align: center;font-weight: 700;font-size: 14px;'>Extra Script 4</td></tr>";
                    $message .= "<tr><td class='title'>Script 6: </td><td>$extrascript4</td></tr>";
                    $message .= "<tr><td class='title'>Paragraph 6: </td><td>$scriptG</td></tr>";
                    $message .= "<tr><td class='title'>Paragraph 6 Characters Count: </td><td>$remLenG</td></tr>";
                }
                if($extrascript5){
                    $message .= "<tr><td class='heading-inner' colspan='2' style='background: #777;color: #fff;text-align: center;font-weight: 700;font-size: 14px;'>Extra Script 5</td></tr>";
                    $message .= "<tr><td class='title'>Script 5: </td><td>$extrascript5</td></tr>";
                    $message .= "<tr><td class='title'>Paragraph 5: </td><td>$scriptH</td></tr>";
                    $message .= "<tr><td class='title'>Paragraph 5 Characters Count: </td><td>$remLenH</td></tr>";
                }
                if($extrascript6){
                    $message .= "<tr><td class='heading-inner' colspan='2' style='background: #777;color: #fff;text-align: center;font-weight: 700;font-size: 14px;'>Extra Script 6</td></tr>";
                    $message .= "<tr><td class='title'>Script 6: </td><td>$extrascript6</td></tr>";
                    $message .= "<tr><td class='title'>Paragraph 6: </td><td>$scriptI</td></tr>";
                    $message .= "<tr><td class='title'>Paragraph 6Characters Count: </td><td>$remLenI</td></tr>";
                }
                if($extrascript7){
                    $message .= "<tr><td class='heading-inner' colspan='2' style='background: #777;color: #fff;text-align: center;font-weight: 700;font-size: 14px;'>Extra Script 7</td></tr>";
                    $message .= "<tr><td class='title'>Script: </td><td>$extrascript7</td></tr>";
                    $message .= "<tr><td class='title'>Paragraph: </td><td>$scriptJ</td></tr>";
                    $message .= "<tr><td class='title'>Paragraph Characters Count: </td><td>$remLenJ</td></tr>";
                }
            }
            
        
            
                     
            $message .= "</table>";
            $message .= "</body></html>";

            if(!mail($to, $subject, $message, $headers)) {
                echo "error";
            } else {
                $_SESSION['messageHtml']=$message;
                $_SESSION['last_timestamp']=time();
                echo "success";
            }	
} else if ($prodType == "prod-for-me") {

            /*************Production Details*************/

            $voiceover=$_REQUEST['voiceover-starter'];
            $music=$_REQUEST['music-starter'];
            $format=$_REQUEST['format-starter'];
            $comments=$_REQUEST['comments-starter'];


            $subject='SF Test Starter Music On Hold';

            $headers  = 'MIME-Version: 1.0' . "\r\n";
            $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
            $headers .= "From: SF Test Music On Hold <noreply@telephonemessage.co.uk>" . "\r\n" .
            "Reply-To: orders@audpro.com" . "\r\n" .
			"Bcc: forms@audpro.com" . "\r\n" .
            "X-Mailer: PHP/" . phpversion();


            $message = '<html><body>';
            $message = "<div><p>You have received an order from your MOH Portal. Please check the script and details below are correct, and also advise us of any special pronunciations, especially the company name.  The script will be read exactly as written below. Once you are happy with the order, please reply or forward this email to orders@audpro.com for processing.<br /></p></div>";

            $message .= '<table  width="100%"; rules="all" style="border:1px solid #3A5896;">';

            /**************Personal Detail*******************************/

            $message .= "<tr><td class='heading' colspan='2' style='background: #6a2e92;color: #fff;text-align: center;font-weight: 700;font-size: 16px;'>Personal Detail</td></tr>";
            $message .= "<tr><td class='title'>Company Name: </td><td>$companyName</td></tr>";
            $message .= "<tr><td class='title'>Contact Name: </td><td>$contactName</td></tr>";
            $message .= "<tr><td class='title'>Phone Number: </td><td>$phone</td></tr>";
            $message .= "<tr><td class='title'>Website: </td><td>$web</td></tr>";

            /**************Production Details*******************************/

            $message .= "<tr><td class='heading' colspan='2' style='background: #6a2e92;color: #fff;text-align: center;font-weight: 700;font-size: 16px;'>Production Details</td></tr>";
            $message .= "<tr><td class='title'>Voice Over: </td><td>$voiceover</td></tr>";
            $message .= "<tr><td class='title'>Music: </td><td>$music</td></tr>";
            $message .= "<tr><td class='title'>Format: </td><td>$format</td></tr>";
            $message .= "<tr><td class='title'>Comments: </td><td>$comments</td></tr>";

            /**************Scrips Details*******************************/

            $message .= "<tr><td class='heading' colspan='2' style='background: #6a2e92;color: #fff;text-align: center;font-weight: 700;font-size: 16px;'>Scripts Details</td></tr>";
            $message .= "<tr><td class='title'>Script to Record: </td><td>Thank you for calling "  . $companyName . ", we are sorry to keep you waiting and will be with you shortly. To find out more about us why not visit our website " . $web . " or ask a member of our staff for more information when we answer your call. Thank you for your patience, we know you are waiting we will be with you in a moment.<br><br> We are sorry to keep you waiting. "  . $companyName . " are committed to offering all our customers a quality professional service and pride ourselves on the number of clients who come back to visit us. Please do not hesitate to ask us for more information about the services and products we can offer you. Or visit our website " . $web . " We know you are waiting and someone will be with you shortly.</td></tr>";

            $message .= "</table>";
            $message .= "</body></html>";

            if(!mail($to, $subject, $message, $headers)) {
                echo "error";
            } else {
                $_SESSION['messageHtml']=$message;
                $_SESSION['last_timestamp']=time();
                echo "success";
            }	

} else {
    echo "error";
}
