From: Steve Sutton Date: Wed, 1 Mar 2017 17:01:59 +0000 (-0500) Subject: Setup search form X-Git-Tag: v1.0.0^2~490 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=d8ef266eba0237edba31d07990584454cecd466c;p=WP-Plugins%2Fglm-member-db-registrations.git Setup search form Setting up the name search for account list page. --- diff --git a/classes/data/dataAccount.php b/classes/data/dataAccount.php index 444d156..d5923f5 100644 --- a/classes/data/dataAccount.php +++ b/classes/data/dataAccount.php @@ -584,4 +584,27 @@ class GlmDataRegistrationsAccount extends GlmDataAbstract return $r; } + /** + * Get ID/Name list + * + * @param string $where + * + * @return array ID/Name pairs + */ + public function getIdName( $where = 'true' ) + { + $savedFields = $this->fields; + + $this->fields = array( + 'id' => $savedFields['id'], + 'lname' => $savedFields['lname'], + 'fname' => $savedFields['fname'], + ); + + $r = $this->getList( $where ); + + $this->fields = $savedFields; + return $r; + + } } diff --git a/models/admin/registrations/accounts.php b/models/admin/registrations/accounts.php index f216f3f..7f26738 100644 --- a/models/admin/registrations/accounts.php +++ b/models/admin/registrations/accounts.php @@ -107,6 +107,7 @@ class GlmMembersAdmin_registrations_accounts extends GlmDataRegistrationsAccount $accountUpdateError = false; $accountAdded = false; $accountAddError = false; + $namesList = false; // Get any provided option if (isset($_REQUEST['option'])) { @@ -174,9 +175,19 @@ class GlmMembersAdmin_registrations_accounts extends GlmDataRegistrationsAccount $view = 'account'; default: + $where = 'true'; $accounts = $this->getList(); $hasAccounts = ( $accounts !== false && count( $accounts > 0 ) ) ? true: false; $view = 'account'; + + // Check if we have a Text Search string + if (isset($_REQUEST['textSearch']) && trim($_REQUEST['textSearch']) != '') { + $textSearch = trim($_REQUEST['textSearch']); + $where .= " AND ( lname LIKE '%$textSearch%' OR fname LIKE '%$textSearch%' OR CONCAT_WS( ' ', fname, lname) LIKE '%$textSearch%' )"; + } + + // Get full list of names matching this where clause for search box + $namesList = $this->getIdName($where); break; } @@ -201,6 +212,7 @@ class GlmMembersAdmin_registrations_accounts extends GlmDataRegistrationsAccount 'option' => $option, 'accountAdded' => $accountAdded, 'accountAddError' => $accountAddError, + 'namesList' => $namesList, ); // Return status, any suggested view, and any data to controller return array( diff --git a/views/admin/registrations/account.html b/views/admin/registrations/account.html index fdc0d77..7d51f9b 100644 --- a/views/admin/registrations/account.html +++ b/views/admin/registrations/account.html @@ -12,7 +12,7 @@

- Text Search: + Name Search:

@@ -64,5 +64,40 @@ + + {include file='admin/footer.html'}