added charts and fixed analysis component
This commit is contained in:
@@ -489,15 +489,21 @@ while ($row = $analysisDistributionResult->fetch_assoc()) {
|
||||
|
||||
// fecth analytes with most fails
|
||||
$failedAnalytesQuery = "
|
||||
SELECT c.namecompoundsvocabulary AS AnalyteName, COUNT(*) AS FailCount
|
||||
SELECT
|
||||
c.namecompoundsvocabulary AS AnalyteName,
|
||||
COUNT(*) AS FailCount
|
||||
FROM result_project rp
|
||||
LEFT JOIN compundsvocabulary c ON rp.result_AnalytsName = c.idcompoundsvocabulary
|
||||
WHERE LOWER(rp.result_AnalytsRating) IN ('f', 'fail', 'doesn\'t comply')
|
||||
LEFT JOIN reports r ON rp.idreports = r.idreports
|
||||
LEFT JOIN products p ON r.idproducts = p.idproducts
|
||||
$filters
|
||||
AND LOWER(rp.result_AnalytsRating) IN ('f', 'fail', 'doesn\'t comply')
|
||||
GROUP BY c.namecompoundsvocabulary
|
||||
ORDER BY FailCount DESC
|
||||
LIMIT 10;
|
||||
";
|
||||
|
||||
|
||||
$resultFailedAnalytes = mysqli_query($repnew, $failedAnalytesQuery) or die("Error in Selecting " . mysqli_error($repnew));
|
||||
|
||||
// Verifica se ci sono risultati
|
||||
@@ -510,6 +516,68 @@ while ($row = mysqli_fetch_assoc($resultFailedAnalytes)) {
|
||||
];
|
||||
}
|
||||
|
||||
// New Query: phasequery
|
||||
$phaseQuery = "
|
||||
SELECT
|
||||
p.products_phase AS phase,
|
||||
COUNT(*) AS totalProducts
|
||||
FROM products p
|
||||
LEFT JOIN reports r ON p.idproducts = r.idproducts
|
||||
$filters
|
||||
AND p.products_phase IS NOT NULL
|
||||
GROUP BY p.products_phase
|
||||
ORDER BY totalProducts DESC
|
||||
";
|
||||
|
||||
$phaseQueryResult = $conn->query($phaseQuery);
|
||||
|
||||
// Process the results
|
||||
$phaseData = [];
|
||||
while ($row = $phaseQueryResult->fetch_assoc()) {
|
||||
$phaseData[] = [
|
||||
'phase' => $row['phase'],
|
||||
'totalProducts' => $row['totalProducts']
|
||||
];
|
||||
}
|
||||
|
||||
// New Query: Phase ratings distribution
|
||||
$phaseRatingsQuery = "
|
||||
SELECT
|
||||
p.products_phase AS phase,
|
||||
SUM(CASE
|
||||
WHEN UPPER(r.reportsRating) IN ('PASS', 'P', 'COMPLY') THEN 1
|
||||
ELSE 0
|
||||
END) AS passCount,
|
||||
SUM(CASE
|
||||
WHEN UPPER(r.reportsRating) IN ('FAIL', 'F', 'DOESN\'T COMPLY') THEN 1
|
||||
ELSE 0
|
||||
END) AS failCount,
|
||||
SUM(CASE
|
||||
WHEN UPPER(r.reportsRating) NOT IN ('PASS', 'P', 'COMPLY', 'FAIL', 'F', 'DOESN\'T COMPLY') THEN 1
|
||||
ELSE 0
|
||||
END) AS otherCount
|
||||
FROM products p
|
||||
LEFT JOIN reports r ON p.idproducts = r.idproducts
|
||||
$filters
|
||||
AND p.products_phase IS NOT NULL
|
||||
GROUP BY p.products_phase
|
||||
ORDER BY p.products_phase ASC
|
||||
";
|
||||
|
||||
$phaseRatingsResult = $conn->query($phaseRatingsQuery);
|
||||
|
||||
// Process the results
|
||||
$phaseRatingsData = [];
|
||||
while ($row = $phaseRatingsResult->fetch_assoc()) {
|
||||
$phaseRatingsData[] = [
|
||||
'phase' => $row['phase'],
|
||||
'passCount' => (int)$row['passCount'],
|
||||
'failCount' => (int)$row['failCount'],
|
||||
'otherCount' => (int)$row['otherCount']
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
// Ora controlliamo se è una richiesta AJAX
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
// Rispondi ai dati aggiornati tramite AJAX
|
||||
@@ -537,7 +605,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
'failedAnalytes' => $failedAnalytes,
|
||||
'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
|
||||
'phaseData' => $phaseData,
|
||||
'horizontalBarAnalysisData' => $horizontalBarAnalysisData,
|
||||
'phaseRatingsData' => $phaseRatingsData // Nuovi dati per il grafico delle fasi
|
||||
]);
|
||||
exit; // Ferma l'esecuzione del resto dello script dopo aver risposto all'AJAX
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user