From e0f3a38be0fb86b4ef133650243114c4701014bb Mon Sep 17 00:00:00 2001 From: Linksehat Staging Server Date: Thu, 31 Aug 2023 16:39:03 +0700 Subject: [PATCH] report livechat --- .../Controllers/Api/LivechatController.php | 22 ++++++++++++++----- .../Transformers/LivechatResource.php | 5 ++++- app/Models/OLDLMS/Livechat.php | 2 +- .../src/pages/Report/Livechat/List.tsx | 8 +++++++ 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/Modules/Internal/Http/Controllers/Api/LivechatController.php b/Modules/Internal/Http/Controllers/Api/LivechatController.php index 9531a1a4..c31ef217 100644 --- a/Modules/Internal/Http/Controllers/Api/LivechatController.php +++ b/Modules/Internal/Http/Controllers/Api/LivechatController.php @@ -15,14 +15,24 @@ class LivechatController extends Controller * Display a listing of the resource. * @return Renderable */ - public function index() + public function index(Request $request) { - $startDate = '2023-01-01'; - $endDate = '2023-08-01'; - $livechat = Livechat::with('doctor.user', 'doctor.speciality', 'appointment.appointmentDetail', 'healthCare') - ->where('nIDAppointment', '!=', null)->where('nIDAppointment', '!=', ''); + $startDate = $request->startDate; + $endDate = $request->endDate; + + $livechat = Livechat::with('doctor.user', 'doctor.speciality', 'appointment.appointmentDetail', 'healthCare') + ->where('nIDAppointment', '!=', null) + ->where('nIDAppointment', '!=', ''); + + + if ($startDate){ + $livechat = $livechat->where('dCreateOn', '>=', $startDate); + } + + if ($endDate){ + $livechat = $livechat->where('dCreateOn', '<=', $endDate); + } - $livechat = $livechat->latest()->paginate(15); return response()->json(Helper::paginateResources(LivechatResource::collection($livechat))); diff --git a/Modules/Internal/Transformers/LivechatResource.php b/Modules/Internal/Transformers/LivechatResource.php index 054a82de..2e87be92 100644 --- a/Modules/Internal/Transformers/LivechatResource.php +++ b/Modules/Internal/Transformers/LivechatResource.php @@ -18,11 +18,14 @@ class LivechatResource extends JsonResource $livechat = [ 'id' => $this->nID, 'doctor_name' => isset($this->doctor->user->sFirstName) ? $this->doctor->user->sFirstName . ' ' . $this->doctor->user->sLastName : null, + 'pasien_name' => isset($this->user->sFirstName) ? $this->user->sFirstName . ' ' . $this->user->sLastName : null, + 'pasien_phone' => isset($this->user->sPhone) ? $this->user->sPhone : '-', + 'pasien_email' => isset($this->user->sEmail) ? $this->user->sEmail : '-', 'speciality' => $this->doctor->speciality->sKeterangan ?? null, 'health_care' => $this->healthCare->sHealthCare ?? null, 'date_appointment' => Carbon::parse($this->appointment->appointmentDetail->dTanggalAppointment)->format('d-m-Y') . ' ' . $this->appointment->appointmentDetail->tTimeAppointment ?? null, - 'status_appointment' => $this->appointment->status_name ?? null, + 'status_appointment' => $this->appointment->paymentStatus ?? null, 'date_created' => Carbon::parse($this->appointment->dCreateOn)->format('d-m-Y H:i:s') ?? null, 'patient_media' => $this->sMedia ?? null, 'doctor_media' => $this->sMediaDokter ?? null, diff --git a/app/Models/OLDLMS/Livechat.php b/app/Models/OLDLMS/Livechat.php index 8b67a310..bfd5cda3 100644 --- a/app/Models/OLDLMS/Livechat.php +++ b/app/Models/OLDLMS/Livechat.php @@ -48,7 +48,7 @@ class Livechat extends Model public function doctor() { - return $this->belongsTo(Dokter::class, 'nIDDokter', 'nID'); + return $this->belongsTo(Dokter::class, 'nIDDokter', 'nIDUser'); } diff --git a/frontend/dashboard/src/pages/Report/Livechat/List.tsx b/frontend/dashboard/src/pages/Report/Livechat/List.tsx index b07e325f..02f56133 100644 --- a/frontend/dashboard/src/pages/Report/Livechat/List.tsx +++ b/frontend/dashboard/src/pages/Report/Livechat/List.tsx @@ -254,6 +254,8 @@ export default function List() { {row.health_care ? row.health_care : '-'} {row.doctor_name ? row.doctor_name : '-'} {row.speciality ? row.speciality : '-'} + {row.pasien_name ? row.pasien_name : '-'} + {row.pasien_phone ? row.pasien_phone : '-'} {row.appointment_media ? row.appointment_media : '-'} {row.patient_media ? row.patient_media : '-'} {row.doctor_media ? row.doctor_media : '-'} @@ -456,6 +458,12 @@ export default function List() { Spesialisasi + + Nama Pasien + + + No Telepon Pasien + Appointment Via App/Website