From cff5dba3145f83c77d215d9a3fc4529f4c05caf2 Mon Sep 17 00:00:00 2001 From: Tb Fajri Date: Sat, 9 Sep 2023 10:36:01 +0700 Subject: [PATCH 1/2] Update Report Livechat --- .../Controllers/Api/LivechatController.php | 70 +++++++++++++------ .../Transformers/LivechatResource.php | 6 +- app/Helpers/Helper.php | 7 +- app/Models/OLDLMS/Livechat.php | 19 +++-- .../src/pages/Report/Livechat/List.tsx | 12 +++- 5 files changed, 81 insertions(+), 33 deletions(-) diff --git a/Modules/Internal/Http/Controllers/Api/LivechatController.php b/Modules/Internal/Http/Controllers/Api/LivechatController.php index 39b1379f..44b0b94e 100644 --- a/Modules/Internal/Http/Controllers/Api/LivechatController.php +++ b/Modules/Internal/Http/Controllers/Api/LivechatController.php @@ -73,20 +73,22 @@ class LivechatController extends Controller $query->where('dCreateOn', '<=', $endDate); } }) - ->get(['nId', 'nIDUser', 'nIDDokter', 'nIDHealthCare', 'nIDAppointment', 'sStatus', 'sMediaDokter', 'sMedia']); + ->get(['nID', 'nIDUser', 'nIDDokter', 'nIDHealthCare', 'nIDAppointment', 'sStatus', 'sMediaDokter', 'sMedia']); $headers = [ ['value' => 'No', 'cell' => 'A1', 'mergeCell' => true, 'mergeToCell' => 'A2'], - ['value' => 'Nama Dokter', 'cell' => 'B1', 'mergeCell' => true, 'mergeToCell' => 'B2'], - ['value' => 'Nama Pasien', 'cell' => 'C1', 'mergeCell' => true, 'mergeToCell' => 'C2'], - ['value' => 'No Telepon Pasien', 'cell' => 'D1', 'mergeCell' => true, 'mergeToCell' => 'D2'], - ['value' => 'Email Pasien', 'cell' => 'E1', 'mergeCell' => true, 'mergeToCell' => 'E2'], - ['value' => 'Faskes', 'cell' => 'F1', 'mergeCell' => true, 'mergeToCell' => 'F2'], - ['value' => 'Tanggal Appointment', 'cell' => 'G1', 'mergeCell' => true, 'mergeToCell' => 'G2'], - ['value' => 'Chat Via App/Website', 'cell' => 'H1', 'mergeCell' => true, 'mergeToCell' => 'I1'], - ['value' => 'Pasien', 'cell' => 'H2', 'mergeCell' => false, 'mergeToCell' => ''], - ['value' => 'Dokter', 'cell' => 'I2', 'mergeCell' => false, 'mergeToCell' => ''], - ['value' => 'Status Appointment', 'cell' => 'J1', 'mergeCell' => true, 'mergeToCell' => 'J2'], + ['value' => 'Kode TC', 'cell' => 'B1', 'mergeCell' => true, 'mergeToCell' => 'B2'], + ['value' => 'Nama Dokter', 'cell' => 'C1', 'mergeCell' => true, 'mergeToCell' => 'C2'], + ['value' => 'Nama Pasien', 'cell' => 'D1', 'mergeCell' => true, 'mergeToCell' => 'D2'], + ['value' => 'No Telepon Pasien', 'cell' => 'E1', 'mergeCell' => true, 'mergeToCell' => 'E2'], + ['value' => 'Email Pasien', 'cell' => 'F1', 'mergeCell' => true, 'mergeToCell' => 'F2'], + ['value' => 'Faskes', 'cell' => 'G1', 'mergeCell' => true, 'mergeToCell' => 'G2'], + ['value' => 'Tanggal Request', 'cell' => 'H1', 'mergeCell' => true, 'mergeToCell' => 'H2'], + ['value' => 'Waktu Request', 'cell' => 'I1', 'mergeCell' => true, 'mergeToCell' => 'I2'], + ['value' => 'Chat Via App/Website', 'cell' => 'J1', 'mergeCell' => true, 'mergeToCell' => 'K1'], + ['value' => 'Pasien', 'cell' => 'J2', 'mergeCell' => false, 'mergeToCell' => ''], + ['value' => 'Dokter', 'cell' => 'K2', 'mergeCell' => false, 'mergeToCell' => ''], + ['value' => 'Status', 'cell' => 'L1', 'mergeCell' => true, 'mergeToCell' => 'L2'], ]; $spreadsheet = new Spreadsheet(); @@ -105,23 +107,47 @@ class LivechatController extends Controller $startFrom = 3; foreach ($liveChats as $indexLiveChat => $liveChat) { + $phone = $liveChat->user->sPhone ?? '-'; + $status = $liveChat->sStatus; + switch ($status) { + case 0: + $statusLivechat = "Request TC"; + break; + case 1: + $statusLivechat = "Accepted by Doctor but User not Payment"; + break; + case 2: + $statusLivechat = "Payment Success"; + break; + case 3: + $statusLivechat = "Decline by Doctor"; + break; + case 4: + $statusLivechat = "Payment Expired"; + break; + default: + $statusLivechat = "Cancel by Patient"; + } + $sheet->setCellValue('A' . $startFrom, $indexLiveChat + 1); - $sheet->setCellValue('B' . $startFrom, $liveChat->doctor->user->full_name ?? '-'); - $sheet->setCellValue('C' . $startFrom, $liveChat->user->full_name ?? '-'); - $sheet->setCellValue('D' . $startFrom, preg_replace('/(\d{3})(\d{4})(\d{3})/', '$1 $2 $3', $liveChat->user->sPhone) ?? '-'); - $sheet->setCellValue('E' . $startFrom, $liveChat->user->sEmail ?? '-'); - $sheet->setCellValue('F' . $startFrom, $liveChat->healthCare->sHealthCare ?? '-'); - $sheet->setCellValue('G' . $startFrom, isset($liveChat->appointment->appointmentDetail) ? Carbon::parse($liveChat->appointment->appointmentDetail->dTanggalAppointment)->format('d-m-Y') . ' ' . $liveChat->appointment->appointmentDetail->tTimeAppointment : '-'); - $sheet->setCellValue('H' . $startFrom, $liveChat->sMedia ?? '-'); - $sheet->setCellValue('I' . $startFrom, $liveChat->sMediaDokter ?? '-'); - $sheet->setCellValue('J' . $startFrom, $liveChat->appointment->paymentStatus ?? '-'); + $sheet->setCellValue('B' . $startFrom, $liveChat->nID ?? '-'); + $sheet->setCellValue('C' . $startFrom, $liveChat->doctor->user->full_name ?? '-'); + $sheet->setCellValue('D' . $startFrom, $liveChat->user->full_name ?? '-'); + $sheet->setCellValue('E' . $startFrom, preg_replace('/(\d{3})(\d{4})(\d{3})/', '$1 $2 $3', $phone)); + $sheet->setCellValue('F' . $startFrom, $liveChat->user->sEmail ?? '-'); + $sheet->setCellValue('G' . $startFrom, $liveChat->healthCare->sHealthCare ?? '-'); + $sheet->setCellValue('H' . $startFrom, Carbon::parse($liveChat->dRequestTime)->format('d-m-Y')); + $sheet->setCellValue('I' . $startFrom, Carbon::parse($liveChat->dRequestTime)->format('H:i:s')); + $sheet->setCellValue('J' . $startFrom, $liveChat->sMedia ?? '-'); + $sheet->setCellValue('K' . $startFrom, $liveChat->sMediaDokter ?? '-'); + $sheet->setCellValue('L' . $startFrom, $statusLivechat); $startFrom++; } - foreach (['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J'] as $header) { + foreach (['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J','K', 'L'] as $header) { if ($header === 'A') { $spreadsheet->getActiveSheet()->getColumnDimension($header)->setWidth(35, 'px'); - } elseif ($header === 'H' || $header === 'I') { + } elseif ($header === 'J' || $header === 'K') { $spreadsheet->getActiveSheet()->getColumnDimension($header)->setWidth(100, 'px'); } else { $spreadsheet->getActiveSheet()->getColumnDimension($header)->setAutoSize(true); diff --git a/Modules/Internal/Transformers/LivechatResource.php b/Modules/Internal/Transformers/LivechatResource.php index 2e87be92..f8977412 100644 --- a/Modules/Internal/Transformers/LivechatResource.php +++ b/Modules/Internal/Transformers/LivechatResource.php @@ -4,6 +4,7 @@ namespace Modules\Internal\Transformers; use Carbon\Carbon; use Illuminate\Http\Resources\Json\JsonResource; +use App\Helpers\Helper; class LivechatResource extends JsonResource { @@ -26,7 +27,8 @@ class LivechatResource extends JsonResource 'date_appointment' => Carbon::parse($this->appointment->appointmentDetail->dTanggalAppointment)->format('d-m-Y') . ' ' . $this->appointment->appointmentDetail->tTimeAppointment ?? null, 'status_appointment' => $this->appointment->paymentStatus ?? null, - 'date_created' => Carbon::parse($this->appointment->dCreateOn)->format('d-m-Y H:i:s') ?? null, + 'date_created' => Carbon::parse($this->dRequestTime)->format('d-m-Y') ?? null, + 'time_request' => Carbon::parse($this->dRequestTime)->format('H:i:s') ?? null, 'patient_media' => $this->sMedia ?? null, 'doctor_media' => $this->sMediaDokter ?? null, 'appointment_media' => $this->appointment->sMedia ?? null, @@ -53,7 +55,7 @@ class LivechatResource extends JsonResource $payment_detail = [ 'payment_type' => $this->appointment->appointmentDetail->sPaymentDetails['payment_type'], 'transaction_time' => $this->appointment->appointmentDetail->sPaymentDetails['transaction_time'], - 'gross_amount' => $this->appointment->appointmentDetail->sPaymentDetails['gross_amount'], + 'gross_amount' => Helper::formatRupiah($this->appointment->appointmentDetail->sPaymentDetails['gross_amount']), 'currency' => $this->appointment->appointmentDetail->sPaymentDetails['currency'], 'status_message' => $this->appointment->appointmentDetail->sPaymentDetails['status_message'], ]; diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index d41a8125..f79ec238 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -198,6 +198,11 @@ class Helper return false; } } - + + public static function formatRupiah($angka) + { + return "Rp " . number_format($angka, 0, ',', '.'); + } + } diff --git a/app/Models/OLDLMS/Livechat.php b/app/Models/OLDLMS/Livechat.php index bfd5cda3..5c0ae646 100644 --- a/app/Models/OLDLMS/Livechat.php +++ b/app/Models/OLDLMS/Livechat.php @@ -11,12 +11,21 @@ class Livechat extends Model use HasFactory; + // public $sStatusNames = [ + // 0 => 'Menunggu Konfirmasi', + // 1 => 'Diterima', + // 3 => 'Ditolak', + // 2 => 'Selesai', + // 4 => 'Expired', + // ]; + public $sStatusNames = [ - 0 => 'Menunggu Konfirmasi', - 1 => 'Diterima', - 3 => 'Ditolak', - 2 => 'Selesai', - 4 => 'Expired', + 0 => 'Request TC', + 1 => 'Accepted by Doctor but User not Payment', + 3 => 'Decline by Doctor', + 2 => 'Payment Success', + 4 => 'Payment Expired', + 5 => 'Cancel by Patient' ]; const CREATED_AT = 'dCreateOn'; diff --git a/frontend/dashboard/src/pages/Report/Livechat/List.tsx b/frontend/dashboard/src/pages/Report/Livechat/List.tsx index f320f0a2..6ca8e5bf 100644 --- a/frontend/dashboard/src/pages/Report/Livechat/List.tsx +++ b/frontend/dashboard/src/pages/Report/Livechat/List.tsx @@ -256,7 +256,7 @@ export default function List() { {row.date_created ? row.date_created : '-'} - {row.date_appointment ? row.date_appointment : '-'} + {row.time_request ? row.time_request : '-'} {row.health_care ? row.health_care : '-'} {row.doctor_name ? row.doctor_name : '-'} {row.speciality ? row.speciality : '-'} @@ -309,6 +309,12 @@ export default function List() { : {row.duration ? row.duration : '-'} + + Kode + + + : {row.id ? row.id : '-'} + @@ -471,10 +477,10 @@ export default function List() { {/* */} - Tanggal Booking + Tanggal Request - Tanggal Appointment + Waktu Request Faskes From 25b668ad2b1c609d120e580b1cdc561674ae849b Mon Sep 17 00:00:00 2001 From: Tb Fajri Date: Sat, 9 Sep 2023 10:42:43 +0700 Subject: [PATCH 2/2] update name --- frontend/dashboard/src/pages/Report/Livechat/Index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/frontend/dashboard/src/pages/Report/Livechat/Index.tsx b/frontend/dashboard/src/pages/Report/Livechat/Index.tsx index df2f3cf0..6031ab63 100644 --- a/frontend/dashboard/src/pages/Report/Livechat/Index.tsx +++ b/frontend/dashboard/src/pages/Report/Livechat/Index.tsx @@ -10,7 +10,7 @@ export default function Doctor() { const { id } = useParams(); - const pageTitle = 'Payment'; + const pageTitle = 'Livechat'; return ( @@ -22,8 +22,8 @@ export default function Doctor() { href: '/report', }, { - name: 'Payment', - href: '/report/payment', + name: 'Livechat', + href: '/report/live-chat', }, ]} />