update report using relation, fix error jana notis 30 hari
This commit is contained in:
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user