Fix function jananotis

This commit is contained in:
Amir
2023-01-07 11:46:41 +08:00
parent d847bc5bbd
commit 589b600d73
3 changed files with 52 additions and 7 deletions
+47
View File
@@ -190,6 +190,53 @@ class NotisController extends Controller
}
public function jananotis2($lelong_id)
{
// focus only on variable: $marhuns, $lelongid, $caw, $tarikh_cetak
// variable not use: $lelong_id, $customer, $listsag
$user = Auth::user();
$caw = Cawangan::where('caw_code', '=', $user->kodcaw)->first();
$currentdate = Carbon::now();
$tarikh_cetak = $currentdate->toDateString();
$lelongid = Lelong::find($lelong_id);
$arraynorujukan = LelongBid::where('lelong_id', $lelong_id)->where('kodcaw', $caw->caw_code)->pluck('norujukan');
$marhuns = Gadai::on($caw->caw_code)->whereIn('norujukan', $arraynorujukan)->select('nokp', 'norujukan')->orderBy('nokp', 'asc')->get();
$marhuns_pluck_nokp = $marhuns->pluck('nokp');
$customers = Customer::whereIn('kpbaru', $marhuns_pluck_nokp)
->orWhereIn('kplama', $marhuns_pluck_nokp)
->join('poskod', 'customer.poskod', '=', 'poskod.poskod')
->join('daerah', 'poskod.koddaerah', '=', 'daerah.koddaerah')
->join('negeri', 'poskod.kodnegeri', '=', 'negeri.kodnegeri')
->get();
$customers_keyBy_noKp = $customers->keyBy(function ($item) {
if ($item->kpbaru != '') {
return $item->kpbaru;
} else if ($item->kplama != '') {
return $item->kplama;
}
});
foreach ($marhuns as $index => $marhun) {
if ($customers_keyBy_noKp[$marhun->nokp]) {
$marhuns[$index]['nama'] = $customers_keyBy_noKp[$marhun->nokp];
}
}
$pdf = PDF::loadView('pdf.jananotis', compact('marhuns', 'lelongid', 'caw', 'tarikh_cetak'))
->setPaper('a4', 'potrait');
return $pdf->download('Penjanaan Notis Fasa 1:Batch Lelong ' . $lelong_id . '.pdf');
}
public function listnotis(Request $request){