From 9d71e0e7657a8d181d5c90b34249f2604d7a6cb1 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Fri, 16 Mar 2018 16:55:15 -0400 Subject: [PATCH] Add account name search to account list page. Can search by account name. --- models/admin/billing/accounts.php | 13 +++++++++++++ views/admin/billing/accounts.html | 29 +++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/models/admin/billing/accounts.php b/models/admin/billing/accounts.php index 3cd9350..54a4f4d 100644 --- a/models/admin/billing/accounts.php +++ b/models/admin/billing/accounts.php @@ -122,6 +122,8 @@ class GlmMembersAdmin_billing_accounts extends GlmDataAccounts $annFromDate = ''; $annToDate = ''; $totalAccounts = false; + $allAccounts = false; + $filterAccounts = false; // Get any provided option if (isset($_REQUEST['option'])) { @@ -287,6 +289,8 @@ class GlmMembersAdmin_billing_accounts extends GlmDataAccounts case 'list': default: + $allAccounts = $this->getSimpleAccountList(); + $where_params = array( 'true' ); // Check for paging @@ -366,6 +370,13 @@ class GlmMembersAdmin_billing_accounts extends GlmDataAccounts $annTo_date = date( 'Y-m-d', strtotime( $annToDate ) ); $where_params[] = "T.anniversary_date <= '$annTo_date'"; } + if ( isset( $_REQUEST['filterAccounts'] ) + && $filterAccounts = filter_var( $_REQUEST['filterAccounts'], FILTER_VALIDATE_INT ) + ) { + $accounts[$filterAccounts]['selected'] = true; + $where_params[] = "T.id = $filterAccounts"; + } + // Build the $where string from the $where_parts array. // By implode with AND. @@ -435,6 +446,8 @@ class GlmMembersAdmin_billing_accounts extends GlmDataAccounts 'annFromDate' => $annFromDate, 'annToDate' => $annToDate, 'totalAccounts' => $totalAccounts, + 'allAccounts' => $allAccounts, + 'filterAccounts' => $filterAccounts, ); // Return status, any suggested view, and any data to controller diff --git a/views/admin/billing/accounts.html b/views/admin/billing/accounts.html index d2c727b..e8f9467 100644 --- a/views/admin/billing/accounts.html +++ b/views/admin/billing/accounts.html @@ -24,6 +24,12 @@ To Date:
+ + Member Account:  + + + +
@@ -86,6 +92,29 @@ dateFormat: 'mm/dd/yy' }); + var availableAccounts = [ + {foreach $allAccounts as $m} + { label: "{$m.ref_name|unescape:'html'|replace:'"':''}", value: "{$m.ref_name|unescape:'html'|replace:'"':''}", id: '{$m.id}' }, + {/foreach} + ] + + $('#account_name').autocomplete({ + source: availableAccounts, + select: function( event, ui ){ + $('#member-account').val( ui.item.id ); + }, + }); + + {if $filterAccounts} + {$selected = 0} + {foreach $accounts as $m} + {if $m.id == $filterAccounts} + {$selected = $m.ref_name|unescape:'html'|replace:'"':''} + {/if} + {/foreach} + $('#account_name').autocomplete().val('{$selected}'); + {/if} + }); -- 2.17.1