Added method to dataRegEvent class to collect all data on setup of a single event
authorChuck Scott <cscott@gaslightmedia.com>
Tue, 22 Aug 2017 18:02:05 +0000 (14:02 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Tue, 22 Aug 2017 18:02:05 +0000 (14:02 -0400)
Fixed naming error for dataRegRate
Minor edit to accounts.
Changed call for getting evnet data for the registrations event dashboard to use the new method

classes/data/dataRegEvent.php
classes/data/dataRegRate.php
models/admin/registrations/accounts.php
models/admin/registrations/event.php
views/admin/registrations/event.html

index f6d2b6f..7943329 100644 (file)
@@ -303,7 +303,7 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract
         if ($this->postProcAddedEventData) {
             
             // If doing the following actions 
-            if (in_array($action, array('l'))) {
+            if (in_array($action, array('l','g'))) {
                     
                 // Use hook to Events to get current data for this event
                 $eventData = apply_filters('glm-member-db-events-get-event', $result_data['event']);
@@ -425,6 +425,66 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract
         
     }
     
+    /**
+     * Get all event configuration data for a specific event 
+     * Used to get data for managing a registration event
+     *
+     * @param integer $id ID of reg_event record
+     * @param boolean $extended Request added data from Event add-on if true
+     * @param boolean $forEdit Ask for results to include arrays necessary for construction of input fields
+     *
+     * @return array All data related to the setup/configuration of a registration event
+     */
+    public function getEventConfig($id = false, $extended = false, $forEdit = false)
+    {
+      
+        // Save status of extended data flag
+        $saveExtended = $this->postProcAddedEventData;
+        
+        // If extended data is requested, then set flag for post processing
+        if ($extended) {
+            $this->postProcAddedEventData = true;
+        }
+
+        // Try to get the base information - and extended data from the Event add-on if requested
+        if ($id > 0) {
+            $eventData = $this->getEntry($id, 'id', $forEdit);
+            if (!$eventData) {
+                return false;
+            }
+        }
+
+        // Get all reg_time records for this event
+        require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegTime.php';
+        $RegTime = new GlmDataRegistrationsRegTime($this->wpdb, $this->config);
+        $eventData['reg_time'] = $RegTime->getList('T.reg_event = '.$eventData['id'], 'start_datetime', true);
+       
+        // Get all reg_class records for this event
+        require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegClass.php';
+        $RegTime = new GlmDataRegistrationsRegClass($this->wpdb, $this->config);
+        $eventData['reg_class'] = $RegTime->getList("T.reg_event = ".$eventData['id'], 'name', true);
+       
+        // If we have any reg_class results
+        if ($eventData['reg_class']) {
+            
+            // Get all reg_rate records for this reg_class
+            require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegRate.php';
+            $RegRate = new GlmDataRegistrationsRegRate($this->wpdb, $this->config);
+            foreach ($eventData['reg_class'] as $k=>$v) {
+                $eventData['reg_class'][$k]['reg_rate'] = $RegRate->getList("T.reg_class = ".$v['id'], 'start_days', true);
+            }
+
+        }
+        
+        // Restore status of extended data flag
+        $this->postProcAddedEventData = $saveExtended;
+
+        return $eventData;
+        
+    }
+    
+    
+    
     
 }
 
index 6c49032..1a8c44c 100644 (file)
@@ -13,7 +13,7 @@
  */
 
 /**
- * GlmDataRegistrationsRegRates class
+ * GlmDataRegistrationsRegRate class
  *
  * PHP version 5
  *
@@ -24,7 +24,7 @@
  *          @release SVN: $Id: dataRegRate.php,v 1.0 2011/01/25 19:31:47 cscott
  *          Exp $
  */
-class GlmDataRegistrationsRegRates extends GlmDataAbstract
+class GlmDataRegistrationsRegRate extends GlmDataAbstract
 {
 
     /**
index 17bcaa2..b382052 100644 (file)
@@ -14,7 +14,7 @@
  */
 
 // Load Registrations data abstract
- require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataAccount.php';
+require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataAccount.php';
 
 class GlmMembersAdmin_registrations_accounts extends GlmDataRegistrationsAccount
 {
index 97e3e5e..6363b18 100644 (file)
@@ -234,9 +234,10 @@ include GLM_MEMBERS_REGISTRATIONS_PLUGIN_PATH . '/data/event_setup.php';
                 
             case 'dashboard':
             default:
-                
+
                 if ($regEventID) {
-                    $regEvent = $this->editEntry($regEventID);
+                    $this->postProcAddedEventData = true;
+                    $regEvent = $this->getEventConfig($regEventID, true, true);
                     if ($regEvent) {
                         $haveRegEvent = true;
                     }
index ce76d6c..70dded7 100644 (file)
@@ -15,7 +15,7 @@
                             <h4>Event Name:</h4>
                         </div>
                         <div class="glm-small-12 glm-column">
-                            {$regEvent.fieldData.event_name}
+                            {$regEvent.event_name}
                         </div>
                     </div>
                 </div>
                             <h4>Event Code:</h4>
                         </div>
                         <div class="glm-small-12 glm-column">
-                            {$regEvent.fieldData.event_code}
+                            {$regEvent.event_code}
                         </div>
                     </div>
                 </div>
             </div>
             {if apply_filters('glm_members_menu_members', true)}
             <div class="glm-small-4 glm-right">
-                <a href="{$thisUrl}?page=glm-members-admin-menu-registrations-event&option=edit&regEventID={$regEvent.fieldData.id}" class="button button-primary glm-button glm-right">Edit Registration Event</a>
+                <a href="{$thisUrl}?page=glm-members-admin-menu-registrations-event&option=edit&regEventID={$regEvent.id}" class="button button-primary glm-button glm-right">Edit Registration Event</a>
             </div>
             {/if}
         </div>