Now deleting reg_request components from database when they don't verify.
authorChuck Scott <cscott@gaslightmedia.com>
Mon, 23 Oct 2017 16:47:55 +0000 (12:47 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Mon, 23 Oct 2017 16:47:55 +0000 (12:47 -0400)
Fixed some registrartion pages navigation issues. When allowed to.

classes/regCartSupport.php
js/frontRegApp.js
models/admin/ajax/regFront/registrant.php
views/front/registrations/cart.html

index 27c16ea..c2b081f 100644 (file)
@@ -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
index 455ae73..fbcb3fe 100644 (file)
@@ -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(){
index 0bb02fc..c57b3bb 100644 (file)
@@ -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;
index 7b4e060..99d3cc3 100644 (file)
@@ -1,9 +1,22 @@
 {include file='front/registrations/header.html'}
 
+  {if !$cart.validated}
+    <div class="glm-registrations-messages glm-reg-warning" style="clear: all;">
+        <i>Please Note:</i>
+        <ul>
+    {foreach $cart.messages as $m}
+            <li>{$m}</li>
+    {/foreach}
+        </ul>
+    </div>
+  {/if}
+
     <div>
         <div class="glm-right" style="padding-top: 1.5em;" title="Please refer to this ID when requesting assistance.">Request ID: {$cartId}</div>
         <h2 class="glm-left" style="clear: none;">Selected Registrations</h2>
     </div>
+    
+    
     <table class="glm-admin-table" width="100%">
     
         <thead>