fixed search clients
This commit is contained in:
@@ -30,6 +30,7 @@ function isInattivo(array $c): bool
|
||||
function formatClientLabel(array $client): string
|
||||
{
|
||||
$name = trim($client['Nominativo'] ?? '');
|
||||
$id = trim((string)($client['IdCliente'] ?? ''));
|
||||
$code = trim((string)($client['CodiceCliente'] ?? ''));
|
||||
|
||||
$parts = explode('_', $code);
|
||||
@@ -43,9 +44,7 @@ function formatClientLabel(array $client): string
|
||||
$suffix = '--';
|
||||
}
|
||||
|
||||
$codePart = $code !== '' ? ' - ' . $code : '';
|
||||
|
||||
return $name . ' - ' . $suffix . $codePart;
|
||||
return $name . ' - ' . $suffix . ' - ' . $id;
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -109,14 +108,16 @@ try {
|
||||
$name = trim($c['Nominativo'] ?? '');
|
||||
$code = trim($c['CodiceCliente'] ?? '');
|
||||
|
||||
// Cerca solo su ciò che viene visualizzato: Nome - Lettera - ID
|
||||
$label = formatClientLabel($c);
|
||||
|
||||
if (
|
||||
$q === '' ||
|
||||
mb_strpos(mb_strtolower($name), $q) !== false ||
|
||||
mb_strpos(mb_strtolower($code), $q) !== false
|
||||
mb_strpos(mb_strtolower($label), $q) !== false
|
||||
) {
|
||||
$results[] = [
|
||||
'id' => $c['IdCliente'],
|
||||
'text' => formatClientLabel($c),
|
||||
'text' => $label,
|
||||
'IdCliente' => $c['IdCliente'],
|
||||
'Nominativo' => $name,
|
||||
'CodiceCliente' => $code
|
||||
|
||||
Reference in New Issue
Block a user