diff --git a/public/userarea/statkpi/parsedatachart.php b/public/userarea/statkpi/parsedatachart.php index 385b3e1..81bfcbf 100644 --- a/public/userarea/statkpi/parsedatachart.php +++ b/public/userarea/statkpi/parsedatachart.php @@ -249,17 +249,19 @@ $otherConditions = implode("', '", array_map('addslashes', RATING_OTHER)); // Query per il grafico a barre orizzontali con sezioni multicolore $horizontalBarQuery = " SELECT - p.$groupingField AS groupingValue, + COALESCE(p.$groupingField, 'empty') AS groupingValue, SUM(CASE WHEN UPPER(r.reportsRating) IN ('$passConditions') THEN 1 ELSE 0 END) AS passCount, SUM(CASE WHEN UPPER(r.reportsRating) IN ('$failConditions') THEN 1 ELSE 0 END) AS failCount, SUM(CASE WHEN UPPER(r.reportsRating) NOT IN ('$passConditions', '$failConditions') THEN 1 ELSE 0 END) AS otherCount FROM reports r LEFT JOIN products p ON r.idproducts = p.idproducts $filters - GROUP BY p.$groupingField + GROUP BY COALESCE(p.$groupingField, 'empty') + LIMIT 20 "; + $horizontalBarResult = $conn->query($horizontalBarQuery); $horizontalBarData = []; while ($row = $horizontalBarResult->fetch_assoc()) { @@ -274,7 +276,7 @@ while ($row = $horizontalBarResult->fetch_assoc()) { // Query per ottenere il conteggio di Pass, Fail e altri dalle analisi $horizontalBarAnalysisQuery = " SELECT - p.$groupingField AS groupingValue, + COALESCE(p.$groupingField, 'empty') AS groupingValue, SUM(CASE WHEN UPPER(ap.test_Rating) IN ('PASS', 'P', 'COMPLIES') THEN 1 ELSE 0 END) AS passCount, SUM(CASE WHEN UPPER(ap.test_Rating) IN ('FAIL', 'F', 'DOESN\'T COMPLY') THEN 1 ELSE 0 END) AS failCount, SUM(CASE WHEN UPPER(ap.test_Rating) NOT IN ('PASS', 'P', 'COMPLIES', 'FAIL', 'F', 'DOESN\'T COMPLY') THEN 1 ELSE 0 END) AS otherCount @@ -282,9 +284,11 @@ $horizontalBarAnalysisQuery = " LEFT JOIN reports r ON ap.idreports = r.idreports LEFT JOIN products p ON r.idproducts = p.idproducts $filters - GROUP BY p.$groupingField + GROUP BY COALESCE(p.$groupingField, 'empty') + LIMIT 20 "; + $horizontalBarAnalysisResult = $conn->query($horizontalBarAnalysisQuery); $horizontalBarAnalysisData = []; while ($row = $horizontalBarAnalysisResult->fetch_assoc()) { @@ -339,7 +343,9 @@ $productBySupplierQuery = " FROM products p WHERE p.namesupplier IS NOT NULL $suPfilters GROUP BY p.namesupplier - ORDER BY totalProducts DESC"; + ORDER BY totalProducts DESC + LIMIT 30 + "; $productBySupplierResult = $conn->query($productBySupplierQuery); $productBySupplier = []; @@ -450,6 +456,7 @@ $analysisDistributionQuery = " $filters GROUP BY ap.result_TestName ORDER BY totalTests DESC + LIMIT 20 ";