Filling out merge tags for messages set in settings for registrations and tested...
authorChuck Scott <cscott@gaslightmedia.com>
Tue, 19 Jun 2018 21:04:37 +0000 (17:04 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Tue, 19 Jun 2018 21:04:37 +0000 (17:04 -0400)
Also updated checkout datat to provide already input data for Register New Account form after checkout

classes/regCartSupport.php
models/front/registrations/checkoutProcess.php
views/admin/settings/registrationsMisc.html
views/front/registrations/summary.html
views/front/registrations/summaryStore.html

index c41b91f..a4f9d65 100644 (file)
@@ -1400,10 +1400,31 @@ class GlmRegCartSupport
         $RegMisc = new GlmDataRegistrationsMisc($this->wpdb, $this->config);
         $regMisc = $RegMisc->getEntry(1);
 
+
+
         // Set view data for site owner, person submitting the event and the event contacts
+        $account = $this->cart['accounts'][$this->cart['request']['account']];
+
         $viewData = array(
-            'events'      => $this->cart['events'],
-            'summary'   => $summary
+            'SubmittedByFirstName'      => $account['fname'],
+            'SubmittedByLastName'       => $account['lname'],
+            'SubmittedByTitle'          => $account['title'],
+            'SubmittedByOrganization'   => $account['org'],
+            'BillingFirstname'          => $this->cart['request']['bill_fname'],
+            'BillingLastname'           => $this->cart['request']['bill_lname'],
+            'BillingAddrLine1'          => $this->cart['request']['bill_addr1'],
+            'BillingAddrLine2'          => $this->cart['request']['bill_addr2'],
+            'BillingCity'               => $this->cart['request']['bill_city'],
+            'BillingState'              => $this->cart['request']['bill_state'],
+            'BillingZIP'                => $this->cart['request']['bill_zip'],
+            'BillingCountry'            => $this->cart['request']['bill_country'],
+            'BillingPhone'              => $this->cart['request']['bill_phone'],
+            'BillingEmailAddress'       => $this->cart['request']['bill_email'],
+            'DateTimeSubmitted'         => $this->cart['request']['date_submitted']['datetime'],
+            'PaymentMethod'             => $this->cart['request']['pay_method']['name'],
+            'Status'                    => $this->cart['request']['status']['name'],
+            'NumberAttendees'           => $this->cart['request']['registrants'],
+            'Summary'                   => $summary
         );
 
         /*
@@ -1412,8 +1433,15 @@ class GlmRegCartSupport
         $emailAddr = $this->config['settings']['reg_org_internal_email'];
         if (trim($emailAddr) != '' && trim($summary) != '') {
             $subjectLine = $this->generateHTML($viewData, $regMisc['notify_subject'], true);
-            $emailMsg = $this->generateHTML($viewData, nl2br($regMisc['notify_text']), true)."\n\n".$summary;
-            $this->sendHtmlEmail($emailAddr, $regMisc['notify_subject'], $emailMsg);
+            $emailMsg = $this->generateHTML($viewData, nl2br($regMisc['notify_text']), true);
+
+            // If front debug is on and this is a test submission output message to screen rather than send.
+            if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG) {
+                $this->displayEmailforTesting('Notice to Site Owner', $emailAddr, $regMisc['notify_subject'], $emailMsg);
+            } else {
+                $this->sendHtmlEmail($emailAddr, $regMisc['notify_subject'], $emailMsg);
+            }
+
         }
 
         /*
@@ -1441,20 +1469,44 @@ class GlmRegCartSupport
             }
         }
 
+
         // For each event
         foreach ($this->cart['events'] as $event) {
 
+            $viewDataEvent = array(
+                'EventName' => $event['event_name'],
+                'EventTerms' => $event['event_terms']
+            );
+
             $eventRegistrants = array();
 
             // For each class
             foreach ($event['classes'] as $class) {
 
+                $viewDataClass = array(
+                    'LevelName' => $class['class_name']
+                );
+
                 // For each rate
                 foreach ($class['rates'] as $rate) {
 
+                    $viewDataRate = array(
+                        'RateName' => $rate['rate_name']
+                    );
+
                     // For each registrant
                     foreach ($rate['registrants'] as $registrant) {
 
+                        $viewDataRegistrant = array(
+                            'AttendeeFirstName'   => $registrant['fname'],
+                            'AttendeeLastName'    => $registrant['lname'],
+
+                        );
+
+                        // Merge Tags for this data
+                        $viewData2 = array_merge($viewData, $viewDataEvent, $viewDataClass, $viewDataRate, $viewDataRegistrant);
+
+
                         // Adjust the inventory and hold numbers
                         if (!$doNotUpdateInventory) {
                             $this->updateTimeEntryCounts($registrant['reg_time'], -1, 1);
@@ -1478,17 +1530,8 @@ class GlmRegCartSupport
                                 $emailAddr = $this->cart['accounts'][$accountId]['contact_email'];
                             }
                             if ($emailAddr != '' && $emailAddr != $submitAddr) {
-                                $vData = array(
-                                    'event' => $event['event_name'],
-                                    'description' => $registrant['reg_event_descr'],
-                                    'fname' => $registrant['fname'],
-                                    'lname' => $registrant['lname'],
-                                    'datetime' => $registrant['non_time_specific'] ? 'any time during event' : 'on '.$registrant['event_time_reformatted'],
-                                    'request_fname' => $this->cart['request']['bill_fname'],
-                                    'request_lname' => $this->cart['request']['bill_lname']
-                                );
-                                $subjectLine = $this->generateHTML($vData, $regMisc['registrant_notify_subject'], true);
-                                $emailMsg = $this->generateHTML($vData, nl2br($regMisc['registrant_notify_text']), true);
+                                $subjectLine = $this->generateHTML($viewData2, $regMisc['registrant_notify_subject'], true);
+                                $emailMsg = $this->generateHTML($viewData2, nl2br($regMisc['registrant_notify_text']), true);
 
                                 // If front debug is on and this is a test submission output message to screen rather than semd.
                                 if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG && $doNotUpdateInventory) {
@@ -1499,7 +1542,7 @@ class GlmRegCartSupport
                             }
                         }
 
-                        $eventRegistrants[] = $registrant;
+                        $eventRegistrants[] = $viewDataRegistrant;
                     }
                 }
             }
@@ -1507,13 +1550,15 @@ class GlmRegCartSupport
             /*
              * Send notifications to contacts listed in event
              */
-            $viewData['event'] = $event;
+
+            $viewData2 = $viewDataEvent;
+            $viewData2['EventAttendees'] = $eventRegistrants;
+
             $eventOther = $RegEvent->getRegEventSimplified($event['reg_event']);
             $emailAddr = $eventOther['notify_email'];
             if (trim($emailAddr) != '') {
-                $viewData['eventRegistrants'] = $eventRegistrants;
-                $subjectLine = $this->generateHTML($viewData, $regMisc['instr_notify_subject'], true);
-                $emailMsg = $this->generateHTML($viewData, nl2br($regMisc['instr_notify_text']), true);
+                $subjectLine = $this->generateHTML($viewData2, $regMisc['instr_notify_subject'], true);
+                $emailMsg = $this->generateHTML($viewData2, nl2br($regMisc['instr_notify_text']), true);
 
                 // If front debug is on and this is a test submission output message to screen rather than semd.
                 if (GLM_MEMBERS_PLUGIN_FRONT_DEBUG && $doNotUpdateInventory) {
index aaa3c03..22995bc 100644 (file)
@@ -189,6 +189,17 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport
             // Otherwise this is a guest so try to create the account using the submitted data
             } else {
 
+                // Since there's no account yet, we'll use the billing data for the base account data
+                $_REQUEST['fname']      = $_REQUEST['bill_fname'];
+                $_REQUEST['lname']      = $_REQUEST['bill_lname'];
+                $_REQUEST['addr1']      = $_REQUEST['bill_addr1'];
+                $_REQUEST['addr2']      = $_REQUEST['bill_addr2'];
+                $_REQUEST['city']       = $_REQUEST['bill_city'];
+                $_REQUEST['state']      = $_REQUEST['bill_state'];
+                $_REQUEST['zip']        = $_REQUEST['bill_zip'];
+                $_REQUEST['country']    = $_REQUEST['bill_country'];
+                $_REQUEST['phone']      = $_REQUEST['bill_phone'];
+
                 // Create the new account
                 $regAccount = $Account->insertEntry();
 
@@ -196,6 +207,36 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport
                 if ($regAccount) {
                     $accountId = $regAccount['fieldData']['id'];
                     $guestAccount = true;
+
+                    $this->wpdb->update(
+                        GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX.'account',
+                        array(
+                            'fname'     => $regAccount['fieldData']['bill_fname'],
+                            'lname'     => $regAccount['fieldData']['bill_lname'],
+                            'addr1'     => $regAccount['fieldData']['bill_addr1'],
+                            'addr2'     => $regAccount['fieldData']['bill_addr2'],
+                            'city'      => $regAccount['fieldData']['bill_city'],
+                            'state'     => $regAccount['fieldData']['bill_state'],
+                            'zip'       => $regAccount['fieldData']['bill_zip'],
+                            'country'   => $regAccount['fieldData']['bill_country'],
+                            'phone'     => $regAccount['fieldData']['bill_phone']
+                        ),
+                        array( 'id' => $accountId ),
+                        array(
+                            '%s',
+                            '%s',
+                            '%s',
+                            '%s',
+                            '%s',
+                            '%s',
+                            '%s',
+                            '%s',
+                            '%s'
+                        )
+                    );
+                    // Now get the account data for editing again
+                    $regAccount = $Account->editEntry($accountId);
+
                 } else {
                     $messages[] = 'Unable to create a guest account for this request. Please try again later.';
                 }
@@ -771,7 +812,6 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport
             'status'         => $this->config['submission_status'],
             'misc'           => $misc
         );
-
         $summary = $this->generateHTML($summaryData, 'front/registrations/summaryStore.html');
 
         // Store this summary in the request reccord
@@ -790,9 +830,6 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport
         // Update inventory totals and send notifications unless this is a test submission
         $this->checkoutUpdateInventoryAndNotify($summary, false, $doNotClear);
 
-        // Send acknowledgement to person submitting request
-        mail($request['email'], $misc['submission_ack_subject'], $summary);
-
         // If this is a guest submission set a guest account ID so it can be used to create a user account
         if ($guestAccount) {
             $_SESSION['glm_reg_guest_account_id'] = $accountId;
@@ -821,14 +858,13 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport
             'summary'        => $summary,
             'misc'           => $misc,
             'reg_account_id' => $accountId,
+            'regAccount'     => $regAccount,
             'states_list'    => $this->config['states'],
             'country_list'   => $this->config['countries'],
             'emailError'     => $emailError,
             'passwordError'  => $passwordError,
         );
 
-        // echo "<pre>".print_r($this->cart,1)."</pre>";
-
         // Return status, any suggested view, and any data to controller
         return array(
             'status'        => true,
index e6b1424..d13fc12 100644 (file)
     </tr>
 </table>
 
+{literal}
+<h2 style="padding: 2em 0 1em 0">Merge Tags useable in E-Mail Notifications</h2>
+<p> 
+    The tags below may be used in the E-Mail Notifications above to include information from the submission. 
+    This is equivelent to doing "Mail Merge" with a word processor. When including these tags include the 
+    "{", "}", and "$" characters shown with each tag. 
+    The first set of tags may be used in the "Subject" and "E-Mail Text" of any of the E-Mail Notifications above.
+    Below those are addtional tags that may be used in certain notifications.
+    Be sure to use the "Curly Braces" symbols '{' and '}' rather than paranthesis for these tags.  
+</p>
+
+<style>
+    .merge-tag-section-title {
+         text-align: left; 
+         text-decoration: underline;" 
+    }
+    .merge-tag-title {
+        text-align: left; 
+        padding-right: 4em;
+    }
+</style>
+<table>
+    <tr><th colspan="3" style="text-align: left; text-decoration: underline;" >Available in All E-Mail Messages</th></tr>
+    <tr><td>&nbsp;</td><th class="merge-tag-title">{$SubmittedByFirstName}</th><td>First name of person submitting the request.</td></tr>
+    <tr><td>&nbsp;</td><th class="merge-tag-title">{$SubmittedByLastName}</th><td>Last name of person submitting the request.</td></tr>
+    <tr><td>&nbsp;</td><th class="merge-tag-title">{$SubmittedByTitle}</th><td>Title of person submitting the request.</td></tr>
+    <tr><td>&nbsp;</td><th class="merge-tag-title">{$SubmittedByOrganization}</th><td>Organization name for person submitting the request.</td></tr>
+    <tr><td>&nbsp;</td><th class="merge-tag-title">{$BillingFirstname}</th><td>Billing first name</td></tr>
+    <tr><td>&nbsp;</td><th class="merge-tag-title">{$BillingLastname}</th><td>Billing last name</td></tr>
+    <tr><td>&nbsp;</td><th class="merge-tag-title">{$BillingAddrLine1}</th><td>Billing address line 1</td></tr>
+    <tr><td>&nbsp;</td><th class="merge-tag-title">{$BillingAddrLine2</th><td>Billing address line 2</td></tr>
+    <tr><td>&nbsp;</td><th class="merge-tag-title">{$BillingCity}</th><td>Billing City</td></tr>
+    <tr><td>&nbsp;</td><th class="merge-tag-title">{$BillingState}</th><td>Billing State </td></tr>
+    <tr><td>&nbsp;</td><th class="merge-tag-title">{$BillingCountry}</th><td>Billing Country</td></tr>
+    <tr><td>&nbsp;</td><th class="merge-tag-title">{$BillingPhone}</th><td>Billing Phone #</td></tr>
+    <tr><td>&nbsp;</td><th class="merge-tag-title">{$BillingEmailAddress}</th><td>Billing E-Mail Address</td></tr>
+    <tr><td>&nbsp;</td><th class="merge-tag-title">{$DateTimeSubmitted}</th><td>Date and Time request was submitted</td></tr>
+    <tr><td>&nbsp;</td><th class="merge-tag-title">{$PaymentMethod}</th><td>Payment Methods</td></tr>
+    <tr><td>&nbsp;</td><th class="merge-tag-title">{$Status}</th><td>Status of Request</td></tr>
+    <tr><td>&nbsp;</td><th class="merge-tag-title">{$NumberAttendees}</th><td>Number of {/literal}{$terms.reg_term_attendee_plur_cap}{literal} for all {/literal}{$terms.reg_term_event_plur}{literal}</td></tr>
+    <tr><td>&nbsp;</td><th class="merge-tag-title">{$Summary}</th><td>Complete summary as shown after checkout.  (large HTML)</td></tr>
+    <tr><td colspan="3"><th>&nbsp;</th>
+
+    <tr><th colspan="3" style="text-align: left; text-decoration: underline;" >Also available in "Notification to {/literal}{$terms.reg_term_event_cap}{literal} Contacts"</th></tr>
+    <tr><td>&nbsp;</td><th class="merge-tag-title">{$EventName}</th><td>Name of {/literal}{$terms.reg_term_event_cap}{literal}</td></tr>
+    <tr><td>&nbsp;</td><th class="merge-tag-title">{$EventAttendees}</th><td>List of {/literal}{$terms.reg_term_attendee_plur}{literal} for the {/literal}{$terms.reg_term_event}{literal}</td></tr>
+    <tr><td>&nbsp;</td><th class="merge-tag-title">&nbsp;</th><td>
+        &nbsp;&nbsp;Example for listing {/literal}{$terms.reg_term_attendee_plur_cap}{literal}<br>
+        &nbsp;&nbsp;&nbsp;&nbsp;{foreach $EventAttendees as $a}{$a.AttendeeFirstName} {$r.AttendeeLastName}<br>
+        &nbsp;&nbsp;&nbsp;&nbsp;{/foreach}
+    </td></tr>    
+    <tr><td>&nbsp;</td><th class="merge-tag-title">&nbsp;</th><td>{$RegistrantFirstName}</td></tr>
+    <tr><td>&nbsp;</td><th class="merge-tag-title">&nbsp;</th><td>{$RegistrantLastName}</td></tr>    
+    <tr><td colspan="3"><th>&nbsp;</th>
+
+    <tr><th colspan="3" style="text-align: left; text-decoration: underline;" >Also available in "Notification to Person Submitting the {/literal}{$terms.reg_term_registration_plur_cap}{literal}"</th></tr>
+    <tr><td colspan="3"><th>&nbsp;</th>
+    
+    <tr><th colspan="3" style="text-align: left; text-decoration: underline;" >Also available in "Notification to {/literal}{$terms.reg_term_attendee_plur_cap}{literal}"</th></tr>
+    <tr><td>&nbsp;</td><th class="merge-tag-title">{$EventName}</th><td>Name of {/literal}{$terms.reg_term_event_cap}{literal}</td></tr>
+    <tr><td>&nbsp;</td><th class="merge-tag-title">{$EventTerms}</th><td>{/literal}{$terms.reg_term_event_cap}{literal} Terms and Conditions</td></tr>
+    <tr><td>&nbsp;</td><th class="merge-tag-title">{$LevelName}</th><td>{/literal}{$terms.reg_term_registration_cap}{literal} {/literal}{$terms.reg_term_level_cap}{literal} name</td></tr>
+    <tr><td>&nbsp;</td><th class="merge-tag-title">{$RateName}</th><td>{/literal}{$terms.reg_term_registration_cap}{literal} Rate name</td></tr>
+    <tr><td>&nbsp;</td><th class="merge-tag-title">{$AttendeeFirstName}</th><td>{/literal}{$terms.reg_term_attendee_cap}{literal} first name</td></tr>
+    <tr><td>&nbsp;</td><th class="merge-tag-title">{$AttendeeLastName}</th><td>{/literal}{$terms.reg_term_attendee_cap}{literal} last name</td></tr>
+    <tr><td colspan="3"><th>&nbsp;</th>
+    
+    <tr><th colspan="3" style="text-align: left; text-decoration: underline;" >Also available in "Acknowledgement to Person Submitting the {/literal}{$terms.reg_term_registration_plur_cap}{literal}"</th></tr>
+    <tr><td colspan="3"><th>&nbsp;</th>
+    
+    <tr><th colspan="3" style="text-align: left; text-decoration: underline;" >Also available in "Acknowledgement to {/literal}{$terms.reg_term_attendee_plur_cap}{literal}"</th></tr>
+    <tr><td colspan="3"><th>&nbsp;</th>
+</table>
+{/literal}
+
 {include file='admin/settings/footer.html'}
\ No newline at end of file
index c782cf1..19ddaca 100644 (file)
                 <div class="small-12 large-6 columns">
                     <label class="error">
                         First Name
-                        <input name="fname" value="{$reg.fname}" required>
+                        <input name="fname" value="{$regAccount.fieldData.fname}" required>
                     </label>
                 </div>
                 <div class="small-12 large-6 columns">
                     <label class="error">
                         Last Name
                     </label>
-                    <input name="lname" value="{$reg.lname}" required>
+                    <input name="lname" value="{$regAccount.fieldData.lname}" required>
                 </div>
             </div>
             <div class="row">
                 <div class="small-12 large-6 columns">
                     <label class="error">
                         Address 1
-                        <input name="addr1" value="{$reg.addr1}" required>
+                        <input name="addr1" value="{$regAccount.fieldData.addr1}" required>
                     </label>
                 </div>
                 <div class="small-12 large-6 columns">
                     <label>
                         Address 2
-                        <input name="addr2" value="{$reg.addr2}">
+                        <input name="addr2" value="{$regAccount.fieldData.addr2}">
                     </label>
                 </div>
             </div>
@@ -81,7 +81,7 @@
                 <div class="small-12 large-4 columns">
                     <label class="error">
                         City
-                        <input name="city" value="{$reg.city}" required>
+                        <input name="city" value="{$regAccount.fieldData.city}" required>
                     </label>
                 </div>
                 <div class="small-12 large-4 columns">
                         State
                         <select name="state">
                             <option value=""></option>
-                            {foreach $states_list as $stateAbbr => $stateName}
-                            <option value="{$stateAbbr}"{if $reg.state == $stateAbbr} selected{/if}>{$stateName}</option>
-                            {/foreach}
+                        {foreach $regAccount.fieldData.state.list as $s}
+                                <option value="{$s.value}"{if $s.default} selected="selected"{/if}>
+                                    {$s.name}
+                                </option>
+                        {/foreach}
                         </select>
                     </label>
                 </div>
                 <div class="small-12 large-4 columns">
                     <label class="error">
                         Zip/Postal Code
-                        <input name="zip" value="{$reg.zip}" required>
+                        <input name="zip" value="{$regAccount.fieldData.zip}" required>
                     </label>
                 </div>
             </div>
                         Country
                         <select name="country">
                             <option value=""></option>
-                            {foreach $country_list as $countryKey => $countryValue}
-                                <option value="{$countryKey}"{if $reg.country == $countryKey} selected{/if}>{$countryValue}</option>
-                            {/foreach}
+                        {foreach $regAccount.fieldData.country.list as $a}
+                                <option value="{$a.value}"{if $a.default} selected="selected"{/if}>
+                                    {$a.name}
+                                </option>
+                        {/foreach}
                         </select>
                     </label>
                 </div>
index 60482e1..438d590 100644 (file)
@@ -86,9 +86,6 @@
         </style>
     </head>
     <body>
-        <div>
-            {$misc.submission_ack_text}
-        </div>
     
         <h3>Checkout Summary</h3>
         <table class="container-table">