Update Report Livechat

This commit is contained in:
2023-09-09 10:36:01 +07:00
parent ab194600c2
commit cff5dba314
5 changed files with 81 additions and 33 deletions

View File

@@ -73,20 +73,22 @@ class LivechatController extends Controller
$query->where('dCreateOn', '<=', $endDate); $query->where('dCreateOn', '<=', $endDate);
} }
}) })
->get(['nId', 'nIDUser', 'nIDDokter', 'nIDHealthCare', 'nIDAppointment', 'sStatus', 'sMediaDokter', 'sMedia']); ->get(['nID', 'nIDUser', 'nIDDokter', 'nIDHealthCare', 'nIDAppointment', 'sStatus', 'sMediaDokter', 'sMedia']);
$headers = [ $headers = [
['value' => 'No', 'cell' => 'A1', 'mergeCell' => true, 'mergeToCell' => 'A2'], ['value' => 'No', 'cell' => 'A1', 'mergeCell' => true, 'mergeToCell' => 'A2'],
['value' => 'Nama Dokter', 'cell' => 'B1', 'mergeCell' => true, 'mergeToCell' => 'B2'], ['value' => 'Kode TC', 'cell' => 'B1', 'mergeCell' => true, 'mergeToCell' => 'B2'],
['value' => 'Nama Pasien', 'cell' => 'C1', 'mergeCell' => true, 'mergeToCell' => 'C2'], ['value' => 'Nama Dokter', 'cell' => 'C1', 'mergeCell' => true, 'mergeToCell' => 'C2'],
['value' => 'No Telepon Pasien', 'cell' => 'D1', 'mergeCell' => true, 'mergeToCell' => 'D2'], ['value' => 'Nama Pasien', 'cell' => 'D1', 'mergeCell' => true, 'mergeToCell' => 'D2'],
['value' => 'Email Pasien', 'cell' => 'E1', 'mergeCell' => true, 'mergeToCell' => 'E2'], ['value' => 'No Telepon Pasien', 'cell' => 'E1', 'mergeCell' => true, 'mergeToCell' => 'E2'],
['value' => 'Faskes', 'cell' => 'F1', 'mergeCell' => true, 'mergeToCell' => 'F2'], ['value' => 'Email Pasien', 'cell' => 'F1', 'mergeCell' => true, 'mergeToCell' => 'F2'],
['value' => 'Tanggal Appointment', 'cell' => 'G1', 'mergeCell' => true, 'mergeToCell' => 'G2'], ['value' => 'Faskes', 'cell' => 'G1', 'mergeCell' => true, 'mergeToCell' => 'G2'],
['value' => 'Chat Via App/Website', 'cell' => 'H1', 'mergeCell' => true, 'mergeToCell' => 'I1'], ['value' => 'Tanggal Request', 'cell' => 'H1', 'mergeCell' => true, 'mergeToCell' => 'H2'],
['value' => 'Pasien', 'cell' => 'H2', 'mergeCell' => false, 'mergeToCell' => ''], ['value' => 'Waktu Request', 'cell' => 'I1', 'mergeCell' => true, 'mergeToCell' => 'I2'],
['value' => 'Dokter', 'cell' => 'I2', 'mergeCell' => false, 'mergeToCell' => ''], ['value' => 'Chat Via App/Website', 'cell' => 'J1', 'mergeCell' => true, 'mergeToCell' => 'K1'],
['value' => 'Status Appointment', 'cell' => 'J1', 'mergeCell' => true, 'mergeToCell' => 'J2'], ['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(); $spreadsheet = new Spreadsheet();
@@ -105,23 +107,47 @@ class LivechatController extends Controller
$startFrom = 3; $startFrom = 3;
foreach ($liveChats as $indexLiveChat => $liveChat) { 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('A' . $startFrom, $indexLiveChat + 1);
$sheet->setCellValue('B' . $startFrom, $liveChat->doctor->user->full_name ?? '-'); $sheet->setCellValue('B' . $startFrom, $liveChat->nID ?? '-');
$sheet->setCellValue('C' . $startFrom, $liveChat->user->full_name ?? '-'); $sheet->setCellValue('C' . $startFrom, $liveChat->doctor->user->full_name ?? '-');
$sheet->setCellValue('D' . $startFrom, preg_replace('/(\d{3})(\d{4})(\d{3})/', '$1 $2 $3', $liveChat->user->sPhone) ?? '-'); $sheet->setCellValue('D' . $startFrom, $liveChat->user->full_name ?? '-');
$sheet->setCellValue('E' . $startFrom, $liveChat->user->sEmail ?? '-'); $sheet->setCellValue('E' . $startFrom, preg_replace('/(\d{3})(\d{4})(\d{3})/', '$1 $2 $3', $phone));
$sheet->setCellValue('F' . $startFrom, $liveChat->healthCare->sHealthCare ?? '-'); $sheet->setCellValue('F' . $startFrom, $liveChat->user->sEmail ?? '-');
$sheet->setCellValue('G' . $startFrom, isset($liveChat->appointment->appointmentDetail) ? Carbon::parse($liveChat->appointment->appointmentDetail->dTanggalAppointment)->format('d-m-Y') . ' ' . $liveChat->appointment->appointmentDetail->tTimeAppointment : '-'); $sheet->setCellValue('G' . $startFrom, $liveChat->healthCare->sHealthCare ?? '-');
$sheet->setCellValue('H' . $startFrom, $liveChat->sMedia ?? '-'); $sheet->setCellValue('H' . $startFrom, Carbon::parse($liveChat->dRequestTime)->format('d-m-Y'));
$sheet->setCellValue('I' . $startFrom, $liveChat->sMediaDokter ?? '-'); $sheet->setCellValue('I' . $startFrom, Carbon::parse($liveChat->dRequestTime)->format('H:i:s'));
$sheet->setCellValue('J' . $startFrom, $liveChat->appointment->paymentStatus ?? '-'); $sheet->setCellValue('J' . $startFrom, $liveChat->sMedia ?? '-');
$sheet->setCellValue('K' . $startFrom, $liveChat->sMediaDokter ?? '-');
$sheet->setCellValue('L' . $startFrom, $statusLivechat);
$startFrom++; $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') { if ($header === 'A') {
$spreadsheet->getActiveSheet()->getColumnDimension($header)->setWidth(35, 'px'); $spreadsheet->getActiveSheet()->getColumnDimension($header)->setWidth(35, 'px');
} elseif ($header === 'H' || $header === 'I') { } elseif ($header === 'J' || $header === 'K') {
$spreadsheet->getActiveSheet()->getColumnDimension($header)->setWidth(100, 'px'); $spreadsheet->getActiveSheet()->getColumnDimension($header)->setWidth(100, 'px');
} else { } else {
$spreadsheet->getActiveSheet()->getColumnDimension($header)->setAutoSize(true); $spreadsheet->getActiveSheet()->getColumnDimension($header)->setAutoSize(true);

View File

@@ -4,6 +4,7 @@ namespace Modules\Internal\Transformers;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Http\Resources\Json\JsonResource; use Illuminate\Http\Resources\Json\JsonResource;
use App\Helpers\Helper;
class LivechatResource extends JsonResource class LivechatResource extends JsonResource
{ {
@@ -26,7 +27,8 @@ class LivechatResource extends JsonResource
'date_appointment' => Carbon::parse($this->appointment->appointmentDetail->dTanggalAppointment)->format('d-m-Y') 'date_appointment' => Carbon::parse($this->appointment->appointmentDetail->dTanggalAppointment)->format('d-m-Y')
. ' ' . $this->appointment->appointmentDetail->tTimeAppointment ?? null, . ' ' . $this->appointment->appointmentDetail->tTimeAppointment ?? null,
'status_appointment' => $this->appointment->paymentStatus ?? 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, 'patient_media' => $this->sMedia ?? null,
'doctor_media' => $this->sMediaDokter ?? null, 'doctor_media' => $this->sMediaDokter ?? null,
'appointment_media' => $this->appointment->sMedia ?? null, 'appointment_media' => $this->appointment->sMedia ?? null,
@@ -53,7 +55,7 @@ class LivechatResource extends JsonResource
$payment_detail = [ $payment_detail = [
'payment_type' => $this->appointment->appointmentDetail->sPaymentDetails['payment_type'], 'payment_type' => $this->appointment->appointmentDetail->sPaymentDetails['payment_type'],
'transaction_time' => $this->appointment->appointmentDetail->sPaymentDetails['transaction_time'], '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'], 'currency' => $this->appointment->appointmentDetail->sPaymentDetails['currency'],
'status_message' => $this->appointment->appointmentDetail->sPaymentDetails['status_message'], 'status_message' => $this->appointment->appointmentDetail->sPaymentDetails['status_message'],
]; ];

View File

@@ -199,5 +199,10 @@ class Helper
} }
} }
public static function formatRupiah($angka)
{
return "Rp " . number_format($angka, 0, ',', '.');
}
} }

