diff --git a/public/userarea/class/VisualLimsApiClient.php b/public/userarea/class/VisualLimsApiClient.php index 21c19675..e9b4a808 100644 --- a/public/userarea/class/VisualLimsApiClient.php +++ b/public/userarea/class/VisualLimsApiClient.php @@ -120,4 +120,4 @@ class VisualLimsApiClient return $data; } -} \ No newline at end of file +} diff --git a/public/userarea/class/block_alert.php b/public/userarea/class/block_alert.php new file mode 100644 index 00000000..e2e2f5c0 --- /dev/null +++ b/public/userarea/class/block_alert.php @@ -0,0 +1,68 @@ + [Nominativo, CodiceASL], letta una sola volta per richiesta + static $clienti = null; + + $useFatturazione = !empty($clienteFatturazione); + $targetId = $useFatturazione ? (int) $clienteFatturazione : (int) $clienteId; + + if ($targetId <= 0) { + return null; + } + + if ($clienti === null) { + $clienti = []; + $cacheFile = dirname(__DIR__) . '/cache/clienti.json'; + + if (!is_file($cacheFile)) { + error_log("getClientBlockAlert: cache clienti non trovata ({$cacheFile}), controllo saltato"); + return null; + } + + $json = json_decode((string) file_get_contents($cacheFile), true); + foreach (($json['value'] ?? []) as $c) { + $clienti[(int) ($c['IdCliente'] ?? 0)] = [ + 'nominativo' => trim((string) ($c['Nominativo'] ?? '')), + 'codiceASL' => trim((string) ($c['CodiceASL'] ?? '')), + ]; + } + } + + $cliente = $clienti[$targetId] ?? null; + if (!$cliente) { + return null; + } + + $motivo = $cliente['codiceASL']; + if ($motivo === '' || stripos($motivo, 'blocco') === false) { + return null; + } + + return [ + 'idCliente' => $targetId, + 'nominativo' => $cliente['nominativo'], + 'motivo' => $motivo, + 'campo' => $useFatturazione ? 'Fatturazione avanzata' : 'Client', + ]; + } +} diff --git a/public/userarea/exportLims_gridData.js b/public/userarea/exportLims_gridData.js index cfd68f48..e719be45 100644 --- a/public/userarea/exportLims_gridData.js +++ b/public/userarea/exportLims_gridData.js @@ -42,6 +42,23 @@ } window.noPriceBadgeHTML = noPriceBadgeHTML; + // Riquadro "cliente bloccato" per la finestra di export singolo + function blockAlertHTML(b) { + if (!b || !b.motivo) return ""; + return ( + `