diff --git a/app/Http/Controllers/AkaunController.php b/app/Http/Controllers/AkaunController.php index e9a6d97..1197659 100644 --- a/app/Http/Controllers/AkaunController.php +++ b/app/Http/Controllers/AkaunController.php @@ -1757,5 +1757,97 @@ class AkaunController extends Controller return view('akaun.laporan_saghilang', compact('hostname','polis','cawangan_detail','mula_date','hingga_date','tarikh_cetak','api_url')); } + public function cetak_laporanlelong(Request $request) + { + // dd($request->all()); + $api_url = $request->hostname; + $auth_user = Auth::user(); + $current = Carbon::now(); + $tarikh_cetak = $current->toDateString(); + $batchno = $request->batchno; + + // Get input parameters, including batchno + $mula_date = $request->tarikhmula ?? '2017-01-01'; + // dd($mula_date); + $hingga_date = $request->tarikhhingga ?? $current->toDateString(); + // $batchno = $request->batchno ?? null; // Batch Number from input + // dd($request->batchno); + + // Fetch lelong report data with batchno filter + $lelong = Http::get($request->hostname . '/api/laporan/lelong', [ + 'kodcaw' => $request->kodcaw, + 'tarikhmula' => $mula_date, + 'tarikhhingga' => $hingga_date, + 'batchno' => $request->batchno // Include batch number in API request + ])->json(); + // dd($lelong); + + // Initialize totals + $bakilelong = 0; + $rugilelong = 0; + + // Ensure 'data' key exists before looping + if (isset($lelong['data']) && is_array($lelong['data'])) { + foreach ($lelong['data'] as $key => $item) { + // Fetch customer name if nokp exists + $lelong['data'][$key]['nama_cust'] = isset($item['nokp']) && !empty($item['nokp']) + ? Http::get($request->hostname . '/api/customers/' . $item['nokp'])->json()['nama'] ?? 'Unknown' + : 'Unknown'; + + // Accumulate bakilelong and rugilelong + if (isset($item['baki'])) { + if ($item['baki'] > 0) { + $bakilelong += $item['baki']; + } else { + $rugilelong += $item['baki']; + } + } + } + } + // dd($lelong); + $tlelong = $lelong['tarikh_lelong']; + + // Fetch total values from API response + $total_pinjaman = $lelong['totals']['total_pinjaman'] ?? 0; + $total_nilaimarhun = $lelong['totals']['total_nilaimarhun'] ?? 0; + $total_keuntungan = $lelong['totals']['total_keuntungan'] ?? 0; + $total_onepercent = $lelong['totals']['total_onepercent'] ?? 0; + $total_ujrah = $lelong['totals']['total_ujrah'] ?? 0; + $total_cajlelong = $lelong['totals']['total_cajlelong'] ?? 0; + $total_hargajual = $lelong['totals']['total_hargajual'] ?? 0; + $total_baki = $lelong['totals']['total_baki'] ?? 0; + $total_hargaasas = $lelong['totals']['total_hargaasas'] ?? 0; + + // Fetch branch details + $cawangan_info = Http::get($request->hostname . '/api/cawangan/'. $request->kodcaw)->json(); + $cawangan = Http::get($request->hostname . '/api/cawangan/detail/'. $request->kodcaw)->json(); + $cawangan_detail = $cawangan[0]; + + $hostname = $request->hostname; + + // Check if the request is for PDF generation + if (isset($request->jenis) && $request->jenis == 'pdf') { + $pdf = PDF::loadView('akaun.laporan_lelong', compact( + 'total_pinjaman', 'total_nilaimarhun', 'total_keuntungan', 'total_onepercent', + 'total_ujrah', 'total_cajlelong', 'total_hargajual', 'total_baki', + 'total_hargaasas', 'hostname', 'lelong', 'cawangan_detail', + 'tarikh_cetak', 'mula_date', 'hingga_date', 'api_url', + 'bakilelong', 'rugilelong', 'batchno','tlelong' // Pass batchno to view + ))->setPaper('a4', 'landscape'); + + return $pdf->download('laporan_lelong_' . $request->kodcaw . '_' . $mula_date . '_' . $hingga_date . '_batch_' . $batchno . '.pdf'); + } + + // Return the view with batchno included + return view('akaun.laporan_lelong', compact( + 'total_pinjaman', 'total_nilaimarhun', 'total_keuntungan', 'total_onepercent', + 'total_ujrah', 'total_cajlelong', 'total_hargajual', 'total_baki', + 'total_hargaasas', 'hostname', 'lelong', 'cawangan_detail', + 'tarikh_cetak', 'mula_date', 'hingga_date', 'api_url', + 'bakilelong', 'rugilelong','batchno','tlelong' + )); + } + + } diff --git a/resources/js/Akaun/Home.vue b/resources/js/Akaun/Home.vue index d2fa961..52d9bb7 100644 --- a/resources/js/Akaun/Home.vue +++ b/resources/js/Akaun/Home.vue @@ -180,6 +180,11 @@

Sag Hilang

+
+ +

Laporan Lelong

+
+
diff --git a/resources/js/Akaun/LaporanLelong.vue b/resources/js/Akaun/LaporanLelong.vue new file mode 100644 index 0000000..92fccc8 --- /dev/null +++ b/resources/js/Akaun/LaporanLelong.vue @@ -0,0 +1,187 @@ + + + + + \ No newline at end of file diff --git a/resources/js/routes.js b/resources/js/routes.js index d5da7e5..eb1fbf0 100644 --- a/resources/js/routes.js +++ b/resources/js/routes.js @@ -60,6 +60,7 @@ import WtdSpecific from './WTD/SelectWTD' import AuditPage from './Audit/Audit' import KeuntunganSebenarPage from './Audit/KeuntunganSebenar' import UpahSimpanPage from './Audit/UpahSimpan' +import LaporanLelong from './Akaun/LaporanLelong.vue' @@ -103,6 +104,7 @@ export default new VueRouter({ { path: '/akaunhome/AuditTrail', component: AuditTrail }, { path: '/akaunhome/imbangdugabackup', component: ImbangDugaBackup }, { path: '/akaunhome/saghilang', component: SagHilang }, + { path: '/akaunhome/laporanlelong', component: LaporanLelong }, diff --git a/resources/views/akaun/laporan_lelong.blade.php b/resources/views/akaun/laporan_lelong.blade.php new file mode 100644 index 0000000..79b779f --- /dev/null +++ b/resources/views/akaun/laporan_lelong.blade.php @@ -0,0 +1,360 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LAPORAN LELONGAN
TARIKH CETAK: + @php + $myDateTime = DateTime::createFromFormat('Y-m-d', $tarikh_cetak); + echo $myDateTime ? $myDateTime->format('d-m-Y') : '-'; + @endphp +
TARIKH LELONG: + @php + $myDateTime = DateTime::createFromFormat('Y-m-d', $tlelong); + echo $myDateTime ? $myDateTime->format('d-m-Y') : '-'; + @endphp +
BATCH NO:{{ $batchno }}
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + @foreach($lelong['data'] as $sh) + + + + + + + + + + + + + + + + + + + + @endforeach + + + + + + + + + + + + + + + +
NoNo RujukanPenggadaiNilai Marhun Asal (RM)Pembiayaan (RM)Keuntungan (RM)1% (RM)Lain-Lain Caj (RM)Caj Lelong (RM)Harga Jual (RM)Baki (RM)Harga Asas (RM)Nama Pembeli
{{ $loop->iteration }}{{ $sh['norujukan'] }}{{ $sh['nama_cust'] ?? 'Unknown' }}
{{ $sh['nokp'] }}
{{ $sh['nilaimarhun']}}{{ $sh['pinjaman']}}{{ $sh['bakiupah']}}{{ $sh['onepercent']}}{{ $sh['ujrah']}}{{ $sh['cajlelong']}}{{ $sh['hargajual']}}@if($sh['baki'] < 0) + ({{ number_format(abs($sh['baki']), 2, '.', ',') }}) + @else + {{ number_format($sh['baki'], 2, '.', ',') }} + @endif{{ $sh['hargaasas']}}{{ $sh['nama']}}
Jumlah Keseluruhan{{ number_format($total_nilaimarhun, 2)}}{{ number_format($total_pinjaman, 2)}}{{ number_format($total_keuntungan, 2)}}{{ number_format($total_onepercent, 2)}}{{ number_format($total_ujrah, 2)}}{{ number_format($total_cajlelong, 2)}}{{ number_format($total_hargajual, 2)}}{{ number_format($total_baki, 2)}}{{ number_format($total_hargaasas, 2)}}
+ + + + + + + + + + + + + + + + + + + + +
Jumlah Baki Lelong (A):@if($bakilelong < 0) + ({{ number_format(abs($bakilelong), 2, '.', ',') }}) + @else + {{ number_format($bakilelong, 2, '.', ',') }} + @endif
Jumlah Kerugian Lelong (B):@if($rugilelong < 0) + ({{ number_format(abs($rugilelong), 2, '.', ',') }}) + @else + {{ number_format($rugilelong, 2, '.', ',') }} + @endif
A - B: + @if($total_baki < 0) + ({{ number_format(abs($total_baki), 2, '.', ',') }}) + @else + {{ number_format($total_baki, 2, '.', ',') }} + @endif +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
.................................................................. .................................................................. ..................................................................
Disediakan Disemak Disahkan
+ diff --git a/routes/web.php b/routes/web.php index 008f7aa..61911e7 100644 --- a/routes/web.php +++ b/routes/web.php @@ -129,6 +129,7 @@ Route::get('/akaunhome/cetakAnsuranRangeDate',['as'=>'cetak.ansuranRangeDate','u Route::get('/akaunhome/cetakpenebusanRangeDate',['as'=>'cetak.penebusanRangeDate','uses'=>'App\Http\Controllers\AkaunController@cetakLaporanPenebusanRangeDate'])->middleware(['roleChecker:admin,akaun,operasi,kpo,callcenter']); Route::get('/akaunhome/imbangdugabackup',['as'=>'cetak.imbangdugabackup','uses'=>'App\Http\Controllers\AkaunController@cetak_imbangdugaharian'])->middleware(['roleChecker:admin,akaun,operasi,kpo,callcenter']); Route::get('/akaunhome/cetak_saghilang',['as'=>'cetak.saghilang','uses'=>'App\Http\Controllers\AkaunController@cetak_laporansaghilang'])->middleware(['roleChecker:admin,akaun,operasi,kpo,callcenter']); +Route::get('/akaunhome/cetak_laporanlelong',['as'=>'cetak.laporanlelong','uses'=>'App\Http\Controllers\AkaunController@cetak_laporanlelong'])->middleware(['roleChecker:admin,akaun,operasi,kpo,callcenter']);