View File

@@ -11,12 +11,21 @@ class Livechat extends Model
use HasFactory; use HasFactory;
// public $sStatusNames = [
// 0 => 'Menunggu Konfirmasi',
// 1 => 'Diterima',
// 3 => 'Ditolak',
// 2 => 'Selesai',
// 4 => 'Expired',
// ];
public $sStatusNames = [ public $sStatusNames = [
0 => 'Menunggu Konfirmasi', 0 => 'Request TC',
1 => 'Diterima', 1 => 'Accepted by Doctor but User not Payment',
3 => 'Ditolak', 3 => 'Decline by Doctor',
2 => 'Selesai', 2 => 'Payment Success',
4 => 'Expired', 4 => 'Payment Expired',
5 => 'Cancel by Patient'
]; ];
const CREATED_AT = 'dCreateOn'; const CREATED_AT = 'dCreateOn';

View File

@@ -256,7 +256,7 @@ export default function List() {
</IconButton> </IconButton>
</TableCell> </TableCell>
<TableCell align="left">{row.date_created ? row.date_created : '-'}</TableCell> <TableCell align="left">{row.date_created ? row.date_created : '-'}</TableCell>
<TableCell align="left">{row.date_appointment ? row.date_appointment : '-'}</TableCell> <TableCell align="left">{row.time_request ? row.time_request : '-'}</TableCell>
<TableCell align="left">{row.health_care ? row.health_care : '-'}</TableCell> <TableCell align="left">{row.health_care ? row.health_care : '-'}</TableCell>
<TableCell align="left">{row.doctor_name ? row.doctor_name : '-'}</TableCell> <TableCell align="left">{row.doctor_name ? row.doctor_name : '-'}</TableCell>
<TableCell align="left">{row.speciality ? row.speciality : '-'}</TableCell> <TableCell align="left">{row.speciality ? row.speciality : '-'}</TableCell>
@@ -309,6 +309,12 @@ export default function List() {
<Grid item xs={6}> <Grid item xs={6}>
: {row.duration ? row.duration : '-'} : {row.duration ? row.duration : '-'}
</Grid> </Grid>
<Grid item xs={6}>
Kode
</Grid>
<Grid item xs={6}>
: {row.id ? row.id : '-'}
</Grid>
</Grid> </Grid>
</Grid> </Grid>
</Grid> </Grid>
@@ -471,10 +477,10 @@ export default function List() {
{/* <TableCell colSpan={8} rowSpan={1} align="center" /> */} {/* <TableCell colSpan={8} rowSpan={1} align="center" /> */}
<TableCell style={headStyle} align="left" /> <TableCell style={headStyle} align="left" />
<TableCell style={headStyle} rowSpan={2} align="left"> <TableCell style={headStyle} rowSpan={2} align="left">
Tanggal Booking Tanggal Request
</TableCell> </TableCell>
<TableCell style={headStyle} rowSpan={2} align="left"> <TableCell style={headStyle} rowSpan={2} align="left">
Tanggal Appointment Waktu Request
</TableCell> </TableCell>
<TableCell style={headStyle} rowSpan={2} align="left"> <TableCell style={headStyle} rowSpan={2} align="left">
Faskes Faskes