Add Event Attendee Export and Print
authorSteve Sutton <steve@gaslightmedia.com>
Wed, 3 Jan 2018 14:02:59 +0000 (09:02 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Wed, 3 Jan 2018 14:02:59 +0000 (09:02 -0500)
Adding option to export the Attendees to html (print) or csv.

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

index 1b9b852..d3fdeb2 100644 (file)
@@ -335,6 +335,8 @@ class GlmDataRegistrationsRequestRegistrant extends GlmDataAbstract
             return false;
         }
 
+        $customFieldsPluginActive = apply_filters( 'glm-members-customfields-plugin-active', false );
+
         // For each registrant
         foreach ($registrants as $registrantKey=>$registrantVal) {
 
@@ -347,6 +349,23 @@ class GlmDataRegistrationsRequestRegistrant extends GlmDataAbstract
             }
 
             // Try to get any per Event custom field data
+            if ( $customFieldsPluginActive ) {
+                $custom_data = array();
+                // Check if there's custom field data for this record
+                $fid = 'glm_reg_customfields_reg_event_attendee_' . $eventId;
+                $recordId = $registrantVal['id'];
+                $customData = apply_filters( 'glm-members-customfields-form-data-recall', '', $fid, $recordId, false );
+                // echo '<pre>$customData: ' . print_r( $customData, true ) . '</pre>';
+                if ( isset( $customData ) && is_array( $customData ) && !empty( $customData ) ) {
+                    $fields = $customData['form'];
+                    foreach ( $fields as $cField ) {
+                        $custom_data[] = array(
+                            $cField['field_name'] => $cField['stored']
+                        );
+                    }
+                    $registrants[$registrantKey]['custom_data'] = $custom_data;
+                }
+            }
 
             // Try to get any per
         }
@@ -355,17 +374,5 @@ class GlmDataRegistrationsRequestRegistrant extends GlmDataAbstract
 
         return $listResult;
 
-
-
-
-
-
-
-
-
-
-
     }
 }
-
-?>
index eccccd6..7599e07 100644 (file)
@@ -110,6 +110,10 @@ class GlmMembersAdmin_ajax_registrantsListExport extends GlmDataRegistrationsReq
             'exportEmail'      => $this->checkFlag('exportEmail'),
             'exportPhone'      => $this->checkFlag('exportPhone'),
             'exportCounty'     => $this->checkFlag('exportCounty'),
+            'exportLevel'      => $this->checkFlag('exportLevel'),
+            'exportTime'       => $this->checkFlag('exportTime'),
+            'exportRate'       => $this->checkFlag('exportRate'),
+            'exportStatus'     => $this->checkFlag('exportStatus'),
         );
 
         // Get registration event ID if supplied
@@ -155,6 +159,8 @@ class GlmMembersAdmin_ajax_registrantsListExport extends GlmDataRegistrationsReq
         // $list = $this->getList($where, "lname");
         $listResult = $this->getFullRegistrantsData($regEventID, $where, 1, false);
         $list = $listResult['list'];
+        // echo '<pre>$list: ' . print_r( $list, true ) . '</pre>';
+        // exit;
 
         // If we have list entries - even if it's an empty list
         $success         = true;
@@ -171,16 +177,12 @@ class GlmMembersAdmin_ajax_registrantsListExport extends GlmDataRegistrationsReq
 
         // Compile template data
         $templateData = array(
-            'category_data'   => $category_data,
             'select'          => $select,
             'haveRegistrants' => $haveRegistrants,
             'registrants'     => $list,
             'registrantCount' => $registrantCount,
             'categories'      => $categories,
             'haveFilter'      => $haveFilter,
-            'filterArchived'  => $filterArchived,
-            'filterFeatured'  => $filterFeatured,
-            'filterPending'   => $filterPending,
             'numbDisplayed'   => $numbDisplayed,
             'lastDisplayed'   => $lastDisplayed,
             'paging'          => $paging,
index e399aff..34c5e71 100644 (file)
@@ -206,7 +206,25 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent
                     }
                 }
 
+                $customFieldsPluginActive = apply_filters( 'glm-members-customfields-plugin-active', false );
+
                 $listResult = $Registrants->getFullRegistrantsData($regEventID, $where, $start, $limit);
+                // echo '<pre>$listResult: ' . print_r( $listResult['list'], true ) . '</pre>';
+
+                $customFields = false;
+                // Go through the $listResult to pull out the custom fields if available and if plugin is on
+                if ( $customFieldsPluginActive && $listResult['list'] ) {
+                    foreach ( $listResult['list'] as $row ) {
+                        if ( $row['custom_data'] ) {
+                            foreach ( $row['custom_data'] as $cFields ) {
+                                $customFields[] = array_keys( $cFields );
+                            }
+                        }
+                        break;
+                    }
+                }
+                // echo '<pre>$customFields: ' . print_r( $customFields, true ) . '</pre>';
+
 
                 // Get count of registrants listed
                 $registrantCount = $listResult['totalCount'];;
index b1808b3..3235479 100644 (file)
                     {if $select.exportCity}<th align="left">City</th>{/if}
                     {if $select.exportState}<th align="left">State</th>{/if}
                     {if $select.exportZip}<th align="left">ZIP</th>{/if}
-                    {if $select.exportCounty}<th align="left">County</th>{/if}
                     {if $select.exportEmail}<th align="left">Email</th>{/if}
                     {if $select.exportPhone}<th align="left">Phone</th>{/if}
