<?php
include_once('includes.php');
if($_SESSION['registration']['customer']['code'] == "")
{
header("location: index.php");
exit;
}
$bbLink = 'http://xml.canadianblackbook.com/XMLWebServices/service?&account=absolute_xml&key=Dgje48Sw39&schemaVersion=3.0&';
$lists = array('years','makes','models','trims','styles');
if(isset($_GET['getList']))
{
$curKey = array_search($_GET['getList'],$lists);
if($_GET['getList'] == 'years')
{
$xml = simplexml_load_file($bbLink . 'command=' . $_GET['getList']);
$list = $xml->response->years->year;
if($list == '') exit;
}
else if($_GET['getList'] == 'makes')
{
$xml = simplexml_load_file($bbLink . 'year=' . $_GET['year'] . '&command=' . $_GET['getList']);
$list = $xml->response->makes->make;
if($list == '') exit;
}
else if($_GET['getList'] == 'models')
{
$xml = simplexml_load_file($bbLink . 'year=' . $_GET['year'] . '&make=' . urlencode($_GET['make']) . '&command=' . $_GET['getList']);
$list = $xml->response->models->model;
if($list == '') exit;
}
else if($_GET['getList'] == 'trims')
{
$xml = simplexml_load_file($bbLink . 'year=' . $_GET['year'] . '&make=' . urlencode($_GET['make']) . '&model=' . urlencode($_GET['model']) . '&command=' . $_GET['getList']);
$list = $xml->response->trims->trim;
}
else if($_GET['getList'] == 'styles')
{
$xml = simplexml_load_file($bbLink . 'year=' . $_GET['year'] . '&make=' . urlencode($_GET['make']) . '&model=' . urlencode($_GET['model']) . '&trim=' . urlencode($_GET['trim']) . '&command=' . $_GET['getList']);
$list = $xml->response->styles->style;
}
$html = '<select id="' . $_GET['getList'] . '" name="' . $_GET['getList'] . '" style="font-size:1.5em;padding-bottom:1px" ' . ($curKey < (count($lists)-1) ? ' onChange="getList(\'' . $lists[$curKey+1] . '\')"' : '') . '>';
if(count($list) > 1) $html .= '<option value=""></option>';
if($list == '') $html .= '<option value="">None</option>';
foreach($list as $item)
{
$html .= '<option value="' . $item . '">' . $item . '</option>';
}
$html .= '</select>';
?>
document.getElementById('<?= $_GET['getList'] ?>Div').innerHTML = '<?= ajaxHTML($html) ?>';
<?php
for($i = ($curKey+1); $i < count($lists); $i++)
{
?>
document.getElementById('<?= $lists[$i] ?>Div').innerHTML = '<?= ajaxHTML('<select id="' . $_GET['getList'] . '" name="' . $_GET['getList'] . '" style="font-size:1.5em"></select>') ?>';
<?php
}
if(($curKey < (count($lists)-1)) && count($list) == 1)
{
?>
getList('<?= $lists[$curKey+1]?>');
<?php
}
exit;
}
if(isset($_GET['submitList']))
{
//unset($_SESSION['registration']['customer']);
foreach($_GET as $key => $val)
{
if(in_array($key,array('firstname','lastname','email','mainPhone','postalCode','appointmentDate'))) $_SESSION['registration']['customer'][$key] = $val;
else $_SESSION['registration']['tradeIn'][$key] = $val;
}
$xml = simplexml_load_file($bbLink . 'kilometers=' . ereg_replace("[^0-9]", "", $_SESSION['registration']['tradeIn']['kilometers']) . '&year=' . $_SESSION['registration']['tradeIn']['years'] . '&make=' . urlencode($_SESSION['registration']['tradeIn']['makes']) . '&model=' . urlencode($_SESSION['registration']['tradeIn']['models']) . '&trim=' . urlencode($_SESSION['registration']['tradeIn']['trims']) . '&style=' . urlencode($_SESSION['registration']['tradeIn']['styles']) . '&command=priceVehicle');
$list = $xml->response->vehicles->vehicle->values;
$_SESSION['registration']['tradeIn']['values'] = get_object_vars ($list);
?>
document.getElementById('emailFrame').src = 'http://ar.absoluteresults.com/rsvpquant/appraisalEmail.php?regID=<?= urlencode(serialize($_SESSION['registration'])) ?>';
<?php
exit;
}
if(isset($_GET['sendSMS']))
{
$message = urlencode(str_replace(array(" ","&"),array("%20","%26"),"Please reply 'Y' to this message to confirm your registration!"));
$replyMessage = urlencode(str_replace(array(" ","&"),array("%20","%26"),"Thank you for your confirmation. You are now registered. We look forward to seeing you at " . $dealerInfo[$_SESSION['registration']['selectedDealer']]['name'] . "."));
$smsAPI = 'https://x1.taarga.com/sms/create?mobile_number=1' . trim(preg_replace("/[^0-9]/","", $_SESSION['registration']['customer']['mainPhone'])) . '&message=' . $message . '&access_token=e9ef6aacc17289b5238fe42a56a697fe&contact_name=' . urlencode($_SESSION['registration']['customer']['firstname'] . ' ' . $_SESSION['registration']['customer']['lastname']) . '&email_addr=' . urlencode($_SESSION['registration']['customer']['email']) . '&reply_msg=' . $replyMessage . '&sender_ref=' . $_SESSION['registration']['selectedDealer'];
?>
document.getElementById('smsFrame').src = '<?= $smsAPI ?>';
<?php
exit;
}
include_once('header.php');
?>
<script src="scripts/ajax.js" language="javascript"></script>
<script>
function getList(val)
{
htmlStr = 'appraisal.php?getList=' + val;
var arr = new Array('years','makes','models','trims','styles');
var arr2 = new Array('year','make','model','trim','style');
for (var i = 0; i < arr.length; i++)
{
var temp = '';
if(document.getElementById(arr[i]) != undefined) temp=encodeURIComponent(document.getElementById(arr[i]).value);
htmlStr = htmlStr + '&' + arr2[i] + '=' + temp;
}
ajax_do(htmlStr);
}
function submitList()
{
htmlStr = 'appraisal.php?submitList=';
var arrRequired = new Array('firstname','lastname','email','postalCode','mainPhone','years','makes','models','styles','kilometers');
var arr = new Array('firstname','lastname','email','postalCode','mainPhone','appointmentDate','years','makes','models','trims','styles','kilometers');
for (var i = 0; i < arrRequired.length; i++)
{
if(document.getElementById(arrRequired[i]).value == "")
{
alert('Please complete all the required fields to see your appraisal value.\nThank you.');
return false;
}
}
var emailStr = document.getElementById('email').value;
var atpos=emailStr.indexOf("@");
var dotpos=emailStr.lastIndexOf(".");
if (atpos<1 || dotpos<atpos+2 || dotpos+2>=emailStr.length)
{
alert("The email address appears to be invalid.");
return false;
}
for (var i = 0; i < arr.length; i++)
{
var temp = '';
if(document.getElementById(arr[i]) != undefined) temp=encodeURIComponent(document.getElementById(arr[i]).value);
htmlStr = htmlStr + '&' + arr[i] + '=' + temp;
}
document.getElementById('submitButton').value = 'Please wait...';
document.getElementById('submitButton').disabled = true;
ajax_do(htmlStr);
return false;
}
function emailSent()
{
if(document.getElementById('emailFrame').src != "")
{
ajax_do('appraisal.php?sendSMS=');
}
}
function smsSent()
{
if(document.getElementById('smsFrame').src != "")
{
alert('Thank you for your submission.\nPlease check your email for details.');
//document.getElementById('submitButton').disabled = false;
//document.getElementById('submitButton').value = 'Submit';
location.href = 'appraisal.php?complete';
}
}
</script>
<div class="container" style="background-color:#ddd;background-image: url('images/greybg.png')">
<div class="sixteen columns">
<div style="padding:10px">
<center><h4><?= (isset($_GET['complete']) ? 'Thank you for your registration.' : '') ?></h4></center>
</div>
</div>
</div>
<div class="container" style="background-color:#163359;padding:10px">
<form method="POST" style="margin:0px" onSubmit="return submitList();">
<div class="ten columns" style="background-color:#efefef;">
<?php if(isset($_GET['complete'])) { ?>
<div style="padding:20px;height:400px">
Your information has been submitted successfully.
<br>
The appraisal value of your vehicle has been emailed to you.
<br><br>
Please visit our dealership:
<br><br>
<h3 style="color:red;font-weight:bold">
<?= $dealerInfo[$_SESSION['registration']['selectedDealer']]['name']?>
</h3>
<h4>
<?= $dealerInfo[$_SESSION['registration']['selectedDealer']]['address'] ?>
<br>
<?= $dealerInfo[$_SESSION['registration']['selectedDealer']]['phone'] ?>
</h4>
</div>
<?php } else { ?>
<div style="padding:10px 20px 0px 20px">
<h4 style="font-weight:bold">Fill out the information below to RSVP and see the value of your vehicle.</h4>
</div>
<div class="four columns alpha">
<div style="padding:20px 0px 20px 20px">
<label for="firstname">First Name</label>
<input type="text" id="firstname" name="firstname" value="<?= $_SESSION['registration']['customer']['firstname'] ?>">
<label for="lastname">Last Name</label>
<input type="text" id="lastname" name="lastname" value="<?= $_SESSION['registration']['customer']['lastname'] ?>">
<label for="postalCode">Postal Code</label>
<input type="text" id="postalCode" name="postalCode" value="<?= $_SESSION['registration']['customer']['postalCode'] ?>">
<label for="mainPhone">Phone</label>
<input type="text" id="mainPhone" name="mainPhone" value="<?= $_SESSION['registration']['customer']['mainPhone'] ?>">
<label for="email">Email</label>
<input type="text" id="email" name="email" value="<?= $_SESSION['registration']['customer']['email'] ?>">
<label for="appointmentDate">When do you want to come in?</label>
<script>
$(function(){
$.datepicker.setDefaults(
$.extend($.datepicker.regional[''])
);
$('#appointmentDate').datepicker( {dateFormat: "yy-mm-dd"});
});
</script>
<input type="text" id="appointmentDate" name="appointmentDate" value="<?= $_SESSION['registration']['customer']['appointmentDate'] ?>">
</div>
</div>
<div class="five columns omega">
<div style="padding:20px 0px 20px 20px">
<label>Year</label>
<div id="yearsDiv"></div>
<label>Make</label>
<div id="makesDiv"></div>
<label>Model</label>
<div id="modelsDiv"></div>
<label>Trim</label>
<div id="trimsDiv"></div>
<label>Style</label>
<div id="stylesDiv"></div>
<label for="kilometers">KM</label>
<input type="text" id="kilometers" name="kilometers" value="<?= $_SESSION['registration']['tradeIn']['kilometers'] ?>">
<br>
<script>
getList('years');
</script>
</div>
</div>
<br class="clear">
<div class="nine columns">
<center>
<input type="submit" id="submitButton" value="RSVP Now" style="font-weight:bold;font-size:1.5em;background-color:#efd23b;width:220px">
</center>
</div>
<?php } ?>
<br class="clear">
</div>
<div class="six columns" style="color:white;">
<div style="padding:10px">
<h3 style="color:yellow;font-weight:bold">NEWS FLASH</h3>
Right now we are offering top-dollar for all trade-in vehicles. Your current car, truck or SUV might be worth thousands more than you think! Fill out the form on the left to get the Canadian Black Book value on your trade-in!
<br>
<div style="text-align:right;font-size:0.8em">* Subject to physical inspection</div>
<img src="images/appraisalImage.png" class="scale-with-grid">
<br>
<div style="font-size:1.1em;padding:20px">
<center>
<font style="font-size:1.3em;font-weight:bold"><?= strtoupper($dealerInfo[$_SESSION['registration']['selectedDealer']]['name']) ?></font>
<br>
<?= $dealerInfo[$_SESSION['registration']['selectedDealer']]['address'] ?>
<br>
<?= $dealerInfo[$_SESSION['registration']['selectedDealer']]['phone'] ?>
<br>
<a href="<?= $dealerInfo[$_SESSION['registration']['selectedDealer']]['website'] ?>" target="_blank" style="color:yellow"><?= $dealerInfo[$_SESSION['registration']['selectedDealer']]['website'] ?></a>
</center>
</div>
</div>
</div>
</form>
</div>
<div class="container" style="background-color:#333;color:white;">
<div style="padding-top:20px">
<center>
<h2 style="color:yellow;font-weight:bold">PRIVATE SALE SPECIAL</h2>
<?php
foreach($daaVehicles[$dealerInfo[$_SESSION['registration']['selectedDealer']]['area']] as $veh => $info)
{
if(!in_array($veh,array('ram','caravan','wrangler'))) continue;
?>
<div class="five columns">
<div style="padding-bottom:20px">
<div style="height:9em"><img src="images/vehicles/<?= $veh ?>.png" class="scale-with-grid"></div>
<div style="font-weight:bold;font-size:1.5em;line-height:1em"><?= $info['description'] ?></div>
<div style="font-weight:bold;font-size:3em;line-height:1em;color:yellow"><font style="vertical-align:super;font-size:0.4em;font-weight:normal">from</font> <font style="font-size:0.8em">$</font><?= $info['payment'] ?> <font style="font-size:0.3em;font-weight:normal">/bi-weekly</font></div>
</div>
</div>
<?php } ?>
<br class="clear">
</center>
</div>
</div>
<?php include_once('footer.php'); ?>