<?php
include_once('includes.php');
if($_SESSION['registration']['selectedDealer'] == "")
{
header("location: index.php");
exit;
}
if(isset($_GET['submitList']))
{
unset($_SESSION['registration']['customer']);
foreach($_GET as $key => $val)
{
$_SESSION['registration']['customer'][$key] = $val;
}
?>
document.getElementById('emailFrame').src = 'http://ar.absoluteresults.com/digital0913/preapproveEmail.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 submitList()
{
htmlStr = 'preapprove.php?submitList=';
var arr = new Array('firstname','lastname','email','postalCode','mainPhone','appointmentDate');
var arrRequired = new Array('firstname','lastname','email','postalCode','mainPhone','appointmentDate');
for (var i = 0; i < arrRequired.length; i++)
{
if(document.getElementById(arrRequired[i]).value == "")
{
alert('Please complete all the required fields to see your offer.\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 true;
}
function emailSent()
{
if(document.getElementById('emailFrame').src != "")
{
//ajax_do('preapprove.php?sendSMS=');
document.getElementById('submitButton').value = 'Get Pre-Approved';
document.getElementById('submitButton').disabled = false;
}
}
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 = 'preapprove.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.' : 'Fill out the information below to initiate the online credit application.') ?></h4></center>
</div>
</div>
</div>
<div class="container" style="background-color:<?= $_SESSION['offers'][$currentPage]['color'] ?>;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:200px">
Your information has been submitted successfully.
</div>
<?php } else { ?>
<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="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'] ?>">
</div>
</div>
<div class="five columns omega">
<div style="padding:20px 0px 20px 20px">
<label for="postalCode">Postal Code</label>
<input type="text" id="postalCode" name="postalCode" value="<?= $_SESSION['registration']['customer']['postalCode'] ?>">
<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'] ?>">
<input type="submit" id="submitButton" onClick="if(submitList()) window.open('<?= $dealerInfo[$_SESSION['registration']['selectedDealer']]['preapproval'] ?>');" value="Get Pre-Approved" style="font-weight:bold;font-size:1.5em;background-color:#efd23b;width:220px;margin-top:10px">
</div>
</div>
<?php } ?>
<br class="clear">
<div style="padding:20px;">
<?php if($nextOffer != "") { ?>
<div style="font-size:12pt"><i>Want another offer?</i></div>
<a href="<?= $nextOffer ?>.php"><img src="images/<?= $nextOffer ?>Button.png" border="0" class="scale-with-grid"></a>
<?php } ?>
</div>
</div>
<div class="six columns" style="color:white;">
<div style="padding:0px 10px">
As a Convenience, many customers are getting pre-approved for a new vehicle before they start shopping. Fill out the information on the left to receive your pre-approval form.
<br><br>
<div style="padding-top:10px"><img src="images/preapproveImage.png" class="scale-with-grid"></div>
</div>
</div>
</form>
</div>
<?php include_once('footer.php'); ?>