From: Steve Sutton Date: Wed, 7 Jan 2015 18:34:51 +0000 (-0500) Subject: Fixing price form X-Git-Tag: v1.1.8^2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=d32f5fa2b16afaefe8448f22b32bec166911dfa4;p=web%2FBigFore.git Fixing price form --- diff --git a/index.php b/index.php index 351cc4c..a9fd406 100644 --- a/index.php +++ b/index.php @@ -47,6 +47,36 @@ HTTP_Session2::useCookies(false); HTTP_Session2::start(); if ($catid == ORDER_FORM_PAGE) { + $arrival = filter_input(INPUT_POST, 'arrival', FILTER_SANITIZE_STRING); + $departure = filter_input(INPUT_POST, 'departure', FILTER_SANITIZE_STRING); + $pattern = '%([0-9]{1,2})/([0-9]{1,2})/([0-9]{4})%'; + if ($arrival && $departure) { + if (!is_array($arrival) && !is_array($departure) + && (preg_match($pattern, $arrival) && preg_match($pattern, $departure)) + ) { + + if (preg_match($pattern, $arrival, $matches)) { + $_POST['arrival'] = array(); + $_POST['arrival']['m'] = $matches[1]; + $_POST['arrival']['d'] = $matches[2]; + $_POST['arrival']['Y'] = $matches[3]; + if ($matches[1] && $matches[2] && $matches[3]) { + $_SESSION['_spacey_container']['values']['page1']['arrival'] + = $_POST['arrival']; + $_SESSION['bfForm']['arrival'] = $_POST['arrival']; + } + } + if (preg_match($pattern, $departure, $matches)) { + $_POST['departure'] = array(); + $_POST['departure']['m'] = $matches[1]; + $_POST['departure']['d'] = $matches[2]; + $_POST['departure']['Y'] = $matches[3]; + $_SESSION['_spacey_container']['values']['page1']['departure'] + = $_POST['departure']; + $_SESSION['bfForm']['departure'] = $_POST['departure']; + } + } + } include 'priceQuoteForm.inc'; } require_once 'setup_functions.phtml'; diff --git a/priceQuoteForm.inc b/priceQuoteForm.inc index 45939c4..1f85d70 100644 --- a/priceQuoteForm.inc +++ b/priceQuoteForm.inc @@ -9,30 +9,6 @@ require_once 'HTML/QuickForm/Action/Back.php'; require_once 'HTML/QuickForm/Action/Jump.php'; require_once 'HTML/QuickForm/Action/Display.php'; -$arrival = filter_var($_REQUEST['arrival']); -$departure = filter_var($_REQUEST['departure']); -if ($arrival && $departure) { - if (!is_array($arrival) && !is_array($departure)) { - $pattern = '%([0-9]{1,2})/([0-9]{1,2})/([0-9]{4})%'; - if (preg_match($pattern, $arrival, $matches)) { - $_POST['arrival'] = array(); - $_POST['arrival']['m'] = (int)$matches[1]; - $_POST['arrival']['d'] = $matches[2]; - $_POST['arrival']['Y'] = $matches[3]; - $_SESSION['_spacey_container']['values']['page1']['arrival'] - = $_POST['arrival']; - } - if (preg_match($pattern, $departure, $matches)) { - $_POST['departure'] = array(); - $_POST['departure']['m'] = (int)$matches[1]; - $_POST['departure']['d'] = $matches[2]; - $_POST['departure']['Y'] = $matches[3]; - $_SESSION['_spacey_container']['values']['page1']['departure'] - = $_POST['departure']; - } - } -} - // Check to make sure the end date is the // same as the start date or later in the year. function check_dates ($data) @@ -162,8 +138,8 @@ class PageFirst extends PageBase $golfers = array('' => '-- Select --') + range(0, 20); $elements[] = array('type' => 'header', 'req' => false, 'name' => 'header_rmv', 'display' => 'Package Price Quote Request page 1 of 4'); - $elements[] = array('type' => 'date', 'req' => true, 'name' => 'arrival', 'display' => 'Arrival:', 'opts' => array('format' => 'm / d / Y', 'minYear' => date('Y'), 'maxYear' => date('Y')+1)); - $elements[] = array('type' => 'date', 'req' => true, 'name' => 'departure', 'display' => 'Departure:', 'opts' => array('format' => 'm / d / Y', 'minYear' => date('Y'), 'maxYear' => date('Y')+1)); + $elements[] = array('type' => 'date', 'req' => true, 'name' => 'arrival', 'display' => 'Arrival:', 'opts' => array('format' => 'm/d/Y', 'minYear' => date('Y'), 'maxYear' => date('Y')+1)); + $elements[] = array('type' => 'date', 'req' => true, 'name' => 'departure', 'display' => 'Departure:', 'opts' => array('format' => 'm/d/Y', 'minYear' => date('Y'), 'maxYear' => date('Y')+1)); $elements[] = array('type' => 'select', 'req' => true, 'name' => 'golfers', 'display' => 'Number of golfers:', 'opts' => $golfers); $elements[] = array('type' => 'select', 'req' => true, 'name' => 'nongolfers', 'display' => 'Number of non-golfers:', 'opts' => $golfers); $elements[] = array('type' => 'submit', 'req' => false, 'name' => $this->getButtonName('next'), 'display' => 'Next step >>'); @@ -249,11 +225,14 @@ class PageThird extends PageBase = MEDIA_BASE_URL . 'libjs/golfersSelect.js'; $this->_formBuilt = true; - $arrival = $this->controller->exportValue('page1', 'arrival'); - $departure = $this->controller->exportValue('page1', 'departure'); + $arrival = ($_SESSION['bfForm']['arrival']) + ? $_SESSION['bfForm']['arrival'] + : $this->controller->exportValue('page1', 'arrival'); + $departure = ($_SESSION['bfForm']['departure']) + ? $_SESSION['bfForm']['departure'] + : $this->controller->exportValue('page1', 'departure'); list($arrivalMonth, $arrivalDay, $arrivalYear) = array_values($arrival); list($departureMonth, $departureDay, $departureYear) = array_values($departure); - $vacationLength = date_difference( $arrivalMonth, $arrivalDay,