<?php
include_once('includes.php');
unset($_SESSION['registration']['customer']['dCode']);
if(isset($_GET['submitList']))
{
unset($_SESSION['registration']['customer']);
unset($_SESSION['registration']['tradeIn']);
$link = 'http://ar.absoluteresults.com/salesevent2013/lookup.php?e=' . $dealerInfo[$_SESSION['registration']['selectedDealer']]['eventID'] . '&c=' . str_replace(' ','',$_GET['code']);
$cus = unserialize(stripslashes(urldecode(file_get_contents($link))));
if($cus['selectedDealer'] != "") $_SESSION['registration']['selectedDealer'] = $cus['selectedDealer'];
if($cus['contactID'] != "")
{
$_SESSION['registration']['customer']['firstname'] = $cus['firstname'];
$_SESSION['registration']['customer']['lastname'] = $cus['lastname'];
$_SESSION['registration']['customer']['postalCode'] = $cus['postalCode'];
$_SESSION['registration']['customer']['mainPhone'] = $cus['mainPhone'];
$_SESSION['registration']['customer']['email'] = $cus['email'];
$_SESSION['registration']['customer']['dCode'] = strtolower($_GET['code']);
$_SESSION['registration']['tradeIn']['model'] = trim($cus['year'] . ' ' . $cus['description']);
if($dealerInfo[$_SESSION['registration']['selectedDealer']]['pullAheadCode'] != '')
{
?>
location.href='pullAheadForm.php';
<?php
}
else if(strtolower($dealerInfo[$_SESSION['registration']['selectedDealer']]['blackbook']) == 'yes')
{
?>
location.href='appraisal.php';
<?php
}
else
{
?>
location.href='form.php';
<?php
}
}
else if($dealerInfo[$_SESSION['registration']['selectedDealer']]['eventID'] != "")
{
?>
if(confirm('The code appears to be invalid. Continue anyway?'))
{
<?php
if(strtolower($dealerInfo[$_SESSION['registration']['selectedDealer']]['blackbook']) == 'yes')
{
?>
location.href='appraisal.php';
<?php
}
else
{
?>
location.href='form.php';
<?php
}
?>
}
else location.href='dCode.php';
<?php
}
else
{
?>
alert('Invalid Code');
location.href='dCode.php';
<?php
}
exit;
}
unset($_SESSION['registration']['customer']);
include_once('header.php');
?>
<script src="scripts/ajax.js" language="javascript"></script>
<script>
function submitList()
{
htmlStr = 'dCode.php?submitList=';
var arr = new Array('code');
var arrRequired = new Array('code');
for (var i = 0; i < arrRequired.length; i++)
{
if(document.getElementById(arrRequired[i]).value == "")
{
alert('Please tell us your offer code to RSVP.\nThank you.');
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;
}
</script>
<div class="container" style="background-image:url('images/layout/transparentBG.png');padding:10px">
<form method="POST" style="margin:0px" onSubmit="return submitList();">
<div class="sixteen columns" style="background-color:#bbb;">
<div style="padding:20px">
<center>
<label for="postalCode" style="font-size:1.5em;margin-bottom:10px"><?=$lang['code']?></label>
<input type="text" id="code" name="code" value="<?= $_GET['code'] ?>" style="font-size:2em">
<input type="submit" id="submitButton" value="<?=$lang['codeBtn']?>" style="font-weight:bold;font-size:1.5em;background-color:#efd23b;width:220px;margin-top:10px">
</center>
</div>
</div>
</form>
</div>
<?php if($_GET['code'] != "") { ?> <script>submitList();</script> <?php } ?>
<?php include_once('footer.php'); ?>