diff --git a/app/Controllers/Doctor.php b/app/Controllers/Doctor.php index 0e56182..1cdf466 100644 --- a/app/Controllers/Doctor.php +++ b/app/Controllers/Doctor.php @@ -5,6 +5,7 @@ namespace App\Controllers; use App\Models\AppointmentModel; use App\Models\DoctorModel; use CodeIgniter\HTTP\RedirectResponse; +use CodeIgniter\HTTP\ResponseInterface; class Doctor extends BaseController { @@ -55,7 +56,7 @@ class Doctor extends BaseController if ($this->request->is('post')) { $rules = [ 'specialization' => 'required|min_length[2]|max_length[191]', - 'experience' => 'permit_empty|max_length[100]', + 'experience' => 'required|max_length[100]', 'fees' => 'permit_empty|decimal', 'available_from' => 'permit_empty', 'available_to' => 'permit_empty', @@ -85,7 +86,7 @@ class Doctor extends BaseController return view('doctor/profile', ['doctor' => $doctor]); } - public function accept($id): RedirectResponse + public function accept($id): ResponseInterface { if ($r = $this->requireRole('doctor')) { return $r; @@ -98,7 +99,7 @@ class Doctor extends BaseController return $this->updateAppointmentStatus((int) $id, 'approved'); } - public function reject($id): RedirectResponse + public function reject($id): ResponseInterface { if ($r = $this->requireRole('doctor')) { return $r; @@ -131,6 +132,7 @@ class Doctor extends BaseController return redirect()->back()->with('error', 'Invalid appointment.'); } + $status = \App\Models\AppointmentModel::normalizeStatus($status); $appointmentModel->update($appointmentId, ['status' => $status]); return redirect()->back()->with('success', 'Appointment updated.'); diff --git a/app/Views/admin/add_doctor.php b/app/Views/admin/add_doctor.php new file mode 100644 index 0000000..3f8ae90 --- /dev/null +++ b/app/Views/admin/add_doctor.php @@ -0,0 +1,94 @@ + + +
+ + +| Sl No | +Name | +Specialization | +Action | +
|---|---|---|---|
| = $i++ ?> | += esc($doc->name) ?> | += esc($doc->specialization ?? 'N/A') ?> | ++ + Delete + + | +
⏰ = esc($a->appointment_time) ?>
- - = esc(ucfirst((string) $a->status)) ?> - + status); + if ($st === '') { + $st = 'pending'; + } elseif ($st === 'confirmed') { + $st = 'approved'; + } elseif ($st === 'cancelled') { + $st = 'rejected'; + } + + $badgeClass = match ($st) { + 'pending' => 'bg-warning text-dark', + 'approved' => 'bg-success', + 'rejected' => 'bg-danger', + default => 'bg-secondary', + }; + ?> + = esc(ucfirst($st)) ?>
-