Completed generation of all E-Mail notices at checkout and failure notice to developers.
authorChuck Scott <cscott@gaslightmedia.com>
Thu, 4 Jan 2018 22:05:12 +0000 (17:05 -0500)
committerChuck Scott <cscott@gaslightmedia.com>
Thu, 4 Jan 2018 22:05:12 +0000 (17:05 -0500)
classes/data/dataRegEvent.php
classes/regCartSupport.php
models/front/registrations/checkoutProcess.php

index 1bba620..6c05088 100644 (file)
@@ -448,6 +448,35 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract
 
     }
 
+    /*
+     * Get simplified event data (limited set of information)
+     *
+     * @param integer $eventId ID of the reg_event record
+     *
+     * @return array Summary array of event counts
+     *
+     */
+    public function getRegEventSimplified($eventId = false)
+    {
+
+        $savedFields = $this->fields;
+
+        $this->fields = array(
+            'id' => $savedFields['id'],
+            'event_name' => $savedFields['event_name'],
+            'notify_email' => $savedFields['notify_email'],
+            'descr' => $savedFields['descr'],
+            'first_datetime' => $savedFields['first_datetime'],
+            'last_datetime' => $savedFields['last_datetime']
+        );
+
+        $r = $this->getEntry($eventId);
+
+        $this->fields = $savedFields;
+
+        return $r;
+    }
+
     /*
      * Completely remove registrations for a specific event
      *
index b7d8d29..edadf15 100644 (file)
@@ -1180,37 +1180,34 @@ class GlmRegCartSupport
     public function checkoutUpdateInventoryAndNotify($summary = '', $requestId = false)
     {
 
+        $RegEvent = new GlmDataRegistrationsRegEvent($this->wpdb, $this->config);
+
         // If a request ID is supplied, load that cart
         if ($requestId) {
             getRegistrationCart($requestId, false, true);
         }
 
-//echo "<pre>".print_r($this->config['settings'],1)."</pre>";
-
-
-
-         require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataMisc.php';
-         $RegMisc = new GlmDataRegistrationsMisc($this->wpdb, $this->config);
-         $regMisc = $RegMisc->getEntry(1);
-
-//echo "<pre>".print_r($this->cart,1)."</pre>";
-
+        // Get the misc settings for registrations
+        require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataMisc.php';
+        $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
+        $viewData = array(
+            'events'      => $this->cart['events'],
+            'summary'   => $summary
+        );
 
         /*
          * Send notification to site owner
          */
         $emailAddr = $this->config['settings']['reg_org_internal_email'];
         if (trim($emailAddr) != '' && trim($summary) != '') {
-            $viewData = array(
-                'summary'   => $summary
-            );
-            $emailMsg = nl2br($regMisc['notify_text'])."\n\n".$summary;
+            $subjectLine = $this->generateHTML($viewData, $regMisc['notify_subject'], true);
+            $emailMsg = $this->generateHTML($viewData, nl2br($regMisc['notify_text']), true)."\n\n".$summary;
             mail($emailAddr, $regMisc['notify_subject'], $emailMsg);
-//echo "<p>E-Mail to site owner</p><hr>$emailMsg<hr>";
         }
 
-
         /*
          * Send notification to person submitting request
          */
@@ -1223,26 +1220,16 @@ class GlmRegCartSupport
                 $emailAddr = $this->cart['accounts'][$accountId]['contact_email'];
             }
             if ($emailAddr != '') {
-                $viewData = array(
-                    'summary'   => $summary
-                );
-                $emailMsg = nl2br($regMisc['submission_notify_text'])."\n\n".$summary;
-                mail($emailAddr, $regMisc['submission_notify_subject'], $emailMsg);
-//echo "<p>E-Mail to person submitting registrations</p><hr>$emailMsg<hr>";
-            } else {
-//echo "<hr><p>No email address for person submitting registrations.<p><hr>";
+                $subjectLine = $this->generateHTML($viewData, $regMisc['submission_notify_subject'], true);
+                $emailMsg = $this->generateHTML($viewData, nl2br($regMisc['submission_notify_text']), true)."\n\n".$summary;
+                mail($emailAddr, $subjectLine, $emailMsg);
             }
         }
 
