<?php
include_once('includes.php');
include_once('displayUtils.php');
if(isset($_GET['dealer']))
{
$_SESSION['tradeup']['selectedDealer'] = strtolower($_GET['dealer']);
$_SESSION['selectedDealer'] = strtolower($_GET['dealer']);
header("location: index.php");
exit;
}
if(!isset($dealerInfo[$_SESSION['tradeup']['selectedDealer']]))
{
header("location: code.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'] . '"' . ($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 = '';
<?php
}
if(($curKey < (count($lists)-1)) && count($list) == 1)
{
?>
getList('<?= $lists[$curKey+1]?>');
<?php
}
exit;
}
if(isset($_POST['firstname']))
{
unset($_SESSION['tradeup']);
$_SESSION['tradeup'] = $_POST;
$_SESSION['tradeup']['selectedDealer'] = $_SESSION['selectedDealer'];
$xml = simplexml_load_file($bbLink . 'kilometers=' . ereg_replace("[^0-9]", "", $_SESSION['tradeup']['kilometers']) . '&year=' . $_SESSION['tradeup']['years'] . '&make=' . urlencode($_SESSION['tradeup']['makes']) . '&model=' . urlencode($_SESSION['tradeup']['models']) . '&trim=' . urlencode($_SESSION['tradeup']['trims']) . '&style=' . urlencode($_SESSION['tradeup']['styles']) . '&command=priceVehicle');
$list = $xml->response->vehicles->vehicle->values;
$_SESSION['tradeup']['values'] = get_object_vars ($list);
header("location: success.php");
exit;
}
?>
<?php include_once('header.php'); ?>
<script src="scripts/ajax.js" language="javascript"></script>
<script>
function getList(val)
{
year = '';
make = '';
model = '';
trim = '';
styleVal = '';
if(document.getElementById('years') != undefined) year=document.getElementById('years').value;
if(document.getElementById('makes') != undefined) make=document.getElementById('makes').value;
if(document.getElementById('models') != undefined) model=document.getElementById('models').value;
if(document.getElementById('trims') != undefined) trim=document.getElementById('trims').value;
if(document.getElementById('styles') != undefined) styleVal=document.getElementById('styles').value;
htmlStr = 'index.php?getList=' + val + '&year=' + year.replace(/&/,"%26") + '&make=' + make.replace(/&/,"%26") + '&model=' + model.replace(/&/,"%26") + '&trim=' + trim.replace(/&/,"%26") + '&style=' + styleVal.replace(/&/,"%26");
//htmlStr = 'index.php?getList=' + val + '&year=' + year + '&make=' + make + '&model=' + model + '&trim=' + trim + '&style=' + styleVal;
//alert(htmlStr);
ajax_do(htmlStr);
}
function checkForm()
{
if(document.getElementById('firstname').value == "")
{
alert('Please tell us your first name.');
return false;
}
else if(document.getElementById('lastname').value == "")
{
alert('Please tell us your last name.');
return false;
}
else if(document.getElementById('mobile').value == "")
{
alert('Please tell us your mobile phone.');
return false;
}
else if(document.getElementById('email').value == "")
{
alert('Please tell us your email address.');
return false;
}
else if(document.getElementById('postalCode').value == "")
{
alert('Please tell us your Postal Code.');
return false;
}
else if(false && document.getElementById('kilometers').value == "")
{
alert('Please tell us the kilometers of your trade in.');
return false;
}
else if(false && (document.getElementById('styles') == undefined || document.getElementById('styles').value == ""))
{
alert('Please tell us information about your current vehicle.');
return false;
}
else
{
return true;
}
}
</script>
<style>
.formTbl td {padding-bottom:2px;height:25px}
.formTbl td input {width:160px}
</style>
<div style="color:#FFF;margin-left:100px; font-size:10px;"> <?= $dealerInfo[$_SESSION['tradeup']['selectedDealer']]['eventDate']?> </div>
<table cellspacing="0" cellpadding="0">
<tr>
<td style="padding-left:40px;text-align:left;">
<center>
<img src="images/titles.jpg">
<div style="background-color:#efefef;padding-top:10px;text-align:left;padding-left:20px;padding-right:20px">
<br>
<form method="POST" onSubmit="return checkForm()">
<table cellspacing="0" cellpadding="0" style="width:100%">
<tr>
<td style="padding:5px 0px;width:250px">
<table cellspacing="0" cellpadding="0" class="formTbl" style="width:100%">
<tr>
<td colspan="2" style="padding-bottom:15px;font-size:12pt;color:red;font-weight:bold;text-align:center">Comment pouvons-nous vous contacter?</td>
</tr>
<tr>
<td nowrap>Prénom</td>
<td><input type="text" id="firstname" name="firstname" value="<?= $_SESSION['tradeup']['firstname'] ?>"></td>
</tr>
<tr>
<td nowrap>Nom</td>
<td><input type="text" id="lastname" name="lastname" value="<?= $_SESSION['tradeup']['lastname'] ?>"></td>
</tr>
<tr>
<td nowrap>Cellulaire</td>
<td><input type="text" id="mobile" name="mobile" value="<?= $_SESSION['tradeup']['mobile'] ?>"></td>
</tr>
<tr>
<td nowrap>Courriel</td>
<td><input type="text" id="email" name="email" value="<?= $_SESSION['tradeup']['email'] ?>"></td>
</tr>
<tr>
<td nowrap>Adresse</td>
<td><input type="text" id="address" name="address" value="<?= $_SESSION['tradeup']['address'] ?>"></td>
</tr>
<tr>
<td nowrap>Code Postal</td>
<td><input type="text" id="postalCode" name="postalCode" value="<?= $_SESSION['tradeup']['postalCode'] ?>"></td>
</tr>
</table>
</td>
<?php if($dealerInfo[$_SESSION['tradeup']['selectedDealer']]['blackbook'] != 'no') { ?>
<td style="padding:5px 10px;padding-bottom:10px;width:250px;background-color:#ccc">
<table cellspacing="0" cellpadding="0" class="formTbl" style="width:100%">
<tr>
<td colspan="2" style="padding-bottom:15px;font-size:18pt;color:red;text-align:center">
<b>OBTENEZ LA VALEUR DE VOTRE VÉHICULE MAINTENANT!</b>
<br>
<font style="color:#777;font-size:9pt">Estimation Canadian Black Book</font>
</td>
</tr>
<tr>
<td style="width:50px">Year</td>
<td style=""><div id="yearsDiv" style="display:inline"></div></td>
</tr>
<tr>
<td>Marque</td>
<td><div id="makesDiv" style="display:inline"></div></td>
</tr>
<tr>
<td>Modèle</td>
<td><div id="modelsDiv" style="display:inline"></div></td>
</tr>
<tr>
<td>Coupe</td>
<td><div id="trimsDiv" style="display:inline"></div></td>
</tr>
<tr>
<td>Carosserie</td>
<td><div id="stylesDiv" style="display:inline"></div></td>
</tr>
<tr>
<td>KM</td>
<td><input type="text" style="width:100px" id="kilometers" name="kilometers" value="<?= $_SESSION['tradeup']['kilometers'] ?>" onkeypress="return onlyNumbers(event);"></td>
</tr>
</table>
</td>
<?php } ?>
<td style="padding:5px 15px;padding-right:5px;width:240px;">
<table cellspacing="0" cellpadding="0" class="formTbl">
<tr>
<td colspan="2" style="padding-bottom:5px;font-size:16pt;color:red;font-weight:bold;text-align:center"><b>OBTENEZ UN MEILLEUR PAIEMENT SUR UN NOUVEAU VÉHICULE</b></td>
</tr>
<tr>
<td colspan="2" style="padding-bottom:2px;font-size:11pt;vertical-align:bottom">Quel est votre paiement actuel?</td>
</tr>
<tr>
<td colspan="2"><input type="text" style="width:260px" id="payment" name="payment" value="<?= $_SESSION['tradeup']['payment'] ?>"></td>
</tr>
<tr>
<td colspan="2" style="padding-bottom:2px;font-size:11pt;vertical-align:bottom">Nombre de mois avant échéance du contrat?</td>
</tr>
<tr>
<td colspan="2"><input type="text" style="width:260px" id="monthsRemaining" name="monthsRemaining" value="<?= $_SESSION['tradeup']['monthsRemaining'] ?>"></td>
</tr>
<tr>
<td colspan="2" style="padding-bottom:2px;font-size:11pt;vertical-align:bottom">Quel véhicule vous intéresse?</td>
</tr>
<tr>
<td colspan="2"><input type="text" style="width:260px" id="nextVehicle" name="nextVehicle" value="<?= $_SESSION['tradeup']['nextVehicle'] ?>" ></td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="3" style="padding-top:10px;padding-bottom:10px">
<center>
<input type="image" src="images/submit.png">
</center>
</td>
</tr>
</table>
</form>
</div>
<?php
if (in_array($dealerInfo[$selectedDealer]['name'], array('centreleprixdugros'))) echo '<img src="images/roundBottomBlank.png">';
else echo '<img src="images/roundBottom' . ($dealerInfo[$_SESSION['tradeup']['selectedDealer']]['blackbook'] == 'no' ? 'Blank' : '') . '.png">';
?>
<!-- <img src="images/roundBottom.png"> -->
</center>
</td>
</tr>
<?php
if (in_array($dealerInfo[$selectedDealer]['logo2'], array('wb_footer'))) $imga = 'wb_footer.png';
?>
<td style="width:940px;height:287px;background-image:url('images/<?= $imga ?>');background-repeat:no-repeat;background-position:center top;"> </tr>
</table>
<?php
if(!isset($_SESSION['webhit']))
{
$_SESSION['webhit'] = true;
?>
<iframe height="0" width="0" src="http://ar.absoluteresults.com/misc/webHits.php?url=<?= str_replace(array('www.'),'',$_SERVER['HTTP_HOST']); ?>&dealer=<?= $_SESSION['tradeup']['selectedDealer'] ?>&eventID=<?= $dealerInfo[$_SESSION['tradeup']['selectedDealer']]['eventID'] ?>" frameborder="0"></iframe>
<?php
}
?>
<script>
getList('years');
</script>
<?php include_once('footer.php'); ?>