Skip to content

Commit

Permalink
improvement: '@' prefix in customer quick search field means force se…
Browse files Browse the repository at this point in the history
…arching by altname
  • Loading branch information
chilek committed Aug 23, 2022
1 parent 9fbdd55 commit c11de6f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions doc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ version 28-git (????-??-??):
- devel/cleanup: renamed 'phpui.cache_documents' to 'documents.cache' [chilan]
- enhancement: introduced alternative name for customer
(important for brands/shortnames/casual names) [interduo]
- improvement: '@' prefix in customer quick search field means force searching
by altname [chilan]

version 27.0 (2021-08-20):

Expand Down
10 changes: 10 additions & 0 deletions modules/quicksearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,23 @@ function macformat($mac, $escape = false)
$search = str_replace('#', '', $search);
}

$resourceKeyOnly = preg_match('/^@.+/', $search) > 0;
if ($resourceKeyOnly) {
$search = str_replace('@', '', $search);
$sql_search = $DB->Escape("$search%");
}

switch ($mode) {
case 'customer':
if (empty($search) || (!ConfigHelper::checkPrivilege('customer_management') && !ConfigHelper::checkPrivilege('read_only'))) {
die;
}

if (isset($_GET['ajax'])) { // support for AutoSuggest
if ($resourceKeyOnly) {
$properties = array('altname' => 'altname');
}

$candidates = $DB->GetAll("SELECT c.id, cc.contact AS email, full_address AS address,
post_name, post_full_address AS post_address, deleted, altname,
" . $DB->Concat('UPPER(lastname)', "' '", 'c.name') . " AS customername,
Expand Down

0 comments on commit c11de6f

Please sign in to comment.