added fatturazione avanzata to template and imported

This commit is contained in:
2026-07-02 15:20:55 +02:00
parent 1476160a38
commit bef600ae11
6 changed files with 146 additions and 63 deletions
+18 -2
View File
@@ -19,6 +19,14 @@ $q = mb_strtolower(trim($_GET['q'] ?? ''));
$limit = max(1, min(50, intval($_GET['limit'] ?? 20)));
$id = isset($_GET['id']) ? intval($_GET['id']) : null;
$tipo = $_GET['tipo'] ?? ''; // 'attivo' | 'inattivo' | '' (nessun filtro)
function isInattivo(array $c): bool
{
$v = $c['Inattivo'] ?? false;
return $v === true || $v === 1 || $v === '1' || $v === 'true';
}
function formatClientLabel(array $client): string
{
$name = trim($client['Nominativo'] ?? '');
@@ -49,7 +57,7 @@ try {
$api = VisualLimsApiClient::getInstance();
$params = [
'$select' => 'IdCliente,Nominativo,CodiceCliente',
'$select' => 'IdCliente,Nominativo,CodiceCliente,Inattivo',
'$orderby' => 'Nominativo asc'
];
@@ -64,6 +72,14 @@ try {
$clients = $data['value'] ?? [];
// Filtro tipo, applicato SOLO alla ricerca, non al lookup per id
$searchClients = $clients;
if ($tipo === 'attivo') {
$searchClients = array_values(array_filter($clients, fn($c) => !isInattivo($c)));
} elseif ($tipo === 'inattivo') {
$searchClients = array_values(array_filter($clients, fn($c) => isInattivo($c)));
}
// If requesting by specific ID, used for loading selected value
if ($id !== null) {
foreach ($clients as $c) {
@@ -88,7 +104,7 @@ try {
// Search by query
$results = [];
foreach ($clients as $c) {
foreach ($searchClients as $c) {
$name = trim($c['Nominativo'] ?? '');
$code = trim($c['CodiceCliente'] ?? '');