From 485748859ecfe03e258e03333964614c1a58a772 Mon Sep 17 00:00:00 2001 From: solocla Date: Mon, 6 Jul 2026 15:54:20 +0200 Subject: [PATCH] fixed search clients --- public/userarea/gridRenderer.js | 6 +++--- public/userarea/search_clienti.php | 13 +++++++------ 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/public/userarea/gridRenderer.js b/public/userarea/gridRenderer.js index 4b9ee607..4048a94b 100644 --- a/public/userarea/gridRenderer.js +++ b/public/userarea/gridRenderer.js @@ -71,6 +71,7 @@ client.text || "Nome non disponibile" ).trim(); + const id = client.IdCliente || client.id || ""; const codiceCliente = ( client.CodiceCliente ?? client.codiceCliente ?? @@ -84,9 +85,8 @@ const shortCode = suffix || (codiceCliente ? codiceCliente.charAt(0) : "--"); - // Nome - I - CODICE_COMPLETO - const codePart = codiceCliente ? ` - ${codiceCliente}` : ""; - return `${nome} - ${shortCode}${codePart}`; + // Nome - I - 123 + return `${nome} - ${shortCode} - ${id}`; } // Cache of resolved client names: id → name diff --git a/public/userarea/search_clienti.php b/public/userarea/search_clienti.php index 75a4d6ce..165214ca 100644 --- a/public/userarea/search_clienti.php +++ b/public/userarea/search_clienti.php @@ -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