update function edit rugi lelong dan caj lelong
This commit is contained in:
@@ -6266,7 +6266,7 @@ class LelongController extends Controller
|
||||
$total_hargaasas = $total_hargaasas + $cal['hargaasas'];
|
||||
$total_nilaimarhun = $total_nilaimarhun + $cal['nilaimarhun'];
|
||||
$total_bakiupah = $total_bakiupah + $cal['bakiupah'];
|
||||
$total_cazlelong = $total_cazlelong + $cal['bakiupah'];
|
||||
$total_cazlelong = $total_cazlelong + $cal['cajlelong'];
|
||||
$total_hargajual = $total_hargajual + $cal['hargajual'];
|
||||
}
|
||||
|
||||
@@ -7033,6 +7033,234 @@ class LelongController extends Controller
|
||||
->with('success','Kemaskini Berjaya');
|
||||
}
|
||||
|
||||
public function ubahrugilelong($lelongid, $cawid){
|
||||
$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_hargajual = 0;
|
||||
// dd($cawid);
|
||||
|
||||
$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) {
|
||||
array_push($arraymarhun,[
|
||||
'norujukan' => $cal['norujukan'],
|
||||
'tempoh' => $cal['jbg'],
|
||||
'berat' => $cal['berat'],
|
||||
'nilaimarhun' => $cal['nilaimarhun'],
|
||||
'hargaasas' => $cal['hargaasas'],
|
||||
'hargajual' => $cal['hargajual'],
|
||||
'pinjaman' => $cal['pinjaman'],
|
||||
'bakiupah' => $cal['bakiupah'],
|
||||
'cajlelong' => $cal['cajlelong'],
|
||||
'baki' => $cal['baki'],
|
||||
]);
|
||||
$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 + $cal['cajlelong'];
|
||||
$total_hargajual = $total_hargajual + $cal['hargajual'];
|
||||
}
|
||||
|
||||
$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]);
|
||||
}
|
||||
return view('lelong.senaraiubahrugilelong',compact('arraymarhun','marhuns','lelongid','cawid','arrayinfo','total_berat',
|
||||
'total_pinjaman',
|
||||
'total_upah',
|
||||
'total_hargaasas',
|
||||
'total_bakiupah',
|
||||
'total_nilaimarhun',
|
||||
'lelonglel',
|
||||
'cawanganDetail',
|
||||
'total_cazlelong',
|
||||
'total_hargajual'));
|
||||
}
|
||||
|
||||
public function cajrugilelong(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]);
|
||||
}
|
||||
return view('lelong.senaraiubahrugilelongnew',compact('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'));
|
||||
}
|
||||
|
||||
public function editcajrugilelong(Request $request){
|
||||
$lelongbid_id = $request->lelongbid_id;
|
||||
$norujukan = $request->norujukan;
|
||||
$cajlelongnew = $request->cajlelongnew;
|
||||
$rugilelongnew = $request->rugilelongnew;
|
||||
$lelongid = $request->lelongid;
|
||||
$cawid = $request->cawid;
|
||||
$cajlelong = $request->cajlelong;
|
||||
$user = Auth::user();
|
||||
$currentdate = Carbon::now();
|
||||
$currentdate = $currentdate->toDateTimeString();
|
||||
for($i=0; $i<count($lelongbid_id); $i++)
|
||||
{
|
||||
if($lelongbid_id[$i])
|
||||
{
|
||||
$updatecajrugilelong = LelongBid::where('id', $lelongbid_id[$i])->first();
|
||||
$updatecajrugilelong->baki = $rugilelongnew[$i];
|
||||
$updatecajrugilelong->cajlelong = $cajlelongnew[$i];
|
||||
$updatecajrugilelong->update();
|
||||
|
||||
$loguser = new LogUser;
|
||||
$loguser->user_id = $user->id;
|
||||
$loguser->date = $currentdate;
|
||||
$loguser->username = $user->username;
|
||||
$loguser->nama_user = $user->name;
|
||||
$loguser->norujukan = $norujukan[$i];
|
||||
$loguser->nota = 'Ubah Rugi Lelong: Caj '.$cajlelong.'%';
|
||||
$loguser->save();
|
||||
}
|
||||
}
|
||||
return redirect()->route('lelong.senaraimarhundone',['lelongid'=>$lelongid,'cawid'=>$cawid])
|
||||
->with('success','Kemaskini Rugi Lelong Berjaya');
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user