From e97e7f114ec57921f8045aaf9165fe19acf796b0 Mon Sep 17 00:00:00 2001 From: Amirah22 <94591077+Amirah22@users.noreply.github.com> Date: Wed, 23 Nov 2022 12:03:59 +0800 Subject: [PATCH] (PDF) Senarai simulasi mengikut pelanggan --- app/Http/Controllers/ReportController.php | 56 +++- .../views/pdf/simulasireportbycust.blade.php | 278 ++++++++++++++++++ .../views/simulasi/listsagbycust.blade.php | 8 +- routes/web.php | 2 + 4 files changed, 339 insertions(+), 5 deletions(-) create mode 100644 resources/views/pdf/simulasireportbycust.blade.php diff --git a/app/Http/Controllers/ReportController.php b/app/Http/Controllers/ReportController.php index 9642b25c..106353f2 100644 --- a/app/Http/Controllers/ReportController.php +++ b/app/Http/Controllers/ReportController.php @@ -33,6 +33,7 @@ use App\Models\Resit; use App\Models\Customer; use App\Models\LelongTebus; use App\Models\Pengesahan; +use App\Models\TransaksiKeuntungan; use Carbon\Carbon; @@ -649,10 +650,63 @@ class ReportController extends Controller ->setPaper('a4','potrait'); return $pdf->download('Laporan Simulasi Cawangan.pdf'); - + } + public function simulasireportbycust($simulasi_id, $cawid) + { + $keuntungan = 0; + $arraylistgadai = 0; + + $simulasilel = Simulasi::with('cawangan')->find($simulasi_id); + $cawname = Cawangan::where('id','=',$cawid)->first(); + + $cawanganDetail = $simulasilel->cawangan->find($cawid); + + $marhun = SimulasiBid::join('cawangan', 'simulasibid.caw_id', '=', 'cawangan.id') + ->where('simulasi_id','=',$simulasi_id) + ->where('caw_id','=',$cawid); + + $arraynorujukan = $marhun->pluck('norujukan')->toArray(); + $datasimulasi = $marhun->get(); + $marhuns = Gadai::on($datasimulasi[0]['kodcaw'])->whereIn('norujukan', $arraynorujukan) + ->select('nokp') + ->groupBy('nokp')->get(); + // dd($datagadai); + $arraysag = []; + + foreach($marhuns as $index1=>$cal) + { + $customer = Customer::where('kpbaru','=',$cal['nokp']) + ->orWhere('kplama','=',$cal['nokp']) + ->first(); + // dd($customer); + + $listsag = Gadai::on($datasimulasi[0]['kodcaw'])->whereIn('norujukan', $arraynorujukan) + ->where('nokp','=',$cal['nokp']) + ->get(); + // dd($listgadai); + foreach($listsag as $index=>$listing){ + $ktlhbyr = TransaksiKeuntungan::on('main')->where('norujukan','=',$listing['norujukan'])->sum('bayaran_keuntungan'); + // dd($ktlhbyr); + $total_untung_rebet = TransaksiKeuntungan::on('main')->where('norujukan','=',$listing['norujukan'])->sum('keuntungan_rebet'); + $total_untung_asal = TransaksiKeuntungan::on('main')->where('norujukan','=',$listing['norujukan'])->sum('bayaran_keuntungan'); + $beza_keuntungan = $total_untung_asal - $total_untung_rebet; + $keuntungan = bcdiv(($listing['tempoh']-$listing['tempohbayar'])*$listing['kadarupah']/100*$listing['bakipjm'],1,1)-$beza_keuntungan; + // dd($keuntungan); + $listsag[$index]['ktlhbyr'] = $ktlhbyr; + $listsag[$index]['keuntungan'] = $keuntungan; + } + $marhuns[$index1]['nama'] = $customer; + $marhuns[$index1]['listsag'] = $listsag; + + } + $pdf = PDF::loadView('pdf.simulasireportbycust',compact('simulasilel','cawanganDetail','marhuns','simulasi_id','cawid','ktlhbyr','cawname')) + ->setPaper('a4','potrait'); + + return $pdf->download('Laporan Simulasi Cawangan by Pelanggan.pdf'); + } public function lelongreport ($lelongid, $cawid){ diff --git a/resources/views/pdf/simulasireportbycust.blade.php b/resources/views/pdf/simulasireportbycust.blade.php new file mode 100644 index 00000000..86a0f8f1 --- /dev/null +++ b/resources/views/pdf/simulasireportbycust.blade.php @@ -0,0 +1,278 @@ + + + + + + + +
+| No | +Nama Pelanggan | +No.KP | +No.Rujukan | +Tempoh | +Berat(gm) | +Keuntungan Telah Bayar (RM) | +Keuntungan 6 Bulan (RM) | +Keuntungan Semasa (RM) | +Pembiayaan Asal (RM) | +Baki Pembiayaan (RM) | +Nilai Marhun (RM) | +
|---|---|---|---|---|---|---|---|---|---|---|---|
| {{$loop->iteration}} | +{{ $marhun['nama']['nama']}} | +{{ $marhun['nokp']}} | +@foreach ($marhun['listsag'] as $item)
+ {{-- {{$loop->iteration}}.{{ $item['norujukan'] }} --}} + {{ $item['norujukan'] }} + @endforeach |
+ @foreach ($marhun['listsag'] as $item)
+ {{ $item['tempoh'] }} + @endforeach |
+
+ @php $jumberat = 0;@endphp
+ @foreach ($marhun['listsag'] as $item)
+ @php
+ $jumberat = $jumberat + $item['berat'];
+ @endphp
+ {{ number_format($item['berat'], 2, '.', ',') }} + @endforeach + {{ number_format($jumberat, 2, '.', ',') }} + |
+
+ @php $jumktlhbyr = 0;@endphp
+ @foreach ($marhun['listsag'] as $item)
+ @php
+ $jumktlhbyr = $jumktlhbyr + $item['ktlhbyr'];
+ @endphp
+ {{ number_format($item['ktlhbyr'], 2, '.', ',') }} + @endforeach + {{ number_format($jumktlhbyr, 2, '.', ',') }} + + |
+
+ @php $jum6bulan = 0;@endphp
+ @foreach ($marhun['listsag'] as $item)
+ @php
+ $jum6bulan = $jum6bulan + $item['bakiupah'];
+ @endphp
+ {{ number_format($item['bakiupah'], 2, '.', ',') }} + @endforeach + {{ number_format($jum6bulan, 2, '.', ',') }} + + |
+
+ @php $jum6bulan = 0;@endphp
+ @foreach ($marhun['listsag'] as $item)
+ @php
+ $jum6bulan = $jum6bulan + $item['keuntungan'];
+ @endphp
+ {{ number_format($item['keuntungan'], 2, '.', ',') }} + @endforeach + {{ number_format($jum6bulan, 2, '.', ',') }} + + |
+
+ @php $jumpinjasal = 0;@endphp
+ @foreach ($marhun['listsag'] as $item)
+ @php
+ $jumpinjasal = $jumpinjasal + $item['pinjaman'];
+ @endphp
+ {{ number_format($item['pinjaman'], 2, '.', ',') }} + @endforeach + {{ number_format($jumpinjasal, 2, '.', ',') }} + + |
+
+ @php $jumpinjaman = 0;@endphp
+ @foreach ($marhun['listsag'] as $item)
+ @php
+ $jumpinjaman = $jumpinjaman + $item['bakipjm'];
+ @endphp
+ {{ number_format($item['bakipjm'], 2, '.', ',') }} + @endforeach + {{ number_format($jumpinjaman, 2, '.', ',') }} + + |
+
+
+
+ @php $jumnilaimarhun = 0;@endphp
+ @foreach ($marhun['listsag'] as $item)
+ @php
+ $jumnilaimarhun = $jumnilaimarhun + $item['nilaimarhun'];
+ @endphp
+ {{ number_format($item['nilaimarhun'], 2, '.', ',') }} + @endforeach + {{ number_format($jumnilaimarhun, 2, '.', ',') }} + + |
+
+
+
+
+
+
| Jumlah Keseluruhan | +{{ number_format($total_berat, 2, '.', ',') }} | +{{ number_format($total_nilaimarhun, 2, '.', ',') }} | +{{ number_format($total_hargaasas, 2, '.', ',') }} | +{{ number_format($total_pinjaman, 2, '.', ',') }} | +{{ number_format($total_bakiupah, 2, '.', ',') }} | +{{ number_format($total_cajlelong, 2, '.', ',') }} | +{{ number_format($total_bakilelong, 2, '.', ',') }} | +||||
{{ $message }}
@endif - {{----}} +