0) { $stmt = $pdo->prepare("UPDATE questionnaire_items SET step=?, section=?, question_key=?, label=?, type=?, options=?, required=?, sort_order=?, help_text=? WHERE id=?"); $stmt->execute([$step, $section, $key, $label, $type, $options, $required, $sortOrder, $helpText, $id]); } else { $stmt = $pdo->prepare("INSERT INTO questionnaire_items (step, section, question_key, label, type, options, required, sort_order, help_text) VALUES (?,?,?,?,?,?,?,?,?)"); $stmt->execute([$step, $section, $key, $label, $type, $options, $required, $sortOrder, $helpText]); } $message = $id > 0 ? 'Вопрос обновлён.' : 'Вопрос создан.'; } catch (\PDOException $e) { $message = 'Ошибка: ' . $e->getMessage(); } } } } // Delete item if (isset($_GET['delete']) && auth_csrf_verify($_GET['csrf'] ?? '')) { $pdo->prepare("DELETE FROM questionnaire_items WHERE id=?")->execute([(int)$_GET['delete']]); $message = 'Вопрос удалён.'; } // Toggle active if (isset($_GET['toggle']) && auth_csrf_verify($_GET['csrf'] ?? '')) { $pdo->prepare("UPDATE questionnaire_items SET is_active=NOT is_active WHERE id=?")->execute([(int)$_GET['toggle']]); $message = 'Статус изменён.'; } $editItem = null; if (isset($_GET['edit'])) { $stmt = $pdo->prepare("SELECT * FROM questionnaire_items WHERE id=?"); $stmt->execute([(int)$_GET['edit']]); $editItem = $stmt->fetch(); } $stepFilter = (int)($_GET['step'] ?? 0); if ($stepFilter > 0) { $stmt = $pdo->prepare("SELECT * FROM questionnaire_items WHERE step=? ORDER BY sort_order, id"); $stmt->execute([$stepFilter]); } else { $stmt = $pdo->query("SELECT * FROM questionnaire_items ORDER BY step, sort_order, id"); } $items = $stmt->fetchAll(); $stepLabels = [1 => 'Коммерческий', 2 => 'Технический', 3 => 'Эксплуатация', 4 => 'Риски', 5 => 'Расчёт SLA']; $csrf = auth_csrf_token(); require __DIR__ . '/../../inc/header.php'; ?>
| Шаг | Секция | Ключ | Название | Тип | Обяз. | Порядок | Статус | Действия |
|---|---|---|---|---|---|---|---|---|
| Нет вопросов | ||||||||
| = $item['step'] ?> | = htmlspecialchars($item['section']) ?> | = htmlspecialchars($item['question_key']) ?> |
= htmlspecialchars($item['label']) ?> | = $item['type'] ?> | = $item['required'] ? '✓' : '—' ?> | = $item['sort_order'] ?> | = $item['is_active'] ? 'Активен' : 'Отключён' ?> | ✏️ 🔄 🗑️ |