<?
define ("LEVEL", '');
include_once(LEVEL."inc/include.php");
$clean = array();
foreach ($_POST as $key=>$value) {
$clean[$key] = strip_tags(strtolower(stripslashes($_POST[$value])));
}
unset($_POST);//
$user = new user();
$reservation = new reservation();
$form_type = $reservation->loadFields($clean["form_type"]);
$step = ($clean["step"]) ? ($clean["step"]) : ("1");
switch($step) {
case "1":
$clean["form_type"] = $form_type;
$clean["yes_no"] = 1;
$order = array("check__fields", "form_type", "Resort", "Hotel", "Room_Type", "Arrival_Month", "Arrival_Date", "Arrival_Year",
"Nights", "Tickets", "Adults", "Juniors", "Children");
$res = sort_res($reservation->showRecord($clean,$reservation->lists), $order);
for($i = 0; $i < sizeof($res); ++$i){
if(in_array($res[$i]["name"], array("Resort", "Hotel", "Arrival_Month", "Arrival_Date", "Arrival_Year", "Room_Type", "Nights", "Tickets"))){
if (isset($clean[$res[$i]["name"]])) {
$res[$i]["type"] = "static";
}
}
}
/*
if($form_type == "cancun"){
$newres = array();
foreach($res as $item){
$newres[] = $item;
if($item["name"] == "Adults"){
$newres[] = array(
'type' => 'Juniors',
'check' => '#',
'name' => 'Juniors',
'title' => 'Juniors (12-17)',
'value' => '',
);
}
}
$res = $newres;
} */
$smarty->assign("reservation", $res);
break;
case "cc":
$order = array("check__fields", "form_type", "Resort", "Hotel", "Room_Type", "Arrival_Month", "Arrival_Date", "Arrival_Year", "Checkin_Date", "Checkout_Date", "Nights", "Tickets", "Adults", "Juniors", "Children", "Number_of_Guest", "Price",
"First_Name", "Last_Name", "Spouse_Name", "Marital_Status", "Address", "City", "State",
"Province", "Country", "Zip_Code", "Day_Phone", "Night_Phone", "Email", "Fax",
"Best_Time_to_Call", "Age", "Income", "Card_Number",
"Card_Expiration", "Name_on_card", "Comments", "agreement");
$price = CalculatePrice($clean);
$clean["Price"] = $price["txt"];
$clean["Country"] = "United States";
$guests = 0;
foreach (array("Adults", "Juniors", "Children") as $type){
if(isset($clean[$type])){
$guests += $clean[$type];
}
}
$clean["Number_of_Guest"] = $guests;
unset($clean["check__fields"]);
$res = $reservation->showRecord($clean,$reservation->lists);
for($i = 0; $i < sizeof($res); ++$i) {
if ($res[$i]["name"] == "Checkout_Date") {
$res[$i]["type"] = "static";
$res[$i]["check"] = "Check";
$res[$i]["title"] = "Checkout Date";
$res[$i]["value"] = date("l F jS Y", strtotime("+ $_POST[Nights] days", strtotime($clean["Arrival_Month"] . " " . $clean["Arrival_Date"] . " " . $clean["Arrival_Year"])));
}
if ($res[$i]["name"] == "Checkin_Date") {
$res[$i]["type"] = "static";
$res[$i]["check"] = "Check";
$res[$i]["title"] = "Check In Date";
$res[$i]["value"] = date("l F jS Y", strtotime($clean["Arrival_Month"] . " " . $clean["Arrival_Date"] . " " . $clean["Arrival_Year"]));
}
}
//var_dump($res);
$res[] = array(
'type' => 'checkbox',
'check' => 'Check',
'name' => 'agreement',
'title' => 'I Agree to the Terms & Conditions',
'value' => 'To submit the form you must accept the Terms and Conditions.'
);
// $res[] = array(
// 'type' => 'static',
// 'check' => '',
// 'name' => 'Checkout_Date',
// 'title' => 'Checkout Date',
// 'value' => date("l F jS Y", strtotime("+ $_POST[Nights] days", strtotime($_POST["Arrival_Month"] . " " . $_POST["Arrival_Date"] . " " . $_POST["Arrival_Year"])))
// );
// $res[] = array(
// 'type' => 'static',
// 'check' => 'Check',
// 'name' => 'Checkin_Date',
// 'title' => 'Check In Date',
// 'value' => date("l F jS Y", strtotime($_POST["Arrival_Month"] . " " . $_POST["Arrival_Date"] . " " . $_POST["Arrival_Year"]))
// );
$res = sort_res($res, $order);
for($i = 0; $i < sizeof($res); ++$i){
if(in_array($res[$i]["name"], array("Resort", "Hotel", "Room_Type", "Arrival_Month", "Arrival_Date", "Arrival_Year", "Checkin_Date", "Checkout_Date",
"Nights", "Tickets", "Adults", "Juniors", "Children", "Number_of_Guest", "Price"))){
$res[$i]["type"] = "static";
$res[$i]["check"] = '';
}
if ($res[$i]["name"] == "check__fields") {
$res[$i]["value"] .= ",agreement,Check";
}
}
$smarty->assign("reservation", $res);
break;
case "2":
$order = array("check__fields", "form_type", "Resort", "Hotel", "Room_Type", "Arrival_Month", "Arrival_Date", "Arrival_Year", "Checkin_Date", "Checkout_Date", "Nights", "Tickets", "Adults", "Juniors", "Children", "Number_of_Guest", "Price",
"First_Name", "Last_Name", "Spouse_Name", "Marital_Status", "Address", "City", "State",
"Province", "Country", "Zip_Code", "Day_Phone", "Night_Phone", "Email", "Fax",
"Best_Time_to_Call", "Age", "Income", "Card_Number", "Card_Type",
"Card_Expiration", "Name_on_card", "Comments");
$price = CalculatePrice($clean);
$clean["Price"] = $price["txt"];
$guests = 0;
foreach (array("Adults", "Juniors", "Children") as $type){
if(isset($clean[$type])){
$guests += $clean[$type];
}
}
$clean["Number_of_Guest"] = $guests;
$clean["Card_Number"] = ereg_replace("[^0-9]", "", $clean["Card_Number"]);
if($clean["Card_Number"][0] == "5"){
$clean["Card_Type"] = "Master Card";
}
else if ($clean["Card_Number"][0] == "4"){
$clean["Card_Type"] = "Visa";
}
else if (substr($clean["Card_Number"],0, 2) == "34" or substr($clean["Card_Number"],0, 2) == "37"){
$clean["Card_Type"] = "American Express";
}
else if (substr($clean["Card_Number"], 0, 4) == "6011"){
$clean["Card_Type"] = "Discover";
}
else{
$clean["Card_Type"] = "Unknown";
}
// Format the phone numbers
$clean['Day_Phone'] = formatPhone($clean['Day_Phone']);
$clean['Night_Phone'] = formatPhone($clean['Night_Phone']);
$clean['Fax'] = formatPhone($clean['Fax']);
$res = sort_res($reservation->showRecord($clean,$reservation->lists), $order);
$newres = array();
foreach($res as $item){
if($item["name"] == "Card_Number"){
$item["type"] = "hidden";
$newres[] = $item;
$newres[] = array(
'type' => 'Juniors',
'check' => '#',
'name' => '',
'title' => 'Card Number',
'value' => substr("****************", 0, strlen($item["value"]) - 4) . substr($item["value"], strlen($item["value"]) - 4, 4)
);
}
else{
$newres[] = $item;
}
}
$smarty->assign("reservation", $newres);
break;
}
function sort_res($res, $order) {
$newres = array();
foreach($order as $row) {
foreach($res as $item) {
if ($item["name"] == $row) {
$newres[] = $item;
}
}
}
return $newres;
}
$smarty->assign("content", "reservation".$step.".html");
$smarty->display("form_".$form_type.".html");
?>