fixed dettaglio worksheet

This commit is contained in:
2026-10-20 08:59:38 +02:00
parent 3209ac969f
commit 3f5c14836f
3 changed files with 584 additions and 220 deletions
+37 -1
View File
@@ -167,6 +167,7 @@ try {
exit;
}
// Mescole del foglio
$stmtMix = $pdo->prepare("
SELECT
wsm.*,
@@ -180,6 +181,30 @@ try {
$stmtMix->execute([$worksheetId]);
$mixRows = $stmtMix->fetchAll(PDO::FETCH_ASSOC);
// Imballi del foglio (come nella sezione 3 di manage-worksheet.php)
$stmtPkg = $pdo->prepare("
SELECT
wsp.id,
wsp.package_position,
pi.category AS package_category,
pi.item_name AS package_name,
pi.item_code AS package_item_code
FROM work_sheet_packages wsp
LEFT JOIN packaging_items pi ON pi.id = wsp.package_code
WHERE wsp.worksheet_id = ?
ORDER BY wsp.package_position ASC, wsp.id ASC
");
$stmtPkg->execute([$worksheetId]);
$packageRows = $stmtPkg->fetchAll(PDO::FETCH_ASSOC);
// Etichette dei menu a tendina (marchiatura, frequenze controllo, lubrificazione...)
// Prese tutte, anche le disattivate, così i fogli vecchi mostrano comunque l'etichetta
$lookups = [];
$stmtLk = $pdo->query("SELECT category, value, label FROM ws_lookup_options");
foreach ($stmtLk->fetchAll(PDO::FETCH_ASSOC) as $r) {
$lookups[$r['category']][(string)$r['value']] = $r['label'];
}
echo json_encode([
'success' => true,
'worksheet' => [
@@ -218,6 +243,7 @@ try {
'speed_actual_m_h' => $ws['speed_actual_m_h'] ?? '',
'approved_by' => $ws['approved_by'] ?? '',
'notes' => $ws['notes'] ?? '',
'source_xlsx_path' => $ws['source_xlsx_path'] ?? '',
'created_at' => $ws['created_at'] ?? '',
'created_at_it' => formatDateTimeIT($ws['created_at'] ?? ''),
'updated_at' => $ws['updated_at'] ?? '',
@@ -235,7 +261,17 @@ try {
'lubrication_type' => $r['lubrication_type'] ?? '',
'lubrication_notes' => $r['lubrication_notes'] ?? ''
];
}, $mixRows)
}, $mixRows),
'package_rows' => array_map(function ($r) {
return [
'id' => (int)$r['id'],
'package_position' => (int)$r['package_position'],
'package_category' => $r['package_category'] ?? '',
'package_name' => $r['package_name'] ?? '',
'package_item_code' => $r['package_item_code'] ?? ''
];
}, $packageRows),
'lookups' => (object)$lookups
]);
exit;
}