From 4e9d6d69625075a4dab96d6d88b41455239ea44c Mon Sep 17 00:00:00 2001 From: Chuck Scott Date: Mon, 23 Oct 2017 12:47:55 -0400 Subject: [PATCH] Now deleting reg_request components from database when they don't verify. Fixed some registrartion pages navigation issues. When allowed to. --- classes/regCartSupport.php | 96 ++++++++++++++++++++--- js/frontRegApp.js | 2 +- models/admin/ajax/regFront/registrant.php | 2 +- views/front/registrations/cart.html | 13 +++ 4 files changed, 100 insertions(+), 13 deletions(-) diff --git a/classes/regCartSupport.php b/classes/regCartSupport.php index 27c16ea..c2b081f 100644 --- a/classes/regCartSupport.php +++ b/classes/regCartSupport.php @@ -329,7 +329,7 @@ class GlmRegCartSupport // If a submission account is specified (otherwise it should be a guest user prior to checkout) if ($this->cart['request']['account'] && !isset($this->cart['accounts'][$this->cart['request']['account']])) { - $this->cart['messages'][] .= 'Account for person submitting the request is missing.'; + $this->cart['messages'][] .= 'The account for person submitting the request is missing.'; } /* @@ -338,7 +338,7 @@ class GlmRegCartSupport // If we don't have events for this cart if (!is_array($this->cart['events']) || count($this->cart['events']) == 0) { - $this->cart['messages'][] = 'Cart is empty.'; + $this->cart['messages'][] = 'Your cart is empty.'; $this->cart['blockCheckout'] = true; } else { @@ -428,7 +428,10 @@ class GlmRegCartSupport // If this registrant is flagged for removal from cart if ($removeRegistrant) { -// *** remove registrant from cart in Database + + // Remove registrant request from Database + $this->removeRegistrantFromCart($registrant['id']); + $this->cart['message'][] = 'Registrant '.$registrant['fname'].' '.$registrant['fname'].' was removed from cart due to lack of availabile space.'; $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['registrants'][$registrantKey]['removed'] = true; $this->cart['blockCheckout'] = true; @@ -443,6 +446,7 @@ class GlmRegCartSupport $rateBaseCharge = $rate['base_rate']; } $rateRegistrants++; + if ($rateRegistrants > $rate['registrant_credits']) { $registrantCharges = $rate['per_registrant']; } @@ -462,7 +466,7 @@ class GlmRegCartSupport // If we don't have registrants if (!$haveRegistrants) { - $this->cart['messages'][] = 'Rate '.$rate['rate_name'].' has no registrants.'; + $this->cart['messages'][] = 'Rate "'.$rate['rate_name'].'" has no registrants. This rate has been removed from the cart.'; $removeRate = true; $deleteRateNow = true; } @@ -475,7 +479,9 @@ class GlmRegCartSupport if ($removeRate) { -// Remove rate from cart in database + // Remove rate request from database + $this->removeRateFromCart($rate['id']); + $this->cart['message'][] = 'Rate '.$rate['rate_name'].' was removed from cart.'; $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['removed'] = true; $this->cart['blockCheckout'] = true; @@ -508,7 +514,7 @@ class GlmRegCartSupport // If we don't have rates if (!$haveRates) { - $this->cart['messages'][] = 'Class '.$class['class_name'].' has no rates.'; + $this->cart['messages'][] = 'Class "'.$class['class_name'].'" has no rates. This class has been removed from the cart.'; $removeClass = true; $deleteClassNow = true; } @@ -516,12 +522,13 @@ class GlmRegCartSupport // If class has been flagged for removal from cart, delete it from cart in database if ($removeClass) { + // Remove class request from Database + $this->removeClassFromCart($class['id']); + $this->cart['message'][] = 'Class '.$class['class_name'].' was removed from cart.'; $this->cart['events'][$eventKey]['classes'][$classKey]['removed'] = true; $this->cart['blockCheckout'] = true; -// *** remove class from cart in Database - } else { $haveClasses = true; @@ -548,7 +555,7 @@ class GlmRegCartSupport // If we don't have classes if (!$haveClasses) { - $this->cart['messages'][] = 'Event '.$event['event_name'].' has no classes.'; + $this->cart['messages'][] = 'Event "'.$event['event_name'].'" has no classes. This event has been removed from the cart.'; $removeEvent = true; $deleteEventNow = true; } @@ -556,12 +563,13 @@ class GlmRegCartSupport // If has been flagged for removal from cart, delete it from cart in database if ($removeEvent) { + // Remove event request from database + $this->removeEventFromCart($event['id']); + $this->cart['message'][] = 'Event '.$event['event_name'].' was removed from cart.'; $this->cart['events'][$eventKey]['removed'] = true; $this->cart['blockCheckout'] = true; -// *** remove event from cart in Database - } else { $haveEvents = true; @@ -607,6 +615,7 @@ class GlmRegCartSupport $this->cart['validated'] = true; } + // If a JSON is requested, return data that way if ($json) { return json_encode($this->cart); } @@ -736,6 +745,71 @@ class GlmRegCartSupport return false; } + /* + * Remove a registrant record from the cart + * + * + * @param integer $id ID of this reg_request_registrant record + * + * @access public + */ + public function removeRegistrantFromCart($registrantId) + { + + $RequestRegistrant = new GlmDataRegistrationsRequestRegistrant($this->wpdb, $this->config); + $RequestRegistrant->deleteEntry($registrantId, true); + + } + + /* + * Remove a rate record from the cart + * + * + * @param integer $id ID of this reg_request_rate record + * + * @access public + */ + public function removeRateFromCart($rateId) + { + + $RequestRate = new GlmDataRegistrationsRegRequestRate($this->wpdb, $this->config); + $RequestRate->deleteEntry($rateId, true); + + } + + /* + * Remove a class record from the cart + * + * + * @param integer $id ID of this reg_request_class record + * + * @access public + */ + public function removeClassFromCart($classId) + { + + $RequestClass = new GlmDataRegistrationsRequestClass($this->wpdb, $this->config); + $RequestClass->deleteEntry($classId, true); + + } + + /* + * Remove an event record from the cart + * + * + * @param integer $id ID of this reg_request_event record + * + * @access public + */ + public function removeEventFromCart($eventId) + { + + $RequestEvent = new GlmDataRegistrationsRequestEvent($this->wpdb, $this->config); + $RequestEvent->deleteEntry($eventId, true); + + } + + /* * Add an account to the accounts list in the temoporary cart array if not already there diff --git a/js/frontRegApp.js b/js/frontRegApp.js index 455ae73..fbcb3fe 100644 --- a/js/frontRegApp.js +++ b/js/frontRegApp.js @@ -387,7 +387,7 @@ app.Views.Front.App = Backbone.View.extend({ }, events: { -// 'click #glm-reg-cart-continue': 'continue', + 'click #glm-reg-cart-continue': 'continue', }, continue: function(){ diff --git a/models/admin/ajax/regFront/registrant.php b/models/admin/ajax/regFront/registrant.php index 0bb02fc..c57b3bb 100644 --- a/models/admin/ajax/regFront/registrant.php +++ b/models/admin/ajax/regFront/registrant.php @@ -82,7 +82,7 @@ class GlmMembersAdmin_registrations_ajax_registrant extends GlmDataRegistrations { $validated = false; - trigger_error(print_r($modelData,1)); +// trigger_error(print_r($modelData,1)); if ( !isset( $modelData['option'] ) ) { $option = null; diff --git a/views/front/registrations/cart.html b/views/front/registrations/cart.html index 7b4e060..99d3cc3 100644 --- a/views/front/registrations/cart.html +++ b/views/front/registrations/cart.html @@ -1,9 +1,22 @@ {include file='front/registrations/header.html'} + {if !$cart.validated} +
+ Please Note: + +
+ {/if} +
Request ID: {$cartId}

Selected Registrations

+ + -- 2.17.1