-
         // For each event
-        foreach ($this->cart[events] as $event) {
-
-            /*
-             * Send notifications to contcts listed in event
-             */
-            // Need to add contact addresses
+        foreach ($this->cart['events'] as $event) {
 
+            $eventRegistrants = array();
 
             // For each class
             foreach ($event['classes'] as $class) {
@@ -1252,7 +1239,7 @@ class GlmRegCartSupport
 
                     // For each registrant
                     foreach ($rate['registrants'] as $registrant) {
-/*
+
                         // Adjust the inventory and hold numbers
                         $this->updateTimeEntryCounts($registrant['reg_time'], -1, 1);
 
@@ -1263,7 +1250,7 @@ class GlmRegCartSupport
                                 'registrant' => $registrant['id']
                             )
                         );
-*/
+
                         // Send registrant a confirmation
                         $accountId = $registrant['account'];
                         if (isset($this->cart['accounts'][$accountId])) {
@@ -1274,23 +1261,31 @@ class GlmRegCartSupport
                                 $emailAddr = $this->cart['accounts'][$accountId]['contact_email'];
                             }
                             if ($emailAddr != '') {
-                                $viewData = $registrant;
-//echo "<pre>".print_r($registrant,1)."</pre>";
+                                $viewData['registrant'] = $registrant;
+                                $subjectLine = $this->generateHTML($viewData, $regMisc['registrant_notify_subject'], true);
                                 $emailMsg = $this->generateHTML($viewData, nl2br($regMisc['registrant_notify_text']), true);
-                                mail($emailAddr, $regMisc['registrant_notify_subject'], $emailMsg);
-//echo "<p>E-Mail to registrant: ".$registrant['fname']." ".$registrant['lname']."</p><hr>$emailMsg<hr>";
-                            } else {
-//echo "<hr><p>No email address for this registrant.<p><hr>";
+                                mail($emailAddr, $subjectLine, $emailMsg);
                             }
-
                         }
 
-
-                        $registrantEmail = $this->config['settings']['?????'];
-
+                        $eventRegistrants[] = $registrant;
                     }
                 }
             }
+
+            /*
+             * Send notifications to contcts listed in event
+             */
+            $viewData['event'] = $event;
+            $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);
+                mail($emailAddr, $subjectjectLine, $emailMsg);
+            }
+
         }
 
     }
@@ -1375,6 +1370,10 @@ class GlmRegCartSupport
 
     }
 
+
+
+
+
     /*
      * Get a quick summary of a registration request (cart)
      *
index 776af18..7e18109 100644 (file)
@@ -605,13 +605,28 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport
             array( 'id' => $requestId ),
             $reqFormat
         );
-// Check if properly stored ..... Retrieve and test. Send E-Mail if not able to store
+
+        // Check if not properly stored ..... Send E-Mail to developers
+        if ($updated != 1) {
+            $reqData['user_trace_info'] = unserialize($reqData['user_trace_info']);
+            $reqData['REQUEST'] = $_REQUEST;
+            $reqData['REQUEST']['cc_numb'] = '(suppressed)';
+            $requestText = print_r($reqData,1);
+            mail('cscott@gaslightmedia.com', 'Registration Add-On Failure:', $requestText);
+            $messages[] =
+                 'Oops, we had a technical problem of some sort. '
+                .'Our shiny new servers were unable to store the request you submitted but have already taken the precaution to notify us. '
+                .'If you paid by credit card, your card make have already been processed. '
+                .'Please contact us immediately for assistance and refer to the following request #.'
+                .'<br><b>Request# '.$_SESSION['glm_reg_cart_id'].'</b>'
+                .'<br>Phone: '.$this->config['settings']['reg_org_phone']
+                .', Toll Free: '.$this->config['settings']['reg_org_toll_free'];
+        }
 
         // Get the updated information for the request and account
         $request = $Request->getEntry($this->cart['request']['id']);
         $account = $Account->getEntry($request['account']);
 
-
         /*
          * If there's been a problem, use model redirect to go back to the checkout page
          */
@@ -641,7 +656,6 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport
             );
         }
 
-
         /*
          * Successful checkout
          */