add report ubah rugi dan ubah home add totalbid
This commit is contained in:
@@ -7210,7 +7210,30 @@ class LelongController extends Controller
|
||||
->toArray();
|
||||
array_push($arrayinfo,['laporan' => $laporan,'details' => $details]);
|
||||
}
|
||||
return view('lelong.senaraiubahrugilelongnew',compact('arraymarhun','marhuns','lelongid','cawid','arrayinfo','total_berat',
|
||||
|
||||
//check button kemaskini
|
||||
|
||||
$lelong = Lelong::with(['cawangan', 'lelongBidJual'])->find($lelongid);
|
||||
$allCawangan = $lelong->cawangan->keyBy('caw_code');
|
||||
$lelongBid = $lelong->lelongBidJual->where('caw_id', '=', $cawid)->groupBy('kodcaw');
|
||||
// dd( $lelongBid);
|
||||
|
||||
foreach ($lelongBid as $index => $lelong_bid) {
|
||||
foreach ($allCawangan as $data => $cawangan) {
|
||||
if ($data == $index) {
|
||||
$cawangan['lelongBid'] = $lelong_bid;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach ($lelong->cawangan as $index => $caw) {
|
||||
$allLelongBid = $caw->lelongBid->where('caw_id', '=', $cawid)->count();
|
||||
$settlePayment = $caw->lelongBid->where('status_payment', 1)->where('caw_id', '=', $cawid)->count();
|
||||
|
||||
$lelong->cawangan[$index]['lelong_laku'] = $allLelongBid;
|
||||
$lelong->cawangan[$index]['selesai_bayar'] = $settlePayment;
|
||||
}
|
||||
return view('lelong.senaraiubahrugilelongnew',compact('lelong','arraymarhun','marhuns','lelongid','cawid','arrayinfo','total_berat',
|
||||
'total_pinjaman',
|
||||
'total_upah',
|
||||
'total_hargaasas',
|
||||
@@ -7260,6 +7283,130 @@ class LelongController extends Controller
|
||||
}
|
||||
|
||||
|
||||
public function reportcajrugilelong(Request $request){
|
||||
$total_berat = 0;
|
||||
$total_pinjaman = 0;
|
||||
$total_upah = 0;
|
||||
$total_hargaasas = 0;
|
||||
$total_bakiupah = 0;
|
||||
$total_nilaimarhun = 0;
|
||||
$keuntungan = 0;
|
||||
$bakilelong = 0;
|
||||
$total_cazlelong = 0;
|
||||
$total_bakilelong = 0;
|
||||
$total_hargajual = 0;
|
||||
$total_cajlelnew = 0;
|
||||
$total_rugilelongnew = 0;
|
||||
$newcajlel= 0;
|
||||
$newbaki = 0;
|
||||
$lelongid = $request->lelongid;
|
||||
$cawid = $request->cawid;
|
||||
$cajlelong = $request->cajlelong;
|
||||
// dd($cajlelong);
|
||||
|
||||
$lelonglel = Lelong::with('cawangan')->find($lelongid);
|
||||
|
||||
$cawanganDetail = $lelonglel->cawangan->find($cawid);
|
||||
|
||||
$marhuns = LelongBid::where('caw_id', '=', $cawid)
|
||||
->where('lelong_id', '=', $lelongid)
|
||||
->where('status_jual', '=', 1)
|
||||
->where('baki', '<', 0.00)
|
||||
->get();
|
||||
// dd($marhuns);
|
||||
$arraymarhun = [];
|
||||
foreach ($marhuns as $index1=> $cal) {
|
||||
$cajlel = $cal['hargajual'] * ($cajlelong/100) ;
|
||||
$cajlelnew = round($cajlel, 1, 1);
|
||||
// dd($cajlelnew);
|
||||
$rugilelongnew = $cal['hargajual'] - $cal['pinjaman'] - $cal['bakiupah'] - $cajlelnew;
|
||||
// dd($rugilelongnew);
|
||||
//cajlelong baru
|
||||
if($rugilelongnew < 0){
|
||||
$newbaki = $cajlelnew + $rugilelongnew;
|
||||
if($newbaki > 0)
|
||||
{
|
||||
$newcajlel = $newbaki;
|
||||
$newbaki = 0;
|
||||
}
|
||||
else {
|
||||
$newcajlel = 0;
|
||||
// $newbaki = 0;
|
||||
}
|
||||
}elseif($rugilelongnew > 0){
|
||||
$newcajlel = $cajlelnew;
|
||||
$newbaki = $rugilelongnew;
|
||||
}
|
||||
|
||||
array_push($arraymarhun,[
|
||||
'norujukan' => $cal['norujukan'],
|
||||
'lelongbid_id' => $cal['id'],
|
||||
'tempoh' => $cal['jbg'],
|
||||
'berat' => $cal['berat'],
|
||||
'nilaimarhun' => $cal['nilaimarhun'],
|
||||
'hargaasas' => $cal['hargaasas'],
|
||||
'hargajual' => $cal['hargajual'],
|
||||
'pinjaman' => $cal['pinjaman'],
|
||||
'bakiupah' => $cal['bakiupah'],
|
||||
'cajlelong' => $cajlelnew,
|
||||
'baki' => $rugilelongnew,
|
||||
'cajlelongnew' => $newcajlel,
|
||||
'rugilelongnew' => $newbaki,
|
||||
]);
|
||||
$total_berat = $total_berat + $cal['berat'];
|
||||
$total_pinjaman = $total_pinjaman + $cal['pinjaman'];
|
||||
$total_hargaasas = $total_hargaasas + $cal['hargaasas'];
|
||||
$total_nilaimarhun = $total_nilaimarhun + $cal['nilaimarhun'];
|
||||
$total_bakiupah = $total_bakiupah + $cal['bakiupah'];
|
||||
$total_cazlelong = $total_cazlelong + $cajlelnew;
|
||||
$total_bakilelong = $total_bakilelong + $rugilelongnew;
|
||||
$total_hargajual = $total_hargajual + $cal['hargajual'];
|
||||
$total_cajlelnew = $total_cajlelnew + $newcajlel;
|
||||
$total_rugilelongnew = $total_rugilelongnew + $newbaki;
|
||||
|
||||
}
|
||||
|
||||
$arrayinfo = [];
|
||||
|
||||
$lelong_id = Lelong::join('cawangan_lelong','lelong.id','=','cawangan_lelong.lelong_id')
|
||||
->where('cawangan_lelong.lelong_id','=',$lelongid)
|
||||
->select('lelong_id','tarikh_lelong','lelong.fasa')
|
||||
->groupBy('lelong_id')
|
||||
->get()->toArray();
|
||||
|
||||
|
||||
foreach($lelong_id as $laporan)
|
||||
{
|
||||
$details = CawanganLelong::join('cawangan','cawangan_lelong.caw_id','=','cawangan.id')
|
||||
->where('lelong_id',$laporan['lelong_id'])
|
||||
->where('caw_id',$cawid)
|
||||
->get()
|
||||
->toArray();
|
||||
array_push($arrayinfo,['laporan' => $laporan,'details' => $details]);
|
||||
}
|
||||
$datacaw = Cawangan::where('id','=',$cawid)
|
||||
->get();
|
||||
|
||||
|
||||
$pdf = PDF::loadView('pdf.pdfcajrugilelong',compact('datacaw','arraymarhun','marhuns','lelongid','cawid','arrayinfo','total_berat',
|
||||
'total_pinjaman',
|
||||
'total_upah',
|
||||
'total_hargaasas',
|
||||
'total_bakiupah',
|
||||
'total_nilaimarhun',
|
||||
'lelonglel',
|
||||
'cawanganDetail',
|
||||
'total_cazlelong',
|
||||
'total_bakilelong',
|
||||
'total_hargajual',
|
||||
'total_cajlelnew',
|
||||
'total_rugilelongnew','cajlelong'))
|
||||
->setPaper('a4','potrait');
|
||||
|
||||
return $pdf->download('Laporan Perubahan Rugi Lelong.pdf');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user