147 lines
7.1 KiB
PHP
147 lines
7.1 KiB
PHP
<?= $this->extend('layout/management_layout') ?>
|
|
<?= $this->section('content') ?>
|
|
<div class="container-fluid">
|
|
<div class="wrapper">
|
|
<div class="content">
|
|
<br>
|
|
<h2 class="text-center mt-4 mb-3">School Calendar</h2>
|
|
<?php
|
|
$addParams = array_filter([
|
|
'school_year' => $schoolYear ?? '',
|
|
'semester' => $semester ?? '',
|
|
], fn($value) => $value !== '');
|
|
$addQuery = $addParams ? ('?' . http_build_query($addParams)) : '';
|
|
?>
|
|
<div class="d-flex gap-2 mb-3 justify-content-end">
|
|
<a href="/administrator/calendar_add_event<?= $addQuery ?>" class="btn btn-success">Add New Event</a>
|
|
</div>
|
|
<br>
|
|
|
|
<!-- School Year / Semester Filter Form -->
|
|
<form method="get" action="<?= base_url('administrator/calendar_view') ?>" class="mb-3 text-center d-flex gap-2 justify-content-center align-items-end flex-wrap">
|
|
<div>
|
|
<label for="school_year" class="form-label">School Year:</label>
|
|
<select name="school_year" id="school_year" class="form-select w-auto d-inline-block ms-2">
|
|
<?php foreach (range(date('Y') + 1, 2023) as $y):
|
|
$sy = ($y - 1) . '-' . $y; ?>
|
|
<option value="<?= $sy ?>" <?= $sy === ($schoolYear ?? '') ? 'selected' : '' ?>>
|
|
<?= $sy ?>
|
|
</option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<label for="semester" class="form-label">Semester:</label>
|
|
<?php $semVal = (string)($semester ?? ($_GET['semester'] ?? '')); ?>
|
|
<select name="semester" id="semester" class="form-select w-auto d-inline-block ms-2">
|
|
<option value="">—</option>
|
|
<option value="Fall" <?= (strcasecmp($semVal,'Fall')===0?'selected':'') ?>>Fall</option>
|
|
<option value="Spring" <?= (strcasecmp($semVal,'Spring')===0?'selected':'') ?>>Spring</option>
|
|
</select>
|
|
</div>
|
|
<div>
|
|
<button type="submit" class="btn btn-secondary">Apply</button>
|
|
<a href="<?= base_url('administrator/calendar_view') ?>" class="btn btn-outline-secondary">Reset</a>
|
|
</div>
|
|
</form>
|
|
|
|
<?php if (session()->getFlashdata('success')): ?>
|
|
<div class="alert alert-success">
|
|
<?= session()->getFlashdata('success') ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php
|
|
$emailStatus = session()->getFlashdata('email_status');
|
|
$emailStatusClass = session()->getFlashdata('email_status_class') ?? 'info';
|
|
?>
|
|
<?php if ($emailStatus): ?>
|
|
<div class="alert alert-<?= esc($emailStatusClass) ?>">
|
|
<?= esc($emailStatus) ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<?php if (session()->getFlashdata('error')): ?>
|
|
<div class="alert alert-danger">
|
|
<?= session()->getFlashdata('error') ?>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="table-responsive mb-3">
|
|
<table id="myTable" class="display">
|
|
<thead>
|
|
<tr>
|
|
<th>ID</th>
|
|
<th>Title</th>
|
|
<th>Type</th>
|
|
<th>Description</th>
|
|
<th>Date</th>
|
|
<th>Notify Parent</th>
|
|
<th>Notify Teacher</th>
|
|
<th>Notify Admin</th>
|
|
<th>No School</th>
|
|
<th>Actions</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php if (!empty($events)): ?>
|
|
<?php if ($emailStatus): ?>
|
|
<tr class="table-warning">
|
|
<td colspan="10" class="text-center small">
|
|
<?= esc($emailStatus) ?>
|
|
</td>
|
|
</tr>
|
|
<?php endif; ?>
|
|
<?php foreach ($events as $event): ?>
|
|
<tr>
|
|
<td><?= esc($event['id']) ?></td>
|
|
<td><?= esc($event['title']) ?></td>
|
|
<td><?= esc($event['event_type'] ?? '—') ?></td>
|
|
<td><?= esc($event['description']) ?></td>
|
|
<td><?= esc(!empty($event['date']) ? date('m-d-Y', strtotime($event['date'])) : '') ?></td>
|
|
<td>
|
|
<input type="checkbox" disabled <?= $event['notify_parent'] ? 'checked' : '' ?>>
|
|
</td>
|
|
<td>
|
|
<input type="checkbox" disabled <?= $event['notify_teacher'] ? 'checked' : '' ?>>
|
|
</td>
|
|
<td>
|
|
<input type="checkbox" disabled <?= $event['notify_admin'] ? 'checked' : '' ?>>
|
|
</td>
|
|
<td>
|
|
<input type="checkbox" disabled <?= !empty($event['no_school']) ? 'checked' : '' ?>>
|
|
</td>
|
|
<td>
|
|
<a href="/administrator/calendar_edit/<?= $event['id'] ?>" class="btn btn-primary btn-sm">Edit</a>
|
|
<form action="/administrator/calendar_delete/<?= $event['id'] ?>" method="post" style="display:inline;">
|
|
<?= csrf_field() ?>
|
|
<button type="submit" class="btn btn-danger btn-sm"
|
|
onclick="return confirm('Are you sure you want to delete this event?')">Delete</button>
|
|
</form>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
<?php else: ?>
|
|
<tr>
|
|
<td colspan="10" class="text-center">No events found</td>
|
|
</tr>
|
|
<?php endif; ?>
|
|
</tbody>
|
|
|
|
</table>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<?= $this->endSection() ?>
|
|
|
|
<?= $this->section('scripts') ?>
|
|
<script>
|
|
$(document).ready(function() {
|
|
$('#myTable').DataTable();
|
|
});
|
|
</script>
|
|
<?= $this->endSection() ?>
|