From 3760875a3dcb51941fd1d54c3cbbc39a4ffe2299 Mon Sep 17 00:00:00 2001 From: Sayan Das Date: Wed, 1 Apr 2026 19:30:56 +0530 Subject: [PATCH] Doctor_dashboard --- app/Controllers/Doctor.php | 8 +-- app/Views/admin/add_doctor.php | 94 +++++++++++++++++++++++++++++++++ app/Views/admin/doctors.php | 68 ++++++++++++++++++++++++ app/Views/doctor/dashboard.php | 46 ++++++++++------ app/Views/patient/dashboard.php | 10 +++- 5 files changed, 206 insertions(+), 20 deletions(-) create mode 100644 app/Views/admin/add_doctor.php create mode 100644 app/Views/admin/doctors.php 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 @@ + + + + + + Add doctor + + + + + + + +
+ +

Add doctor

+ + getFlashdata('error')): ?> +
getFlashdata('error')) ?>
+ + +
+ + +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+ + + +
+ +
+
+ + + +
+
+ + + +
+
+ +
+ Cancel + +
+
+ +
+ + + diff --git a/app/Views/admin/doctors.php b/app/Views/admin/doctors.php new file mode 100644 index 0000000..074f29d --- /dev/null +++ b/app/Views/admin/doctors.php @@ -0,0 +1,68 @@ + + + + + + Doctors + + + + + +
+ +

Doctors

+ + getFlashdata('success')): ?> +
getFlashdata('success')) ?>
+ + getFlashdata('error')): ?> +
getFlashdata('error')) ?>
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
Sl NoNameSpecializationAction
name) ?>specialization ?? 'N/A') ?> + + Delete + +
+ +
+ + + +
+ + + diff --git a/app/Views/doctor/dashboard.php b/app/Views/doctor/dashboard.php index 93e5c78..2dbe184 100644 --- a/app/Views/doctor/dashboard.php +++ b/app/Views/doctor/dashboard.php @@ -37,24 +37,38 @@

appointment_time) ?>

- - 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', + }; + ?> +

-
-
- - -
-
- - -
-
+ +
+
+ + +
+
+ + +
+
+ diff --git a/app/Views/patient/dashboard.php b/app/Views/patient/dashboard.php index 5f47027..f47a59a 100644 --- a/app/Views/patient/dashboard.php +++ b/app/Views/patient/dashboard.php @@ -51,7 +51,15 @@ appointment_time) ?> status; + $st = trim((string) $ap->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',