prepare(" SELECT e.*, c.name AS category_name, pl.name AS line_name, pl.line_number, d.name AS department_name FROM inv_equipment e LEFT JOIN inv_categories c ON c.id = e.category_id LEFT JOIN production_lines pl ON pl.id = e.line_id LEFT JOIN departments d ON d.id = e.department_id WHERE e.id = ? "); $stmt->execute([$equipmentId]); $equipment = $stmt->fetch(PDO::FETCH_ASSOC); if (!$equipment) { http_response_code(404); exit('Attrezzatura non trovata.'); } $stmt = $pdo->prepare(" SELECT m.*, sup.supplier_name, CONCAT(a.first_name, ' ', a.last_name) AS assignee_name FROM maint_maintenances m LEFT JOIN suppliers sup ON sup.idsupplier = m.supplier_id LEFT JOIN employees a ON a.id = m.assignee_employee_id WHERE m.equipment_id = ? AND m.is_active = 1 ORDER BY m.code ASC, m.title ASC "); $stmt->execute([$equipmentId]); $maintenances = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt = $pdo->prepare(" SELECT i.*, m.code AS maintenance_code, m.title AS maintenance_title, CONCAT(e.first_name, ' ', e.last_name) AS operator_full_name, sup.supplier_name FROM maint_interventions i INNER JOIN maint_maintenances m ON m.id = i.maintenance_id LEFT JOIN employees e ON e.id = i.operator_employee_id LEFT JOIN suppliers sup ON sup.idsupplier = i.supplier_id WHERE i.equipment_id = ? ORDER BY i.performed_at DESC, i.id DESC "); $stmt->execute([$equipmentId]); $interventions = $stmt->fetchAll(PDO::FETCH_ASSOC); $statusLabels = mnt_lookup($pdo, 'maint_status', ['planned' => 'Pianificato', 'in_progress' => 'In corso', 'completed' => 'Completato']); $resultLabels = mnt_lookup($pdo, 'maint_result', []); $executionLabels = mnt_execution_types(); ?>
, before any relative URL on the page $mntScriptName = $_SERVER['SCRIPT_NAME'] ?? ''; $mntPos = strpos($mntScriptName, '/userarea/'); $printBase = $mntPos !== false ? substr($mntScriptName, 0, $mntPos + strlen('/userarea/')) : '/userarea/'; ?>| Tipo | Intervento | Frequenza | Esecuzione |
|---|---|---|---|
| Nessuna manutenzione attiva definita. | |||
| = mnt_h($maintenance['code'] ?: '—') ?> |
= mnt_h($maintenance['title']) ?>
(critica)
= nl2br(mnt_h($maintenance['description'])) ?>
|
= mnt_h(mnt_format_frequency( $maintenance['frequency_value'] !== null ? (int)$maintenance['frequency_value'] : null, $maintenance['frequency_unit'], $maintenance['frequency_note'] )) ?> |
= mnt_h($executionLabels[$maintenance['execution_type']] ?? '') ?>
= mnt_h($maintenance['supplier_name']) ?>
= mnt_h($maintenance['assignee_name']) ?>
|
| Data | Tipo | Intervento / note | Operatore | Firma |
|---|---|---|---|---|
| Nessun intervento registrato. | ||||
| = mnt_format_date($intervention['performed_at']) ?> | = mnt_h($intervention['maintenance_code'] ?: '—') ?> |
= mnt_h($intervention['maintenance_title']) ?>
= mnt_h($statusLabels[$intervention['status']] ?? $intervention['status']) ?>
— = mnt_h($resultLabels[$intervention['result']] ?? $intervention['result']) ?>
= nl2br(mnt_h($intervention['notes'])) ?>
Materiali: = mnt_h($intervention['materials']) ?>
|
= mnt_h($intervention['operator_full_name'] ?: ($intervention['operator_name'] ?: '—')) ?>
= mnt_h($intervention['supplier_name']) ?>
|
|