<?php
session_start();
if(isset($_GET['regID']))
{
$info = unserialize(stripslashes(urldecode($_GET['regID'])));
$info['dealer'] = $info['selectedDealer'];
include_once('includes.php');
if($dealerInfo[$info['dealer']]['eventID'] != "")
{
$_GET['promo'] = 'Trade My Keys Event';
$_GET['eventID'] = $dealerInfo[$info['dealer']]['eventID'];
$_GET['source'] = 'web';
$_GET['lastName'] = $info['lastname'];
$_GET['firstName'] = $info['firstname'];
$_GET['mobilePhone'] = $info['mobile'];
$_GET['email'] = $info['email'];
$_GET['address'] = $info['address'];
$_GET['postalCode'] = $info['postalCode'];
$_GET['currentVehicleYear'] = $info['years'];
$_GET['currentVehicleModel'] = $info['makes'] . ' ' . $info['models'];
$_GET['currentVehicleKM'] = $info['kilometers'];
$_GET['nextVehicleModel'] = $info['nextVehicle'];
$_GET['notes'] = '$' . $info['payment'] . '/mth - ' . $info['monthsRemaining'] . ' Mths Remaining - Worth $' . number_format($info['values']['tradeInLow']) . ' - $' . number_format($info['values']['tradeInHigh']);
$_GET['requiredUpdates'] = array();
if($info['mobile'] != "") $_GET['requiredUpdates'] = array_merge($_GET['requiredUpdates'],array('mobilePhone'));
if($info['email'] != "") $_GET['requiredUpdates'] = array_merge($_GET['requiredUpdates'],array('email'));
if($info['years'] != "") $_GET['requiredUpdates'] = array_merge($_GET['requiredUpdates'],array('currentVehicleYear','currentVehicleModel','currentVehicleKM','email','mainPhone'));
if($info['nextVehicle'] != "") $_GET['requiredUpdates'] = array_merge($_GET['requiredUpdates'],array('nextVehicleModel'));
if($info['address'] != "") $_GET['requiredUpdates'] = array_merge($_GET['requiredUpdates'],array('address'));
if($info['postalCode'] != "") $_GET['requiredUpdates'] = array_merge($_GET['requiredUpdates'],array('postalCode'));
$_GET['requiredUpdates'] = array_merge($_GET['requiredUpdates'],array('notes'));
include_once('../misc/rsvp.php');
//include_once('adfEmail.php');
}
$_SESSION['registerEmail']['dealerInfo'] = $dealerInfo;
include_once('displayUtils.php');
include_once('Emailer/swift_required.php');
try
{
$transport = Swift_SmtpTransport::newInstance('mx2.newgencloud.com');
$mailer = Swift_Mailer::newInstance($transport);
$message = Swift_Message::newInstance($dealerInfo[$info['dealer']]['name'] . " Trade My Keys Event Confirmation");
// Gift Value
$eventDate = $dealerInfo[$info['dealer']]['eventDate'];
$gift = $dealerInfo[$info['dealer']]['gift'];
switch ($gift)
{
case "no":
case "NO":
case "none":
case "NONE":
//$perks = "";
$perks = '<br /><br /><b><font style="color:blue;font-size:11pt">Come in for a test drive on ' . $eventDate . ' and save big when you purchase a new vehicle!</font></b>';
break;
default:
$perks = '<br /><br /><b><font style="color:blue;font-size:11pt">EXTRA BONUS: Come in for a test drive on ' . $eventDate . ' and receive ' . $gift .'!</font></b>';
break;
}
// Extra Bonus
$extraBonus = $dealerInfo[$info['dealer']]['bonus'];
switch ($extraBonus)
{
case "no":
case "NO":
case "none":
case "NONE":
$extra = "";
break;
case "TV":
$extra = '<br /><br /><font style="color:blue;font-size:11pt;font-weight:bold;">EVERY REGISTER CUSTOMER RECEIVES A CHANCE TO WIN CANUCKS TICKETS AND A 50" TV !!</font>';
break;
case "tablet":
$extra = '<br /><br /><b><font style="color:blue;font-size:11pt">BUY A NEW VEHICLE AND RECEIVE A </b> <span style="color:red">FREE SAMSUNG TABLET</span>!!!</font></b>';
break;
case "spin":
$extra = '<br /><br /><b><font style="color:blue;font-size:11pt">BUY A NEW VEHICLE AND </b> <span style="color:red">Spin For A Free Gas Card for up to $1000 in value</span>!!!</font></b>';
break;
case "redwater":
$extra = '<br /><br /><b><font style="color:blue;font-size:11pt">PRINT AND BRING THIS CONFIRMATION TO THE DEALERSHIP on ' . $eventDate . ' and receive a </b> <span style="color:red">Loyalty Credit of $500</span> towards your new vehicle!!!</font></b>';
break;
default:
// $extra = '<b>JUST ANNOUNCED:</b> <span style="color:red">$500 HOLIDAY CASH BONUS</span> on qualifing new vehicles!!';
$extra = '<br /><br /><b><font style="color:blue;font-size:11pt">JUST ANNOUNCED:</b> <span style="color:red">'. $extraBonus .'</span> on qualifing new vehicles!!</font></b>';
break;
}
if($info['values']['tradeInLow'] != "" && $info['values']['tradeInLow'] != 0)
{
// Black Book Value
$blackbook = $dealerInfo[$info['dealer']]['blackbook'];
$bbooke = '<br><br><b>
<font style="font-size:11pt">
According to Canadian Black Book,
</font>
<br>
<font style="font-size:13pt">
Your ' . ucwords($info['years'] . ' ' . $info['makes'] . ' ' . $info['models']) . ' Is Worth <u>$' . number_format($info['values']['tradeInLow']) . ' - $' . number_format($info['values']['tradeInHigh']) . '</u>
</font>
</b>';
switch ($blackbook)
{
case "no":
case "NO":
case "none":
case "NONE":
$bbook = "";
break;
default:
$bbook = $bbooke;
}
}
// NO VOUCHER (see below for attachement at bottom of email)
$voucher = $dealerInfo[$info['dealer']]['voucher'];
$vouche = '<br><br>Your Savings Certificate is attached to this email.<br>Please print and bring with you to the dealership.';
switch ($voucher)
{
case "no":
case "NO":
case "none":
case "NONE":
$vouch = "";
break;
default:
$vouch = $vouche;
break;
}
// BODY OF MESSAGE STARTS HERE
$blackbook2 = $dealerInfo[$info['dealer']]['blackbook'];
switch ($blackbook2)
{
case "no":
case "NO":
case "none":
case "NONE":
$body = '
<font style="font-size:10pt;font-family:Arial">
Dear ' . $info['firstname'] . ',
<br><br>
Thank you for your registration!'
//Voucher Value * Gift Value * Bonus Value
. $vouch . $perks . $extra .
'<br><br>
<b>' . $dealerInfo[$info['dealer']]['name'] . '</b><br>
' . $dealerInfo[$info['dealer']]['address'] . '<br><br>
</font>';
break;
default:
$body = '
<font style="font-size:10pt;font-family:Arial">
Dear ' . $info['firstname'] . ',
<br><br>
Thank you for your registration!'
//Black Book Value * Voucher Value * Gift Value * Bonus Value
. $bbook . $vouch . $perks . $extra .
'<br><br>
<table cellspacing="0" cellpadding="0">
<tr>
<td style="font-size:10pt;font-family:Arial;padding:10px 0px">
<b>Name:</b> ' . $info['firstname'] . ' ' . $info['lastname'] . '<br>
<b>Email:</b> ' . $info['email'] . '<br>
<b>Mobile:</b> ' . $info['mobile'] . '<br>
<b>Address:</b> ' . $info['address'] . ' ' . $info['postalCode'] . '<br>
<b>Year:</b> ' . $info['years'] . '<br>
<b>Make:</b> ' . $info['makes'] . '<br>
<b>Model:</b> ' . $info['models'] . '<br>
<b>Trim:</b> ' . $info['trims'] . '<br>
<b>Style:</b> ' . $info['styles'] . '<br>
<b>KM:</b> ' . $info['kilometers'] . '<br>
<!-- <b>Trade in Value:</b> '. ($info['values']['tradeInLow'] != "" && $info['values']['tradeInLow'] != 0 ? '$' . number_format($info['values']['tradeInLow']) . ' - $' . number_format($info['values']['tradeInHigh']) : '') . '
<br>-->
<b>Current Payment:</b> ' . $info['payment'] . '<br>
<b>Months Remaining:</b> ' . $info['monthsRemaining'] . '<br>
<b>Interested In:</b> ' . $info['nextVehicle'] . '<br>
</td>
</tr>
</table>
</b>
<br><br>
<b>' . $dealerInfo[$info['dealer']]['name'] . '</b><br>
' . $dealerInfo[$info['dealer']]['address'] . '<br><br>
</font>
<br><br>
<font style="font-size:9pt">* Your vehicle may have significant more value based on equipment/trim level. Value is subject to full inspection & appraisal.</font>';
}
//}
// END: BODY OF MESSAGE
$_SESSION['registerEmail']['info'] = $info;
//VOUCHER ATTACHED - Naming the attachment
// NO VOUCHER (see below for attachement at bottom of email)
$voucherjpg = $dealerInfo[$info['dealer']]['voucher'];
switch ($voucherjpg)
{
case "no":
case "NO":
case "none":
case "NONE":
echo '';
break;
default:
ob_start();
include('rebateCertificateImage.php');
$r_contents = ob_get_contents();
ob_end_clean();
$attachment = Swift_Attachment::newInstance($r_contents, "Savings Coupons.jpg", 'image/jpeg');
$message->attach($attachment);
break;
}
$message->setBody($body, 'text/html');
$message->setTo(array(trim($info['email'])));
//see dealerEvent.php
$message->setBcc(array('dave@absoluteresults.com'));
$message->setReturnPath('dave@absoluteresults.com');
$message->setFrom($dealerInfo[$info['dealer']]['email1']);
if($mailer->send($message))
{
echo 'true';
}
else
{
echo 'false';
}
}
catch (Swift_TransportException $e)
{
echo 'false';
}
catch (Swift_Message_MimeException $e)
{
echo 'false';
}
}
?>