52 lines
1.7 KiB
PHP
52 lines
1.7 KiB
PHP
<?php
|
|
include('../include/headscript.php');
|
|
$conn = new mysqli($servername, $username, $password, $database);
|
|
if ($conn->connect_error) {
|
|
die("Connection failed: " . $conn->connect_error);
|
|
}
|
|
|
|
// Recupera il nome del fornitore
|
|
$supplierName = isset($_GET['supplier']) ? $conn->real_escape_string($_GET['supplier']) : '';
|
|
|
|
if (empty($supplierName)) {
|
|
echo json_encode(['error' => 'Supplier name not provided.']);
|
|
exit;
|
|
}
|
|
|
|
// Query SQL per ottenere i dettagli delle analisi FAIL
|
|
$query = "
|
|
SELECT
|
|
av.nameanalysisvoc AS analysis_name,
|
|
r.reportsNumberLab AS report_number, -- Numero del rapporto
|
|
p.products_description AS product_description,
|
|
p.products_refnumber AS product_refnumber, -- Numero di riferimento del prodotto
|
|
r.idreports AS report_id -- ID del rapporto per eventuali azioni o collegamenti
|
|
FROM products p
|
|
JOIN reports r ON p.idproducts = r.idproducts
|
|
JOIN parts pt ON r.idreports = pt.idreports
|
|
JOIN analysis_project ap ON pt.idParts = ap.idPart
|
|
JOIN analysisvocabulary av ON ap.result_TestName = av.idanalysisvocabulary
|
|
WHERE p.namesupplier = 'PONTOGLIO S.P.A.'
|
|
AND LOWER(ap.test_Rating) IN ('fail', 'f', 'doesn\'t comply');
|
|
";
|
|
|
|
$result = $conn->query($query);
|
|
|
|
if (!$result) {
|
|
echo json_encode(['error' => $conn->error]);
|
|
exit;
|
|
}
|
|
|
|
$failDetails = [];
|
|
while ($row = $result->fetch_assoc()) {
|
|
$failDetails[] = [
|
|
'analysis_name' => $row['analysis_name'],
|
|
'report_number' => $row['report_number'],
|
|
'product_refnumber' => $row['product_refnumber'],
|
|
'product_description' => $row['product_description'],
|
|
'report_id' => $row['report_id'],
|
|
];
|
|
}
|
|
|
|
echo json_encode(['failDetails' => $failDetails]);
|