add function excel untuk WTD

This commit is contained in:
Nur Izzati Zulkifli
2023-06-04 10:56:37 +08:00
parent a1bdd68222
commit 5da794ef24
7 changed files with 333 additions and 5 deletions
+127
View File
@@ -2349,6 +2349,133 @@ Sekian, terima kasih.';
->setPaper('a4', 'potrait');
return $pdf->download('Senarai SAG WTD By Customer Dalam Proses ' . $cawanganDetail->caw_name . '.pdf');
}
Public function excellistsagwtdproses ($kodcaw){
$wtddraft = WtdDraft::on('main')
->where('kodcaw', $kodcaw)
->where('batchno_serah', '0')
->orderBy('norujukan','ASC')
->get();
$wtddraft_groupby_caw = $wtddraft->groupBy('kodcaw');
$wtddraft_data_pluck_norujukan = $wtddraft->pluck('norujukan')->toArray();
$lelong_all = LelongCawangan::on($kodcaw)->whereIn('lelong.norujukan', $wtddraft_data_pluck_norujukan)
->join('gadai','gadai.norujukan','=','lelong.norujukan')
->select('nokp', 'lelong.norujukan','lelong.t_jual','lelong.hargajual','lelong.gst_hj','lelong.pinjaman','lelong.bakiupah','lelong.cajlelong','lelong.gst_cl','lelong.cajlain','lelong.baki')
->orderBy('lelong.norujukan','ASC')
->get();
$cawanganDetail = Cawangan::where('caw_code', $kodcaw)->first();
$lelong_all_pluck_nokp = $lelong_all->pluck('nokp')->unique();
$customers = Customer::whereIn('kpbaru', $lelong_all_pluck_nokp)
->orWhereIn('kplama', $lelong_all_pluck_nokp)
->select('nama','kpbaru', 'kplama','alamat1','alamat2','alamat3','telefon')
->get();
// dd($customers->toArray());
$customers_keyBy_noKp = $customers->keyBy(function ($item) {
if ($item->kpbaru != '') {
return $item->kpbaru;
} else if ($item->kplama != '') {
return $item->kplama;
}
});
$lelong_all_groupby_nokp = $lelong_all->groupBy('nokp');
$jumlahbil = sizeof($lelong_all);
$jumlahbaki = number_format($lelong_all->SUM('baki'), 2, '.', ',');
foreach($lelong_all as $index1=>$bil){
if($customers_keyBy_noKp[$bil->nokp]){
$lelong_all[$index1]["cust_info"] = $customers_keyBy_noKp[$bil->nokp];
}
// dd($customers_keyBy_noKp[$bil->nokp]);
}
return view('wtd.excellistsagwtdproses',compact('lelong_all','kodcaw','cawanganDetail','jumlahbil','jumlahbaki'));
}
public function excellistsagwtdprosesbycust($cawid)
{
$keuntungan = 0;
$arraylistgadai = 0;
$cawanganDetail = Cawangan::where('id', $cawid)->first();
$wtddraft = WtdDraft::on('main')
->where('kodcaw', $cawanganDetail->caw_code)
->where('batchno_serah', '0')
->orderBy('norujukan','ASC')
->get();
$wtddraft_groupby_caw = $wtddraft->groupBy('kodcaw');
$wtddraft_data_pluck_norujukan = $wtddraft->pluck('norujukan')->toArray();
$lelongbid_keyby_norujukan = $wtddraft->keyBy('norujukan');
$lelong_all = LelongCawangan::on($cawanganDetail->caw_code)->whereIn('lelong.norujukan', $wtddraft_data_pluck_norujukan)
->join('gadai','gadai.norujukan','=','lelong.norujukan')
->select('nokp', 'lelong.norujukan','lelong.t_jual','lelong.hargajual','lelong.gst_hj','lelong.pinjaman','lelong.bakiupah','lelong.cajlelong','lelong.gst_cl','lelong.cajlain','lelong.baki')
->orderBy('lelong.norujukan','ASC')
->get();
$jumlahbil = sizeof($lelong_all);
$jumlahbaki = number_format($lelong_all->SUM('baki'), 2, '.', ',');
$lelong_all_groupby_norujukan = $lelong_all->groupBy('norujukan');
$gadai_all_pluck_nokp = $lelong_all->pluck('nokp')->unique();
$customers = Customer::whereIn('kpbaru', $gadai_all_pluck_nokp)
->orWhereIn('kplama', $gadai_all_pluck_nokp)
->select('nama','kpbaru', 'kplama','alamat1','alamat2','alamat3','telefon')
->orderBy('nama','ASC')
->get();
$customers_keyBy_noKp = $customers->keyBy(function ($item) {
if ($item->kpbaru != '') {
return $item->kpbaru;
} else if ($item->kplama != '') {
return $item->kplama;
}
});
// $gadai_all_groupby_nokp = $gadai_all->groupBy('nokp');
$gadai_all_keyBy_norujukan = $lelong_all->keyBy('norujukan');
$gadai_all_groupby_nokp = $gadai_all_keyBy_norujukan->groupBy('nokp');
// dd($gadai_all_groupby_nokp['961114106974']);
foreach($customers as $index=>$customer){
if($customer->kpbaru != ''){
$customers[$index]['nokp'] = $customer->kpbaru;
}
elseif($customer->kplama != ''){
$customers[$index]['nokp'] = $customer->kplama;
}
// dd($gadai_all_groupby_nokp, $customer, $gadai_all_groupby_nokp[$customer->nokp]);
if($gadai_all_groupby_nokp[$customer->nokp]){
$customers[$index]['gadai'] = $gadai_all_groupby_nokp[$customer->nokp];
}
// dd($customer);
foreach($customer['gadai'] as $index2=>$datagadai){
// dd($datagadai);
if($lelongbid_keyby_norujukan[$datagadai->norujukan]){
// dd(isset($datagadai['data_transaksi']));
$lelongbid_true = $lelongbid_keyby_norujukan[$datagadai->norujukan];
$pinjaman = $lelongbid_true->pinjaman;
$customer['gadai'][$index2]['pnjaman'] = $pinjaman;
}
}
// dd($customer);
}
return view('wtd.excellistsagwtdprosesbycust',compact('customers','cawanganDetail','cawid','jumlahbil','jumlahbaki'));
}