Files
2026-05-17 05:22:06 +03:00

141 lines
6.8 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
require_once __DIR__ . '/../../inc/auth.php';
require_once __DIR__ . '/../../inc/functions.php';
$session = auth_require('owner', 'engineer');
$pdo = getDB();
$id = (int)($_GET['id'] ?? 0);
$stmt = $pdo->prepare("SELECT op.*, o.name as object_name, u.full_name as author_name FROM object_passports op LEFT JOIN objects o ON o.id=op.object_id LEFT JOIN users u ON u.id=op.created_by WHERE op.id=?");
$stmt->execute([$id]);
$pass = $stmt->fetch();
if (!$pass) {
header('Location: passports.php');
exit;
}
$data = json_decode($pass['passport_data'], true) ?: [];
require __DIR__ . '/../../inc/header.php';
?>
<div class="main-header">
<div>
<h1>Паспорт объекта</h1>
<div class="breadcrumb"><a href="/service/dashboard.php">Главная</a> / <a href="passports.php">Паспорта</a> / #<?= $pass['id'] ?></div>
</div>
<a href="javascript:window.print()" class="btn btn-secondary btn-sm" data-tooltip="Распечатать">🖨️ Печать</a>
</div>
<div class="card" style="border-color:var(--accent);">
<div class="card-header">
<h2><?= htmlspecialchars($pass['object_name'] ?: 'Паспорт #' . $pass['id']) ?></h2>
<span class="badge badge-<?= object_class($pass['object_index']) ?>">Класс <?= object_class($pass['object_index']) ?></span>
</div>
<div class="card-grid">
<div>
<div class="card-value value-accent"><?= $pass['risk_score'] ?></div>
<div class="card-label">Оценка риска (<?= risk_label($pass['risk_score']) ?>)</div>
</div>
<div>
<div class="card-value value-info"><?= $pass['complexity_index'] ?></div>
<div class="card-label">Сложность обслуживания</div>
</div>
<div>
<div class="card-value"><?= $pass['object_index'] ?></div>
<div class="card-label">Индекс объекта · <?= object_class_label($pass['object_index']) ?></div>
</div>
<div>
<div class="card-value value-green"><?= fmt_money($pass['sla_price_monthly']) ?></div>
<div class="card-label">Стоимость SLA / месяц</div>
</div>
</div>
<p style="color:var(--text-muted);font-size:12px;">Автор: <?= htmlspecialchars($pass['author_name'] ?: '—') ?> · <?= date('d.m.Y H:i', strtotime($pass['created_at'])) ?></p>
</div>
<?php if (!empty($data['answers'])): $a = $data['answers']; ?>
<div class="card">
<h3 style="margin-bottom:12px;">Данные опросника</h3>
<div style="display:grid;grid-template-columns:repeat(auto-fill,minmax(280px,1fr));gap:12px;">
<?php foreach ([
'object_name' => 'Название объекта', 'object_type' => 'Тип объекта', 'address' => 'Адрес',
'area' => 'Площадь (м²)', 'employees' => 'Сотрудников',
'contact_person' => 'Контактное лицо', 'contact_phone' => 'Телефон',
'region_factor' => 'Регион',
'camera_count' => 'Количество камер', 'video_type' => 'Тип видеонаблюдения',
'archive_depth' => 'Глубина архива',
'access_points' => 'Точки СКУД', 'acs_vendor' => 'Производитель СКУД',
'fire_type' => 'Пожарная сигнализация',
'server_state' => 'Сервер', 'network_state' => 'Сеть', 'power_state' => 'Электропитание',
'service_state' => 'Обслуживание', 'resolution_time' => 'Время устранения',
'controller' => 'Контроль системы',
'sla_level' => 'Уровень SLA', 'visit_frequency' => 'Частота выездов',
'reaction_time' => 'Время реакции',
] as $key => $label): ?>
<?php if (!empty($a[$key])): ?>
<div>
<span style="color:var(--text-muted);font-size:11px;"><?= $label ?></span>
<div style="font-weight:600;"><?= htmlspecialchars(is_array($a[$key]) ? implode(', ', $a[$key]) : $a[$key]) ?></div>
</div>
<?php endif; ?>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<?php if (!empty($data)): ?>
<div class="card">
<h3 style="margin-bottom:12px;">Расчётные параметры</h3>
<div class="card-grid">
<div>
<div class="card-label">Компоненты оценки риска</div>
<div style="font-size:12px;">
<?php if (isset($data['risk_score'])): ?>
Оценка риска = <?= $data['risk_score'] ?><br>
<?php endif; ?>
<?php if (isset($data['complexity'])): ?>
Сложность = <?= $data['complexity'] ?><br>
<?php endif; ?>
<?php if (isset($data['infra_load'])): ?>
Нагрузка на инфраструктуру = <?= $data['infra_load'] ?><br>
<?php endif; ?>
<?php if (isset($data['service_history'])): ?>
История обслуживания = <?= $data['service_history'] ?>
<?php endif; ?>
</div>
</div>
<div>
<div class="card-label">Формула индекса объекта</div>
<div style="font-size:12px;">
(Риск × 0.4) + (Сложность × 0.3) + (Инфраструктура × 0.2) + (История × 0.1)<br>
<?php if (isset($data['object_index'])): ?>
= <strong><?= $data['object_index'] ?></strong>
<?php endif; ?>
</div>
</div>
<div>
<div class="card-label">Стоимость SLA</div>
<div style="font-size:12px;">
Базовая стоимость × Индекс объекта × Регион × Множитель риска<br>
<?php if (isset($data['sla_price'])): ?>
= <strong><?= fmt_money($data['sla_price']) ?></strong> / мес
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php endif; ?>
<div style="margin-top:16px;">
<a href="questionnaire.php?id=<?= $pass['session_id'] ?>" class="btn btn-secondary btn-sm" data-tooltip="Открыть опросник">📝 Опросник</a>
<?php if ($pass['object_id']): ?>
<a href="../owner/objects.php?edit=<?= $pass['object_id'] ?>" class="btn btn-secondary btn-sm" data-tooltip="Перейти к объекту">🏢 Объект</a>
<a href="../owner/sla.php?object_id=<?= $pass['object_id'] ?>" class="btn btn-secondary btn-sm" data-tooltip="Создать SLA контракт">📋 Создать SLA</a>
<?php endif; ?>
</div>
<?php require __DIR__ . '/../../inc/footer.php'; ?>