first commit
This commit is contained in:
@@ -0,0 +1,134 @@
|
||||
<h1 class="h3 mb-3">Создание поля</h1>
|
||||
|
||||
<?php if (!empty($_SESSION['error'])): ?>
|
||||
<div class="alert alert-danger">
|
||||
<?= htmlspecialchars((string)$_SESSION['error']) ?>
|
||||
</div>
|
||||
<?php unset($_SESSION['error']); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($_SESSION['success'])): ?>
|
||||
<div class="alert alert-success">
|
||||
<?= htmlspecialchars((string)$_SESSION['success']) ?>
|
||||
</div>
|
||||
<?php unset($_SESSION['success']); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<form method="post" action="/admin/boards/fields/store">
|
||||
<input type="hidden" name="board_id" value="<?= (int)$board['id'] ?>">
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Доска</label>
|
||||
<input type="text" class="form-control" value="<?= htmlspecialchars((string)$board['name']) ?>" disabled>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Код</label>
|
||||
<input type="text" name="code" class="form-control" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Название</label>
|
||||
<input type="text" name="name" class="form-control" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Тип поля</label>
|
||||
<select name="field_type" class="form-select" id="field_type">
|
||||
<option value="text">text</option>
|
||||
<option value="textarea">textarea</option>
|
||||
<option value="number">number</option>
|
||||
<option value="date">date</option>
|
||||
<option value="select">select</option>
|
||||
<option value="checkbox">checkbox</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="mb-3" id="select_options_wrap" style="display:none;">
|
||||
<label class="form-label">Варианты select</label>
|
||||
<textarea name="select_options" class="form-control" rows="5" placeholder="Каждый вариант с новой строки"></textarea>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Порядок</label>
|
||||
<input type="number" name="sort_order" class="form-control" value="100">
|
||||
</div>
|
||||
|
||||
<div class="form-check mb-2">
|
||||
<input class="form-check-input" type="checkbox" name="is_required" id="is_required">
|
||||
<label class="form-check-label" for="is_required">Обязательное</label>
|
||||
</div>
|
||||
|
||||
<div class="form-check mb-3">
|
||||
<input class="form-check-input" type="checkbox" name="is_active" id="is_active" checked>
|
||||
<label class="form-check-label" for="is_active">Активное</label>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-success">Создать</button>
|
||||
<a href="/admin/boards/fields?id=<?= (int)$board['id'] ?>" class="btn btn-secondary">Назад</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($fields)): ?>
|
||||
<div class="card shadow-sm mt-4">
|
||||
<div class="card-body">
|
||||
<h5 class="mb-3">Уже созданные поля</h5>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-sm align-middle mb-0">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Код</th>
|
||||
<th>Название</th>
|
||||
<th>Тип</th>
|
||||
<th>Порядок</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($fields as $field): ?>
|
||||
<tr>
|
||||
<td><?= (int)$field['id'] ?></td>
|
||||
<td><?= htmlspecialchars((string)$field['code']) ?></td>
|
||||
<td><?= htmlspecialchars((string)$field['name']) ?></td>
|
||||
<td><?= htmlspecialchars((string)$field['field_type']) ?></td>
|
||||
<td><?= (int)$field['sort_order'] ?></td>
|
||||
<td>
|
||||
<div class="d-flex gap-2">
|
||||
<a href="/admin/boards/fields/edit?id=<?= (int)$field['id'] ?>" class="btn btn-sm btn-outline-primary">
|
||||
Изменить
|
||||
</a>
|
||||
|
||||
<form method="post" action="/admin/boards/fields/delete" onsubmit="return confirm('Удалить поле и все его значения у задач?');" class="d-inline">
|
||||
<input type="hidden" name="id" value="<?= (int)$field['id'] ?>">
|
||||
<button type="submit" class="btn btn-sm btn-outline-danger">
|
||||
Удалить
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const fieldType = document.getElementById('field_type');
|
||||
const wrap = document.getElementById('select_options_wrap');
|
||||
|
||||
if (fieldType && wrap) {
|
||||
fieldType.addEventListener('change', function () {
|
||||
wrap.style.display = this.value === 'select' ? 'block' : 'none';
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
$settings = json_decode((string)($field['settings_json'] ?? ''), true);
|
||||
$optionsText = '';
|
||||
|
||||
if (!empty($settings['options']) && is_array($settings['options'])) {
|
||||
$optionsText = implode("\n", $settings['options']);
|
||||
}
|
||||
?>
|
||||
|
||||
<h1 class="h3 mb-3">Изменение поля</h1>
|
||||
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<form method="post" action="/admin/boards/fields/update">
|
||||
<input type="hidden" name="id" value="<?= (int)$field['id'] ?>">
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Доска</label>
|
||||
<input type="text" class="form-control" value="<?= htmlspecialchars((string)$field['board_name']) ?>" disabled>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Код</label>
|
||||
<input type="text" name="code" class="form-control" value="<?= htmlspecialchars((string)$field['code']) ?>" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Название</label>
|
||||
<input type="text" name="name" class="form-control" value="<?= htmlspecialchars((string)$field['name']) ?>" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Тип поля</label>
|
||||
<select name="field_type" class="form-select" id="field_type">
|
||||
<?php foreach (['text','textarea','number','date','select','checkbox'] as $type): ?>
|
||||
<option value="<?= $type ?>" <?= $field['field_type'] === $type ? 'selected' : '' ?>>
|
||||
<?= $type ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="mb-3" id="select_options_wrap" style="<?= $field['field_type'] === 'select' ? '' : 'display:none;' ?>">
|
||||
<label class="form-label">Варианты select</label>
|
||||
<textarea name="select_options" class="form-control" rows="5"><?= htmlspecialchars($optionsText) ?></textarea>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Порядок</label>
|
||||
<input type="number" name="sort_order" class="form-control" value="<?= (int)$field['sort_order'] ?>">
|
||||
</div>
|
||||
|
||||
<div class="form-check mb-2">
|
||||
<input class="form-check-input" type="checkbox" name="is_required" id="is_required" <?= (int)$field['is_required'] ? 'checked' : '' ?>>
|
||||
<label class="form-check-label" for="is_required">Обязательное</label>
|
||||
</div>
|
||||
|
||||
<div class="form-check mb-3">
|
||||
<input class="form-check-input" type="checkbox" name="is_active" id="is_active" <?= (int)$field['is_active'] ? 'checked' : '' ?>>
|
||||
<label class="form-check-label" for="is_active">Активное</label>
|
||||
</div>
|
||||
|
||||
<button type="submit" class="btn btn-success">Сохранить</button>
|
||||
<a href="/admin/boards/fields?id=<?= (int)$field['board_id'] ?>" class="btn btn-secondary">Назад</a>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.getElementById('field_type').addEventListener('change', function () {
|
||||
document.getElementById('select_options_wrap').style.display = this.value === 'select' ? 'block' : 'none';
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,93 @@
|
||||
<h1 class="h3 mb-3">Создание поля</h1>
|
||||
|
||||
<?php if (!empty($_SESSION['error'])): ?>
|
||||
<div class="alert alert-danger">
|
||||
<?= htmlspecialchars($_SESSION['error']) ?>
|
||||
</div>
|
||||
<?php unset($_SESSION['error']); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="d-flex justify-content-between align-items-center mb-3">
|
||||
<div>
|
||||
<h1 class="h3 mb-0">Поля доски</h1>
|
||||
<div class="text-muted small">
|
||||
<?= htmlspecialchars((string)$board['name']) ?> (<?= htmlspecialchars((string)$board['code']) ?>)
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="/admin/boards/fields/create?board_id=<?= (int)$board['id'] ?>" class="btn btn-primary">
|
||||
+ Создать поле
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<?php if (!empty($_SESSION['success'])): ?>
|
||||
<div class="alert alert-success">
|
||||
<?= htmlspecialchars($_SESSION['success']) ?>
|
||||
</div>
|
||||
<?php unset($_SESSION['success']); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if (!empty($_SESSION['error'])): ?>
|
||||
<div class="alert alert-danger">
|
||||
<?= htmlspecialchars($_SESSION['error']) ?>
|
||||
</div>
|
||||
<?php unset($_SESSION['error']); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="card shadow-sm">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle mb-0">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Код</th>
|
||||
<th>Название</th>
|
||||
<th>Тип</th>
|
||||
<th>Обязательное</th>
|
||||
<th>Активно</th>
|
||||
<th>Порядок</th>
|
||||
<th style="width: 220px;">Действия</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach ($fields as $field): ?>
|
||||
<tr>
|
||||
<td><?= (int)$field['id'] ?></td>
|
||||
<td><?= htmlspecialchars((string)$field['code']) ?></td>
|
||||
<td><?= htmlspecialchars((string)$field['name']) ?></td>
|
||||
<td><?= htmlspecialchars((string)$field['field_type']) ?></td>
|
||||
<td><?= (int)$field['is_required'] ? 'Да' : 'Нет' ?></td>
|
||||
<td><?= (int)$field['is_active'] ? 'Да' : 'Нет' ?></td>
|
||||
<td><?= (int)$field['sort_order'] ?></td>
|
||||
<td>
|
||||
<div class="d-flex gap-2">
|
||||
<a href="/admin/boards/fields/edit?id=<?= (int)$field['id'] ?>" class="btn btn-sm btn-outline-primary">
|
||||
Изменить
|
||||
</a>
|
||||
|
||||
<form method="post" action="/admin/boards/fields/delete" onsubmit="return confirm('Удалить поле и все его значения у задач?');" class="d-inline">
|
||||
<input type="hidden" name="id" value="<?= (int)$field['id'] ?>">
|
||||
<button type="submit" class="btn btn-sm btn-outline-danger">
|
||||
Удалить
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
|
||||
<?php if (empty($fields)): ?>
|
||||
<tr>
|
||||
<td colspan="8" class="text-center text-muted py-4">Поля пока не созданы</td>
|
||||
</tr>
|
||||
<?php endif; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.getElementById('field_type').addEventListener('change', function () {
|
||||
document.getElementById('select_options_wrap').style.display = this.value === 'select' ? 'block' : 'none';
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user