Files
CRM-IKZ/app/Views/tasks/create.php
T
2026-07-14 08:19:56 +04:00

158 lines
7.1 KiB
PHP
Raw 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.
<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="card shadow-sm">
<div class="card-body">
<form method="post" action="/tasks/store">
<div class="mb-3">
<label class="form-label">Доска</label>
<select name="board_id" class="form-select" required>
<option value="">Выберите доску</option>
<?php foreach ($boards as $board): ?>
<option value="<?= (int)$board['id'] ?>" <?= (($board_code ?? '') === ($board['code'] ?? '')) ? 'selected' : '' ?>>
<?= htmlspecialchars((string)$board['name']) ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="mb-3">
<label class="form-label">Постановщик</label>
<select name="creator_id" class="form-select" required>
<?php foreach ($users as $item): ?>
<option value="<?= (int)$item['id'] ?>" <?= (int)$item['id'] === (int)$user['id'] ? 'selected' : '' ?>>
<?= htmlspecialchars((string)($item['display_name'] ?: $item['login'])) ?>
</option>
<?php endforeach; ?>
</select>
</div>
<div class="mb-3">
<label class="form-label">Ответственный</label>
<select name="assignee_id" class="form-select">
<option value="">Не выбран</option>
<?php foreach ($users as $item): ?>
<option value="<?= (int)$item['id'] ?>">
<?= htmlspecialchars((string)($item['display_name'] ?: $item['login'])) ?>
</option>
<?php endforeach; ?>
</select>
</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>
<textarea name="description" class="form-control" rows="4"></textarea>
</div>
<div class="row g-3 mt-1">
<div class="col-md-6">
<label class="form-label">Дата постановки</label>
<input type="datetime-local" name="task_created_at" class="form-control">
</div>
<div class="col-md-6">
<label class="form-label">Дата план</label>
<input type="datetime-local" name="planned_at" class="form-control">
</div>
</div>
<?php foreach ($boardFields as $field): ?>
<div class="mb-3">
<label class="form-label">
<?= htmlspecialchars((string)$field['name']) ?>
</label>
<?php
$inputName = 'custom_field_' . (int)$field['id'];
$required = (int)$field['is_required'] === 1 ? 'required' : '';
?>
<?php if ($field['field_type'] === 'textarea'): ?>
<textarea
name="<?= $inputName ?>"
class="form-control"
<?= $required ?>
></textarea>
<?php elseif ($field['field_type'] === 'date'): ?>
<input
type="date"
name="<?= $inputName ?>"
class="form-control"
<?= $required ?>
>
<?php elseif ($field['field_type'] === 'number'): ?>
<input
type="number"
name="<?= $inputName ?>"
class="form-control"
<?= $required ?>
>
<?php elseif ($field['field_type'] === 'checkbox'): ?>
<div class="form-check">
<input
type="checkbox"
name="<?= $inputName ?>"
value="1"
class="form-check-input"
id="field_<?= (int)$field['id'] ?>"
>
<label class="form-check-label" for="field_<?= (int)$field['id'] ?>">
Да
</label>
</div>
<?php else: ?>
<input
type="text"
name="<?= $inputName ?>"
class="form-control"
<?= $required ?>
>
<?php endif; ?>
</div>
<?php endforeach; ?>
<div class="mb-3">
<label class="form-label">Статус</label>
<select name="status" class="form-select">
<option value="NEW">Новая</option>
<option value="IN_PROGRESS">В работе</option>
<option value="REVIEW">На проверке</option>
<option value="DONE">Закрыта</option>
<option value="CANCELED">Отменена</option>
<option value="OVERDUE">Просрочена</option>
</select>
</div>
<div class="mb-3">
<label class="form-label">Приоритет</label>
<select name="priority" class="form-select">
<option value="LOW">Низкий</option>
<option value="MEDIUM" selected>Средний</option>
<option value="HIGH">Высокий</option>
<option value="CRITICAL">Критический</option>
</select>
</div>
<input type="hidden" name="board_code" value="<?= htmlspecialchars((string)($board_code ?? '')) ?>">
<?php
$backUrl = !empty($board_code) ? '/boards/' . urlencode((string)$board_code) : '/tasks';
?>
<input type="hidden" name="board_code" value="<?= htmlspecialchars((string)($board_code ?? '')) ?>">
<button type="submit" class="btn btn-success">Создать</button>
<a href="<?= htmlspecialchars($backUrl) ?>" class="btn btn-secondary">Назад</a>
</form>
</div>
</div>