update
This commit is contained in:
@@ -5,6 +5,7 @@ namespace Modules\Internal\Http\Controllers\Api;
|
||||
use App\Helpers\Helper;
|
||||
use App\Models\OLDLMS\Livechat;
|
||||
use App\Models\OLDLMS\Appointment;
|
||||
use App\Models\Organization;
|
||||
use Illuminate\Contracts\Support\Renderable;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Http\Request;
|
||||
@@ -25,12 +26,18 @@ class LivechatController extends Controller
|
||||
{
|
||||
$startDate = $request->startDate;
|
||||
$endDate = $request->endDate;
|
||||
$search = $request->search;
|
||||
|
||||
$livechat = Livechat::with('doctor.user', 'doctor.speciality', 'appointment.appointmentDetail', 'healthCare');
|
||||
$livechat = Livechat::with('doctor.user', 'doctor.speciality', 'appointment.appointmentDetail', 'healthCare', 'user');
|
||||
// ->where('nIDAppointment', '!=', null)
|
||||
// ->where('nIDAppointment', '!=', '');
|
||||
|
||||
|
||||
if ($search) {
|
||||
$livechat = $livechat->whereHas('user', function ($query) use ($search) {
|
||||
$query->where('sFirstName', 'like', '%' . $search . '%')
|
||||
->orWhere('sLastName', 'like', '%' . $search . '%');
|
||||
});
|
||||
}
|
||||
if ($startDate) {
|
||||
$livechat = $livechat->where('dCreateOn', '>=', $startDate);
|
||||
}
|
||||
@@ -443,9 +450,10 @@ class LivechatController extends Controller
|
||||
['value' => 'Poli', 'cell' => 'Y1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'Total', 'cell' => 'Z1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'Obat', 'cell' => 'AA1', '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' => ''],
|
||||
['value' => 'Apotek', 'cell' => 'AB1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'Nama Obat', 'cell' => 'AC1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'Jumlah Obat', 'cell' => 'AD1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
['value' => 'By', 'cell' => 'AE1', 'mergeCell' => false, 'mergeToCell' => ''],
|
||||
];
|
||||
|
||||
$spreadsheet = new Spreadsheet();
|
||||
@@ -472,7 +480,7 @@ class LivechatController extends Controller
|
||||
$startFromSheet1 = 2;
|
||||
$startFromSheet2 = 2;
|
||||
foreach ($liveChats as $indexLiveChat => $liveChat) {
|
||||
if (!$liveChat->prescription) {
|
||||
//###################### SHEET 1 ##########
|
||||
$phone = $liveChat->user->sPhone ?? '-';
|
||||
$status = $liveChat->sStatus;
|
||||
$nIDUser = $liveChat->user->nIDUser ?? 0; // Principal or Dependent
|
||||
@@ -566,6 +574,11 @@ class LivechatController extends Controller
|
||||
|
||||
$tebusResep = 'Belum Ditebus';
|
||||
$paymentTebus = '-';
|
||||
$obat = '-';
|
||||
$obatQty = '-';
|
||||
$qtyTotal = 0;
|
||||
// Nama Apotek
|
||||
$apotek = '-';
|
||||
if ($liveChat->prescription){
|
||||
// Tanggal target (misalnya, dari database atau input)
|
||||
$tanggalResep = Carbon::parse($liveChat->prescription->dTanggalResep);
|
||||
@@ -584,10 +597,31 @@ class LivechatController extends Controller
|
||||
}
|
||||
if($liveChat->prescription->payment){
|
||||
$tebusResep = 'Online';
|
||||
$apotek = Organization::where('code', $liveChat->prescription->payment->nIDApotek)->first();
|
||||
if ($apotek){
|
||||
$apotek = $apotek->name;
|
||||
} else {
|
||||
$apotek = '-';
|
||||
}
|
||||
|
||||
if ($liveChat->prescription->payment->sPaymentStatus == 'paid'){
|
||||
$paymentTebus = Carbon::parse($liveChat->prescription->payment->dCreateOn)->format('d-m-Y H:i:s');
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
if ($liveChat->prescription->items){
|
||||
$obatArray = [];
|
||||
$obatQtyArray = [];
|
||||
foreach($liveChat->prescription->items as $data){
|
||||
$obatArray[] = $data->sItemName;
|
||||
$obatQtyArray[] = $data->nQty;
|
||||
$qtyTotal += $data->nQty;
|
||||
}
|
||||
|
||||
$obat = implode('; ',$obatArray);
|
||||
$obatQty = implode('; ',$obatQtyArray);
|
||||
}
|
||||
} else {
|
||||
$tebusResep = '-';
|
||||
}
|
||||
@@ -614,8 +648,6 @@ class LivechatController extends Controller
|
||||
$nIDHubunganKeluarga = $liveChat->user->relation->sHubunganKeluarga;
|
||||
}
|
||||
|
||||
$obat = '-';
|
||||
|
||||
$sheet->setCellValue('A' . $startFromSheet1, $liveChat->nID ?? '-');
|
||||
$sheet->setCellValue('B' . $startFromSheet1, $liveChat->sNoSpj ?? '-');
|
||||
$sheet->setCellValue('C' . $startFromSheet1, (string)($liveChat->userInsurance->sCorporateCode ?? '-'));
|
||||
@@ -645,12 +677,13 @@ class LivechatController extends Controller
|
||||
$sheet->setCellValue('X' . $startFromSheet1, $liveChat->rujukan ? 'Ya' : 'Tidak');
|
||||
$sheet->setCellValue('Y' . $startFromSheet1, $liveChat->rujukan->sDepartement ?? '-' );
|
||||
|
||||
$sheet->setCellValue('Z' . $startFromSheet1, '-');
|
||||
$sheet->setCellValue('Z' . $startFromSheet1, $qtyTotal);
|
||||
$sheet->setCellValue('AA' . $startFromSheet1, $tebusResep);
|
||||
|
||||
$sheet->setCellValue('AB' . $startFromSheet1, '-');
|
||||
$sheet->setCellValue('AC' . $startFromSheet1, '-');
|
||||
$sheet->setCellValue('AD' . $startFromSheet1, 'LMS');
|
||||
$sheet->setCellValue('AB' . $startFromSheet1, $apotek);
|
||||
$sheet->setCellValue('AC' . $startFromSheet1, $obat);
|
||||
$sheet->setCellValue('AD' . $startFromSheet1, $obatQty);
|
||||
$sheet->setCellValue('AE' . $startFromSheet1, 'LMS');
|
||||
// $sheet->setCellValue('AC' . $startFrom, $liveChat->prescription->dCreateOn ?? '-');
|
||||
// $sheet->setCellValue('AD' . $startFrom, $obat);
|
||||
// $sheet->setCellValue('AE' . $startFrom, $tebusResep);
|
||||
@@ -661,8 +694,13 @@ class LivechatController extends Controller
|
||||
// $sheet->setCellValue('AI' . $startFrom, $liveChat->summary->sSubjective ?? '-');
|
||||
// $sheet->setCellValue('AJ' . $startFrom, $liveChat->sNoSpj ?? '-');
|
||||
$startFromSheet1++;
|
||||
//###################### END SHEET 1 ##########
|
||||
if (!$liveChat->prescription) {
|
||||
|
||||
} else {
|
||||
if ($liveChat->prescription->items){
|
||||
$obatArray = [];
|
||||
$obatQtyArray = [];
|
||||
foreach($liveChat->prescription->items as $data){
|
||||
$phone = $liveChat->user->sPhone ?? '-';
|
||||
$status = $liveChat->sStatus;
|
||||
@@ -779,6 +817,13 @@ class LivechatController extends Controller
|
||||
}
|
||||
if($liveChat->prescription->payment){
|
||||
$tebusResep = 'Online';
|
||||
$apotek = Organization::where('id', $liveChat->prescription->payment->nIDApotek)->first();
|
||||
if ($apotek){
|
||||
$apotek = $apotek->name;
|
||||
} else {
|
||||
$apotek = '-';
|
||||
}
|
||||
|
||||
if ($liveChat->prescription->payment->sPaymentStatus == 'paid'){
|
||||
$paymentTebus = Carbon::parse($liveChat->prescription->payment->dCreateOn)->format('d-m-Y H:i:s');
|
||||
}
|
||||
@@ -809,7 +854,10 @@ class LivechatController extends Controller
|
||||
$nIDHubunganKeluarga = $liveChat->user->relation->sHubunganKeluarga;
|
||||
}
|
||||
|
||||
$obat = '-';
|
||||
$obat = $data->sItemName;
|
||||
$obatQty = $data->nQty;
|
||||
|
||||
|
||||
$sheet2->setCellValue('A' . $startFromSheet2, $liveChat->nID ?? '-');
|
||||
$sheet2->setCellValue('B' . $startFromSheet2, $liveChat->sNoSpj ?? '-');
|
||||
$sheet2->setCellValue('C' . $startFromSheet2, (string)($liveChat->userInsurance->sCorporateCode ?? '-'));
|
||||
@@ -842,9 +890,10 @@ class LivechatController extends Controller
|
||||
$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');
|
||||
$sheet2->setCellValue('AB' . $startFromSheet2, $apotek );
|
||||
$sheet2->setCellValue('AC' . $startFromSheet2, $obat);
|
||||
$sheet2->setCellValue('AD' . $startFromSheet2, $obatQty);
|
||||
$sheet2->setCellValue('AE' . $startFromSheet2, 'LMS');
|
||||
// $sheet->setCellValue('AC' . $startFromSheet2, $liveChat->prescription->dCreateOn ?? '-');
|
||||
// $sheet->setCellValue('AD' . $startFromSheet2, $obat);
|
||||
// $sheet->setCellValue('AE' . $startFromSheet2, $tebusResep);
|
||||
|
||||
Reference in New Issue
Block a user