Added registrant list output to registrants tab in admin registration event pages.
authorChuck Scott <cscott@gaslightmedia.com>
Fri, 15 Dec 2017 02:09:09 +0000 (21:09 -0500)
committerChuck Scott <cscott@gaslightmedia.com>
Fri, 15 Dec 2017 02:09:09 +0000 (21:09 -0500)
Added post-processing and function to dataRegRequestRegistrant.php to include more data on a registrant.
Added "registrants" option code to events.php to collect registrant data.
Added template code to eventRegistrants.html

classes/data/dataRegRequestRegistrant.php
models/admin/registrations/events.php
views/admin/registrations/eventRegistrants.html

index 0bd087d..e5d7d46 100644 (file)
@@ -151,6 +151,14 @@ class GlmDataRegistrationsRequestRegistrant extends GlmDataAbstract
                 'use'       => 'lg'
             ),
 
+            // Pointer to reg_request table entry
+            'reg_request' => array (
+                'field'     => 'reg_request',
+                'type'      => 'integer',
+                'required'  => true,
+                'use'       => 'lgneud'
+            ),
+
             // Pointer to reg_request_event table entry
             'reg_request_event' => array (
                 'field'     => 'reg_request_event',
@@ -211,10 +219,135 @@ class GlmDataRegistrationsRequestRegistrant extends GlmDataAbstract
                 'use'       => 'a'
             ),
 
+            // Additional quick data
+
+            // Class Name
+            'class_name' => array (
+                'field'     => 'reg_request_class',
+                'as'        => 'class_name',
+                'type'      => 'pointer',
+                    'p_table'   => GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . 'reg_request_class',
+                    'p_field'   => 'class_name',
+                    'p_static'  => true,
+                'required'  => true,
+                'use'       => 'lg'
+             ),
+
+             // Rate Name
+            'rate_name' => array (
+                'field'     => 'reg_request_rate',
+                'as'        => 'rate_name',
+                'type'      => 'pointer',
+                    'p_table'   => GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . 'reg_request_rate',
+                    'p_field'   => 'rate_name',
+                    'p_static'  => true,
+                'required'  => true,
+                'use'       => 'lg'
+            ),
+
+            // Request Status
+            'request_status' => array (
+                'field'     => 'reg_request',
+                'as'        => 'request_status',
+                'type'      => 'pointer',
+                    'p_table'   => GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . 'reg_request',
+                    'p_field'   => 'status',
+                    'p_static'  => true,
+                'required'  => true,
+                'use'       => 'lg'
+            )
+
         );
 
     }
 
+    /**
+     * Entry Post Processing Call-Back Method
+     *
+     * Perform post-processing for all result entries.
+     *
+     * @param array  $r Array of field result data for a single entry
+     * @param string $a Action being performed (l, i, g, ...)
+     *
+     * @return object Class object
+     *
+     */
+    public function entryPostProcessing( $r, $action )
+    {
+
+        // If doing the following actions
+        if (in_array($action, array('l','g'))) {
+
+            // Get the registration request status name
+            $r['request_status_name'] = $this->config['submission_status'][$r['request_status']];
+
+            // Add a reformatted date/time
+            $r['event_time_reformatted'] = '';
+            $t = strtotime($r['event_time']);
+            if ($t > 0) {
+                $r['event_time_reformatted'] = date('m/d/Y h:i A', strtotime($r['event_time']));
+            }
+
+        }
+
+        return $r;
+    }
+
+
+    /*
+     * Get full information on registrants for an event
+     *
+     * @param integer $eventId ID of the reg_event record
+     *
+     * @return array List of registrants with optional additional data or false if none
+     *
+     */
+    public function getFullRegistrantsData($eventId = false)
+    {
+
+        // Check Event ID
+        $eventId = ($eventId - 0);
+        if ($eventId <= 0) {
+            return false;
+        }
+
+        // Get registrants for this event
+        $registrants = $this->getList("T.reg_event = $eventId");
+
+        // Make sure we received registrants
+        if (!is_array($registrants) || count($registrants) == 0) {
+            return false;
+        }
+
+        // For each registrant
+        foreach ($registrants as $registrantKey=>$registrantVal) {
+
+            // Try to get account
+            $registrants[$registrantKey]['account'] = false;
+            if ($registrantVal['account']) {
+                require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataAccount.php';
+                $Accounts = new GlmDataRegistrationsAccount($this->wpdb, $this->config);
+                $registrants[$registrantKey]['account'] = $Accounts->getEntry($registrantVal['account']);
+            }
+
+            // Try to get any per Event custom field data
+
+            // Try to get any per
+        }
+
+        return $registrants;
+
+
+
+
+
+
+
+
+
+
+
+    }
 }
 
 ?>
