revert stats_export files to pre-a1e91f8 version

This commit is contained in:
2026-08-04 20:10:27 +02:00
parent 601e72ca61
commit 14a7cc2738
2 changed files with 23 additions and 23 deletions
@@ -17,11 +17,11 @@ try {
$year = $dm->format('Y');
// --- Export per cliente (status = 'l', filtro mese) ---
// tot = numero commesse, parts = numero parti/campioni (+1 per commessa)
// tot = numero commesse, parts = numero parti/campioni
$stmtC = $pdo->prepare("
SELECT d.idclient AS idclient,
COUNT(DISTINCT d.iddatadb) AS tot,
COUNT(ip.id) + COUNT(DISTINCT d.iddatadb) AS parts
COUNT(ip.id) AS parts
FROM datadb d
LEFT JOIN identification_parts ip ON ip.iddatadb = d.iddatadb
WHERE d.status = 'l'
@@ -43,12 +43,12 @@ try {
}
// --- Export per utente (status = 'l', filtro mese) ---
// tot = numero commesse, parts = numero parti/campioni (+1 per commessa)
// tot = numero commesse, parts = numero parti/campioni
$stmtU = $pdo->prepare("
SELECT d.user_id AS user_id,
TRIM(CONCAT(COALESCE(u.first_name,''),' ',COALESCE(u.last_name,''))) AS username,
COUNT(DISTINCT d.iddatadb) AS tot,
COUNT(ip.id) + COUNT(DISTINCT d.iddatadb) AS parts
COUNT(ip.id) AS parts
FROM datadb d
LEFT JOIN auth_users u ON u.id = d.user_id
LEFT JOIN identification_parts ip ON ip.iddatadb = d.iddatadb
@@ -80,11 +80,11 @@ try {
// --- Totale COMMESSE del mese ---
$totExport = array_sum(array_column($byClient, 'tot'));
// --- Totale PARTI/CAMPIONI del mese (status = 'l', +1 per commessa) ---
// --- Totale PARTI/CAMPIONI del mese (status = 'l') ---
$stmtP = $pdo->prepare("
SELECT COUNT(ip.id) + COUNT(DISTINCT d.iddatadb)
FROM datadb d
LEFT JOIN identification_parts ip ON ip.iddatadb = d.iddatadb
SELECT COUNT(*)
FROM identification_parts ip
INNER JOIN datadb d ON d.iddatadb = ip.iddatadb
WHERE d.status = 'l'
AND DATE_FORMAT(d.export_date, '%Y-%m') = :m
");
@@ -101,11 +101,11 @@ try {
$stmtY->execute(['y' => $year]);
$totExportYear = (int)$stmtY->fetchColumn();
// --- Totale PARTI dell'ANNO del mese selezionato (+1 per commessa) ---
// --- Totale PARTI dell'ANNO del mese selezionato ---
$stmtYP = $pdo->prepare("
SELECT COUNT(ip.id) + COUNT(DISTINCT d.iddatadb)
FROM datadb d
LEFT JOIN identification_parts ip ON ip.iddatadb = d.iddatadb
SELECT COUNT(*)
FROM identification_parts ip
INNER JOIN datadb d ON d.iddatadb = ip.iddatadb
WHERE d.status = 'l'
AND YEAR(d.export_date) = :y
");