tambah format baru notis lelong 30jun

This commit is contained in:
BTMS2
2024-07-04 13:45:02 +08:00
parent be39254e52
commit 884c061b50
5 changed files with 446 additions and 1 deletions
+85
View File
@@ -330,6 +330,91 @@ class NotisController extends Controller
return $pdf->download('Penjanaan Notis Fasa 1:Batch Lelong ' . $lelong_id . '.pdf');
}
public function jananotis2_new($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();
$current_date_time = $currentdate->toDateTimeString();
Log::info("Jana notis fasa 1: " . $user->kodcaw . ", " . $user->name);
NotifyJanaNotis::dispatch($user->id, $user->kodcaw, $user->name, 'Jana Notis Fasa 1', $current_date_time);
$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','bakipjm','tagbaru')->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];
}
$getdatalelongbid = LelongBid::where('lelong_id', $lelong_id)->where('norujukan', $marhun->norujukan)->first();
//jika ambil data dari api
$tagbaru = $marhun->tagbaru;
// dd($tagbaru);
if($tagbaru == '0'){
$getkeuntunganhinggatarikhlelong = Http::get(config('app.api_ujrah_url'). 'get/upahtawarruqbytarikh',[
'kodcaw' => $user->kodcaw,
'norujukan' => $marhun->norujukan,
'tarikh' => $getdatalelongbid['t_lelong'],
'jeniskeuntungan' => 'asal'
])->json();
}elseif($tagbaru == '1'){
$getkeuntunganhinggatarikhlelong = Http::get(config('app.api_ujrah_url'). 'get/upahtawarruqbytarikh',[
'kodcaw' => $user->kodcaw,
'norujukan' => $marhun->norujukan,
'tarikh' => $getdatalelongbid['t_lelong'],
'jeniskeuntungan' => 'onepercent'
])->json();
}
// dd($getkeuntunganhinggatarikhlelong);
$nilaitebus = (float) $getkeuntunganhinggatarikhlelong['harga_tebus'];
$nilaipembiayaan = (float) $getdatalelongbid['pinjaman'];
$nilaikeuntungan = (float) $getkeuntunganhinggatarikhlelong['upahsemasa'];
$jumlah = $nilaipembiayaan + $nilaikeuntungan;
$marhuns[$index]['nilaitebus'] = $nilaitebus;
$marhuns[$index]['nilaipembiayaan'] = $nilaipembiayaan;
$marhuns[$index]['nilaikeuntungan'] = $nilaikeuntungan;
$marhuns[$index]['jumlah'] = $jumlah;
}
// return view('pdf.jananotis', compact('marhuns', 'lelongid', 'caw', 'tarikh_cetak'));
$pdf = PDF::loadView('pdf.jananotis_new', 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){