\ No newline at end of file
index eec5a41..ba2ef28 100644 (file)
@@ -70,9 +70,6 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent
 
         /*
          * Run constructor for the REgistrations data class
-         *
-         * Note, the third parameter is a flag that indicates to the Contacts
-         * data class that it should flag a group of fields as 'view_only'.
          */
         parent::__construct(false, false, true);
 
@@ -116,6 +113,8 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent
         $regTimesJSON              = false;
         $regEventDeleted           = false;
         $classes                   = false;
+        $haveRegistrants           = false;
+        $registrants               = false;
 
         // Register the masked input script that we need for input controls
         wp_dequeue_script('glm-members-admin-maskedinput');
@@ -159,6 +158,18 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent
 
             case 'registrants':
 
+                require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegRequestRegistrant.php';
+                $Registrants = new GlmDataRegistrationsRequestRegistrant($this->wpdb, $this->config);
+
+                // Get list of all registrants for this event
+                $registrants = $Registrants->getFullRegistrantsData($regEventID);
+
+                if ($registrants) {
+                    $haveRegistrants = true;
+                }
+
+                // echo "<pre>".print_r($registrants,1)."</pre>";
+
                 $view = 'eventRegistrants';
 
                 break;
@@ -562,7 +573,9 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent
             'regEventJSON'            => $regEventJSON,
             'regClassesJSON'          => $regClassesJSON,
             'regTimesJSON'            => $regTimesJSON,
-            'classes'                 => $classes
+            'classes'                 => $classes,
+            'haveRegistrants'         => $haveRegistrants,
+            'registrants'             => $registrants
         );
 
         // echo "<pre>".print_r($templateData,1)."</pre>";
index 5680b15..be1c037 100644 (file)
@@ -1,4 +1,51 @@
 {include file='admin/registrations/eventHeader.html'}
 {include file='admin/registrations/eventSubTabs.html'}
     
-this is the registrants page.
\ No newline at end of file
+{if $errorMsg}
+    <h3 class="glm-error">{$errorMsg}</h3>
+{/if}
+    
+<h1>Registrant List</h1>
+
+<div class="glm-admin-table-inner glm-admin-table">
+
+        <table class="wp-list-table striped glm-admin-table" style="width: 100%;">
+            <thead>
+                <tr>
+                    <th>First Name</th>
+                    <th>Last Name</th>
+                    <th>City</th>
+                    <th>State</th>
+                    <th>Phone</th>
+                    <th>Level</th>
+                    <th>Date/Time</th>
+                    <th>Rate</th>
+                    <th>Status</th>
+                    <th>&nbsp;</th>
+                </tr>
+            </thead>
+            <tbody>
+    {if $haveRegistrants}
+        {foreach $registrants as $r}
+                <tr>
+                    <td>{$r.fname}</td>
+                    <td>{$r.lname}</td>
+                    <td>{$r.account.city}</td>
+                    <td>{$r.account.state.value}</td>
+                    <td>{$r.account.phone}</td>
+                    <td>{$r.class_name}</td>
+                    <td>{$r.event_time_reformatted}</td>
+                    <td>{$r.rate_name}</td>
+                    <td>{$r.request_status_name}</td>
+                    <td><a href="{$thisUrl}?page=glm-members-admin-menu-registrations-requests&option=requestDashboard&requestID={$r.reg_request}">Request</a></td>
+                </tr>
+        {/foreach}
+    {else}
+                <tr class="alternate"><td colspan="2">(no registrants listed)</td></tr>
+    {/if}
+            </tbody>
+        </table>
+
+</div>
+    
+{include file='admin/footer.html'}