Update form to fix the arrival and departure dates.
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 27 Jan 2017 15:53:12 +0000 (10:53 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 27 Jan 2017 15:53:12 +0000 (10:53 -0500)
They weren't being put into email correctly.
Also update the top form so it hold the arrival departure and numbers.

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

index 8456ea2..172bb6c 100755 (executable)
@@ -416,8 +416,21 @@ 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);
+        $this->arrivalDate
+            = ($_SESSION['bfForm']['arrival'])
+            ? $_SESSION['bfForm']['arrival']['m'].'/'.$_SESSION['bfForm']['arrival']['d'].'/'.$_SESSION['bfForm']['arrival']['Y']
+            : date('m').'/'.date('d').'/'.date('Y');
+        $this->departureDate
+            = ($_SESSION['bfForm']['departure'])
+            ? $_SESSION['bfForm']['departure']['m'].'/'.$_SESSION['bfForm']['departure']['d'].'/'.$_SESSION['bfForm']['departure']['Y']
+            : date('m', $nextWeek).'/'.date('d', $nextWeek).'/'.date('Y', $nextWeek);
+        $this->golfers = ($_SESSION['bfForm']['golfers'])
+            ? $_SESSION['bfForm']['golfers']
+            : '';
+        $this->nongolfers = ($_SESSION['bfForm']['nongolfers'])
+            ? $_SESSION['bfForm']['golfers']
+            : '';
+
         if (defined('MEMBERS_DB') && MEMBERS_DB) {
             // check to see if this page is a member only page
             $memberOnlyPage = Toolkit_Template_Page::isMemberOnly(
index a9fd406..366df68 100644 (file)
--- a/index.php
+++ b/index.php
@@ -75,6 +75,8 @@ if ($catid == ORDER_FORM_PAGE) {
                     = $_POST['departure'];
                 $_SESSION['bfForm']['departure'] = $_POST['departure'];
             }
+            $_SESSION['bfForm']['golfers'] = $_POST['golfers'];
+            $_SESSION['bfForm']['nongolfers'] = $_POST['nongolfers'];
         }
     }
     include 'priceQuoteForm.inc';
index 9c0e4b2..551976f 100644 (file)
@@ -334,8 +334,16 @@ class PageFourth extends PageBase
         $GLOBALS['styleSheets'][] = MEDIA_BASE_URL . 'css/orderForm.css';
         $this->_formBuilt = true;
 
-        $arrival =  $this->controller->exportValue('page1', 'arrival');
-        $departure = $this->controller->exportValue('page1', 'departure');
+        //$arrival =  $this->controller->exportValue('page1', 'arrival');
+        //$departure = $this->controller->exportValue('page1', 'departure');
+
+        $arrival =  ($_SESSION['bfForm']['arrival'])
+            ? $_SESSION['bfForm']['arrival']
+            : $page->controller->exportValue('page1', 'arrival');
+        $departure = ($_SESSION['bfForm']['departure'])
+            ? $_SESSION['bfForm']['departure']
+            : $page->controller->exportValue('page1', 'departure');
+
         list($arrivalMonth, $arrivalDay, $arrivalYear) = array_values($arrival);
         list($departureMonth, $departureDay, $departureYear) = array_values($departure);
 
@@ -510,7 +518,12 @@ class ActionProcess extends HTML_QuickForm_Action
     private function _getEntireForm(&$page)
     {
         $values = $page->controller->exportValues();
-//        $return .= print_r($values, true);
+        $values['arrival'] =  ($_SESSION['bfForm']['arrival'])
+            ? $_SESSION['bfForm']['arrival']
+            : $page->controller->exportValue('page1', 'arrival');
+        $values['departure'] = ($_SESSION['bfForm']['departure'])
+            ? $_SESSION['bfForm']['departure']
+            : $page->controller->exportValue('page1', 'departure');
         unset($temp);
         unset($renderer);
         $rmvElements = array(
@@ -526,7 +539,6 @@ class ActionProcess extends HTML_QuickForm_Action
             $back = $temp->getButtonName('back');
             $next = $temp->getButtonName('next');
             $temp->buildForm();
-//          $return .= print_r($temp, true);
             if ($temp->elementExists($back)) {
                 $temp->removeElement($back);
             }
@@ -575,6 +587,12 @@ class ActionProcess extends HTML_QuickForm_Action
     private function _process(&$page, $email)
     {
         $values = $page->controller->exportValues();
+        $values['arrival'] =  ($_SESSION['bfForm']['arrival'])
+            ? $_SESSION['bfForm']['arrival']
+            : $page->controller->exportValue('page1', 'arrival');
+        $values['departure'] = ($_SESSION['bfForm']['departure'])
+            ? $_SESSION['bfForm']['departure']
+            : $page->controller->exportValue('page1', 'departure');
         try {
             $dbh = Toolkit_Database::getInstance();
             $dbh->beginTransaction();
@@ -741,6 +759,7 @@ class ActionProcess extends HTML_QuickForm_Action
 //          }
 
             $dbh->commit();
+            unset($_SESSION['bfForm']);
 
             if ($values['lodging'] === 'Trout Creek Condominiums') {
                 $toEmail = TROUT_CREEK_EMAILS;
@@ -778,8 +797,6 @@ class ActionProcess extends HTML_QuickForm_Action
             echo 'Error: ' . $e->getMessage() . '<br>';
             echo 'File: ' . $e->getFile() . '<br>';
             echo 'Line: ' . $e->getLine() . '<br>';
-//          echo 'PDO::errorInfo(): <pre>' . print_r($dbh->errorInfo(), true) . '</pre><br>';
-//          echo 'TraceAsString: <pre>' . print_r($e->getTrace(), true) . '</pre><br>';
             return false;
         }
         return false;
index 56e015d..2f3aa47 100755 (executable)
                 <label>Arrival:</label> <input name="arrival" value="{arrivalDate:h}" id="quoteArrival">
                 <label>Departure:</label> <input name="departure" value="{departureDate:h}" id="quoteDeparture">
                 <label>Golfers:</label> <select name="golfers">
-                    <?php for ($i = 0; $i <= 20; ++$i) {?>
-                    <option value="<?php echo $i;?>"><?php echo $i;?></option>
-                    <?php }?>
+                    <?php for ($i = 0; $i <= 20; ++$i) {
+                        echo '<option value="' . $i . '"';
+                        if ( $i == $t->golfers ) {
+                            echo ' selected';
+                        }
+                        echo '>' . $i . '</option>';
+                    }?>
                 </select>
                 <label>Non-Golfers:</label> <select name="nongolfers">
-                    <?php for ($i = 0; $i <= 20; ++$i) {?>
-                    <option value="<?php echo $i;?>"><?php echo $i;?></option>
-                    <?php }?>
+                    <?php for ($i = 0; $i <= 20; ++$i) {
+                        echo '<option value="' . $i . '"';
+                        if ( $i == $t->nongolfers ) {
+                            echo ' selected';
+                        }
+                        echo '>' . $i . '</option>';
+                    }?>
                 </select>
                 <input type="submit" value="NEXT STEP">
             </form>