maintaince module
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/auth_check.php';
|
||||
|
||||
mnt_require_permission('maintenance.maintenances.view');
|
||||
|
||||
try {
|
||||
$pdo = mnt_pdo();
|
||||
|
||||
$id = (int)($_GET['id'] ?? 0);
|
||||
|
||||
if ($id <= 0) {
|
||||
mnt_json_fail('ID non valido.');
|
||||
}
|
||||
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT m.*, e.name AS equipment_name
|
||||
FROM maint_maintenances m
|
||||
INNER JOIN inv_equipment e ON e.id = m.equipment_id
|
||||
WHERE m.id = ?
|
||||
");
|
||||
$stmt->execute([$id]);
|
||||
$maintenance = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$maintenance) {
|
||||
mnt_json_fail('Manutenzione non trovata.');
|
||||
}
|
||||
|
||||
$stmt = $pdo->prepare("
|
||||
SELECT id, original_name, size
|
||||
FROM maint_maintenance_files
|
||||
WHERE maintenance_id = ?
|
||||
ORDER BY created_at ASC
|
||||
");
|
||||
$stmt->execute([$id]);
|
||||
|
||||
mnt_json_ok([
|
||||
'maintenance' => $maintenance,
|
||||
'files' => $stmt->fetchAll(PDO::FETCH_ASSOC),
|
||||
]);
|
||||
} catch (Throwable $e) {
|
||||
mnt_json_fail('Errore: ' . $e->getMessage());
|
||||
}
|
||||
Reference in New Issue
Block a user