150 lines
7.5 KiB
PHP
150 lines
7.5 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<title>Patient Dashboard</title>
|
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
|
<link rel="stylesheet" href="<?= base_url('css/app.css') ?>">
|
|
<link rel="stylesheet" href="<?= base_url('css/dashboard.css') ?>">
|
|
</head>
|
|
<body class="app-body overview-layout">
|
|
<?php $validationErrors = validation_errors(); ?>
|
|
|
|
<aside class="ov-sidebar" id="sidebar">
|
|
<div class="ov-brand"><h1><i class="bi bi-hospital me-1"></i> DoctGuide</h1><span>Patient Panel</span></div>
|
|
<nav class="ov-nav">
|
|
<div class="ov-nav__section">Patient</div>
|
|
<a href="<?= base_url('patient/dashboard') ?>" class="ov-nav__link active"><i class="bi bi-calendar2-plus"></i> Book Appointment</a>
|
|
</nav>
|
|
<div class="ov-sidebar__footer"><a href="<?= base_url('logout') ?>"><i class="bi bi-box-arrow-left"></i> Logout</a></div>
|
|
</aside>
|
|
|
|
<div class="ov-main" id="mainContent">
|
|
<header class="ov-topbar">
|
|
<div class="d-flex align-items-center">
|
|
<button class="ov-toggle-btn" onclick="toggleSidebar()" title="Toggle Sidebar"><i class="bi bi-list" id="toggleIcon"></i></button>
|
|
<p class="ov-topbar__title mb-0">Book Appointment</p>
|
|
</div>
|
|
</header>
|
|
|
|
<main class="ov-content">
|
|
<?php if (session()->getFlashdata('success')): ?>
|
|
<div class="alert alert-success app-alert"><?= esc(session()->getFlashdata('success')) ?></div>
|
|
<?php endif; ?>
|
|
<?php if (session()->getFlashdata('error')): ?>
|
|
<div class="alert alert-danger app-alert"><?= 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="ov-panel mb-4">
|
|
<div class="ov-panel__header">
|
|
<h2 class="ov-panel__title">My Appointments</h2>
|
|
</div>
|
|
<div class="p-0">
|
|
<table class="table ov-mini-table mb-0">
|
|
<thead>
|
|
<tr>
|
|
<th class="ps-3">Doctor</th>
|
|
<th>Date</th>
|
|
<th>Time</th>
|
|
<th>Status</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($myAppointments as $ap): ?>
|
|
<tr>
|
|
<td class="ps-3">
|
|
<?= esc($ap->doctor_name) ?>
|
|
<?php if (! empty($ap->specialization)): ?>
|
|
<br><span class="text-muted small"><?= esc($ap->specialization) ?></span>
|
|
<?php endif; ?>
|
|
</td>
|
|
<td><?= esc($ap->appointment_date) ?></td>
|
|
<td><?= esc($ap->appointment_time) ?></td>
|
|
<td>
|
|
<?php
|
|
$st = trim((string) $ap->status);
|
|
if ($st === '') {
|
|
$st = 'pending';
|
|
} elseif ($st === 'confirmed') {
|
|
$st = 'approved';
|
|
} elseif ($st === 'cancelled') {
|
|
$st = 'rejected';
|
|
}
|
|
|
|
$badgeClass = match ($st) {
|
|
'pending' => 'ov-badge ov-badge--warning',
|
|
'approved' => 'ov-badge ov-badge--success',
|
|
'rejected' => 'ov-badge ov-badge--danger',
|
|
default => 'ov-badge',
|
|
};
|
|
?>
|
|
<span class="<?= $badgeClass ?>"><?= esc(ucfirst($st)) ?></span>
|
|
</td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<?php endif; ?>
|
|
|
|
<div class="ov-panel mb-3">
|
|
<div class="ov-panel__header">
|
|
<h2 class="ov-panel__title">Available Doctors</h2>
|
|
</div>
|
|
<div class="ov-panel__body">
|
|
<?php if (! empty($doctors)): ?>
|
|
<div class="row g-3">
|
|
<?php foreach ($doctors as $doc): ?>
|
|
<div class="col-md-6 col-xl-4">
|
|
<div class="border rounded-3 p-3 h-100">
|
|
<h6 class="mb-1">Dr. <?= esc($doc->name) ?></h6>
|
|
<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 else: ?>
|
|
<p class="text-muted mb-0">No doctors available yet.</p>
|
|
<?php endif; ?>
|
|
</div>
|
|
</div>
|
|
</main>
|
|
</div>
|
|
|
|
<script>
|
|
function toggleSidebar() {
|
|
const sidebar = document.getElementById('sidebar');
|
|
const main = document.getElementById('mainContent');
|
|
const icon = document.getElementById('toggleIcon');
|
|
sidebar.classList.toggle('collapsed');
|
|
main.classList.toggle('expanded');
|
|
icon.className = sidebar.classList.contains('collapsed') ? 'bi bi-layout-sidebar' : 'bi bi-list';
|
|
}
|
|
</script>
|
|
</body>
|
|
</html>
|