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;
+
+ }
}
$accountUpdateError = false;
$accountAdded = false;
$accountAddError = false;
+ $namesList = false;
// Get any provided option
if (isset($_REQUEST['option'])) {
$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;
}
'option' => $option,
'accountAdded' => $accountAdded,
'accountAddError' => $accountAddError,
+ 'namesList' => $namesList,
);
// Return status, any suggested view, and any data to controller
return array(
<div class="">
<p>
<span class="glm-nowrap">
- <b>Text Search: </b><input id="glmEventsSearch" name="textSearch" type="text" id="autoTest">
+ <b>Name Search: </b><input id="glmEventsSearch" name="textSearch" type="text" id="autoTest">
<input type="submit" value="Submit">
</span>
<p>
</form>
+ <script>
+ jQuery(document).ready(function($){
+ /*
+ * Do autocomplete search for member
+ * label: What will be searched
+ * value: What will be displayed when selected
+ * id: Member id added so we can go to the member while showing what was selected
+ * Also note that autocomplete does not properly render HTML codes, so we
+ * "unescape" them for HTML in Smarty.
+ */
+
+ var availableTags = [
+ {foreach $namesList as $e}
+ { label: "{$e.fname|replace:'"':"'"} {$e.lname|replace:'"':"'"}", value: "{$e.fname|replace:'"':"'"} {$e.lname|replace:'"':"'"}", id: '{$e.id}' },
+ {/foreach}
+ ];
+
+ $( "#glmEventsSearch" ).autocomplete({
+ source: availableTags,
+ html: true,
+ position: { my : "right top", at: "right bottom" },
+ select: function( event, ui ) {
+ var accountID = ui.item.id;
+ window.location.replace("{$adminUrl}?page=glm-members-admin-menu-registrations-accounts&glm_action=accounts&option=edit&account=" + accountID );
+ },
+ response: function(event, ui) {
+ if (!ui.content.length) {
+ var noResult = { value:"",label:"No results found" };
+ ui.content.push(noResult);
+ }
+ }
+ });
+ });
+ </script>
+
{include file='admin/footer.html'}