From 313f1d5cb8d4044f6de0cac661ef624e8a3726ee Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Thu, 4 Jan 2018 17:05:12 -0500 Subject: [PATCH] Completed generation of all E-Mail notices at checkout and failure notice to developers. --- classes/data/dataRegEvent.php | 29 +++++++ classes/regCartSupport.php | 85 +++++++++---------- .../front/registrations/checkoutProcess.php | 20 ++++- 3 files changed, 88 insertions(+), 46 deletions(-) diff --git a/classes/data/dataRegEvent.php b/classes/data/dataRegEvent.php index 1bba620..6c05088 100644 --- a/classes/data/dataRegEvent.php +++ b/classes/data/dataRegEvent.php @@ -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 * diff --git a/classes/regCartSupport.php b/classes/regCartSupport.php index b7d8d29..edadf15 100644 --- a/classes/regCartSupport.php +++ b/classes/regCartSupport.php @@ -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 "
".print_r($this->config['settings'],1)."
"; - - - - require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataMisc.php'; - $RegMisc = new GlmDataRegistrationsMisc($this->wpdb, $this->config); - $regMisc = $RegMisc->getEntry(1); - -//echo "
".print_r($this->cart,1)."
"; - + // 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 "

E-Mail to site owner


$emailMsg
"; } - /* * 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 "

E-Mail to person submitting registrations


$emailMsg
"; - } else { -//echo "

No email address for person submitting registrations.


"; + $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 "
".print_r($registrant,1)."
"; + $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 "

E-Mail to registrant: ".$registrant['fname']." ".$registrant['lname']."


$emailMsg
"; - } else { -//echo "

No email address for this registrant.


"; + 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) * diff --git a/models/front/registrations/checkoutProcess.php b/models/front/registrations/checkoutProcess.php index 776af18..7e18109 100644 --- a/models/front/registrations/checkoutProcess.php +++ b/models/front/registrations/checkoutProcess.php @@ -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 #.' + .'
Request# '.$_SESSION['glm_reg_cart_id'].'' + .'
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 */ -- 2.17.1