Now have preliminary data displaying on cart page.
authorChuck Scott <cscott@gaslightmedia.com>
Fri, 29 Sep 2017 20:14:43 +0000 (16:14 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Fri, 29 Sep 2017 20:14:43 +0000 (16:14 -0400)
Added some comments and spacing in registrations page model.
Finished initial tests of cart validation. Still need to add total calculations.
Have cart page model now getting cartID from session.

12 files changed:
classes/data/dataRegRequestClass.php
classes/data/dataRegRequestEvent.php
classes/data/dataRegRequestRate.php
classes/data/dataRegRequestRegistrant.php
classes/regCartSupport.php
index.php
models/front/registrations/cart.php
models/front/registrations/index.php
models/front/registrations/list.php
models/front/registrations/registration.php
setup/databaseScripts/create_database_V0.0.12.sql
views/front/registrations/cart.html

index 842d3d2..cd12676 100644 (file)
@@ -116,14 +116,6 @@ class GlmDataRegistrationsRequestClass extends GlmDataAbstract
                 'use'       => 'a'
             ),
 
-            // Pointer to account (person submitting the registration)
-            'account' => array (
-                'field'     => 'account',
-                'type'      => 'integer',
-                'required'  => true,
-                'use'       => 'lgneud'
-            ),
-
             // Pointer to reg_event
             'reg_event' => array (
                 'field'     => 'reg_event',
@@ -180,14 +172,6 @@ class GlmDataRegistrationsRequestClass extends GlmDataAbstract
                 'use'       => 'lgneud'
             ),
 
-            // Last calculated total of all charges for registration to this event for all registrants
-            'total_class_charge' => array (
-                'field'     => 'total_class_charge',
-                'type'      => 'money',
-                'required'  => false,
-                'use'       => 'a'
-            ),
-
             // Any MagicForm data associated with requested event
             'mf_data' => array (
                 'field'     => 'mf_data',
index 03d8179..4b41b1b 100644 (file)
@@ -116,14 +116,6 @@ class GlmDataRegistrationsRequestEvent extends GlmDataAbstract
                 'use'       => 'a'
             ),
 
-            // Pointer to account (person submitting the registration)
-            'account' => array (
-                'field'     => 'account',
-                'type'      => 'integer',
-                'required'  => true,
-                'use'       => 'lgneud'
-            ),
-
             // Pointer to reg_request table
             'reg_request' => array (
                 'field'     => 'reg_request',
@@ -164,14 +156,6 @@ class GlmDataRegistrationsRequestEvent extends GlmDataAbstract
                 'use'       => 'lgneud'
             ),
 
-            // Last calculated total of all charges for registration to this event for all registrants
-            'total_charge' => array (
-                'field'     => 'total_charge',
-                'type'      => 'money',
-                'required'  => false,
-                'use'       => 'a'
-            ),
-
             // System operator's notes for this registration request
             'notes' => array (
                 'field'     => 'notes',
index 6de377c..12b2c7b 100644 (file)
@@ -117,14 +117,6 @@ class GlmDataRegistrationsRegRequestRate extends GlmDataAbstract
                 'use'       => 'a'
             ),
 
-            // Pointer to account (person submitting the registration)
-            'account' => array (
-                'field'     => 'account',
-                'type'      => 'integer',
-                'required'  => true,
-                'use'       => 'lgneud'
-            ),
-
             // Pointer to reg_event entry
             'reg_event' => array (
                 'field'     => 'reg_event',
@@ -213,22 +205,6 @@ class GlmDataRegistrationsRegRequestRate extends GlmDataAbstract
                 'use'       => 'a'
             ),
 
-            // Last calculated number of registrants with this rate
-            'numb_registrants' => array (
-                'field'     => 'numb_registrants',
-                'type'      => 'integer',
-                'required'  => false,
-                'use'       => 'a'
-            ),
-
-            // Per Registrant Rate at time of registration
-            'total_registrant_charges' => array (
-                'field'     => 'total_registrant_charges',
-                'type'      => 'money',
-                'required'  => false,
-                'use'       => 'a'
-            ),
-
             // Any MagicForm data associated with registrant
             'mf_data' => array (
                 'field'     => 'mf_data',
index ae67d07..c9a9e00 100644 (file)
@@ -116,7 +116,7 @@ class GlmDataRegistrationsRequestRegistrant extends GlmDataAbstract
                 'use'       => 'a'
             ),
 
