From 6a21d4afbbb110a234c278d6d6a7fe269f935ac8 Mon Sep 17 00:00:00 2001 From: BTMS2 Date: Mon, 24 Feb 2025 13:13:14 +0800 Subject: [PATCH] tambah laporan lelong dlm admin --- app/Http/Controllers/AkaunController.php | 79 ++++ resources/js/Akaun/Home.vue | 5 + resources/js/Akaun/LaporanLelong.vue | 128 ++++++ resources/js/routes.js | 2 + .../views/akaun/laporan_lelong.blade.php | 372 ++++++++++++++++++ routes/web.php | 1 + 6 files changed, 587 insertions(+) create mode 100644 resources/js/Akaun/LaporanLelong.vue create mode 100644 resources/views/akaun/laporan_lelong.blade.php diff --git a/app/Http/Controllers/AkaunController.php b/app/Http/Controllers/AkaunController.php index e9a6d97..7d10f44 100644 --- a/app/Http/Controllers/AkaunController.php +++ b/app/Http/Controllers/AkaunController.php @@ -1757,5 +1757,84 @@ 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) +{ + $api_url = $request->hostname; + $auth_user = Auth::user(); + $current = Carbon::now(); + $tarikh_cetak = $current->toDateString(); + + $mula_date = $request->datemula ?? '2017-01-01'; + $hingga_date = $request->datehingga ?? $current->toDateString(); + + $lelong = Http::get($request->hostname . 'api/laporan/lelong', [ + 'kodcaw' => $request->kodcaw, + 'tarikh_mula' => $mula_date, + 'tarikh_akhir' => $hingga_date + ])->json(); + + // Initialize variables + $bakilelong = 0; + $rugilelong = 0; + + // Ensure 'data' key exists before looping + if (isset($lelong['data']) && is_array($lelong['data'])) { + foreach ($lelong['data'] as $key => $item) { + // Check if 'nokp' exists and is not null + $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` based on `baki` + if (isset($item['baki'])) { + if ($item['baki'] > 0) { + $bakilelong += $item['baki']; + } else { + $rugilelong += $item['baki']; + } + } + } + } + + // Get totals from API response + $total_pinjaman = $lelong['total_pinjaman'] ?? 0; + $total_nilaimarhun = $lelong['total_nilaimarhun'] ?? 0; + $total_keuntungan = $lelong['total_keuntungan'] ?? 0; + $total_onepercent = $lelong['total_onepercent'] ?? 0; + $total_ujrah = $lelong['total_ujrah'] ?? 0; + $total_cajlelong = $lelong['total_cajlelong'] ?? 0; + $total_hargajual = $lelong['total_hargajual'] ?? 0; + $total_baki = $lelong['total_baki'] ?? 0; + $total_hargaasas = $lelong['total_hargaasas'] ?? 0; + + // Fetch cawangan 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; + + 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' + ))->setPaper('a4', 'portrait'); + + return $pdf->download('laporan_lelong_' . $request->kodcaw . '_' . $mula_date . '_' . $hingga_date . '.pdf'); + } + + 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' + )); +} + + } 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..d6af7e0 --- /dev/null +++ b/resources/js/Akaun/LaporanLelong.vue @@ -0,0 +1,128 @@ + + + \ 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..567ab3c --- /dev/null +++ b/resources/views/akaun/laporan_lelong.blade.php @@ -0,0 +1,372 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LAPORAN LELONG
TARIKH CETAK: + @php + $myDateTime = DateTime::createFromFormat('Y-m-d', $tarikh_cetak); + $formattedweddingdate = $myDateTime->format('d-m-Y'); + echo($formattedweddingdate); + @endphp +
TARIKH:@php + $myDateTime = DateTime::createFromFormat('Y-m-d', $mula_date); + $formattedweddingdate = $myDateTime->format('d-m-Y'); + echo($formattedweddingdate); + @endphp HINGGA:@php + $myDateTime = DateTime::createFromFormat('Y-m-d', $hingga_date); + $formattedweddingdate = $myDateTime->format('d-m-Y'); + echo($formattedweddingdate); + @endphp
+ +
+ + + + + + + + + + + + + + + + + + + + + + @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']);