fix event issues

This commit is contained in:
root
2026-04-19 12:05:10 -04:00
parent 35988e9ce1
commit 596d368b1d
7 changed files with 239 additions and 29 deletions
+76 -3
View File
@@ -4,6 +4,12 @@
<div class="container mt-4">
<h2>Edit Event</h2>
<?php
$defaultCategories = ['Fun Event-1', 'Fun Event-2', 'Fun Event-3'];
$existingCategories = array_map('strval', $categories ?? []);
$allCategories = array_unique(array_merge($defaultCategories, $existingCategories));
?>
<?php if (session()->getFlashdata('error')): ?>
<div class="alert alert-danger"><?= session()->getFlashdata('error') ?></div>
<?php endif; ?>
@@ -23,7 +29,7 @@
<label class="form-label">Category</label>
<select name="event_category" class="form-control" required>
<option value="" disabled <?= empty($event['event_category']) ? 'selected' : '' ?>>Select category</option>
<?php foreach (($categories ?? []) as $category): ?>
<?php foreach ($allCategories as $category): ?>
<option value="<?= esc($category) ?>" <?= (string)($event['event_category'] ?? '') === (string)$category ? 'selected' : '' ?>>
<?= esc(ucwords($category)) ?>
</option>
@@ -33,7 +39,7 @@
<div class="mb-3">
<label class="form-label">Description</label>
<textarea name="description" class="form-control"><?= esc($event['description']) ?></textarea>
<textarea id="event_description" name="description" class="form-control"><?= esc($event['description']) ?></textarea>
</div>
<div class="mb-3">
@@ -44,7 +50,7 @@
<div class="mb-3">
<label class="form-label">Current Flyer</label><br>
<?php if ($event['flyer']): ?>
<img src="<?= base_url('writable/uploads/' . $event['flyer']) ?>" width="150" class="mb-2">
<img src="<?= base_url('uploads/' . ltrim((string) $event['flyer'], '/')) ?>" width="150" class="mb-2">
<?php else: ?>
<div class="text-muted">No flyer uploaded.</div>
<?php endif; ?>
@@ -70,6 +76,37 @@
<input type="text" name="school_year" class="form-control" value="<?= esc($event['school_year']) ?>" required>
</div>
<div class="card mb-3">
<div class="card-header">School Calendar</div>
<div class="card-body">
<div class="form-check mb-2">
<input class="form-check-input" type="checkbox" id="add_to_calendar" name="add_to_calendar" value="1">
<label class="form-check-label" for="add_to_calendar">
Add this event to the school calendar
</label>
</div>
<div id="calendar_recipients" class="ms-3" style="display:none;">
<div class="mb-2 fw-semibold">Visible On Calendars</div>
<div class="d-flex flex-wrap gap-3">
<label class="form-check-label">
<input class="form-check-input me-1" type="checkbox" name="notify_parent" value="1" checked>
Parents
</label>
<label class="form-check-label">
<input class="form-check-input me-1" type="checkbox" name="notify_teacher" value="1" checked>
Teachers
</label>
<label class="form-check-label">
<input class="form-check-input me-1" type="checkbox" name="notify_admin" value="1" checked>
Admins
</label>
</div>
<div class="form-text">If none are selected, the event is visible to everyone.</div>
</div>
</div>
</div>
<div class="card mb-3">
<div class="card-header">Parent Email Broadcast</div>
<div class="card-body">
@@ -89,3 +126,39 @@
</div>
<?= $this->endSection() ?>
<?= $this->section('scripts') ?>
<script src="<?= base_url('assets/tinymce/tinymce.min.js') ?>"></script>
<script>
(function () {
const toggle = document.getElementById('add_to_calendar');
const recipients = document.getElementById('calendar_recipients');
const description = document.getElementById('event_description');
if (toggle && recipients) {
function sync() {
recipients.style.display = toggle.checked ? '' : 'none';
}
toggle.addEventListener('change', sync);
sync();
}
if (description && window.tinymce) {
tinymce.init({
selector: '#event_description',
base_url: '<?= base_url('assets/tinymce') ?>',
suffix: '.min',
license_key: 'gpl',
height: 320,
menubar: true,
branding: false,
promotion: false,
plugins: 'advlist autolink lists link charmap preview anchor searchreplace visualblocks code fullscreen insertdatetime table help wordcount',
toolbar: 'undo redo | blocks | bold italic underline strikethrough forecolor backcolor | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link table | removeformat | preview code',
convert_urls: false,
content_style: 'body { font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif; font-size: 14px; }'
});
}
})();
</script>
<?= $this->endSection() ?>