add stats, and add history import details
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
<?php include('../../Connections/repnew.php'); ?>
|
||||
<?php include('../../Connections/repnew.php');
|
||||
include('../include/class/rating_definitions.php'); ?>
|
||||
<?php
|
||||
$conn = new mysqli($servername, $username, $password, $database);
|
||||
// error_reporting(1);
|
||||
@@ -238,6 +239,63 @@ while ($row = $topFailingAnalysisResult->fetch_assoc()) {
|
||||
$topFailingAnalysis[] = ['name' => $analysisName, 'failCount' => $row['failCount']];
|
||||
}
|
||||
|
||||
// Query per il grafico a barre orizzontali con raggruppamento basato su products_season
|
||||
// Gestione del raggruppamento dinamico dal POST
|
||||
$groupingField = isset($_POST['groupingField']) ? $_POST['groupingField'] : 'products_season';
|
||||
$passConditions = implode("', '", array_map('addslashes', RATING_PASS));
|
||||
$failConditions = implode("', '", array_map('addslashes', RATING_FAIL));
|
||||
$otherConditions = implode("', '", array_map('addslashes', RATING_OTHER));
|
||||
|
||||
// Query per il grafico a barre orizzontali con sezioni multicolore
|
||||
$horizontalBarQuery = "
|
||||
SELECT
|
||||
p.$groupingField 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
|
||||
";
|
||||
|
||||
|
||||
$horizontalBarResult = $conn->query($horizontalBarQuery);
|
||||
$horizontalBarData = [];
|
||||
while ($row = $horizontalBarResult->fetch_assoc()) {
|
||||
$horizontalBarData[] = [
|
||||
'groupingValue' => $row['groupingValue'],
|
||||
'passCount' => $row['passCount'],
|
||||
'failCount' => $row['failCount'],
|
||||
'otherCount' => $row['otherCount']
|
||||
];
|
||||
}
|
||||
|
||||
// Query per ottenere il conteggio di Pass, Fail e altri dalle analisi
|
||||
$horizontalBarAnalysisQuery = "
|
||||
SELECT
|
||||
p.$groupingField 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
|
||||
FROM analysis_project ap
|
||||
LEFT JOIN reports r ON ap.idreports = r.idreports
|
||||
LEFT JOIN products p ON r.idproducts = p.idproducts
|
||||
$filters
|
||||
GROUP BY p.$groupingField
|
||||
";
|
||||
|
||||
$horizontalBarAnalysisResult = $conn->query($horizontalBarAnalysisQuery);
|
||||
$horizontalBarAnalysisData = [];
|
||||
while ($row = $horizontalBarAnalysisResult->fetch_assoc()) {
|
||||
$horizontalBarAnalysisData[] = [
|
||||
'groupingValue' => $row['groupingValue'],
|
||||
'passCount' => (int)$row['passCount'],
|
||||
'failCount' => (int)$row['failCount'],
|
||||
'otherCount' => (int)$row['otherCount']
|
||||
];
|
||||
}
|
||||
|
||||
// Statistic for worst suppliers based on % of failed reports
|
||||
$worstSuppliersQuery = "
|
||||
SELECT p.namesupplier AS supplier, COUNT(r.idreports) AS totalReports,
|
||||
@@ -451,7 +509,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
'tesType' => $tesType,
|
||||
'numberLabs' => $numberLabs,
|
||||
'failedAnalytes' => $failedAnalytes,
|
||||
'analysisDistribution' => $analysisDistribution // Distribuzione delle analisi per il grafico a torta
|
||||
'analysisDistribution' => $analysisDistribution, // Distribuzione delle analisi per il grafico a torta
|
||||
'horizontalBarData' => $horizontalBarData, // Dati per il grafico a barre orizzontali
|
||||
'horizontalBarAnalysisData' => $horizontalBarAnalysisData // Nuovi dati per le analisi
|
||||
]);
|
||||
exit; // Ferma l'esecuzione del resto dello script dopo aver risposto all'AJAX
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user