Fix status pembayaran by cawangan operasi and akaun
This commit is contained in:
@@ -915,6 +915,69 @@ class PembidaController extends Controller
|
||||
return view('pembida.statuspembayaran',compact('arraysms','arraysls','listwinner','lelong','arrayinfo','detailsinfo'));
|
||||
}
|
||||
|
||||
public function statuspembayaran2()
|
||||
{
|
||||
$current_date = Carbon::now();
|
||||
$current_date = $current_date->toDateString();
|
||||
|
||||
$lelong_all = Lelong::with(
|
||||
'cawangan:id,caw_code,caw_name',
|
||||
'lelongBidJual:lelong_id,id,norujukan,caw_id,kodcaw',
|
||||
'lelongBidJual.lelongBidderMenang:lelongbid_id,user_id,nama_bidder,hargabida,status_payment',
|
||||
'lelongBidJual.lelongBidderMenang.payment:lelongbid_id,user_id,status_payment_opt',
|
||||
'lelongBidJual.lelongBidderMenang.payment.user:id,name',
|
||||
)->select('id', 'tarikh_lelong')->where('sts_lelong', 3)->get();
|
||||
|
||||
$lelong_array = [];
|
||||
foreach ($lelong_all as $lelong) {
|
||||
$allCawangan = $lelong->cawangan->keyBy('caw_code');
|
||||
$lelongBid = $lelong->lelongBidJual->groupBy('kodcaw');
|
||||
|
||||
foreach ($lelongBid as $index => $lelong_bid) {
|
||||
foreach ($allCawangan as $data => $cawangan) {
|
||||
if ($data == $index) {
|
||||
$cawangan['lelongBid'] = $lelong_bid;
|
||||
}
|
||||
}
|
||||
}
|
||||
$cawangan_array = [];
|
||||
foreach ($lelong->cawangan as $caw) {
|
||||
$users = $caw->lelongBid->pluck('lelongBidderMenang')->groupBy('user_id');
|
||||
$jumlah_bidaan_cawangan = $caw->lelongBid->pluck('lelongBidderMenang')->sum('hargabida');
|
||||
$user_array = [];
|
||||
foreach ($users as $user) {
|
||||
$user_to_be_added = [];
|
||||
$user_to_be_added['name_bidder'] = $user[0]->nama_bidder;
|
||||
$user_to_be_added['jumlah_bidaan'] = $user->sum('hargabida');
|
||||
$user_to_be_added['status_bayaran'] = $user[0]->status_payment;
|
||||
$user_to_be_added['jenis_bayaran'] = $user[0]->payment->status_payment_opt;
|
||||
array_push($user_array, $user_to_be_added);
|
||||
}
|
||||
$cawangan_to_be_added = [];
|
||||
$cawangan_to_be_added['caw_code'] = $caw->caw_code;
|
||||
$cawangan_to_be_added['caw_name'] = $caw->caw_name;
|
||||
$cawangan_to_be_added['pembida'] = $user_array;
|
||||
$cawangan_to_be_added['jumlah_bidaan_cawangan'] = $jumlah_bidaan_cawangan;
|
||||
array_push($cawangan_array, $cawangan_to_be_added);
|
||||
}
|
||||
$lelong_to_be_added = [];
|
||||
$lelong_to_be_added['lelong_id'] = $lelong->id;
|
||||
$lelong_to_be_added['tarikh_lelong'] = $lelong->tarikh_lelong;
|
||||
$lelong_to_be_added['cawangan'] = $cawangan_array;
|
||||
array_push($lelong_array, $lelong_to_be_added);
|
||||
}
|
||||
$lelong_array_semasa = [];
|
||||
$lelong_array_selesai = [];
|
||||
foreach ($lelong_array as $lelong) {
|
||||
if ($lelong['tarikh_lelong'] == $current_date) {
|
||||
array_push($lelong_array_semasa, $lelong);
|
||||
} else {
|
||||
array_push($lelong_array_selesai, $lelong);
|
||||
}
|
||||
}
|
||||
return view('pembida.statuspembayaran2', compact('lelong_array_semasa', 'lelong_array_selesai'));
|
||||
}
|
||||
|
||||
public function statuspembayaranbypembida(Request $request)
|
||||
{
|
||||
$kodcaw = $request->kodcaw;
|
||||
|
||||
Reference in New Issue
Block a user