-            // Pointer to account for person submitting the registration
+            // Pointer to account for person being registered
             'account' => array (
                 'field'     => 'account',
                 'type'      => 'integer',
@@ -180,28 +180,6 @@ class GlmDataRegistrationsRequestRegistrant extends GlmDataAbstract
                 'use'       => 'lgneud'
             ),
 
-            // Pointer to account for registrant (person attending) - Not needed if registrants are off for the event
-            'reg_request_registrant' => array (
-                'field'     => 'reg_request_registrant',
-                'type'      => 'integer',
-                'required'  => true,
-                'use'       => 'lgneud'
-            ),
-
-            // First Name of registrant
-            'reg_request_hold' => array (
-                'field'     => 'reg_request_hold',
-                'type'      => 'checkbox',
-                'use'       => 'lgneud'
-            ),
-
-            // Flag for no registrant slot available for this registrant - Unable to get hold
-            'reg_request_hold_not_available' => array (
-                'field'     => 'reg_request_hold_not_available',
-                'type'      => 'checkbox',
-                'use'       => 'lgneud'
-            ),
-
             // First Name of registrant
             'fname' => array (
                 'field'     => 'fname',
index b014da4..1a98e3c 100644 (file)
@@ -1,5 +1,4 @@
 <?php
-
 /**
  * Gaslight Media Associate
  * Registrations Plugin support class
@@ -111,9 +110,9 @@ class GlmRegCartSupport
         }
 
         // If there's a new reg request id, declare success
-        $requestID = $this->wpdb->insert_id;
-        if ($requestID) {
-            return $requestID;
+        $requestId = $this->wpdb->insert_id;
+        if ($requestId) {
+            return $requestId;
         }
 
         return false;
@@ -158,8 +157,8 @@ class GlmRegCartSupport
         // Clear cart data
         $this->cart = array(
             'status'        => false,           // Return status, default to false, true if valid request returned
-            'errorMsg'      => '',              // Any applicable error message
-            'notes'         => array(),         // System generated notes regarding status of request
+            'validated'     => false,           // Flag indicating that the cart has been validated - see checkRegistrationRequest(0)
+            'messages'      => array(),         // System generated notes regarding status of request
             'accounts'      => array(),         // Accounts associated with this request - both requesting and attending (might be the same)
                                                 // Index in this array is the account ID as used in data below
             'times'         => array(),         // reg_time records associated with this request - Index is the reg_time ID
@@ -173,7 +172,7 @@ class GlmRegCartSupport
         }
 
         // Try to get the base registration request data
-        $this->cart['request'] = $RegRequest->getEntry($requestId);
+        $this->cart['request'] = $RegRequest->getEntry($requestId);        
         if (!$this->cart['request']) {
             $this->cart['errorMsg'] = 'Unable to retrieve the requested registration request.';
             return $this->cart;
@@ -183,31 +182,28 @@ class GlmRegCartSupport
         $this->addAccountToCart($this->cart['request']['account']);
 
         // Get list of events being requested
-        $this->cart['events'] = $RequestEvent->getList("T.reg_request =  $requestId");
-
+        $this->cart['events'] = $RequestEvent->getList("T.reg_request = $requestId");
+        
         // For each event
         if ($this->cart['events']) {
             foreach ($this->cart['events'] as $eventKey => $event) {
 
-                // Get reg_event record for this event
-                $this->cart['events'][$eventKey]['reg_event'] = $RegEvent->getEntry($event['reg_event']);
-
                 // Get list of event classes requested for this event
-                $this->cart['events'][$eventKey]['classes'] = $RequestClass->getList("T.reg_request =  $requestId");
+                $this->cart['events'][$eventKey]['classes'] = $RequestClass->getList("T.reg_request_event =  ".$event['id']);
 
                 // For each class selected for this event
                 if ($this->cart['events'][$eventKey]['classes']) {
                     foreach ($this->cart['events'][$eventKey]['classes'] as $classKey => $class) {
 
                         // Get list of rates requested for this class
-                        $this->cart['events'][$eventKey]['classes'][$classKey]['rates'] = $RequestRate->getList("T.reg_request =  $requestId");
+                        $this->cart['events'][$eventKey]['classes'][$classKey]['rates'] = $RequestRate->getList("T.reg_request_class = ".$class['id']);
 
                         // For each rate selected for this class
                         if ($this->cart['events'][$eventKey]['classes'][$classKey]['rates']) {
                             foreach ($this->cart['events'][$eventKey]['classes'][$classKey]['rates'] as $rateKey => $rate) {
 
                                 // Get list of registrants requested for this rate
-                                $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['registrants'] = $RequestRegistrant->getList("T.reg_request =  $requestId");
+                                $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['registrants'] = $RequestRegistrant->getList("T.reg_request_rate =  ".$rate['id']);
 
                                 // For each rate selected for this class
                                 if ($this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['registrants']) {
@@ -233,12 +229,16 @@ class GlmRegCartSupport
         }
 
         $this->cart['status'] = true;
+        $this->cart['validated'] = false;
+        
+//        echo "<br>getRegistrationCart() Results:<pre>".print_r($this->cart,1)."</pre>";        exit;
+        
 
         if ($json) {
             return json_encode($this->cart);
         }
 
-        return $this->cart;
+        return;
 
     }
 
@@ -257,119 +257,213 @@ class GlmRegCartSupport
      *  Updates all totals
      *  Updates request last accessed time
      *
+     * @param integer $requestId
+     * 
      * @return array Array of request and all associated information or false
      * @access public
      */
-    public function checkRegistrationRequest() 
+    public function checkRegistrationRequest($requestId = false
     {
 
-        $messages[] = '';
-        $totalCharges = 0;
-        $totalRegistrants = 0;
-        $totalDiscounts = 0;
-        $grandTotal = 0;
+        // Try to get the cart data
+        $this->getRegistrationCart($requestId);
         
-
-        // If request ID is not false, get the cart first
-        if ($requestId !== false) {
-
-            // If we didn't get a cart using this ID or there was some failure getting it, then return false
-            if (!$this->getRegistrationCart($requestId) || !$this->cart['status']) {
-               return false;
-            }
-        }
-
-        // 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']])) {
-            $messages[] .= 'Account for person submitting the request is missing.';
+        if (!$this->cart) {
+            return false;
         }
+        
+        $RegEvent = new GlmDataRegistrationsRegEvent($this->wpdb, $this->config);
+        $RegTime = new GlmDataRegistrationsRegTime($this->wpdb, $this->config);
+        $RegRequest = new GlmDataRegistrationsRegRequest($this->wpdb, $this->config);
+        $RequestEvent = new GlmDataRegistrationsRequestEvent($this->wpdb, $this->config);
+        $RequestClass = new GlmDataRegistrationsRequestClass($this->wpdb, $this->config);
+        $RequestRate = new GlmDataRegistrationsRegRequestRate($this->wpdb, $this->config);
+        $RequestRegistrant = new GlmDataRegistrationsRequestRegistrant($this->wpdb, $this->config);
+        
+        $this->cart['messages'] = array();
+        
+        $totalRegistrants       = 0;
+        $totalCharges           = 0;
+        $totalDiscounts         = 0;
+        $grandTotal             = 0;
+        
+        // If we have a cart (request)
+        if ($this->cart) {
 
-        // Check if there's no events listed
-        if (is_array($this->cart['events']) && count($this->cart['events']) > 0) {
-            $messages[] = 'Cart is empty.';
-        } else {
-
-            // Loop through all events in the cart
-            foreach ($this->cart['events'] as $eventKey => $event) {
-
-                $this->cart['events'][$eventKey]['charges'] = 0;
-                $this->cart['events'][$eventKey]['credits'] = 0;
-                $this->cart['events'][$eventKey]['discounts'] = 0;
-                $this->cart['events'][$eventKey]['total'] = 0;
-                $this->cart['events'][$eventKey]['numbRegistrants'] = 0;
-                
-                // Check if Event exists in Events add-on and is active in registrations or if doing admin (admin_active)
-                $regEvent = $RegEvent->getEntry($event['reg_event']);
-                if (!$regEvent) {
-                    $messages[] = 'Event in cart is not currently available for registratiosn.';
-                }
-                
-                // Check if the event is time-specific and if there's a list of times for this event - If not, should be a default
-                
-                // Check if there's a list of classes (levels) for this event - If not, add as a problem
-                
-                    // Loop though all classes - Might be multiple classes (levels) that are the same but for different reg_times.
-
-                        // [this class]['charges'] = 0;
-                        // [this class]['credits'] = 0;
-                        // [this class]['discounts'] = 0;
-                        // [this class]['total'] = 0;
-                        // [this class]['numbRegistrants'] = 0;
-                
-
-                        // Check if there's a list of rates - if not, add as a problem
-                            
-                        // loop through all rates
+            // 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 rate]['charges'] = 0;
-                            // [this rate]['credits'] = 0;
-                            // [this rate]['discounts'] = 0;
-                            // [this rate]['total'] = 0;
-                            // [this rate]['numbRegistrants'] = 0;
+            /*
+             * Events Processing
+             */
+       
+            // 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.';
+            } else {
+                
+                // Loop through all events in the cart
+                foreach ($this->cart['events'] as $eventKey => $event) {
+  
+                    $eventRegistrants   = 0;
+                    $eventCharges       = 0;
+                    $eventDiscounts     = 0;
+                    $eventTotal         = 0;
+                    
+                    // Do event Checks
+                    
+                    
+                    
+                    // Check if Event exists in Events add-on and is active in registrations or if doing admin (admin_active)
+                    $regEvent = $RegEvent->getEntry($event['reg_event']);
+                    if (!$regEvent) {
+                        $this->cart['messages'][] = 'Event in cart is not currently available for registration.';
+                    }
+                    
+                    // Check if the event is time-specific and if there's a list of times for this event - If not, should be a default
+                    
+                    /*
+                     * Classes (levels) Processing
+                     */
+                    
+                    // If we don't have classes for this event
+                    if (!is_array($event['classes']) || count($event['classes']) == 0 ) {
+                        $this->cart['messages'][] = 'Event '.$event['event_name'].' has no levels.';
+                    } else {
+   
+                        // Loop through all classes (levels) for this event
+                        foreach ($event['classes'] as $classKey => $class) { 
+                        
+                            $classRegistrants   = 0;
+                            $classCharges       = 0;
+                            $classDiscounts     = 0;
+                            $classTotal         = 0;
                             
-                            // Check if listed rate is currently available - If not, add as a problem
+                            // Do class (level) checks
                             
-                            // Check if there's a list of registrants for this class (level) - If not, add as a problem
                             
-                            // Loop through all registrants
+                            /*
+                             * Rates Processing
+                             */
                             
-                                // [this registrant]['charges'] = 0;
-                                // [this registrant]['credits'] = 0;
-                                // [this registrant]['discounts'] = 0;
-                                // [this registrant]['total'] = 0;
+                            // If we don't have rates for this class
+                            if (!is_array($class['rates']) || count($class['rates']) == 0 ) {
+                                $this->cart['messages'][] = 'Class '.$class['class_name'].' has no rates.';
+                            } else {
                                 
-                                // Check that registrant has an account that's active - If not, add as a problem
-                                
-                                // Check if limited registration
-                                
-                                    // Check for a current hold - If expired or not listed
+                                // loop through all rates
+                                foreach ($class['rates'] as $rateKey => $rate) {
                                     
-                                        // If no current hold, try to get new hold - If not, add as a problem
-                                        
-                                // If no problems, then calculate charges
-                                
-                                    // If there's not already a charge for this class (level) - Add base rate to charges
+                                    $rateRegistrants   = 0;
+                                    $rateCharges       = 0;
+                                    $rateDiscounts     = 0;
+                                    $rateTotal         = 0;
                                     
-                                    // If the number of registrants is less than the registrant credits - Add the per-registrant rate
+                                    // Do rate Checks
+
                                     
-                                    // Check if there's a comp or discount code - if so add add discount
+                                    // Check if listed rate is currently available - If not, add as a problem
                                     
-                                    // Calculate net charge for this registrant and put it in registrant data
+                                    /*
+                                     * Registrants Processing
+                                     */
                                     
-                                // Add charges, credits, discounts, totals to the current rate
-                                
-                            // Add charges, credits, discounts, totals for this rate to the current class (level)
-                             
-                    // Add charges, credits, discounts, totals for class (level) to the current event
+                                    // If we don't have registrants for this class
+                                    if (!is_array($rate['registrants']) || count($rate['registrants']) == 0 ) {
+                                        $this->cart['messages'][] = 'Rate '.$rate['rate_name'].' has no registrants.';
+                                    } else {
+                                        
+                                        // loop through all Registrants
+                                        foreach ($rate['registrants'] as $registrantKey => $registrant) {
+                                            
+                                            $registrantCharges       = 0;
+                                            $registrantDiscounts     = 0;
+                                            $registrantTotal         = 0;
+                                            
+                                            // Do registrant checks
+                                            
+
+                                            
+                                            // Save totals for this registrant
+                                            $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['registrants'][$registrantKey]['totalCharges']        = $registrantCharges;
+                                            $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['registrants'][$registrantKey]['totalDiscounts']      = $registrantDiscounts;
+                                            $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['registrants'][$registrantKey]['rateTotal']           = $registrantTotal;
+                                            
+                                            // Add totals to rate
+                                            $rateRegistrants++;
+                                            $rateCharges       += $registrantCharges;
+                                            $rateDiscounts     += $registrantDiscounts;
+                                            $rateTotal         += $registrantTotal;
+                                            
+                                        } // Each registrant
+                                    
+                                    } // Have registrants
+                                    
+                                    // Save totals for this rate
+                                    $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['totalRegistrants']    = $rateRegistrants;
+                                    $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['totalCharges']        = $rateCharges;
+                                    $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['totalDiscounts']      = $rateDiscounts;
+                                    $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['rateTotal']           = $rateTotal;
+                                    
+                                    // Add totals to class
+                                    $classRegistrants   += $rateRegistrants;
+                                    $classCharges       += $rateCharges;
+                                    $classDiscounts     += $rateDiscounts;
+                                    $classTotal         += $rateTotal;
+
+                                } // Each Rate
+                            
+                            } // Have rates
+                            
+                            // Save totals for this class (level)
+                            $this->cart['events'][$eventKey]['classes'][$classKey]['totalRegistrants']    = $classRegistrants;
+                            $this->cart['events'][$eventKey]['classes'][$classKey]['totalCharges']        = $classCharges;
+                            $this->cart['events'][$eventKey]['classes'][$classKey]['totalDiscounts']      = $classDiscounts;
+                            $this->cart['events'][$eventKey]['classes'][$classKey]['classTotal']          = $classTotal;
+                            
+                            // Add totals to event
+                            $eventRegistrants   += $classRegistrants;
+                            $eventCharges       += $classCharges;
+                            $eventDiscounts     += $classDiscounts;
+                            $eventTotal         += $classTotal;
+                            
+                        
+                        } // Each class
+                        
+                    } // Have Classes
+                    
+                    // Save totals for this event
+                    $this->cart['events'][$eventKey]['totalRegistrants']    = $eventRegistrants;
+                    $this->cart['events'][$eventKey]['totalCharges']        = $eventCharges;
+                    $this->cart['events'][$eventKey]['totalDiscounts']      = $eventDiscounts;
+                    $this->cart['events'][$eventKey]['eventTotal']          = $eventTotal;
                     
-                // Add charges, credits, discounts, totals for this event to the grand totals
+                    // Add totals to request
+                    $totalCharges       += $eventCharges;
+                    $totalRegistrants   += $eventRegistrants;
+                    $totalDiscounts     += $eventDiscounts;
+                    $totalTotal         += $eventTotal;
+                    
+                } // Each event
                 
-                                
-            }
+            } // Have events
+            
+            // Update request last_update timestamp
+            
+        } // have request
+        
+        // Check if Event Time exists in Events add-on
+        
+//        echo "<pre>".print_r($this->cart,1)."</pre>";
 
-        } // have events
+        // Check if no messages then cart validated
+        if (count($this->cart['messages']) == 0) {
+            $this->cart['validated'] = true;
+        }
 
-        // Check if Event Time exists in Events add-on
+        return;
 
     }
 
index 5c0a0e8..d086fe0 100644 (file)
--- a/index.php
+++ b/index.php
@@ -28,7 +28,7 @@ if (!defined('ABSPATH')) {
     die();
 }
 
-    /*
+/*
  *  Plugin and Database Versions
  *
  *  Note that the database version matches the version of the last
index fe18985..6bb5fe7 100644 (file)
@@ -79,10 +79,10 @@ class GlmMembersFront_registrations_cart extends GlmRegCartSupport
 
     public function modelAction($actionData = false)
     {
-
-        $cartID = false;
-        $haveCart = false;
         
+        $cartId = false;
+        $haveCart = false;
+        $option = false;
         
         // Get any provided option
         if (isset($_REQUEST['option'])) {
@@ -101,22 +101,28 @@ class GlmMembersFront_registrations_cart extends GlmRegCartSupport
         }
 
         // Get cart ID if supplied
-        if (isset($_REQUEST['cart'])) {
+        if (isset($_SESSION['glm_reg_cart_id'])) {
+           
+            // Get ID from sessiosn
+            $cartId = $_SESSION['glm_reg_cart_id'];
             
-            // Make sure it's numeric
-            $cartID = ($_REQUEST['cart'] - 0);
+        } elseif (isset($_REQUEST['cart'])) {
             
-            if ($cartID <= 0) {
-                $cartID = false;
-            } else {
-                $cart = $this->getRegistrationCart($cartID);
-                if ($cart) {
-                    $haveCart = true;
-                }
+            // Get ID from REQUEST Make sure it's numeric
+            $cartId = ($_REQUEST['cart'] - 0);
+            
+            if ($cartId <= 0) {
+                $cartId = false;
+            }
+            
+        }
+
+        if ($cartId) {
+            $this->getRegistrationCart($cartId);
+            if ($this->cart) {
+                $haveCart = true;
             }
         }
-        
-        
         
         $view = 'cart';
 
@@ -126,7 +132,12 @@ class GlmMembersFront_registrations_cart extends GlmRegCartSupport
             case 'showCart':
             default:
                 
-                    
+                    if ($cartId) {
+
+                        // Try to get a Validate cart with updated totals
+                        $this->checkRegistrationRequest($cartId);
+                        
+                    }
                 
                 break;
 
@@ -134,8 +145,14 @@ class GlmMembersFront_registrations_cart extends GlmRegCartSupport
 
         // Compile template data
         $templateData = array(
+            'cartId'        => $cartId,
+            'haveCart'      => $haveCart,
+            'cart'          => $this->cart
 
         );
+        
+//echo "<pre>".print_r($templateData,1)."</pre>";
+
              // Return status, any suggested view, and any data to controller
         return array(
             'status'        => true,
index 7305a44..3a5e84e 100644 (file)
@@ -94,7 +94,7 @@ class GlmMembersFront_registrations_index
 
         // Load the specified model
         $pageFile = GLM_MEMBERS_REGISTRATIONS_PLUGIN_PATH.'/models/front/registrations/'.$page.'.php';
-        require_once($pageFile);
+        require_once $pageFile;
 
         // load and run the model
         $regClass = 'GlmMembersFront_registrations_'.$page;
index b2c7406..e5f5500 100644 (file)
         switch ( $option ) {
 
         default:
+            
             // Get a current list of reg events
             $listResult = $this->getSimpleRegEventsList($where.$alphaWhere, 'event_name', true, 'id', $start, $limit, true);
+            
             //echo '<pre>$listResult: ' . print_r( $listResult, true ) . '</pre>';
 
             // Get paging results
index 32df2be..8cda31b 100644 (file)
 
     public function modelAction($actionData = false)
     {
-        $loginAccount = '';
+        
+        $loginAccount   = '';
+        $cartId         = false;
 
+        // Have Backbone.js loaded
         $scripts = array(
             //'backbone-local' => 'js/lib/backbone.localStorage.min.js',
             'regApp' => 'js/frontRegApp.js',
         }
         $view = 'registration';
 
-        // Check to see if a session is set for this cart
+        // Load cart support class
         include GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH . '/regCartSupport.php';
-        $regCart = new GlmRegCartSupport( $this->wpdb, $this->config );
+        $RegCart = new GlmRegCartSupport( $this->wpdb, $this->config );
+        
+        // Check if there's a current session
         if ( isset( $_SESSION['glm_reg_cart_id'] ) ) {
             $cartId = $_SESSION['glm_reg_cart_id'];
         } else {
-            // create one
-            $cartId = $regCart->createRegistrationCart();
+
+            // There isn't so create one
+            $cartId = $RegCart->createRegistrationCart();
             if ( isset( $cartId ) && filter_var( $cartId, FILTER_VALIDATE_INT ) ) {
                 $_SESSION['glm_reg_cart_id'] = $cartId;
             }
 
         }
+
         if ( isset( $cartId ) && filter_var( $cartId, FILTER_VALIDATE_INT ) ) {
-            $cart = $regCart->getRegistrationCart( $cartId );
+            $cart = $RegCart->getRegistrationCart( $cartId );
             //echo '<pre>$cart: ' . print_r( $cart, true ) . '</pre>';
             $regRequestJSON = json_encode( $cart['request'], JSON_NUMERIC_CHECK );
         }
index bf222a1..651040d 100644 (file)
@@ -526,7 +526,7 @@ CREATE TABLE {prefix}reg_request (
 ----
 
 -- Registration for a specific event
--- Has one or more reg_selected_rate records associated with it - *** Need to remove the account entry in this table ****
+-- Has one or more reg_selected_rate records associated with it - *** Need to remove from this table: account, total_charge ****
 CREATE TABLE {prefix}reg_request_event (
     id INT NOT NULL AUTO_INCREMENT,
     reg_request INT NULL,                                       -- Pointer to reg_request table
@@ -534,7 +534,6 @@ CREATE TABLE {prefix}reg_request_event (
     event_name TINYTEXT NULL,                                   -- Name of Event so it will always be in the cart data
     reg_time INT NULL,                                          -- Pointer to times table entry in Events add-on
     event_datetime DATETIME NULL,                               -- Date and time of event time selected so it will always be in the cart
-    total_charge FLOAT,                                         -- Last calculated total of all charges for registration to this event for all registrants
     mf_data TEXT NULL,                                          -- Any MagicForm data associated with requested event
     notes TEXT NULL,                                            -- System operator's notes for this registration request
     PRIMARY KEY (id),
@@ -546,7 +545,7 @@ CREATE TABLE {prefix}reg_request_event (
 ----
 
 --  A particular reg_class selected
---  Has one or more reg_request_rate records associated with it - *** Need to remove the account entry in this table ****
+--  Has one or more reg_request_rate records associated with it - *** Need to remove from this table: account, total_class_charge ****
 CREATE TABLE {prefix}reg_request_class (
     id INT NOT NULL AUTO_INCREMENT,
     reg_event INT NULL,                                         -- Pointer to reg_event entry
@@ -557,7 +556,6 @@ CREATE TABLE {prefix}reg_request_class (
     reg_request_event INT NULL,                                 -- Pointer to reg_request_event table entry
     class INT NULL,                                             -- Pointer to event reg_class table - False (0) if registration class no longer exits
     class_name TINYTEXT NULL,                                   -- Name of event class at the time selected
-    total_class_charge FLOAT,                                   -- Last calculated total of all charges for this registration class for this request
     mf_data TEXT NULL,                                          -- Any MagicForm data associated with registrant
     notes TEXT NULL,                                            -- System operator's notes for this registration request
     PRIMARY KEY (id),
@@ -569,7 +567,7 @@ CREATE TABLE {prefix}reg_request_class (
 ----
 
 --  A particular reg_rate selected
---  Has one or more reg_request_registrant records associated with it - *** Need to remove the account entry in this table ****
+--  Has one or more reg_request_registrant records associated with it - *** Need to remove from this table:  account, numb_registrants, total_registrant_charges  ****
 CREATE TABLE {prefix}reg_request_rate (
     id INT NOT NULL AUTO_INCREMENT,
     reg_event INT NULL,                                         -- Pointer to reg_event entry
@@ -583,9 +581,7 @@ CREATE TABLE {prefix}reg_request_rate (
     rate_name TINYTEXT NULL,                                    -- Name of event class rate at the time selected
     base_rate FLOAT,                                            -- Base rate at time of registration
     per_registrant FLOAT,                                       -- Per Registrant Rate at time of registration
-    registrant_credits TINYINT NULL,                            -- Number of registrant credits in base rate at time of registration
-    numb_registrants TINYINT NULL,                              -- Last calculated number of registrants with this rate
-    total_registrant_charges FLOAT,                             -- Last calculation registrant charges assoicated with this selected rate
+    registrant_credits TINYINT NULL,                            -- Number of registrants included in base rate at time of registration
     mf_data TEXT NULL,                                          -- Any MagicForm data associated with registrant
     notes TEXT NULL,                                            -- System operator's notes for this registration request
     PRIMARY KEY (id),
@@ -597,7 +593,7 @@ CREATE TABLE {prefix}reg_request_rate (
 
 ----
 
---  A specific registrant for a selected registration rate - *** Need to remove the reg_request_registrant entry in this table ****
+--  A specific registrant for a selected registration rate - *** Need to remove from this table: reg_request_registrant, reg_request_hold, reg_request_hold_not_available ****
 CREATE TABLE {prefix}reg_request_registrant (
     id INT NOT NULL AUTO_INCREMENT,
     account INT NULL,                                           -- Pointer to the account entry for the person being registered - False (0) if account no longer exists or registrant account not needed
@@ -609,8 +605,6 @@ CREATE TABLE {prefix}reg_request_registrant (
     reg_request_event INT NULL,                                 -- Pointer to reg_request_event table entry
     reg_request_class INT NULL,                                 -- Pointer to reg_request_class table entry
     reg_request_rate INT NULL,                                  -- Pointer to reg_request_rate table entry
-    reg_request_hold BOOLEAN NULL,                              -- Registrant hold active - Registrant slots held certain time since last cart access - After this the slot needs to be updated if available
-    reg_request_hold_not_available BOOLEAN NULL,                -- No registrant slot available for this registrant - Unable to get hold
     fname TINYTEXT NULL,                                        -- First name of registrant at the time of selection
     lname TINYTEXT NULL,                                        -- Last name of registrant at the time of selection
     mf_data TEXT NULL,                                          -- Any MagicForm data associated with registrant
index e69de29..f9c7be3 100644 (file)
@@ -0,0 +1,65 @@
+<h1> *** THIS IS THE CART PAGE *** </h1>
+
+<h3>Temporary output for testing cart data</h3>
+
+{if $haveCart}
+    <h2>Cart Contents</h2>
+    {foreach $cart.events as $event}
+    <div>
+        
+        <p>
+            Event: {$event.event_name} (id={$event.id})<br>
+        </p>
+        
+        <div style="margin-left: 2em;">
+        
+        {foreach $event.classes as $class}
+            
+             <p>    
+             Level: {$class.class_name}<br>
+             </p>
+
+                <div style="margin-left: 2em;">
+        
+                {foreach $class.rates as $rate}
+
+                    <p>                
+                    Rate: {$rate.rate_name}<br>
+                    Base Rate: {$rate.base_rate}<br>
+                    Per Registrant: {$rate.per_registrant}<br>
+                    Registrant Credits: {$rate.registrant_credits}<br>
+                    </p>
+                
+                    <div style="margin-left: 2em;">
+                    
+                    {foreach $rate.registrants as $registrant}
+                    
+                        <p>
+                        
+                        {$account = $cart.accounts}
+                        {$aid = $registrant.account}
+                        
+                        Registrant Name: {$account.$aid.fname} {$account.$aid.lname}<br>
+                        Date & Time: {$registrant.event_datetime.datetime}<br>
+                        Charges: {$registrant.totalCharges}<br>
+                        Discounts: {$registrant.totalDiscounts}<br>
+                        Net Charges: {$registrant.rateTotal}<br>
+                        </p>
+                    
+                    {/foreach}
+                    
+                    </div>
+                    
+                {/foreach}
+                
+                </div>
+                
+        {/foreach}
+        
+        </div>
+    </div>
+
+    {/foreach}
+{else}
+            <tr class="alternate"><td colspan="2">No cart data</td></tr>
+{/if}