124 lines
4.8 KiB
PHP
124 lines
4.8 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Book Appointment</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="<?= base_url('css/app.css') ?>">
|
|
</head>
|
|
<body class="app-body app-page--patient">
|
|
|
|
<?php $validationErrors = validation_errors(); ?>
|
|
|
|
<div class="container py-5">
|
|
|
|
<h2 class="text-center mb-4 app-heading">Book appointment</h2>
|
|
|
|
<?php if (session()->getFlashdata('success')): ?>
|
|
<div class="alert alert-success app-alert text-center"><?= esc(session()->getFlashdata('success')) ?></div>
|
|
<?php endif; ?>
|
|
<?php if (session()->getFlashdata('error')): ?>
|
|
<div class="alert alert-danger app-alert text-center"><?= esc(session()->getFlashdata('error')) ?></div>
|
|
<?php endif; ?>
|
|
<?php if (! empty($validationErrors)): ?>
|
|
<div class="alert alert-danger app-alert"><?= validation_list_errors() ?></div>
|
|
<?php endif; ?>
|
|
|
|
<?php if (! empty($myAppointments)): ?>
|
|
<div class="card app-card-dashboard p-4 mb-5">
|
|
<h3 class="h5 mb-3">My appointments</h3>
|
|
<div class="table-responsive">
|
|
<table class="table table-bordered table-hover align-middle mb-0 small">
|
|
<thead class="table-light">
|
|
<tr>
|
|
<th>Doctor</th>
|
|
<th>Date</th>
|
|
<th>Time</th>
|
|
<th>Status</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($myAppointments as $ap): ?>
|
|
<tr>
|
|
<td>
|
|
<?= esc($ap->doctor_name) ?>
|
|
<?php if (! empty($ap->specialization)): ?>
|
|
<br><span class="text-muted"><?= esc($ap->specialization) ?></span>
|
|
<?php endif; ?>
|
|
</td>
|
|
<td><?= esc($ap->appointment_date) ?></td>
|
|
<td><?= esc($ap->appointment_time) ?></td>
|
|
<td>
|
|
<?php
|
|
$st = (string) $ap->status;
|
|
$badgeClass = match ($st) {
|
|
'pending' => 'bg-warning text-dark',
|
|
'approved' => 'bg-success',
|
|
'rejected' => 'bg-danger',
|
|
default => 'bg-secondary',
|
|
};
|
|
?>
|
|
<span class="badge <?= $badgeClass ?>"><?= esc(ucfirst($st)) ?></span>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<h3 class="h5 text-center mb-3 text-muted">Available doctors</h3>
|
|
|
|
<div class="row">
|
|
|
|
<?php foreach ($doctors as $doc): ?>
|
|
<div class="col-md-4 mb-4">
|
|
|
|
<div class="card app-card-dashboard p-4 h-100">
|
|
|
|
<h5 class="mb-2">👨⚕️ <?= esc($doc->name) ?></h5>
|
|
<p class="text-muted small mb-3">Specialization: <?= esc($doc->specialization ?? 'N/A') ?></p>
|
|
|
|
<form method="post" action="<?= base_url('book-appointment') ?>" class="app-form" novalidate>
|
|
<?= csrf_field() ?>
|
|
<input type="hidden" name="doctor_id" value="<?= esc($doc->doctor_id) ?>">
|
|
|
|
<div class="mb-2">
|
|
<label class="form-label small">Date</label>
|
|
<input type="date" name="date" value="<?= esc(old('date')) ?>"
|
|
class="form-control form-control-sm <?= ! empty($validationErrors['date']) ? 'is-invalid' : '' ?>"
|
|
required>
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
<label class="form-label small">Time</label>
|
|
<input type="time" name="time" value="<?= esc(old('time')) ?>"
|
|
class="form-control form-control-sm <?= ! empty($validationErrors['time']) ? 'is-invalid' : '' ?>"
|
|
required>
|
|
</div>
|
|
|
|
<button type="submit" class="btn btn-app-primary w-100 btn-sm">Book</button>
|
|
</form>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
<?php endforeach; ?>
|
|
|
|
</div>
|
|
|
|
<?php if (empty($doctors)): ?>
|
|
<p class="text-center text-muted">No doctors available yet.</p>
|
|
<?php endif; ?>
|
|
|
|
<div class="text-center mt-4">
|
|
<a href="<?= base_url('logout') ?>" class="btn btn-outline-danger btn-sm rounded-pill px-4">Logout</a>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|