73 lines
3.1 KiB
PHP
73 lines
3.1 KiB
PHP
<?php
|
|
require_once __DIR__ . '/../layout.php';
|
|
|
|
$error = $_SESSION['error'] ?? null;
|
|
unset($_SESSION['error']);
|
|
|
|
ob_start();
|
|
?>
|
|
|
|
<div class="card">
|
|
<div class="card-header text-center text-white">
|
|
<i class="bi bi-<?= $isEdit ? 'pencil-square' : 'calendar-plus' ?> icon-large"></i>
|
|
<h4 class="mt-2 mb-0"><?= $isEdit ? 'Edytuj wydarzenie' : 'Nowe wydarzenie' ?></h4>
|
|
</div>
|
|
<div class="card-body p-4">
|
|
<?php if (isset($error)): ?>
|
|
<div class="alert alert-danger alert-dismissible fade show" role="alert">
|
|
<i class="bi bi-exclamation-triangle-fill me-2"></i>
|
|
<?= htmlspecialchars($error) ?>
|
|
<button type="button" class="btn-close" data-bs-dismiss="alert"></button>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<form method="POST" action="<?= $isEdit ? '/kalendarz/zapisz/' . $event['id'] : '/kalendarz/dodaj' ?>">
|
|
<div class="mb-3">
|
|
<label for="title" class="form-label">
|
|
<i class="bi bi-type me-1"></i>Tytuł wydarzenia
|
|
</label>
|
|
<input type="text" class="form-control" id="title" name="title"
|
|
value="<?= htmlspecialchars($event['title'] ?? '') ?>"
|
|
placeholder="Np. Spotkanie z klientem" required autofocus>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label for="event_date" class="form-label">
|
|
<i class="bi bi-calendar-date me-1"></i>Data
|
|
</label>
|
|
<input type="date" class="form-control" id="event_date" name="event_date"
|
|
value="<?= htmlspecialchars($event['event_date'] ?? $selectedDate) ?>" required>
|
|
</div>
|
|
|
|
<div class="mb-4">
|
|
<label for="content" class="form-label">
|
|
<i class="bi bi-text-paragraph me-1"></i>Opis (opcjonalnie)
|
|
</label>
|
|
<textarea class="form-control" id="content" name="content" rows="4"
|
|
placeholder="Dodatkowe informacje o wydarzeniu..."><?= htmlspecialchars($event['content'] ?? '') ?></textarea>
|
|
</div>
|
|
|
|
<div class="d-grid gap-2">
|
|
<button type="submit" class="btn btn-primary btn-lg">
|
|
<i class="bi bi-check-lg me-2"></i><?= $isEdit ? 'Zapisz zmiany' : 'Dodaj wydarzenie' ?>
|
|
</button>
|
|
<?php
|
|
$backUrl = '/kalendarz';
|
|
if ($isEdit && isset($event['event_date'])) {
|
|
$backUrl = '/kalendarz/dzien/' . $event['event_date'];
|
|
} elseif (isset($selectedDate)) {
|
|
$backUrl = '/kalendarz/dzien/' . $selectedDate;
|
|
}
|
|
?>
|
|
<a href="<?= $backUrl ?>" class="btn btn-outline-secondary">
|
|
<i class="bi bi-arrow-left me-2"></i>Anuluj
|
|
</a>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
</div>
|
|
|
|
<?php
|
|
$content = ob_get_clean();
|
|
renderLayout($isEdit ? 'Edytuj wydarzenie' : 'Nowe wydarzenie', $content, true, 'kalendarz', 'col-md-6');
|