From 8287bff759d5410d846262bf4d310d0b4cbb6330 Mon Sep 17 00:00:00 2001 From: Tb Fajri Date: Sat, 9 Sep 2023 15:42:51 +0700 Subject: [PATCH] Update metode pembayaran --- .../Http/Controllers/Api/LivechatController.php | 11 +++++------ app/Helpers/Helper.php | 16 ++++++++++++++-- app/Models/OLDLMS/Appointment.php | 1 + 3 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Modules/Internal/Http/Controllers/Api/LivechatController.php b/Modules/Internal/Http/Controllers/Api/LivechatController.php index 1692dd68..173b19a7 100644 --- a/Modules/Internal/Http/Controllers/Api/LivechatController.php +++ b/Modules/Internal/Http/Controllers/Api/LivechatController.php @@ -4,6 +4,7 @@ namespace Modules\Internal\Http\Controllers\Api; use App\Helpers\Helper; use App\Models\OLDLMS\Livechat; +use App\Models\OLDLMS\Appointment; use Illuminate\Contracts\Support\Renderable; use Illuminate\Database\Eloquent\Builder; use Illuminate\Http\Request; @@ -62,7 +63,7 @@ class LivechatController extends Controller $startDate = $request->has('startDate') ? $request->input('startDate') : ''; $endDate = $request->has('endDate') ? $request->input('endDate') : ''; - $liveChats = Livechat::with('user:nID,sFirstName,sLastName,sEmail,sPhone,nIDUser', 'doctor:nID,nIDSpesialis,nIDUser', 'doctor.user:nID,sFirstName,sLastName', 'appointment:nID,sPaymentStatus', 'appointment.appointmentDetail:nID,nIDAppointment,dTanggalAppointment,tTimeAppointment', 'healthCare:nID,sHealthCare') + $liveChats = Livechat::with('user:nID,sFirstName,sLastName,sEmail,sPhone,nIDUser', 'doctor:nID,nIDSpesialis,nIDUser', 'doctor.user:nID,sFirstName,sLastName', 'appointment:nID,sPaymentStatus,sPaymentMethod', 'appointment.appointmentDetail:nID,nIDAppointment,dTanggalAppointment,tTimeAppointment', 'healthCare:nID,sHealthCare') ->where(function (Builder $query) use ($startDate, $endDate) { // $query->where('nIDAppointment', '!=', null); // $query->where('nIDAppointment', '!=', ''); @@ -93,6 +94,7 @@ class LivechatController extends Controller ['value' => 'Status', 'cell' => 'N1', 'mergeCell' => true, 'mergeToCell' => 'N2'], ['value' => 'Record Type', 'cell' => 'O1', 'mergeCell' => true, 'mergeToCell' => 'O2'], ['value' => 'nID Principal', 'cell' => 'P1', 'mergeCell' => true, 'mergeToCell' => 'P2'], + ['value' => 'Metode Pembayaran', 'cell' => 'Q1', 'mergeCell' => true, 'mergeToCell' => 'Q2'], ]; $spreadsheet = new Spreadsheet(); @@ -112,11 +114,9 @@ class LivechatController extends Controller $startFrom = 3; foreach ($liveChats as $indexLiveChat => $liveChat) { $phone = $liveChat->user->sPhone ?? '-'; - // $phone = str_replace(' ', '', $phone) ?? '-'; $status = $liveChat->sStatus; $nIDUser = $liveChat->user->nIDUser ?? 0; // Principal or Dependent - - // dd($nIDUser); + $paymentMethod = $liveChat->appointment ? Helper::sPaymentMethod($liveChat->appointment->sPaymentMethod) : 'Belum ada Pembayaran'; $recordType = 'P'; if ($nIDUser){ $recordType = 'D'; @@ -141,8 +141,6 @@ class LivechatController extends Controller $statusLivechat = "Cancel by Patient"; } - - $sheet->setCellValue('A' . $startFrom, $indexLiveChat + 1); $sheet->setCellValue('B' . $startFrom, $liveChat->nID ?? '-'); $sheet->setCellValue('C' . $startFrom, Carbon::parse($liveChat->dRequestTime)->format('d-m-Y')); @@ -159,6 +157,7 @@ class LivechatController extends Controller $sheet->setCellValue('N' . $startFrom, $statusLivechat); $sheet->setCellValue('O' . $startFrom, $recordType); $sheet->setCellValue('P' . $startFrom, $nIDUser ?? '-'); + $sheet->setCellValue('Q' . $startFrom, $paymentMethod ?? '-'); $startFrom++; } diff --git a/app/Helpers/Helper.php b/app/Helpers/Helper.php index f79ec238..7ae4d707 100644 --- a/app/Helpers/Helper.php +++ b/app/Helpers/Helper.php @@ -199,10 +199,22 @@ class Helper } } - public static function formatRupiah($angka) - { + public static function formatRupiah($angka) { return "Rp " . number_format($angka, 0, ',', '.'); } + public static function sPaymentMethod($id) { + $sPaymentMethod = [ + 1 => 'Pribadi', + 2 => 'On-Site Payment', + 3 => 'OVO', + 4 => 'Asuransi', + 5 => 'Voucher', + 6 => 'ASO' + ]; + + return $sPaymentMethod[$id]; + } + } diff --git a/app/Models/OLDLMS/Appointment.php b/app/Models/OLDLMS/Appointment.php index 7326025d..ec0b8a0a 100644 --- a/app/Models/OLDLMS/Appointment.php +++ b/app/Models/OLDLMS/Appointment.php @@ -29,6 +29,7 @@ class Appointment extends Model 3 => 'OVO', 4 => 'Asuransi', 5 => 'Voucher', + 6 => 'ASO' ]; public $sPaymentStatusName = [