+
+                    {if $select.exportLevel}<th align="left">Level</th>{/if}
+                    {if $select.exportTime}<th align="left">Date/Time</th>{/if}
+                    {if $select.exportRate}<th align="left">Rate</th>{/if}
+                    {if $select.exportStatus}<th align="left">Status</th>{/if}
                 </tr>
             </thead>
             <tbody>
                     {if $select.exportCity}<td>{$m.account.city}</td>{/if}
                     {if $select.exportState}<td>{if $m.account.state}{$m.account.state.value}{/if}</td>{/if}
                     {if $select.exportZip}<td>{$m.account.zip}</td>{/if}
-                    {if $select.exportCounty}<td>{if $m.account.county}{$m.account.county.value}{/if}</td>{/if}
                     {if $select.exportEmail}<td>{$m.account.email}</td>{/if}
                     {if $select.exportPhone}<td>{$m.account.phone}</td>{/if}
 
+                    {if $select.exportLevel}<td>{$m.class_name}</td>{/if}
+                    {if $select.exportTime}<td>{$m.event_time_reformatted}</td>{/if}
+                    {if $select.exportRate}<td>{$m.rate_name}</td>{/if}
+                    {if $select.exportStatus}<td>{$m.request_status_name}</td>{/if}
+
                 </tr>
         {/foreach}
     {else}
index 311b475..5594ecb 100644 (file)
@@ -6,22 +6,26 @@
 {if $select.exportCity}"City",{/if}
 {if $select.exportState}"State",{/if}
 {if $select.exportZip}"ZIP/Postal",{/if}
-{if $select.exportCounty}"County",{/if}
-{if $select.exportRegion}"Region",{/if}
 {if $select.exportEmail}"Email",{/if}
-{if $select.exportPhone}"Phone"{/if}
+{if $select.exportPhone}"Phone",{/if}
+{if $select.exportLevel}"Level",{/if}
+{if $select.exportTime}"Date/Time",{/if}
+{if $select.exportRate}"Rate",{/if}
+{if $select.exportStatus}"Status"{/if}
 
 {foreach $registrants as $m}
 {if $select.exportId}"{$m.id}",{/if}
-{if $select.exportRegistrant}"{$m.registrant}",{/if}
+{if $select.exportRegistrant}"{$m.fname} {$m.lname}",{/if}
 {if $select.exportAddr1}"{$m.account.addr1}",{/if}
 {if $select.exportAddr2}"{$m.account.addr2}",{/if}
 {if $select.exportCity}"{$m.account.city}",{/if}
 {if $select.exportState}"{if $m.account.state}{$m.account.state.value}{/if}",{/if}
 {if $select.exportZip}"{$m.account.zip}",{/if}
-{if $select.exportCounty}"{if $m.account.county}{$m.county.account.value}{/if}",{/if}
 {if $select.exportEmail}"{$m.account.email}",{/if}
-{if $select.exportPhone}"{$m.account.phone}"{/if}
-
+{if $select.exportPhone}"{$m.account.phone}",{/if}
+{if $select.exportLevel}"{$m.class_name}",{/if}
+{if $select.exportTime}"{$m.event_time_reformatted}",{/if}
+{if $select.exportRate}"{$m.rate_name}",{/if}
+{if $select.exportStatus}"{$m.request_status_name}"{/if}
 {/foreach}
 {else}No {$terms.reg_term_attendee_plur_cap} Selected{/if}
index 0546dc6..16000b6 100644 (file)
                                 <input type="checkbox" name="exportCity" checked> City<br>
                                 <input type="checkbox" name="exportState" checked> State<br>
                                 <input type="checkbox" name="exportZip" checked> ZIP/Postal Code<br>
+                            </td>
+                            <td class="exportFieldsTd">
                                 <input type="checkbox" name="exportEmail" checked> Email <br>
                                 <input type="checkbox" name="exportPhone" checked> Phone <br>
                                 <input type="checkbox" name="exportCounty" checked> County <br>
+                                <input type="checkbox" name="exportLevel" checked> Level <br>
+                                <input type="checkbox" name="exportTime" checked> Date/Time <br>
+                                <input type="checkbox" name="exportRate" checked> Rate <br>
+                                <input type="checkbox" name="exportStatus" checked> Status <br>
+
                             </td>
                         </tr>
                     </table>
 
 <script>
 jQuery(document).ready(function($){
+
+    // Setup the Export Registrant Dialog
     var dialog = $('#exportRegistrantsDialog').dialog({
         autoOpen: false,
         minWidth: 500,
         dialogClass: 'glm-dialog-no-close',
     });
 
+    // Setup the Export Registrant Button
     $('#exportRegistrantsButton').click(function(){
         $('#exportRegistrantsDialog').dialog('open');
     });
+
+    // Setup the Export Registrant Cancel Button
     $('#exportRegistrantsCancel').click(function(){
         $('#exportRegistrantsDialog').dialog('close');
     });
+
+    // Setup the select and unselect all
+    $('#selectAllExportFields').click(function(){
+        $('.exportFieldsTd input[type="checkbox"]').each(function(){
+            $(this).prop('checked', true);
+        });
+    });
+    $('#unselectAllExportFields').click(function(){
+        $('.exportFieldsTd input[type="checkbox"]').each(function(){
+            $(this).prop('checked', false);
+        });
+    });
+
 });
 </script>