update report using relation, fix error jana notis 30 hari

This commit is contained in:
Amirah22
2022-11-08 09:53:47 +08:00
parent 3d614dd677
commit 3a2128cff7
6 changed files with 70 additions and 65 deletions
+8 -44
View File
@@ -89,23 +89,12 @@ class ReportController extends Controller
$arrayinfo = [];
$lelongid = Lelong::join('cawangan_lelong','lelong.id','=','cawangan_lelong.lelong_id')
->join('cawangan','cawangan_lelong.caw_id','=','cawangan.id')
->where('cawangan_lelong.lelong_id','=',$lelong_id)
->where('cawangan.caw_code', $kodcaw)
->select('lelong_id','tarikh_lelong','lelong.fasa')
->groupBy('lelong_id')
->get()->toArray();
$test = Lelong::with(['cawangan','lelongBid'])
->find($lelong_id);
foreach($lelongid as $laporan)
{
$details = CawanganLelong::join('cawangan','cawangan_lelong.caw_id','=','cawangan.id')
->where('lelong_id',$laporan['lelong_id'])
->where('cawangan.caw_code', $kodcaw)
->get()
->toArray();
array_push($arrayinfo,['laporan' => $laporan,'details' => $details]);
}
$cawangan = $test->cawangan;
$lelong_bid = $test->lelongBid;
$keuntungan=0;
@@ -113,39 +102,14 @@ class ReportController extends Controller
$total_berat = 0;
$marhun = LelongBid::join('cawangan', 'lelongbid.caw_id', '=', 'cawangan.id')
->where('lelong_id','=',$lelong_id)
->where('lelongbid.kodcaw', $kodcaw);
$arraynorujukan = $marhun->pluck('norujukan')->toArray();
$datasimulasi = $marhun->get();
foreach($datasimulasi as $index=>$totharga){
$total_hargaasas = $lelong_bid->sum('hargaasas');
$total_berat = $lelong_bid->sum('berat');
$total_hargaasas = $total_hargaasas + $totharga['hargaasas'];
$total_berat = $total_berat + $totharga['berat'];
}
$marhuns = Gadai::on($datasimulasi[0]['kodcaw'])->whereIn('norujukan', $arraynorujukan)
->get()->toArray();
// dd($marhuns);
foreach($marhuns as $index1=>$upah)
{
$listsag = Gadai::on($datasimulasi[0]['kodcaw'])->whereIn('norujukan', $arraynorujukan)
->where('nokp','=',$upah['nokp'])
->get();
}
$marhuns[$index1]['listsag'] = $listsag;
$pdf = PDF::loadView('pdf.listlelong',compact('arrayinfo','marhuns','lelong_id','keuntungan','total_hargaasas',
'total_berat','datasimulasi'))
$pdf = PDF::loadView('pdf.listlelong',compact('cawangan','lelong_bid','total_hargaasas','total_berat'))
->setPaper('a4', 'potrait');
return $pdf->download('Senarai Barang Lelong.pdf');