From: Steve Sutton Date: Thu, 28 Dec 2017 21:22:26 +0000 (-0500) Subject: Updates for the admin registration list page for regEvent X-Git-Tag: v1.0.0^2~128 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=8863ed8f4f7044be6f61769af1b8a8c02b2984f8;p=WP-Plugins%2Fglm-member-db-registrations.git Updates for the admin registration list page for regEvent Adding to registration list page: * Set default sort order last then first name. * Option to show only completed registrations. * Add pagination to the registration list. * Add search form with name search. (Searches first and last name). * Add link for each registrant to their "Account" dashboard. --- diff --git a/classes/data/dataRegRequestRegistrant.php b/classes/data/dataRegRequestRegistrant.php index e5d7d46..933fcd9 100644 --- a/classes/data/dataRegRequestRegistrant.php +++ b/classes/data/dataRegRequestRegistrant.php @@ -250,7 +250,7 @@ class GlmDataRegistrationsRequestRegistrant extends GlmDataAbstract 'field' => 'reg_request', 'as' => 'request_status', 'type' => 'pointer', - 'p_table' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . 'reg_request', + 'p_table' => GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . 'reg_request R', 'p_field' => 'status', 'p_static' => true, 'required' => true, @@ -302,7 +302,7 @@ class GlmDataRegistrationsRequestRegistrant extends GlmDataAbstract * @return array List of registrants with optional additional data or false if none * */ - public function getFullRegistrantsData($eventId = false) + public function getFullRegistrantsData($eventId = false, $where = '', $start = false, $limit = false) { // Check Event ID @@ -311,8 +311,16 @@ class GlmDataRegistrationsRequestRegistrant extends GlmDataAbstract return false; } + $whereEvent = "T.reg_event = $eventId "; + if ( $where ) { + $whereEvent .= " AND $where"; + } + // Get registrants for this event - $registrants = $this->getList("T.reg_event = $eventId"); + $listResult = $this->getList( $whereEvent, "T.lname, T.fname", true, 'id', $start, $limit ); + $registrants = $listResult['list']; + + $registrantCount = $this->getStats(str_replace('T.', '', $whereEvent)); // Make sure we received registrants if (!is_array($registrants) || count($registrants) == 0) { @@ -334,8 +342,10 @@ class GlmDataRegistrationsRequestRegistrant extends GlmDataAbstract // Try to get any per } + $listResult['list'] = $registrants; + $listResult['totalCount'] = $registrantCount; - return $registrants; + return $listResult; @@ -350,4 +360,4 @@ class GlmDataRegistrationsRequestRegistrant extends GlmDataAbstract } } -?> \ No newline at end of file +?> diff --git a/config/plugin.ini b/config/plugin.ini index 2e00476..c110be1 100644 --- a/config/plugin.ini +++ b/config/plugin.ini @@ -2,7 +2,7 @@ ; Main Configuration File ; {descrName} ; -; Place any static configuration parameters here. +; Place any static configuration parameters here. ; [common] @@ -34,9 +34,9 @@ payment_method[1] = 'No Charge' payment_method[2] = 'Comp Code' payment_method[3] = 'Cash' payment_method[4] = 'Check' -payment_method[5] = 'Call from Merchant' -payment_method[6] = 'Credit Card' -payment_method[7] = 'PayPal' +payment_method[5] = 'Call from Merchant' +payment_method[6] = 'Credit Card' +payment_method[7] = 'PayPal' payment_method_numb['NoCharge'] = 1 payment_method_numb['CompCode'] = 2 @@ -85,7 +85,7 @@ reg_ref_type[50] = 'Registrant' reg_ref_type_numb['Registration Request'] = 10 reg_ref_type_numb['Event'] = 20 -reg_ref_type_numb['Registration CLass'] = 30 +reg_ref_type_numb['Registration Class'] = 30 reg_ref_type_numb['Registration Rate'] = 40 reg_ref_type_numb['Registrant'] = 50 @@ -180,15 +180,15 @@ billing_field[10] = 'Country' billing_field[11] = 'Phone' billing_field[12] = 'FAX' -billing_field_numb['First Name'] = 1 -billing_field_numb['Last Name'] = 2 -billing_field_numb['Organization'] = 3 -billing_field_numb['Title/Department'] = 4 -billing_field_numb['Address Line 1'] = 5 -billing_field_numb['Address Line 2'] = 6 -billing_field_numb['City'] = 7 -billing_field_numb['State'] = 8 -billing_field_numb['ZIP/Postal Code'] = 9 +billing_field_numb['First Name'] = 1 +billing_field_numb['Last Name'] = 2 +billing_field_numb['Organization'] = 3 +billing_field_numb['Title/Department'] = 4 +billing_field_numb['Address Line 1'] = 5 +billing_field_numb['Address Line 2'] = 6 +billing_field_numb['City'] = 7 +billing_field_numb['State'] = 8 +billing_field_numb['ZIP/Postal Code'] = 9 billing_field_numb['Country'] = 10 billing_field_numb['Phone'] = 11 billing_field_numb['FAX'] = 12 @@ -227,7 +227,7 @@ added_info_field_type[30] = 'Account - Person who submits added_info_field_type[40] = 'Registrant - Person who registers for events' added_info_field_type[50] = 'Registration - Registration of a specific registrant to a specific event' -added_info_field_type_numb['Request'] = 10 +added_info_field_type_numb['Request'] = 10 added_info_field_type_numb['Event'] = 20 added_info_field_type_numb['Account'] = 30 added_info_field_type_numb['Registrant'] = 40 diff --git a/models/admin/registrations/events.php b/models/admin/registrations/events.php index ba2ef28..a09ae6d 100644 --- a/models/admin/registrations/events.php +++ b/models/admin/registrations/events.php @@ -87,7 +87,8 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent $prevStart = false; $nextStart = false; $start = 1; - $limit = 20; // Set to the number of listings per page + $limit = 5; // Set to the number of listings per page + $registrantCount = 0; $textSearch = false; $where = ' TRUE '; $alphaList = false; @@ -115,6 +116,8 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent $classes = false; $haveRegistrants = false; $registrants = false; + $completed = false; + $errorMsg = false; // Register the masked input script that we need for input controls wp_dequeue_script('glm-members-admin-maskedinput'); @@ -158,16 +161,86 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent case 'registrants': + $whereParts = array(); + + if (isset($_REQUEST['textSearch']) && trim($_REQUEST['textSearch'] != '')) { + $textSearch = trim($_REQUEST['textSearch']); + $whereParts[] = "concat( T.fname, ' ', T.lname) LIKE '%".$textSearch."%'"; + + // Clean up for use in redisplaying search value + $textSearch = stripslashes($textSearch); + } + require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegRequestRegistrant.php'; $Registrants = new GlmDataRegistrationsRequestRegistrant($this->wpdb, $this->config); + // Get the regEvent data + $regEvent = $this->getEntry($regEventID); + if ( isset( $_REQUEST['complete'] ) && filter_var( $_REQUEST['complete'], FILTER_VALIDATE_BOOLEAN) ) { + $completed = true; + $whereParts[] = "T.reg_request in ( + SELECT id + FROM " . GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . "reg_request + WHERE status = {$this->config['submission_status_numb']['COMPLETE']})"; + } // Get list of all registrants for this event - $registrants = $Registrants->getFullRegistrantsData($regEventID); + $where = implode( ' AND ', $whereParts ); + + // Check if we're doing paging + if ( isset( $_REQUEST['pageSelect'] ) ) { + + // If request is for Next + if ( $_REQUEST['pageSelect'][0] == 'N' ) { + $newStart = $_REQUEST['nextStart'] - 0; + + // Otherwise it must be Previous + } else { + $newStart = $_REQUEST['prevStart'] - 0; + } + + if ($newStart > 0) { + $start = $newStart; + } + } + + $listResult = $Registrants->getFullRegistrantsData($regEventID, $where, $start, $limit); + + // Get count of registrants listed + $registrantCount = $listResult['totalCount'];; + echo '
$registrantCount: ' . print_r( $registrantCount, true ) . '
'; + + // If the number of registrants is less than a page, don't do paging + if ($registrantCount <= $limit) { + // $paging = false; + } - if ($registrants) { - $haveRegistrants = true; + // Get paging results + $numbDisplayed = $listResult['returned']; + $lastDisplayed = $listResult['last']; + if ($start == 1) { + $prevStart = false; + } else { + $prevStart = $start - $limit; + if ($start < 1) { + $start = 1; + } } + if ($listResult['returned'] == $limit) { + $nextStart = $start + $limit; + } + $registrants = $listResult['list']; + + $success = true; + $haveRegistrants = false; + if ($registrants !== false) { + $success = true; + + // If we have any entries + if (count($registrants) > 0) { + $haveRegistrants = true; + } + } // echo "
".print_r($registrants,1)."
"; $view = 'eventRegistrants'; @@ -555,6 +628,7 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent 'nextStart' => $nextStart, 'start' => $start, 'limit' => $limit, + 'registrantCount' => $registrantCount, 'namesList' => $namesList, 'textSearch' => $textSearch, 'regEventID' => $regEventID, @@ -575,7 +649,9 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent 'regTimesJSON' => $regTimesJSON, 'classes' => $classes, 'haveRegistrants' => $haveRegistrants, - 'registrants' => $registrants + 'registrants' => $registrants, + 'completed' => $completed, + 'errorMsg' => $errorMsg, ); // echo "
".print_r($templateData,1)."
"; diff --git a/views/admin/registrations/eventRegistrants.html b/views/admin/registrations/eventRegistrants.html index be1c037..7d4a996 100644 --- a/views/admin/registrations/eventRegistrants.html +++ b/views/admin/registrations/eventRegistrants.html @@ -1,19 +1,48 @@ {include file='admin/registrations/eventHeader.html'} {include file='admin/registrations/eventSubTabs.html'} - + {if $errorMsg}

{$errorMsg}

{/if} -

Registrant List

-
+{* Search form for registrants *} +
+ + + + + + +
+

+ + Show Completed Only: + + + + Text Search: + + + + + +

+
+ +
+ +

Total found: {$registrantCount}  

+ + {if $paging} + + + {/if} - - + @@ -28,8 +57,7 @@ {if $haveRegistrants} {foreach $registrants as $r} - - + @@ -46,6 +74,13 @@
First NameLast NameName City State Phone
{$r.fname}{$r.lname}{$r.fname} {$r.lname} {$r.account.city} {$r.account.state.value} {$r.account.phone}
-
- + + {if $paging} + + + {/if} + +
+ + {include file='admin/footer.html'}