From 065fbeb44cf423b3747088e7c2a8ac29ac250a91 Mon Sep 17 00:00:00 2001 From: Amirah22 <94591077+Amirah22@users.noreply.github.com> Date: Sun, 7 Aug 2022 16:55:18 +0800 Subject: [PATCH] excel jana notis --- app/Http/Controllers/NotisController.php | 87 +++++++++---------- .../views/excel/listnotis_excel.blade.php | 29 ++++--- resources/views/pdf/listnotis.blade.php | 26 +++--- 3 files changed, 72 insertions(+), 70 deletions(-) diff --git a/app/Http/Controllers/NotisController.php b/app/Http/Controllers/NotisController.php index 4e4d4d81..2fddd4f6 100644 --- a/app/Http/Controllers/NotisController.php +++ b/app/Http/Controllers/NotisController.php @@ -186,64 +186,63 @@ class NotisController extends Controller public function listnotis(Request $request){ + $lelong_id = $request->lelong_id; + $user = Auth::user(); $caw = Cawangan::where('caw_code','=',$user->kodcaw) ->first(); - $lelong_id = $request->lelong_id; - - $senarai = LelongBid::where('lelongbid.kodcaw','=',$user->kodcaw) - ->where('lelongbid.lelong_id', $lelong_id); - - $arraysenarai = $senarai->pluck('norujukan')->toArray(); - $datasenarai = $senarai->get(); - - $gadaicaw = Gadai::on($datasenarai[0]['kodcaw'])->whereIn('norujukan',$arraysenarai) - ->where('gadai.kodcaw','=',$user->kodcaw) - ->get()->toArray(); - $bayaran=0; - foreach($gadaicaw as $index1=>$pay) - { - $bayaran = $pay['hargajualan'] - $pay['bakihargajualan']; + $arraydetails = []; + + $caw = Cawangan::where('caw_code','=',$user->kodcaw) + ->first(); + + $lelong_id = $lelong_id; + + $marhun = LelongBid::join('cawangan', 'lelongbid.caw_id', '=', 'cawangan.id') + ->where('lelong_id','=',$lelong_id) + ->where('lelongbid.kodcaw','=',$user->kodcaw); + + $arraynorujukan = $marhun->pluck('norujukan')->toArray(); + $datalelong = $marhun->get(); + $marhuns = Gadai::on($datalelong[0]['kodcaw'])->whereIn('norujukan', $arraynorujukan) + ->select('nokp') + ->groupBy('nokp') + ->get(); + // dd($marhuns); + $arraysag = []; + + + foreach($marhuns as $index1=>$cal){ + $customer = Customer::where('kpbaru','=',$cal['nokp']) + ->orWhere('kplama','=',$cal['nokp']) + ->get(); + + $listsag = Gadai::on($datalelong[0]['kodcaw'])->whereIn('norujukan', $arraynorujukan) + ->where('nokp','=',$cal['nokp']) + ->get(); + // dd($listgadai); + foreach($listsag as $index=>$listing){ + + $bayaran = $listing['hargajualan'] - $listing['bakihargajualan']; + + } + $marhuns[$index1]['nama'] = $customer; + $marhuns[$index1]['listsag'] = $listsag; +// dd($marhuns[$index1]['nama']); + } - $gadaicaw2 = Gadai::on($datasenarai[0]['kodcaw'])->whereIn('norujukan',$arraysenarai) - ->where('gadai.kodcaw','=',$user->kodcaw); - - - $arraycustomer = $gadaicaw2->pluck('nokp')->toArray(); - $datacustomer = $gadaicaw2->get(); - // dd($gadaicaw2); - $customer = Customer::query() - ->whereIn('kpbaru',$arraycustomer) - ->orWhereIn('kplama',$arraycustomer) - ->get()->toArray(); - - - - // $customer[$index1]['listsag'] = $listsag; - - // ->join('customer', function ($join) { - // $join->on('gadai.nokp', '=', 'customer.kpbaru')->orOn('gadai.nokp', '=', 'customer.kplama'); - // }) - // ->where('gadai.kodcaw','=',$user->kodcaw) - // ->where('lelongbid.lelong_id', $lelong_id) - // ->get()->toArray(); - - - // $payment[$index1]['payment'] = $payment; - // $payment[$index1]['bayaran_keuntungan'] = $bayaran; - if($request->type == 'excel') { - return view('excel.listnotis_excel',compact('gadaicaw','caw','lelong_id','bayaran','customer')); + return view('excel.listnotis_excel',compact('marhuns','lelong_id','bayaran','listsag','caw')); } else { - $pdf = PDF::loadView('pdf.listnotis',compact('gadaicaw','caw','lelong_id','bayaran')) + $pdf = PDF::loadView('pdf.listnotis',compact('marhuns','lelong_id','bayaran','listsag','caw')) ->setPaper('a4', 'potrait'); return $pdf->download('Senarai Notis.pdf'); diff --git a/resources/views/excel/listnotis_excel.blade.php b/resources/views/excel/listnotis_excel.blade.php index 4c562f9b..13d51534 100644 --- a/resources/views/excel/listnotis_excel.blade.php +++ b/resources/views/excel/listnotis_excel.blade.php @@ -63,28 +63,29 @@ No Nama + No KP No Rujukan No Telefon Tempoh - No KP Pembiayaan Keuntungan 6 Bulan Bayaran Telah Dibuat - @foreach($customer as $index1=> $pay) - - {{ $loop->iteration }} - {{ $pay['nama']}} - {{ $gadaicaw[$index1]['norujukan'] }} - 6{{ $pay['telefon']}} - {{ $gadaicaw[$index1]['tempoh'] }} - {{ $gadaicaw[$index1]['nokp'] }} - {{ number_format($gadaicaw[$index1]['pinjaman'], 2, '.', ',')}} - {{ number_format($gadaicaw[$index1]['bakiupah'], 2, '.', ',')}} - {{ number_format($bayaran, 2, '.', ',')}} + @foreach($marhuns as $index1=> $notis) + + + {{ $loop->iteration }} + @foreach($notis['nama'] as $data){{ $data['nama']}}
@endforeach + {{ $notis['nokp']}} + @foreach($notis['listsag'] as $item){{ $item['norujukan']}},
@endforeach + @foreach($notis['nama'] as $data)6{{ $data['telefon']}}
@endforeach + @foreach($notis['listsag'] as $item){{ $item['tempoh']}},
@endforeach + @foreach($notis['listsag'] as $item){{ number_format($item['pinjaman'], 2, '.', ',')}},
@endforeach + @foreach($notis['listsag'] as $item){{ number_format($item['bakiupah'], 2, '.', ',')}},
@endforeach + {{ number_format($bayaran, 2, '.', ',')}}
- @endforeach + @endforeach @@ -97,7 +98,7 @@ var table2excel = new Table2Excel(); table2excel.export(document.querySelectorAll("#customers"),'senarai_notis'); - setTimeout(function(){ window.close() }, 1000); + setTimeout(function(){ window.close() }, 10); }); diff --git a/resources/views/pdf/listnotis.blade.php b/resources/views/pdf/listnotis.blade.php index 8fbc66ef..5d3d4cd4 100644 --- a/resources/views/pdf/listnotis.blade.php +++ b/resources/views/pdf/listnotis.blade.php @@ -91,26 +91,28 @@ tr:nth-child(even) { No + No Kp No Rujukan JGB - No Kp Pembiayaan Keuntungan 6 Bulan Bayaran Telah Dibuat - @foreach($gadaicaw as $index1=> $pay) - - {{ $loop->iteration }} - {{ $pay['norujukan']}} - {{ $pay['tempoh']}} - {{ $pay['nokp']}} - {{ number_format($pay['pinjaman'], 2, '.', ',')}} - {{ number_format($pay['bakiupah'], 2, '.', ',')}} - {{ number_format($bayaran, 2, '.', ',')}} - - @endforeach + @foreach($marhuns as $index1=> $notis) + + {{ $loop->iteration }} + {{ $notis['nokp']}} + {{-- {{ $notis['nama']['nama']}} --}} + + @foreach($notis['listsag'] as $item){{ $item['norujukan']}}
@endforeach + @foreach($notis['listsag'] as $item){{ $item['tempoh']}}
@endforeach + @foreach($notis['listsag'] as $item){{ number_format($item['pinjaman'], 2, '.', ',')}}
@endforeach + @foreach($notis['listsag'] as $item){{ number_format($item['bakiupah'], 2, '.', ',')}}
@endforeach + {{ number_format($bayaran, 2, '.', ',')}}
+ + @endforeach