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 ( + `
` + + `Cliente bloccato (${escHtml(b.campo)}): ` + + `${escHtml(b.nominativo)} - ${escHtml(b.idCliente)}
` + + `${escHtml(b.motivo)}
` + ); + } + + // Badge "Bloccato" per l'elenco commesse dell'Export All + function blockBadgeHTML(b) { + if (!b || !b.motivo) return ""; + return ` Bloccato`; + } + function getGridRow(iddatadb) { return document.querySelector(`.grid-row[data-id="${iddatadb}"]`); } @@ -267,7 +284,8 @@ .map((n) => `
  • ${escHtml(n)}
  • `) .join("") + `` - : ""); + : "") + + blockAlertHTML(data.blockAlert); label.textContent = "Esportazione Completata"; } else { msg.textContent = `Errore: ${data.message}`; @@ -761,6 +779,7 @@ commessaweb: data.commessaweb, noPriceCount: data.noPriceCount || 0, noPriceAnalyses: data.noPriceAnalyses || [], + blockAlert: data.blockAlert || null, }); } else { failed++; @@ -835,11 +854,17 @@ const npCommesse = exportedList.filter( (x) => x.noPriceCount > 0, ).length; + const blockedCommesse = exportedList.filter( + (x) => x.blockAlert, + ).length; msgEl.innerHTML += `
    ` + (npCommesse > 0 ? `
    ${npCommesse} commesse con analisi senza prezzo
    ` : "") + + (blockedCommesse > 0 + ? `
    ${blockedCommesse} commesse con cliente bloccato
    ` + : "") + `
    Commesse esportate:
    ` + `