prepare(" SELECT e.*, c.name AS category_name, c.color AS category_color, pl.name AS line_name, pl.line_number, d.name AS department_name, cf.stored_name AS cover_stored 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 LEFT JOIN inv_equipment_files cf ON cf.id = e.cover_file_id WHERE e.id = ? "); $stmt->execute([$equipmentId]); $equipment = $stmt->fetch(PDO::FETCH_ASSOC); if (!$equipment) { http_response_code(404); exit('Attrezzatura non trovata.'); } // Photos and documents $stmt = $pdo->prepare("SELECT * FROM inv_equipment_files WHERE equipment_id = ? ORDER BY created_at ASC"); $stmt->execute([$equipmentId]); $files = $stmt->fetchAll(PDO::FETCH_ASSOC); $photos = array_values(array_filter($files, fn($f) => $f['kind'] === 'photo')); $documents = array_values(array_filter($files, fn($f) => $f['kind'] !== 'photo')); // Maintenances $maintenances = []; $interventionsByMaintenance = []; if ($canSeeMaintenances) { $stmt = $pdo->prepare(" SELECT m.*, CONCAT(a.first_name, ' ', a.last_name) AS assignee_name, CONCAT(s.first_name, ' ', s.last_name) AS supervisor_name, sup.supplier_name, (SELECT COUNT(*) FROM maint_interventions i WHERE i.maintenance_id = m.id) AS intervention_count, (SELECT COUNT(*) FROM maint_maintenance_files f WHERE f.maintenance_id = m.id) AS file_count FROM maint_maintenances m LEFT JOIN employees a ON a.id = m.assignee_employee_id LEFT JOIN employees s ON s.id = m.supervisor_employee_id LEFT JOIN suppliers sup ON sup.idsupplier = m.supplier_id WHERE m.equipment_id = ? ORDER BY m.is_active DESC, m.code ASC, m.title ASC "); $stmt->execute([$equipmentId]); $maintenances = $stmt->fetchAll(PDO::FETCH_ASSOC); $stmt = $pdo->prepare(" SELECT i.*, CONCAT(e.first_name, ' ', e.last_name) AS operator_full_name, sup.supplier_name, (SELECT COUNT(*) FROM maint_intervention_files f WHERE f.intervention_id = i.id) AS file_count FROM maint_interventions i 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]); foreach ($stmt->fetchAll(PDO::FETCH_ASSOC) as $intervention) { $interventionsByMaintenance[(int)$intervention['maintenance_id']][] = $intervention; } } $formData = mnt_form_data($pdo); $statuses = mnt_equipment_statuses(); $statusLabels = mnt_lookup($pdo, 'maint_status', ['planned' => 'Pianificato', 'in_progress' => 'In corso', 'completed' => 'Completato']); $resultLabels = mnt_lookup($pdo, 'maint_result', []); $typeLabels = mnt_intervention_types(); $executionLabels = mnt_execution_types(); $MNT_TITLE = $equipment['name']; ?>
Scheda PDF
Dati
Categoria
Linea
Linea —
Matricola
Numero di serie
Lotto / partita
Costruttore
Tipo
Acquisto
Messa in servizio
Reparto
Ubicazione
Descrizione
Note
Foto

Nessuna foto caricata.

Documenti

Nessun documento caricato.

Manutenzioni

Non hai i permessi per vedere le manutenzioni.

Nessuna manutenzione definita per questa attrezzatura.
Un'attrezzatura senza manutenzioni è esclusa dalle pianificazioni.

Critica Disattivata
· () ·
Ultimo: · Prossimo:
Incaricato: · Responsabile:
0): ?>
istruzioni