From: Chuck Scott Date: Tue, 2 Oct 2018 16:56:24 +0000 (-0400) Subject: Added account detail to accounts list in the admin Accounts page. X-Git-Tag: v1.1.0^2~3 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=459180b81cfaaade83f2db0843eabfd691a18385;p=WP-Plugins%2Fglm-member-db-registrations.git Added account detail to accounts list in the admin Accounts page. --- diff --git a/classes/data/dataAccount.php b/classes/data/dataAccount.php old mode 100644 new mode 100755 index ed6faae..112c53c --- a/classes/data/dataAccount.php +++ b/classes/data/dataAccount.php @@ -72,6 +72,19 @@ class GlmDataRegistrationsAccount extends GlmDataAbstract * @access public */ public $fields = false; + /** + * Get Account Activity Flag + * + * If this is set then post-processing will include two additional lists under + * each account record, one for attendee records and the other for request records + * associated with this account. + * + * This option is false by default and must be specifically set if it is desired. + * + * @var $getAccountActivity + * @access public + */ + public $getAccountActivity = false; /** * Constructor @@ -632,20 +645,41 @@ class GlmDataRegistrationsAccount extends GlmDataAbstract public function entryPostProcessing( $result_data, $action ) { - // If doing the following actions + // If doing and Insert set the create date if (in_array($action, array('i'))) { // Set the created date $date = date('Y-m-d'); $this->wpdb->update( - GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_request_event", - array('date_created' => $deate), + GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."account", + array('date_created' => $date), array('id' => $result_data['id']), array('%s') ); } + // If doing a list operation + if (in_array($action, array('l'))) { + + // If getAccountActivity is set and this is a list request + if ($this->getAccountActivity) { + + // Load data classes for requests and registrants and get related entries for this account + require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegRequest.php'; + $RegRequest = new GlmDataRegistrationsRegRequest($this->wpdb, $this->config); + $result_data['requests'] = $RegRequest-> getList('T.account = '.$result_data['id'], 'bill_fname, bill_lname'); + $result_data['numb_requests'] = is_array($result_data['requests']) * count($result_data['requests']); + + require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegRequestRegistrant.php'; + $RegRequestRegistrant = new GlmDataRegistrationsRequestRegistrant($this->wpdb, $this->config); + $result_data['registrants'] = $RegRequestRegistrant-> getList('T.account = '.$result_data['id'], 'event_datetime'); + $result_data['numb_registrants'] = is_array($result_data['registrants']) * count($result_data['registrants']); + + } + + } + return $result_data; } diff --git a/models/admin/registrations/accounts.php b/models/admin/registrations/accounts.php index 2b08d22..9cc8029 100755 --- a/models/admin/registrations/accounts.php +++ b/models/admin/registrations/accounts.php @@ -87,6 +87,7 @@ class GlmMembersAdmin_registrations_accounts extends GlmDataRegistrationsAccount public function modelAction($actionData = false) { + $inputData = false; $option = 'dashboard'; $view = 'accountsDashboard'; $reason = false; @@ -264,19 +265,66 @@ class GlmMembersAdmin_registrations_accounts extends GlmDataRegistrationsAccount } } + // filter form input + $inputData = filter_input_array( INPUT_POST, + [ + 'textSearch' => [ 'filter' => FILTER_SANITIZE_STRING ], + 'withRequests' => [ 'filter' => FILTER_VALIDATE_BOOLEAN ], + 'withAttendees' => [ 'filter' => FILTER_VALIDATE_BOOLEAN ], + 'withNoData' => [ 'filter' => FILTER_VALIDATE_BOOLEAN ], + 'inactive' => [ 'filter' => FILTER_VALIDATE_BOOLEAN ] + ] + ); + // Check if we have a Text Search string - if ( isset( $_REQUEST['textSearch'] ) && trim( $_REQUEST['textSearch'] ) != '' ) { - $textSearch = trim( $_REQUEST['textSearch'] ); + if ($inputData['textSearch']) { + $textSearch = trim(addslashes($inputData['textSearch'])); $where .= " AND ( CONCAT_WS( ' ', fname, lname) LIKE '%$textSearch%' or org LIKE '%$textSearch%' OR email LIKE '%$textSearch%' OR + phone LIKE '%$textSearch%' OR id = '$textSearch' )"; } + // Submitted Requests + if ($inputData['withRequests']) { + $where .= " AND ( + SELECT COUNT(id) + FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . "reg_request + WHERE account = T.id + )"; + } + + // Attending Events + if ($inputData['withAttendees']) { + $where .= " AND ( + SELECT COUNT(id) + FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . "reg_request_registrant + WHERE account = T.id + )"; + + } + + // Empty Accounts + if (!$inputData['withNoData']) { + $where .= " AND CONCAT_WS( ' ', fname, lname, email, org, phone) != ''"; + } + + // If not showing inactive show active only + if ($inputData['inactive']) { + $where .= " AND !active"; + } else { + $where .= " AND active"; + } + + // Compile input values array + + + $this->getAccountActivity = true; $accountsResult = $this->getList( $where, 'lname', true, 'id', $start, $limit ); - // echo '
$accountsResult: ' . print_r( $accountsResult, true ) . '
'; + //echo '
$accountsResult: ' . print_r( $accountsResult, true ) . '
'; //$accounts = $this->getList( $where ); // echo '
$where: ' . print_r( $where, true ) . '
'; @@ -321,6 +369,7 @@ class GlmMembersAdmin_registrations_accounts extends GlmDataRegistrationsAccount // Compile template data $templateData = array( + 'inputData' => $inputData, 'hasAccounts' => $hasAccounts, 'numbAccounts' => $numbAccounts, 'accounts' => $accounts, @@ -348,8 +397,7 @@ class GlmMembersAdmin_registrations_accounts extends GlmDataRegistrationsAccount 'haveRequests' => $haveRequests, 'registered' => $registered, 'haveRegistered' => $haveRegistered, - 'reason' => $reason, - 'textSearch' => $textSearch + 'reason' => $reason ); // Return status, any suggested view, and any data to controller return array( diff --git a/setup/databaseScripts/create_database_V1.0.1.sql b/setup/databaseScripts/create_database_V1.0.1.sql index fe3819a..c988a4b 100755 --- a/setup/databaseScripts/create_database_V1.0.1.sql +++ b/setup/databaseScripts/create_database_V1.0.1.sql @@ -388,7 +388,7 @@ CREATE TABLE {prefix}account ( active BOOLEAN NULL, -- Is active flag (may be accessed or used) - default is true validated BOOLEAN NULL, -- Flag indicating that the account has been validated - Set to false when recovering password validation_code TINYTEXT NULL, -- Validation code and timestamp ("{validation code}-{timestamp}) - Clear this after validation - registered_by INT NULL, -- Account + registered_by INT NULL, -- Account *** THIS FIELD NEEDS TO BE DELETED *** member_id TINYTEXT NULL, -- Free-form field for a member ID (not a GLM Associate member ID - See "contact_member_id" below) fname TINYTEXT NULL, -- Account primary address lname TINYTEXT NULL, diff --git a/views/admin/registrations/accountsDashboard.html b/views/admin/registrations/accountsDashboard.html index ebdf4f8..419c43d 100755 --- a/views/admin/registrations/accountsDashboard.html +++ b/views/admin/registrations/accountsDashboard.html @@ -15,10 +15,17 @@

- Name / E-mail / Organization / ID Search: - + Name / E-mail / Organization / Phone / ID Search:

+

+ Accounts with submitted requests + Accounts {$terms.reg_term_registered} for an {$terms.reg_term_event} + Empty Accounts + Inactive Accounts +   +

+

@@ -42,34 +49,115 @@ Last Name E-Mail Address Organization - Title - City - State Phone + Requests + {$terms.reg_term_registered_cap} Created {foreach $accounts as $account} - {if $i++ is odd by 1} - - {else} - - {/if} - {$account.id} - {$account.member_id} - {$account.active.name} - {$account.validated.name} - {$account.fname} - {$account.lname} - {$account.email} - {$account.org} - {$account.title} - {$account.city} - {$account.state.name} - {$account.phone} - {$account.date_created.timestamp|date_format:"%D"} - + + + {$account.id} + {$account.member_id} + {$account.active.name} + {$account.validated.name} + {$account.fname} + {$account.lname} + {$account.email} + {$account.org} + {$account.phone} + {$account.numb_requests} + {$account.numb_registrants} + {$account.date_created.timestamp|date_format:"%D"} + + + + + + + + + + +
Close Account Detail
+
+
+

{if $account.is_member}Member ID: {$account.member_id}  {if $account.active}Active{/if}{/if}

+

+ {if $account.lname != '' || $account.fname != '' || $account.title != ''} + {$account.lname}, {$account.fname}{if $account.title}{if $account.lname != '' || $account.fname != ''} - {/if}{$account.title}{/if} + {/if}
+ {if $account.org != ''}{$account.org}
{/if} + {if $account.add1 != ''}{$account.addr1}
{/if} + {if $account.add2 != ''}{$account.addr2}
{/if} + {if $account.city != ''}{$account.city}{/if} + {if $account.state.value != ''}{if $account.city != ''},ddd {/if}{$account.state.name}{/if} + {if $account.country.value}{$account.country.name}{/if} + {if $account.city || $account.state.value || $account.country.value}
{/if} + {if $account.phone != ''}Phone: {$account.phone}
{/if} + {if $account.email != ''}Email Address: {$account.email}
{/if} +

+ +
+ {if $account.numb_requests} +
+

+

Requests Submitted

+

+ + + + + + + + + {foreach $account.requests as $request} + + + + + + + + {/foreach} +
IDDate SubmittedPay MethodStatus{$terms.reg_term_attendee_plur_cap}
{$request.id}{$request.date_submitted.datetime}{$request.pay_method.name}{$request.status.name}{$request.registrants}
+

+ {/if} + {if $account.numb_registrants} +
+

+

{$terms.reg_term_event_plur_cap} {$terms.reg_term_attended}/{$terms.reg_term_attending}

+

+ + + + + + + + + + + {foreach $account.registrants as $registrant} + + + + + + + + + + {/foreach} +
IDName{$terms.reg_term_event_cap}LevelRateRequeest StatusAttending
{$registrant.id}{$registrant.fname} {$registrant.lname}{$registrant.event_name}{$registrant.class_name}{$registrant.rate_name}{$registrant.request_status_name}{if $registrant.not_attending.value}No{else}Yes{/if}
+

+ {/if} +
+ + {/foreach} @@ -115,6 +203,39 @@ } } }); + + // Account Line Hover Action + var accountEditId = false; + var accountHoverId = false; + $('.glm-account-line').mouseenter( function() { + if (accountEditId) { + return; + } + accountHoverId = $(this).attr('data-account'); + $('.glm-account-links').addClass('glm-hidden'); + $('#accountLinks_' + accountHoverId).removeClass('glm-hidden'); + }); + + // Account Edit Action + $('.glm-account-link').on('click', function() { + if (accountEditId) { + $('.glm-account-edit-area').addClass('glm-hidden'); + accountEditId = false; + return; + } + accountEditId = $(this).attr('data-account'); + $('#accountEdit_' + accountEditId).removeClass('glm-hidden'); + }); + + // Close edit action + $('.close-account-edit-area').on('click', function() { + if (accountEditId) { + $('.glm-account-edit-area').addClass('glm-hidden'); + accountEditId = false; + return; + } + }); + }); diff --git a/views/admin/registrations/eventsDashboard.html b/views/admin/registrations/eventsDashboard.html index 8d1e972..9771900 100755 --- a/views/admin/registrations/eventsDashboard.html +++ b/views/admin/registrations/eventsDashboard.html @@ -142,8 +142,8 @@ - - Edit Request Status | + + Edit Request Status | View Request Detail