update order form
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 16 Jul 2014 14:10:22 +0000 (10:10 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 16 Jul 2014 14:10:22 +0000 (10:10 -0400)
add the order form to the main template on the website.
It does goto the second page on the form with the fields
all setup.

Toolkit/Page.php
priceQuoteForm.inc
templates/template.html

index af96920..232821a 100755 (executable)
@@ -147,6 +147,8 @@ class Toolkit_Page
         $GLOBALS['styleSheets'] = array();
         // Resources needed for every page.
         $GLOBALS['topScripts'][] = JQUERY_CDN_JS;
+        $GLOBALS['topScripts'][] = JQUERY_UI_CDN_JS;
+        $GLOBALS['styleSheets'][] = JQUERY_UI_CDN_CSS;
     }
 
     private function _video()
@@ -412,6 +414,9 @@ class Toolkit_Page
      */
     public function fetchPage()
     {
+        $nextWeek            = mktime(0, 0, 0, date('m'), date('d') + 7, date('Y'));
+        $this->arrivalDate   = date('m').'/'.date('d').'/'.date('Y');
+        $this->departureDate = date('m', $nextWeek).'/'.date('d', $nextWeek).'/'.date('Y', $nextWeek);
         if (defined('MEMBERS_DB') && MEMBERS_DB) {
             // check to see if this page is a member only page
             $memberOnlyPage = Toolkit_Template_Page::isMemberOnly(
index bd64d9e..0211dae 100644 (file)
@@ -9,8 +9,29 @@ require_once 'HTML/QuickForm/Action/Back.php';
 require_once 'HTML/QuickForm/Action/Jump.php';
 require_once 'HTML/QuickForm/Action/Display.php';
 
-// Start the session, form-page values will be kept there
-//session_start();
+$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.
@@ -47,7 +68,7 @@ function checkCountryState($data)
 
 function date_difference($m0, $d0, $y0, $m1, $d1, $y1)
 {
-    $arrival = gregoriantojd($m0, $d0, $y0);
+    $arrival   = gregoriantojd($m0, $d0, $y0);
     $departure = gregoriantojd($m1, $d1, $y1);
 
     $diff = $departure - $arrival;
@@ -135,7 +156,7 @@ class PageFirst extends PageBase
 
         $nextWeek = mktime(0, 0, 0, date('m'), date('d') + 7, date('Y'));
         $defaults = array(
-            'arrival' => array('m' => date('m'), 'd' => date('d'), 'Y' => date('Y')),
+            'arrival'   => array('m' => date('m'), 'd' => date('d'), 'Y' => date('Y')),
             'departure' => array('m' => date('m', $nextWeek), 'd' => date('d', $nextWeek), 'Y' => date('Y', $nextWeek)),
         );
         $golfers = array('' => '-- Select --') + range(0, 20);
@@ -167,7 +188,7 @@ class PageSecond extends PageBase
     {
         $this->_formBuilt = true;
 
-        $golfers $this->controller->exportValue('page1', 'golfers');
+        $golfers    = $this->controller->exportValue('page1', 'golfers');
         $nongolfers = $this->controller->exportValue('page1', 'nongolfers');
 
         $attendees = $golfers + $nongolfers;
@@ -177,8 +198,7 @@ class PageSecond extends PageBase
         $singles = array('' => '-- Select --') + range(0, $attendees);
         $accomodations = array('' => '-- Select --') + range(0, $attendees);
         $bathrooms = range(1, $attendees);
-        foreach ($bathrooms as $k => $v)
-        {
+        foreach ($bathrooms as $k => $v) {
             $temp[++$k] = $v;
         }
         unset($bathrooms);
@@ -188,18 +208,18 @@ class PageSecond extends PageBase
         $lodging[] = array('type' => 'radio', 'req' => true, 'name' => 'lodging', 'display' => null, 'opts' => 'Hamlet Village', 'att' => 'Hamlet Village Condominiums');
         $lodging[] = array('type' => 'radio', 'req' => true, 'name' => 'lodging', 'display' => null, 'opts' => 'Trout Creek', 'att' => 'Trout Creek Condominiums');
 
-        $bedOptions[] = array('type' => 'checkbox', 'req' => false, 'name' => 'twin',       'display' => null, 'opts' => 'Twin Bed is OK');
-        $bedOptions[] = array('type' => 'checkbox', 'req' => false, 'name' => 'sleeper',    'display' => null, 'opts' => 'Sleeper Sofa is OK');
+        $bedOptions[] = array('type' => 'checkbox', 'req' => false, 'name' => 'twin',    'display' => null, 'opts' => 'Twin Bed is OK');
+        $bedOptions[] = array('type' => 'checkbox', 'req' => false, 'name' => 'sleeper', 'display' => null, 'opts' => 'Sleeper Sofa is OK');
 
-        $elements[] = array('type' => 'header',         'req' => false, 'name' => 'header_rmv',         'display' => 'Package Price Quote Request page 2 of 4');
-        $elements[] = array('type' => 'group',          'req' => true,  'name' => 'accommodation',      'group' => $lodging, 'label' => 'Lodging:', 'appendName' => false);
-        $elements[] = array('type' => 'select',         'req' => true,  'name' => 'couples',            'display' => 'Number of Couples:',  'opts' => $couples);
-        $elements[] = array('type' => 'select',         'req' => true,  'name' => 'singles',            'display' => 'Number of Singles:',  'opts' => $singles);
-        $elements[] = array('type' => 'select',         'req' => false, 'name' => 'bathrooms',          'display' => 'Number of Bathrooms:','opts' => $bathrooms);
-        $elements[] = array('type' => 'header',         'req' => false, 'name' => 'accomodation_rmv',   'display' => 'Accommodation Type Preference');
-        $elements[] = array('type' => 'select',         'req' => true,  'name' => 'rooms',              'display' => 'Number of Rooms:',    'opts' => $accomodations);
-        $elements[] = array('type' => 'select',         'req' => true,  'name' => 'beds',               'display' => 'Number of Beds:',     'opts' => $accomodations);
-        $elements[] = array('type' => 'group',          'req' => false, 'name' => 'bedOptions',         'group' => $bedOptions, 'label' => 'Bed Options:', 'separator' => '<br>', 'appendName' => false);
+        $elements[] = array('type' => 'header', 'req' => false, 'name' => 'header_rmv',       'display' => 'Package Price Quote Request page 2 of 4');
+        $elements[] = array('type' => 'group',  'req' => true,  'name' => 'accommodation',    'group' => $lodging, 'label' => 'Lodging:', 'appendName' => false);
+        $elements[] = array('type' => 'select', 'req' => true,  'name' => 'couples',          'display' => 'Number of Couples:',  'opts' => $couples);
+        $elements[] = array('type' => 'select', 'req' => true,  'name' => 'singles',          'display' => 'Number of Singles:',  'opts' => $singles);
+        $elements[] = array('type' => 'select', 'req' => false, 'name' => 'bathrooms',        'display' => 'Number of Bathrooms:','opts' => $bathrooms);
+        $elements[] = array('type' => 'header', 'req' => false, 'name' => 'accomodation_rmv', 'display' => 'Accommodation Type Preference');
+        $elements[] = array('type' => 'select', 'req' => true,  'name' => 'rooms',            'display' => 'Number of Rooms:',    'opts' => $accomodations);
+        $elements[] = array('type' => 'select', 'req' => true,  'name' => 'beds',             'display' => 'Number of Beds:',     'opts' => $accomodations);
+        $elements[] = array('type' => 'group',  'req' => false, 'name' => 'bedOptions',       'group' => $bedOptions, 'label' => 'Bed Options:', 'separator' => '<br>', 'appendName' => false);
 
         $prevnext[] =& $this->createElement('submit',   $this->getButtonName('next'), 'Next step >>');
 
@@ -213,8 +233,8 @@ class PageSecond extends PageBase
         $defaults = array(
             'couples' => '',
             'singles' => '',
-            'rooms' => '',
-            'beds' =>'',
+            'rooms'   => '',
+            'beds'    => '',
         );
         $this->setDefaults($defaults);
     }
index 137d44c..b9162f4 100644 (file)
         </header>
         <div id="quoteRequest">
             <h2>Quote Request</h2>
-            <form>
+            <form flexy:ignore="yes" method="post" action="{mediaBaseURL:h}index.php?catid=9">
+                <input type="hidden" name="_qf_default" value="page1:next">
+                <input name="arrival" value="{arrivalDate:h}">
+                <input name="departure" value="{departureDate:h}">
+                <select name="golfers">
+                    <?php for ($i = 0; $i <= 20; ++$i) {?>
+                    <option value="<?php echo $i;?>"><?php echo $i;?></option>
+                    <?php }?>
+                </select>
+                <select name="nongolfers">
+                    <?php for ($i = 0; $i <= 20; ++$i) {?>
+                    <option value="<?php echo $i;?>"><?php echo $i;?></option>
+                    <?php }?>
+                </select>
+                <input type="submit" value="NEXT STEP">
             </form>
         </div>
+        <script>
+            $(function(){
+                $('input[name="arrival"]').datepicker();
+                $('input[name="departure"]').datepicker();
+            });
+        </script>
         <div id="main">
             <div id="toolbox">
                 <ul id="propertyImages" class="clearfix" flexy:if="property">