diff --git a/app/Http/Controllers/NotisController.php b/app/Http/Controllers/NotisController.php index 38454778..7005602d 100644 --- a/app/Http/Controllers/NotisController.php +++ b/app/Http/Controllers/NotisController.php @@ -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')); + } diff --git a/database/seeders/RolesSeeder.php b/database/seeders/RolesSeeder.php index ca46d56e..1eae025b 100644 --- a/database/seeders/RolesSeeder.php +++ b/database/seeders/RolesSeeder.php @@ -150,6 +150,11 @@ class RolesSeeder extends Seeder 'description' => 'Parameter' ]); + Permission::create([ + 'name' => 'WTD', + 'description' => 'Wang Tidak Dituntut' + ]); + //account Permission::create([ 'name' => 'pengesahanbayaran', @@ -238,6 +243,7 @@ class RolesSeeder extends Seeder $role6->givePermissionTo('pengurusangambar'); $role6->givePermissionTo('reportbycaw'); $role6->givePermissionTo('parameter'); + $role6->givePermissionTo('WTD'); diff --git a/resources/views/wtd/excellistsagwtdproses.blade.php b/resources/views/wtd/excellistsagwtdproses.blade.php new file mode 100644 index 00000000..c9182aaf --- /dev/null +++ b/resources/views/wtd/excellistsagwtdproses.blade.php @@ -0,0 +1,100 @@ + + + + + + +
+ +| --}} + | Bil | +NAMA | +NOKP | +NORUJUKAN | +TARIKH LELONG | +PEMBIAYAAN (RM) | +BAKI (RM) | +
|---|---|---|---|---|---|---|---|
| --}} + | {{$loop->iteration}} | +{{$lel->cust_info->nama}} | +'{{$lel->nokp}} | +{{$lel->norujukan}} | +@php + $myDateTime = DateTime::createFromFormat('Y-m-d', $lel->t_jual ); + $datez = $myDateTime->format('d-m-Y'); + echo($datez); + @endphp | + +{{number_format($lel->pinjaman, 2, '.', ',')}} | +{{number_format($lel->baki, 2, '.', ',')}} | +
| Jumlah Keseluruhan | +{{$jumlahbaki}} | +||||||
| --}} + | Bil | +NAMA | +NOKP | +LEBIHAN(RM) | +
|---|---|---|---|---|
| --}} + | {{$loop->iteration}} | +{{$customer->nama}} | +'{{$customer->nokp}} | +
+ @php $jumbaki = 0;@endphp
+ @foreach($customer['gadai'] as $data)
+ @php
+ $jumbaki = $jumbaki + $data->baki;
+ @endphp
+ {{-- {{$data->baki}} --}} + @endforeach + {{ number_format($jumbaki, 2, '.', ',') }} + |
+
| Jumlah Keseluruhan | +{{$jumlahbaki}} | +|||