0) { $stmt = $pdo->prepare("UPDATE reports SET object_id=?, report_type=?, title=?, description=?, findings=?, recommendations=?, work_done=?, cause_classification=?, status=?, result_status=? WHERE id=? AND created_by=?"); $stmt->execute([$objectId, $type, $title, $desc, $findings, $recs, $workDone, $cause, $status, $result, $id, $userId]); } else { $stmt = $pdo->prepare("INSERT INTO reports (object_id, created_by, report_type, title, description, findings, recommendations, work_done, cause_classification, status, result_status) VALUES (?,?,?,?,?,?,?,?,?,?,?)"); $stmt->execute([$objectId, $userId, $type, $title, $desc, $findings, $recs, $workDone, $cause, $status, $result]); } $message = 'Отчёт сохранён.'; auth_log($userId, 'report_save', "Object: $objectId"); } catch (\PDOException $e) { $message = 'Ошибка: ' . $e->getMessage(); } } } $editReport = null; if (isset($_GET['edit'])) { $stmt = $pdo->prepare("SELECT * FROM reports WHERE id=? AND created_by=?"); $stmt->execute([(int)$_GET['edit'], $userId]); $editReport = $stmt->fetch(); } $typeFilter = $_GET['type'] ?? ''; $sql = "SELECT r.*, o.name as object_name FROM reports r JOIN objects o ON o.id=r.object_id WHERE 1=1"; $params = []; if ($session['user_role'] === 'technician') { $sql .= " AND r.created_by = ?"; $params[] = $userId; } if ($typeFilter) { $sql .= " AND r.report_type = ?"; $params[] = $typeFilter; } $sql .= " ORDER BY r.created_at DESC"; $stmt = $pdo->prepare($sql); $stmt->execute($params); $reports = $stmt->fetchAll(); $objects = $pdo->query("SELECT id, name FROM objects WHERE status IN ('active','audit') ORDER BY name")->fetchAll(); $csrf = auth_csrf_token(); require __DIR__ . '/../../inc/header.php'; ?>
| Тип | Название | Объект | Статус | Результат | Дата | Действия |
|---|---|---|---|---|---|---|
| Нет отчётов | ||||||
| = $r['report_type'] ?> | = htmlspecialchars($r['title'] ?: 'Без названия') ?> | = htmlspecialchars($r['object_name']) ?> | = $r['status'] ?> | = $r['result_status'] ?> | = date('d.m.Y', strtotime($r['created_at'])) ?> | ✏️ |