report monthly
This commit is contained in:
@@ -62,7 +62,10 @@ class LivechatController extends Controller
|
|||||||
{
|
{
|
||||||
$startDate = $request->has('startDate') ? $request->input('startDate') : '';
|
$startDate = $request->has('startDate') ? $request->input('startDate') : '';
|
||||||
$endDate = $request->has('endDate') ? $request->input('endDate') : '';
|
$endDate = $request->has('endDate') ? $request->input('endDate') : '';
|
||||||
|
$type = $request->has('type') ? $request->input('type') : '';
|
||||||
|
if ($type == 1){
|
||||||
|
return $this->exportMonthly($startDate, $endDate);
|
||||||
|
} else {
|
||||||
$liveChats = Livechat::with('userInsurance',
|
$liveChats = Livechat::with('userInsurance',
|
||||||
'user:nID,sFirstName,sLastName,sEmail,sPhone,nIDUser,nIDHubunganKeluarga',
|
'user:nID,sFirstName,sLastName,sEmail,sPhone,nIDUser,nIDHubunganKeluarga',
|
||||||
'doctor:nID,nIDSpesialis,nIDUser', 'doctor.user:nID,sFirstName,sLastName',
|
'doctor:nID,nIDSpesialis,nIDUser', 'doctor.user:nID,sFirstName,sLastName',
|
||||||
@@ -140,6 +143,16 @@ class LivechatController extends Controller
|
|||||||
|
|
||||||
$sheet->getStyle($header['cell'])->getFont()->setBold(true);
|
$sheet->getStyle($header['cell'])->getFont()->setBold(true);
|
||||||
$sheet->getStyle($header['cell'])->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER)->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
|
$sheet->getStyle($header['cell'])->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER)->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
|
||||||
|
|
||||||
|
|
||||||
|
$sheet->setCellValue($header['cell'], $header['value']);
|
||||||
|
|
||||||
|
if ($header['mergeCell'] === true) {
|
||||||
|
$sheet->mergeCells($header['cell'] . ':' . $header['mergeToCell']);
|
||||||
|
}
|
||||||
|
|
||||||
|
$sheet->getStyle($header['cell'])->getFont()->setBold(true);
|
||||||
|
$sheet->getStyle($header['cell'])->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER)->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
$startFrom = 3;
|
$startFrom = 3;
|
||||||
@@ -370,13 +383,11 @@ class LivechatController extends Controller
|
|||||||
"file_url" => $fileUrl
|
"file_url" => $fileUrl
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public function exportMonthly(Request $request)
|
public function exportMonthly($startDate, $endDate)
|
||||||
{
|
{
|
||||||
$startDate = $request->has('startDate') ? $request->input('startDate') : '';
|
|
||||||
$endDate = $request->has('endDate') ? $request->input('endDate') : '';
|
|
||||||
|
|
||||||
$liveChats = Livechat::with('userInsurance',
|
$liveChats = Livechat::with('userInsurance',
|
||||||
'user:nID,sFirstName,sLastName,sEmail,sPhone,nIDUser,nIDHubunganKeluarga',
|
'user:nID,sFirstName,sLastName,sEmail,sPhone,nIDUser,nIDHubunganKeluarga',
|
||||||
'doctor:nID,nIDSpesialis,nIDUser', 'doctor.user:nID,sFirstName,sLastName',
|
'doctor:nID,nIDSpesialis,nIDUser', 'doctor.user:nID,sFirstName,sLastName',
|
||||||
@@ -432,12 +443,16 @@ class LivechatController extends Controller
|
|||||||
['value' => 'Poli', 'cell' => 'Y1', 'mergeCell' => false, 'mergeToCell' => ''],
|
['value' => 'Poli', 'cell' => 'Y1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||||
['value' => 'Total', 'cell' => 'Z1', 'mergeCell' => false, 'mergeToCell' => ''],
|
['value' => 'Total', 'cell' => 'Z1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||||
['value' => 'Obat', 'cell' => 'AA1', 'mergeCell' => false, 'mergeToCell' => ''],
|
['value' => 'Obat', 'cell' => 'AA1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||||
['value' => 'By', 'cell' => 'AB1', 'mergeCell' => false, 'mergeToCell' => ''],
|
['value' => 'Nama Obat', 'cell' => 'AB1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||||
|
['value' => 'Jumlah Obat', 'cell' => 'AC1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||||
|
['value' => 'By', 'cell' => 'AD1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||||
];
|
];
|
||||||
|
|
||||||
$spreadsheet = new Spreadsheet();
|
$spreadsheet = new Spreadsheet();
|
||||||
$sheet = $spreadsheet->getActiveSheet();
|
$sheet = $spreadsheet->setActiveSheetIndex(0);
|
||||||
|
|
||||||
|
$sheet2 = $spreadsheet->createSheet();
|
||||||
|
$sheet2 = $spreadsheet->setActiveSheetIndex(1);
|
||||||
foreach ($headers as $header) {
|
foreach ($headers as $header) {
|
||||||
$sheet->setCellValue($header['cell'], $header['value']);
|
$sheet->setCellValue($header['cell'], $header['value']);
|
||||||
|
|
||||||
@@ -447,10 +462,17 @@ class LivechatController extends Controller
|
|||||||
|
|
||||||
$sheet->getStyle($header['cell'])->getFont()->setBold(true);
|
$sheet->getStyle($header['cell'])->getFont()->setBold(true);
|
||||||
$sheet->getStyle($header['cell'])->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER)->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
|
$sheet->getStyle($header['cell'])->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER)->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
|
||||||
|
|
||||||
|
$sheet2->setCellValue($header['cell'], $header['value']);
|
||||||
|
|
||||||
|
$sheet2->getStyle($header['cell'])->getFont()->setBold(true);
|
||||||
|
$sheet2->getStyle($header['cell'])->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER)->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
$startFrom = 2;
|
$startFromSheet1 = 2;
|
||||||
|
$startFromSheet2 = 2;
|
||||||
foreach ($liveChats as $indexLiveChat => $liveChat) {
|
foreach ($liveChats as $indexLiveChat => $liveChat) {
|
||||||
|
if (!$liveChat->prescription) {
|
||||||
$phone = $liveChat->user->sPhone ?? '-';
|
$phone = $liveChat->user->sPhone ?? '-';
|
||||||
$status = $liveChat->sStatus;
|
$status = $liveChat->sStatus;
|
||||||
$nIDUser = $liveChat->user->nIDUser ?? 0; // Principal or Dependent
|
$nIDUser = $liveChat->user->nIDUser ?? 0; // Principal or Dependent
|
||||||
@@ -593,49 +615,42 @@ class LivechatController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$obat = '-';
|
$obat = '-';
|
||||||
if($liveChat->prescription){
|
|
||||||
if ($liveChat->prescription->items){
|
|
||||||
$obatArray = [];
|
|
||||||
foreach($liveChat->prescription->items as $data){
|
|
||||||
$obatArray[] = $data->sItemName .' - '. $data->nQty;
|
|
||||||
}
|
|
||||||
|
|
||||||
$obat = implode('; ',$obatArray);
|
$sheet->setCellValue('A' . $startFromSheet1, $liveChat->nID ?? '-');
|
||||||
}
|
$sheet->setCellValue('B' . $startFromSheet1, $liveChat->sNoSpj ?? '-');
|
||||||
};
|
$sheet->setCellValue('C' . $startFromSheet1, (string)($liveChat->userInsurance->sCorporateCode ?? '-'));
|
||||||
$sheet->setCellValue('A' . $startFrom, $liveChat->nID ?? '-');
|
$sheet->setCellValue('D' . $startFromSheet1, (string)($liveChat->userInsurance->sCorporateName ?? '-'));
|
||||||
$sheet->setCellValue('B' . $startFrom, $liveChat->sNoSpj ?? '-');
|
$sheet->setCellValue('E' . $startFromSheet1, (string)($liveChat->userInsurance->sNoPolis ?? '-'));
|
||||||
$sheet->setCellValue('C' . $startFrom, (string)($liveChat->userInsurance->sCorporateCode ?? '-'));
|
$sheet->setCellValue('F' . $startFromSheet1, $liveChat->user->full_name ?? '-');
|
||||||
$sheet->setCellValue('D' . $startFrom, (string)($liveChat->userInsurance->sCorporateName ?? '-'));
|
$sheet->setCellValue('G' . $startFromSheet1, $liveChat->user->detail->dTanggalLahir ?? '-');
|
||||||
$sheet->setCellValue('E' . $startFrom, (string)($liveChat->userInsurance->sNoPolis ?? '-'));
|
$sheet->setCellValue('H' . $startFromSheet1, $liveChat->user->detail->nIDJenisKelamin == 1 ? 'Laki-laki' : 'Wanita');
|
||||||
$sheet->setCellValue('F' . $startFrom, $liveChat->user->full_name ?? '-');
|
$sheet->setCellValue('I' . $startFromSheet1, Helper::calculateAge($liveChat->user->detail->dTanggalLahir) ?? '-');
|
||||||
$sheet->setCellValue('G' . $startFrom, $liveChat->user->detail->dTanggalLahir ?? '-');
|
$sheet->setCellValue('J' . $startFromSheet1, (string)($liveChat->userInsurance->sProductCode ?? '-'));
|
||||||
$sheet->setCellValue('H' . $startFrom, $liveChat->user->detail->nIDJenisKelamin == 1 ? 'Laki-laki' : 'Wanita');
|
$sheet->setCellValue('K' . $startFromSheet1, (string)($liveChat->userInsurance->sPlanCode ?? '-'));
|
||||||
$sheet->setCellValue('I' . $startFrom, Helper::calculateAge($liveChat->user->detail->dTanggalLahir) ?? '-');
|
$sheet->setCellValue('L' . $startFromSheet1, $nIDHubunganKeluarga ?? '-');
|
||||||
$sheet->setCellValue('J' . $startFrom, (string)($liveChat->userInsurance->sProductCode ?? '-'));
|
$sheet->setCellValue('M' . $startFromSheet1, $requestTime->format('Y-m-d'));
|
||||||
$sheet->setCellValue('K' . $startFrom, (string)($liveChat->userInsurance->sPlanCode ?? '-'));
|
$sheet->setCellValue('N' . $startFromSheet1, $liveChat->summary->sSubjective ?? '-');
|
||||||
$sheet->setCellValue('L' . $startFrom, $nIDHubunganKeluarga ?? '-');
|
$sheet->setCellValue('O' . $startFromSheet1, $diagnosaCode ?? '-');
|
||||||
$sheet->setCellValue('M' . $startFrom, $requestTime->format('Y-m-d'));
|
$sheet->setCellValue('P' . $startFromSheet1, $diagnosa ?? '-');
|
||||||
$sheet->setCellValue('N' . $startFrom, $liveChat->summary->sSubjective ?? '-');
|
$sheet->setCellValue('Q' . $startFromSheet1, $startTime->format('H:i:s'));
|
||||||
$sheet->setCellValue('O' . $startFrom, $diagnosaCode ?? '-');
|
$sheet->setCellValue('R' . $startFromSheet1, $endTime->format('H:i:s'));
|
||||||
$sheet->setCellValue('P' . $startFrom, $diagnosa ?? '-');
|
$sheet->setCellValue('S' . $startFromSheet1, $chatTime);
|
||||||
$sheet->setCellValue('Q' . $startFrom, $startTime->format('H:i:s'));
|
// $sheet->setCellValue('O' . $startFromSheet1, $recordType);
|
||||||
$sheet->setCellValue('R' . $startFrom, $endTime->format('H:i:s'));
|
// $sheet->setCellValue('P' . $startFromSheet1, $nIDUser ?? '-');
|
||||||
$sheet->setCellValue('S' . $startFrom, $chatTime);
|
// $sheet->setCellValue('Q' . $startFromSheet1, $paymentMethod ?? '-');
|
||||||
// $sheet->setCellValue('O' . $startFrom, $recordType);
|
$sheet->setCellValue('T' . $startFromSheet1, $statusLivechat);
|
||||||
// $sheet->setCellValue('P' . $startFrom, $nIDUser ?? '-');
|
$sheet->setCellValue('U' . $startFromSheet1, $liveChat->prescription->sKodeResep ?? '-');
|
||||||
// $sheet->setCellValue('Q' . $startFrom, $paymentMethod ?? '-');
|
$sheet->setCellValue('V' . $startFromSheet1, $fullNameDoctor);
|
||||||
$sheet->setCellValue('T' . $startFrom, $statusLivechat);
|
$sheet->setCellValue('W' . $startFromSheet1, $liveChat->doctor->speciality->sSpesialis ?? '-');
|
||||||
$sheet->setCellValue('U' . $startFrom, $liveChat->prescription->sKodeResep ?? '-');
|
$sheet->setCellValue('X' . $startFromSheet1, $liveChat->rujukan ? 'Ya' : 'Tidak');
|
||||||
$sheet->setCellValue('V' . $startFrom, $fullNameDoctor);
|
$sheet->setCellValue('Y' . $startFromSheet1, $liveChat->rujukan->sDepartement ?? '-' );
|
||||||
$sheet->setCellValue('W' . $startFrom, $liveChat->doctor->speciality->sSpesialis ?? '-');
|
|
||||||
$sheet->setCellValue('X' . $startFrom, $liveChat->rujukan ? 'Ya' : 'Tidak');
|
|
||||||
$sheet->setCellValue('Y' . $startFrom, $liveChat->rujukan->sDepartement ?? '-' );
|
|
||||||
|
|
||||||
$sheet->setCellValue('Z' . $startFrom, '-');
|
$sheet->setCellValue('Z' . $startFromSheet1, '-');
|
||||||
$sheet->setCellValue('AA' . $startFrom, $tebusResep);
|
$sheet->setCellValue('AA' . $startFromSheet1, $tebusResep);
|
||||||
|
|
||||||
$sheet->setCellValue('AB' . $startFrom, 'LMS');
|
$sheet->setCellValue('AB' . $startFromSheet1, '-');
|
||||||
|
$sheet->setCellValue('AC' . $startFromSheet1, '-');
|
||||||
|
$sheet->setCellValue('AD' . $startFromSheet1, 'LMS');
|
||||||
// $sheet->setCellValue('AC' . $startFrom, $liveChat->prescription->dCreateOn ?? '-');
|
// $sheet->setCellValue('AC' . $startFrom, $liveChat->prescription->dCreateOn ?? '-');
|
||||||
// $sheet->setCellValue('AD' . $startFrom, $obat);
|
// $sheet->setCellValue('AD' . $startFrom, $obat);
|
||||||
// $sheet->setCellValue('AE' . $startFrom, $tebusResep);
|
// $sheet->setCellValue('AE' . $startFrom, $tebusResep);
|
||||||
@@ -645,119 +660,10 @@ class LivechatController extends Controller
|
|||||||
// $sheet->setCellValue('AH' . $startFrom, $liveChat->rujukan->sDepartement ?? '-');
|
// $sheet->setCellValue('AH' . $startFrom, $liveChat->rujukan->sDepartement ?? '-');
|
||||||
// $sheet->setCellValue('AI' . $startFrom, $liveChat->summary->sSubjective ?? '-');
|
// $sheet->setCellValue('AI' . $startFrom, $liveChat->summary->sSubjective ?? '-');
|
||||||
// $sheet->setCellValue('AJ' . $startFrom, $liveChat->sNoSpj ?? '-');
|
// $sheet->setCellValue('AJ' . $startFrom, $liveChat->sNoSpj ?? '-');
|
||||||
$startFrom++;
|
$startFromSheet1++;
|
||||||
}
|
} else {
|
||||||
|
if ($liveChat->prescription->items){
|
||||||
foreach (['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J','K', 'L', 'M', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB'] as $header) {
|
foreach($liveChat->prescription->items as $data){
|
||||||
// if ($header === 'A') {
|
|
||||||
// $spreadsheet->getActiveSheet()->getColumnDimension($header)->setWidth(35, 'px');
|
|
||||||
// } elseif ($header === 'H' || $header === 'I') {
|
|
||||||
// $spreadsheet->getActiveSheet()->getColumnDimension($header)->setWidth(100, 'px');
|
|
||||||
// } else {
|
|
||||||
$spreadsheet->getActiveSheet()->getColumnDimension($header)->setAutoSize(true);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
// $spreadsheet->getActiveSheet()->getStyle('A2:A' . $startFrom)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER)->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
|
|
||||||
|
|
||||||
$sheet->getDefaultRowDimension()->setRowHeight(-1);
|
|
||||||
$sheet->setTitle('Live Chat Report');
|
|
||||||
|
|
||||||
$writer = new Xlsx($spreadsheet);
|
|
||||||
ob_start();
|
|
||||||
$writer->save('php://output');
|
|
||||||
$content = ob_get_contents();
|
|
||||||
ob_end_clean();
|
|
||||||
|
|
||||||
$fileName = 'result-' . now()->getPreciseTimestamp(3) . '-livechat-report.xlsx';
|
|
||||||
Storage::disk('public')->put('temp/' . $fileName, $content);
|
|
||||||
|
|
||||||
$fileUrl = url('storage/temp/' . $fileName);
|
|
||||||
|
|
||||||
return Helper::responseJson([
|
|
||||||
"file_url" => $fileUrl
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function exportMonthly(Request $request)
|
|
||||||
{
|
|
||||||
$startDate = $request->has('startDate') ? $request->input('startDate') : '';
|
|
||||||
$endDate = $request->has('endDate') ? $request->input('endDate') : '';
|
|
||||||
|
|
||||||
$liveChats = Livechat::with('userInsurance',
|
|
||||||
'user:nID,sFirstName,sLastName,sEmail,sPhone,nIDUser,nIDHubunganKeluarga',
|
|
||||||
'doctor:nID,nIDSpesialis,nIDUser', 'doctor.user:nID,sFirstName,sLastName',
|
|
||||||
'appointment:nID,sPaymentStatus,sPaymentMethod',
|
|
||||||
'appointment.appointmentDetail:nID,nIDAppointment,dTanggalAppointment,tTimeAppointment',
|
|
||||||
'healthCare:nID,sHealthCare',
|
|
||||||
'prescription',
|
|
||||||
'rujukan'
|
|
||||||
)
|
|
||||||
->whereHas('userInsurance', function (Builder $query) {
|
|
||||||
// Kondisi pada relasi userInsurance
|
|
||||||
$query->where('nIDInsurance', 107); // khusus inhealth
|
|
||||||
})
|
|
||||||
->where(function (Builder $query) use ($startDate, $endDate) {
|
|
||||||
// $query->where('nIDAppointment', '!=', null);
|
|
||||||
// $query->where('nIDAppointment', '!=', '');
|
|
||||||
if ($startDate) {
|
|
||||||
$query->where('dCreateOn', '>=', $startDate);
|
|
||||||
}
|
|
||||||
if ($endDate) {
|
|
||||||
$endDate = date('Y-m-d', strtotime($endDate . ' +1 day'));
|
|
||||||
$query->where('dCreateOn', '<', $endDate);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
->orderBy('nID', 'desc')
|
|
||||||
->get(['nID', 'nIDUser', 'nIDDokter', 'nIDHealthCare', 'nIDAppointment', 'sStatus', 'sMediaDokter', 'sMedia', 'dCreateOn', 'sNoSpj', 'dRequestTime', 'dAcceptTime', 'dStartTime', 'dEndTime']);
|
|
||||||
|
|
||||||
$headers = [
|
|
||||||
['value' => 'ConsultationId', 'cell' => 'A1', 'mergeCell' => false, 'mergeToCell' => ''],
|
|
||||||
['value' => 'No SJP', 'cell' => 'B1', 'mergeCell' => false, 'mergeToCell' => ''],
|
|
||||||
['value' => 'PKSKD', 'cell' => 'C1', 'mergeCell' => false, 'mergeToCell' => ''],
|
|
||||||
['value' => 'PKSNM', 'cell' => 'D1', 'mergeCell' => false, 'mergeToCell' => ''],
|
|
||||||
['value' => 'Card Number', 'cell' => 'E1', 'mergeCell' => false, 'mergeToCell' => ''],
|
|
||||||
['value' => 'NamaPasien', 'cell' => 'F1', 'mergeCell' => false, 'mergeToCell' => ''],
|
|
||||||
['value' => 'JenisKelamin', 'cell' => 'G1', 'mergeCell' => false, 'mergeToCell' => ''],
|
|
||||||
['value' => 'TanggalLahir', 'cell' => 'H1', 'mergeCell' => false, 'mergeToCell' => ''],
|
|
||||||
['value' => 'Usia', 'cell' => 'I1', 'mergeCell' => false, 'mergeToCell' => ''],
|
|
||||||
['value' => 'Produk', 'cell' => 'J1', 'mergeCell' => false, 'mergeToCell' => ''],
|
|
||||||
['value' => 'Plan', 'cell' => 'K1', 'mergeCell' => false, 'mergeToCell' => ''],
|
|
||||||
['value' => 'DependencyStatus', 'cell' => 'L1', 'mergeCell' => false, 'mergeToCell' => ''],
|
|
||||||
['value' => 'TanggalKonsultasi', 'cell' => 'M1', 'mergeCell' => false, 'mergeToCell' => ''],
|
|
||||||
['value' => 'Keluhan', 'cell' => 'N1', 'mergeCell' => false, 'mergeToCell' => ''],
|
|
||||||
['value' => 'Kode Diagnosa', 'cell' => 'O1', 'mergeCell' => false, 'mergeToCell' => ''],
|
|
||||||
['value' => 'Diagnosa', 'cell' => 'P1', 'mergeCell' => false, 'mergeToCell' => ''],
|
|
||||||
['value' => 'StartTime', 'cell' => 'Q1', 'mergeCell' => false, 'mergeToCell' => ''],
|
|
||||||
['value' => 'EndTime', 'cell' => 'R1', 'mergeCell' => false, 'mergeToCell' => ''],
|
|
||||||
['value' => 'DurasiKonsultasi', 'cell' => 'S1', 'mergeCell' => false, 'mergeToCell' => ''],
|
|
||||||
['value' => 'StatusKonsultasi', 'cell' => 'T1', 'mergeCell' => false, 'mergeToCell' => ''],
|
|
||||||
['value' => 'PrescriptionNumber', 'cell' => 'U1', 'mergeCell' => false, 'mergeToCell' => ''],
|
|
||||||
['value' => 'NamaDokter', 'cell' => 'V1', 'mergeCell' => false, 'mergeToCell' => ''],
|
|
||||||
['value' => 'Jenis Dokter', 'cell' => 'W1', 'mergeCell' => false, 'mergeToCell' => ''],
|
|
||||||
['value' => 'Rujuk (Ya/Tidak)', 'cell' => 'X1', 'mergeCell' => false, 'mergeToCell' => ''],
|
|
||||||
['value' => 'Poli', 'cell' => 'Y1', 'mergeCell' => false, 'mergeToCell' => ''],
|
|
||||||
['value' => 'Total', 'cell' => 'Z1', 'mergeCell' => false, 'mergeToCell' => ''],
|
|
||||||
['value' => 'Obat', 'cell' => 'AA1', 'mergeCell' => false, 'mergeToCell' => ''],
|
|
||||||
['value' => 'By', 'cell' => 'AB1', 'mergeCell' => false, 'mergeToCell' => ''],
|
|
||||||
];
|
|
||||||
|
|
||||||
$spreadsheet = new Spreadsheet();
|
|
||||||
$sheet = $spreadsheet->getActiveSheet();
|
|
||||||
|
|
||||||
foreach ($headers as $header) {
|
|
||||||
$sheet->setCellValue($header['cell'], $header['value']);
|
|
||||||
|
|
||||||
// if ($header['mergeCell'] === true) {
|
|
||||||
// $sheet->mergeCells($header['cell'] . ':' . $header['mergeToCell']);
|
|
||||||
// }
|
|
||||||
|
|
||||||
$sheet->getStyle($header['cell'])->getFont()->setBold(true);
|
|
||||||
$sheet->getStyle($header['cell'])->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER)->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
|
|
||||||
}
|
|
||||||
|
|
||||||
$startFrom = 2;
|
|
||||||
foreach ($liveChats as $indexLiveChat => $liveChat) {
|
|
||||||
$phone = $liveChat->user->sPhone ?? '-';
|
$phone = $liveChat->user->sPhone ?? '-';
|
||||||
$status = $liveChat->sStatus;
|
$status = $liveChat->sStatus;
|
||||||
$nIDUser = $liveChat->user->nIDUser ?? 0; // Principal or Dependent
|
$nIDUser = $liveChat->user->nIDUser ?? 0; // Principal or Dependent
|
||||||
@@ -785,6 +691,8 @@ class LivechatController extends Controller
|
|||||||
if ($nIDUser){
|
if ($nIDUser){
|
||||||
$recordType = 'D';
|
$recordType = 'D';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
switch ($status) {
|
switch ($status) {
|
||||||
case 0:
|
case 0:
|
||||||
$statusLivechat = "Request TC";
|
$statusLivechat = "Request TC";
|
||||||
@@ -833,15 +741,16 @@ class LivechatController extends Controller
|
|||||||
|
|
||||||
$diagnosa = '-';
|
$diagnosa = '-';
|
||||||
$diagnosaCode = '-';
|
$diagnosaCode = '-';
|
||||||
|
|
||||||
if($liveChat->summary){
|
if($liveChat->summary){
|
||||||
$diagnosis = explode(', ', $liveChat->summary->sAssessment);
|
$diagnosis = explode(', ', $liveChat->summary->sAssessment);
|
||||||
|
|
||||||
if ($diagnosis) {
|
if ($diagnosis) {
|
||||||
$diagnosaArray = [];
|
$diagnosaArray = [];
|
||||||
$diagnosaCodeArray = [];
|
$diagnosaCodeArray = [];
|
||||||
foreach($diagnosis as $data){
|
foreach($diagnosis as $dataDiagnosa){
|
||||||
$diagnosaArray[] = Helper::diagnosisName($data); // Tambahkan diagnosis ke array
|
$diagnosaArray[] = Helper::diagnosisName($dataDiagnosa); // Tambahkan diagnosis ke array
|
||||||
$diagnosaCodeArray[] = $data; // Tambahkan diagnosis ke array
|
$diagnosaCodeArray[] = $dataDiagnosa; // Tambahkan diagnosis ke array
|
||||||
}
|
}
|
||||||
|
|
||||||
$diagnosa = implode('; ', $diagnosaArray); // Gabungkan array dengan tanda koma
|
$diagnosa = implode('; ', $diagnosaArray); // Gabungkan array dengan tanda koma
|
||||||
@@ -849,6 +758,7 @@ class LivechatController extends Controller
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$tebusResep = 'Belum Ditebus';
|
$tebusResep = 'Belum Ditebus';
|
||||||
$paymentTebus = '-';
|
$paymentTebus = '-';
|
||||||
if ($liveChat->prescription){
|
if ($liveChat->prescription){
|
||||||
@@ -900,76 +810,74 @@ class LivechatController extends Controller
|
|||||||
}
|
}
|
||||||
|
|
||||||
$obat = '-';
|
$obat = '-';
|
||||||
if($liveChat->prescription){
|
$sheet2->setCellValue('A' . $startFromSheet2, $liveChat->nID ?? '-');
|
||||||
if ($liveChat->prescription->items){
|
$sheet2->setCellValue('B' . $startFromSheet2, $liveChat->sNoSpj ?? '-');
|
||||||
$obatArray = [];
|
$sheet2->setCellValue('C' . $startFromSheet2, (string)($liveChat->userInsurance->sCorporateCode ?? '-'));
|
||||||
foreach($liveChat->prescription->items as $data){
|
$sheet2->setCellValue('D' . $startFromSheet2, (string)($liveChat->userInsurance->sCorporateName ?? '-'));
|
||||||
$obatArray[] = $data->sItemName .' - '. $data->nQty;
|
$sheet2->setCellValue('E' . $startFromSheet2, (string)($liveChat->userInsurance->sNoPolis ?? '-'));
|
||||||
|
$sheet2->setCellValue('F' . $startFromSheet2, $liveChat->user->full_name ?? '-');
|
||||||
|
$sheet2->setCellValue('G' . $startFromSheet2, $liveChat->user->detail->dTanggalLahir ?? '-');
|
||||||
|
$sheet2->setCellValue('H' . $startFromSheet2, $liveChat->user->detail->nIDJenisKelamin == 1 ? 'Laki-laki' : 'Wanita');
|
||||||
|
$sheet2->setCellValue('I' . $startFromSheet2, Helper::calculateAge($liveChat->user->detail->dTanggalLahir) ?? '-');
|
||||||
|
$sheet2->setCellValue('J' . $startFromSheet2, (string)($liveChat->userInsurance->sProductCode ?? '-'));
|
||||||
|
$sheet2->setCellValue('K' . $startFromSheet2, (string)($liveChat->userInsurance->sPlanCode ?? '-'));
|
||||||
|
$sheet2->setCellValue('L' . $startFromSheet2, $nIDHubunganKeluarga ?? '-');
|
||||||
|
$sheet2->setCellValue('M' . $startFromSheet2, $requestTime->format('Y-m-d'));
|
||||||
|
$sheet2->setCellValue('N' . $startFromSheet2, $liveChat->summary->sSubjective ?? '-');
|
||||||
|
$sheet2->setCellValue('O' . $startFromSheet2, $diagnosaCode ?? '-');
|
||||||
|
$sheet2->setCellValue('P' . $startFromSheet2, $diagnosa ?? '-');
|
||||||
|
$sheet2->setCellValue('Q' . $startFromSheet2, $startTime->format('H:i:s'));
|
||||||
|
$sheet2->setCellValue('R' . $startFromSheet2, $endTime->format('H:i:s'));
|
||||||
|
$sheet2->setCellValue('S' . $startFromSheet2, $chatTime);
|
||||||
|
// $sheet2->setCellValue('O' . $startFromSheet2, $recordType);
|
||||||
|
// $sheet2->setCellValue('P' . $startFromSheet2, $nIDUser ?? '-');
|
||||||
|
// $sheet2->setCellValue('Q' . $startFromSheet2, $paymentMethod ?? '-');
|
||||||
|
$sheet2->setCellValue('T' . $startFromSheet2, $statusLivechat);
|
||||||
|
$sheet2->setCellValue('U' . $startFromSheet2, $liveChat->prescription->sKodeResep ?? '-');
|
||||||
|
$sheet2->setCellValue('V' . $startFromSheet2, $fullNameDoctor);
|
||||||
|
$sheet2->setCellValue('W' . $startFromSheet2, $liveChat->doctor->speciality->sSpesialis ?? '-');
|
||||||
|
$sheet2->setCellValue('X' . $startFromSheet2, $liveChat->rujukan ? 'Ya' : 'Tidak');
|
||||||
|
$sheet2->setCellValue('Y' . $startFromSheet2, $liveChat->rujukan->sDepartement ?? '-' );
|
||||||
|
|
||||||
|
$sheet2->setCellValue('Z' . $startFromSheet2, '-');
|
||||||
|
$sheet2->setCellValue('AA' . $startFromSheet2, $tebusResep);
|
||||||
|
|
||||||
|
$sheet2->setCellValue('AB' . $startFromSheet2, $data->sItemName);
|
||||||
|
$sheet2->setCellValue('AC' . $startFromSheet2, $data->nQty);
|
||||||
|
$sheet2->setCellValue('AD' . $startFromSheet2, 'LMS');
|
||||||
|
// $sheet->setCellValue('AC' . $startFromSheet2, $liveChat->prescription->dCreateOn ?? '-');
|
||||||
|
// $sheet->setCellValue('AD' . $startFromSheet2, $obat);
|
||||||
|
// $sheet->setCellValue('AE' . $startFromSheet2, $tebusResep);
|
||||||
|
|
||||||
|
// $sheet->setCellValue('AF' . $startFromSheet2, $paymentTebus);
|
||||||
|
// $sheet->setCellValue('AG' . $startFromSheet2, $liveChat->rujukan->nIDHealthcare ?? '-');
|
||||||
|
// $sheet->setCellValue('AH' . $startFromSheet2, $liveChat->rujukan->sDepartement ?? '-');
|
||||||
|
// $sheet->setCellValue('AI' . $startFromSheet2, $liveChat->summary->sSubjective ?? '-');
|
||||||
|
// $sheet->setCellValue('AJ' . $startFromSheet2, $liveChat->sNoSpj ?? '-');
|
||||||
|
$startFromSheet2++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$obat = implode('; ',$obatArray);
|
foreach (['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J','K', 'L', 'M', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB', 'AC', 'AD'] as $header) {
|
||||||
}
|
|
||||||
};
|
|
||||||
$sheet->setCellValue('A' . $startFrom, $liveChat->nID ?? '-');
|
|
||||||
$sheet->setCellValue('B' . $startFrom, $liveChat->sNoSpj ?? '-');
|
|
||||||
$sheet->setCellValue('C' . $startFrom, (string)($liveChat->userInsurance->sCorporateCode ?? '-'));
|
|
||||||
$sheet->setCellValue('D' . $startFrom, (string)($liveChat->userInsurance->sCorporateName ?? '-'));
|
|
||||||
$sheet->setCellValue('E' . $startFrom, (string)($liveChat->userInsurance->sNoPolis ?? '-'));
|
|
||||||
$sheet->setCellValue('F' . $startFrom, $liveChat->user->full_name ?? '-');
|
|
||||||
$sheet->setCellValue('G' . $startFrom, $liveChat->user->detail->dTanggalLahir ?? '-');
|
|
||||||
$sheet->setCellValue('H' . $startFrom, $liveChat->user->detail->nIDJenisKelamin == 1 ? 'Laki-laki' : 'Wanita');
|
|
||||||
$sheet->setCellValue('I' . $startFrom, Helper::calculateAge($liveChat->user->detail->dTanggalLahir) ?? '-');
|
|
||||||
$sheet->setCellValue('J' . $startFrom, (string)($liveChat->userInsurance->sProductCode ?? '-'));
|
|
||||||
$sheet->setCellValue('K' . $startFrom, (string)($liveChat->userInsurance->sPlanCode ?? '-'));
|
|
||||||
$sheet->setCellValue('L' . $startFrom, $nIDHubunganKeluarga ?? '-');
|
|
||||||
$sheet->setCellValue('M' . $startFrom, $requestTime->format('Y-m-d'));
|
|
||||||
$sheet->setCellValue('N' . $startFrom, $liveChat->summary->sSubjective ?? '-');
|
|
||||||
$sheet->setCellValue('O' . $startFrom, $diagnosaCode ?? '-');
|
|
||||||
$sheet->setCellValue('P' . $startFrom, $diagnosa ?? '-');
|
|
||||||
$sheet->setCellValue('Q' . $startFrom, $startTime->format('H:i:s'));
|
|
||||||
$sheet->setCellValue('R' . $startFrom, $endTime->format('H:i:s'));
|
|
||||||
$sheet->setCellValue('S' . $startFrom, $chatTime);
|
|
||||||
// $sheet->setCellValue('O' . $startFrom, $recordType);
|
|
||||||
// $sheet->setCellValue('P' . $startFrom, $nIDUser ?? '-');
|
|
||||||
// $sheet->setCellValue('Q' . $startFrom, $paymentMethod ?? '-');
|
|
||||||
$sheet->setCellValue('T' . $startFrom, $statusLivechat);
|
|
||||||
$sheet->setCellValue('U' . $startFrom, $liveChat->prescription->sKodeResep ?? '-');
|
|
||||||
$sheet->setCellValue('V' . $startFrom, $fullNameDoctor);
|
|
||||||
$sheet->setCellValue('W' . $startFrom, $liveChat->doctor->speciality->sSpesialis ?? '-');
|
|
||||||
$sheet->setCellValue('X' . $startFrom, $liveChat->rujukan ? 'Ya' : 'Tidak');
|
|
||||||
$sheet->setCellValue('Y' . $startFrom, $liveChat->rujukan->sDepartement ?? '-' );
|
|
||||||
|
|
||||||
$sheet->setCellValue('Z' . $startFrom, '-');
|
|
||||||
$sheet->setCellValue('AA' . $startFrom, $tebusResep);
|
|
||||||
|
|
||||||
$sheet->setCellValue('AB' . $startFrom, 'LMS');
|
|
||||||
// $sheet->setCellValue('AC' . $startFrom, $liveChat->prescription->dCreateOn ?? '-');
|
|
||||||
// $sheet->setCellValue('AD' . $startFrom, $obat);
|
|
||||||
// $sheet->setCellValue('AE' . $startFrom, $tebusResep);
|
|
||||||
|
|
||||||
// $sheet->setCellValue('AF' . $startFrom, $paymentTebus);
|
|
||||||
// $sheet->setCellValue('AG' . $startFrom, $liveChat->rujukan->nIDHealthcare ?? '-');
|
|
||||||
// $sheet->setCellValue('AH' . $startFrom, $liveChat->rujukan->sDepartement ?? '-');
|
|
||||||
// $sheet->setCellValue('AI' . $startFrom, $liveChat->summary->sSubjective ?? '-');
|
|
||||||
// $sheet->setCellValue('AJ' . $startFrom, $liveChat->sNoSpj ?? '-');
|
|
||||||
$startFrom++;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J','K', 'L', 'M', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB'] 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 === 'H' || $header === 'I') {
|
||||||
// $spreadsheet->getActiveSheet()->getColumnDimension($header)->setWidth(100, 'px');
|
// $spreadsheet->getActiveSheet()->getColumnDimension($header)->setWidth(100, 'px');
|
||||||
// } else {
|
// } else {
|
||||||
$spreadsheet->getActiveSheet()->getColumnDimension($header)->setAutoSize(true);
|
$spreadsheet->getActiveSheet(0)->getColumnDimension($header)->setAutoSize(true);
|
||||||
|
$spreadsheet->getActiveSheet(1)->getColumnDimension($header)->setAutoSize(true);
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
// $spreadsheet->getActiveSheet()->getStyle('A2:A' . $startFrom)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER)->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
|
// $spreadsheet->getActiveSheet()->getStyle('A2:A' . $startFrom)->getAlignment()->setHorizontal(\PhpOffice\PhpSpreadsheet\Style\Alignment::HORIZONTAL_CENTER)->setVertical(\PhpOffice\PhpSpreadsheet\Style\Alignment::VERTICAL_CENTER);
|
||||||
|
|
||||||
$sheet->getDefaultRowDimension()->setRowHeight(-1);
|
$sheet->getDefaultRowDimension()->setRowHeight(-1);
|
||||||
$sheet->setTitle('Live Chat Report');
|
$sheet->setTitle('Live Chat Report');
|
||||||
|
|
||||||
|
$sheet2->getDefaultRowDimension()->setRowHeight(-1);
|
||||||
|
$sheet2->setTitle('DATA KHUSUS OBAT');
|
||||||
|
|
||||||
$writer = new Xlsx($spreadsheet);
|
$writer = new Xlsx($spreadsheet);
|
||||||
ob_start();
|
ob_start();
|
||||||
$writer->save('php://output');
|
$writer->save('php://output');
|
||||||
|
|||||||
Reference in New Issue
Block a user