Updating trip planner for thank you message after form submit.
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 12 Dec 2018 17:20:01 +0000 (12:20 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 12 Dec 2018 17:20:01 +0000 (12:20 -0500)
After submitting the trip planner send form output the form thank you
message.

models/front/itinerary/list.php
setup/frontHooks.php
views/front/itinerary/moreinfo.html

index a7acff4..b937ab5 100755 (executable)
@@ -74,6 +74,7 @@ class GlmMembersFront_itinerary_list // extends GlmMembersFront_events_baseActio
         $createSuccess     = false;
         $email             = false;
         $token             = false;
+        $sendFormSubmit    = false;
         $members           = array();
         $membersWithEmails = array();
         $memberEmails      = array();
@@ -315,22 +316,30 @@ class GlmMembersFront_itinerary_list // extends GlmMembersFront_events_baseActio
             $view = 'passwordReset.html';
             break;
         case 'moreinfo':
+            // echo '<pre>$_SESSION: ' . print_r( $_SESSION, true ) . '</pre>';
+            // echo '<pre>$_REQUEST: ' . print_r( $_REQUEST, true ) . '</pre>';
             // Need to create two list one with emails and one without.
-            foreach ( $members as $member ) {
-                if ( $member['email'] && filter_var( $member['email'], FILTER_VALIDATE_EMAIL ) ) {
-                    $membersWithEmails[] = $member;
-                    $memberEmwails[] = $member['email'];
-                } else if ( $member['phone'] ) {
-                   $membersNoEmails[] = $member;
+            if ( is_array( $members ) && !empty( $members ) ) {
+                foreach ( $members as $member ) {
+                    if ( $member['email'] && filter_var( $member['email'], FILTER_VALIDATE_EMAIL ) ) {
+                        $membersWithEmails[] = $member;
+                        $memberEmails[] = $member['email'];
+                    } else if ( $member['phone'] ) {
+                       $membersNoEmails[] = $member;
+                    }
                 }
             }
-            if ( count( $membersNoEmails ) == 0 && count( $membersWithEmails ) == 0 ) {
+            if ( isset( $_REQUEST['send_form_submit'] ) && $sendFormSubmit = filter_var( $_REQUEST['send_form_submit'], FILTER_VALIDATE_BOOLEAN ) ) {
+                $view = 'moreinfo.html';
+            } else if ( count( $membersNoEmails ) == 0 && count( $membersWithEmails ) == 0 ) {
                 $view = 'list.html';
             } else {
                 $view = 'moreinfo.html';
             }
-            if ( count( $membersWithEmails ) > 0 ) {
-                $_GET['member_emails'] = implode( ',', $memberEmwails );
+            if ( count( $membersWithEmails ) > 0 || $sendFormSubmit ) {
+                if ( isset( $memberEmails ) && is_array( $memberEmails ) ) {
+                    $_GET['member_emails'] = implode( ',', $memberEmails );
+                }
                 $form_id = $this->config['settings']['send_itinerary_form_id'];
                 if ( isset( $form_id ) && filter_var( $form_id, FILTER_VALIDATE_INT ) ) {
                     $formContents = do_shortcode( '[gravityform id="' . $form_id . '" title="false" description="false"]' );
@@ -375,6 +384,7 @@ class GlmMembersFront_itinerary_list // extends GlmMembersFront_events_baseActio
             'email'             => $email,
             'token'             => $token,
             'helpUrl'           => GLM_MEMBERS_ITINERARY_PLUGIN_URL . 'templates/helpme.html',
+            'sendFormSubmit'    => $sendFormSubmit,
         );
 
         error_reporting(E_ALL ^ E_NOTICE);
index de2ac60..12afb34 100644 (file)
@@ -77,6 +77,7 @@ $form_id = ( isset( $config['settings']['send_itinerary_form_id'] ) ) ? $config[
 if ( isset( $form_id ) && filter_var( $form_id, FILTER_VALIDATE_INT ) ) {
     // Send Trip Planner Form action after submission
     add_action( 'gform_after_submission_' . $form_id, function(){
+        $_REQUEST['send_form_submit'] = true;
         unset( $_SESSION['travel-list'] );
     }, 10, 2);
 }
index bebad0f..8fa0e91 100644 (file)
@@ -1,15 +1,17 @@
 <h1>Your Trip Planner List</h1>
 
-<p>Below is the list of businesses you have added to your Trip Planner. The
-form below will be sent to each individual business listing that has an email
-address listed with their business listing. For those businesses with no
-email address, we have included their phone numbers for you to call directly
-and request additional information.</p>
-<p>These business listings have no current email address on file. To receive
-additional information please call the phone numbers listed next to each
-business name.</p>
-
-{if count($membersNoEmails) > 0}
+{if !$sendFormSubmit}
+    <p>Below is the list of businesses you have added to your Trip Planner. The
+    form below will be sent to each individual business listing that has an email
+    address listed with their business listing. For those businesses with no
+    email address, we have included their phone numbers for you to call directly
+    and request additional information.</p>
+    <p>These business listings have no current email address on file. To receive
+    additional information please call the phone numbers listed next to each
+    business name.</p>
+{/if}
+
+{if count($membersNoEmails) > 0 && !$sendFormSubmit}
     <h2>Request Information by Phone From:</h2>
     <p>These business listings have no current email address on file. To receive
     additional information please call the phone numbers listed next to each
@@ -32,7 +34,7 @@ business name.</p>
     </table>
 {/if}
 
-{if count($membersWithEmails) > 0}
+{if count($membersWithEmails) > 0 && !$sendFormSubmit}
     <h2>Request Information by Email From:</h2>
     <p>This list of businesses will receive the following information form directly
     to their email account.</p>
@@ -55,6 +57,9 @@ business name.</p>
 
 {/if}
 
+{if $sendFormSubmit}
+    {$formContents}
+{/if}
 
 <script>
 var glm_itinerary_page_url = '{$thisUrl}';