diff --git a/app/Http/Controllers/AkaunController.php b/app/Http/Controllers/AkaunController.php index 7d10f44..1197659 100644 --- a/app/Http/Controllers/AkaunController.php +++ b/app/Http/Controllers/AkaunController.php @@ -1758,83 +1758,96 @@ class AkaunController extends Controller } public function cetak_laporanlelong(Request $request) -{ - $api_url = $request->hostname; - $auth_user = Auth::user(); - $current = Carbon::now(); - $tarikh_cetak = $current->toDateString(); + { + // dd($request->all()); + $api_url = $request->hostname; + $auth_user = Auth::user(); + $current = Carbon::now(); + $tarikh_cetak = $current->toDateString(); + $batchno = $request->batchno; - $mula_date = $request->datemula ?? '2017-01-01'; - $hingga_date = $request->datehingga ?? $current->toDateString(); + // 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); - $lelong = Http::get($request->hostname . 'api/laporan/lelong', [ - 'kodcaw' => $request->kodcaw, - 'tarikh_mula' => $mula_date, - 'tarikh_akhir' => $hingga_date - ])->json(); + // 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 variables - $bakilelong = 0; - $rugilelong = 0; + // 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) { - // 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'; + // 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` based on `baki` - if (isset($item['baki'])) { - if ($item['baki'] > 0) { - $bakilelong += $item['baki']; - } else { - $rugilelong += $item['baki']; + // 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']; - // 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 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 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]; + // 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; + $hostname = $request->hostname; - if (isset($request->jenis) && $request->jenis == 'pdf') { - $pdf = PDF::loadView('akaun.laporan_lelong', compact( + // 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' - ))->setPaper('a4', 'portrait'); - - return $pdf->download('laporan_lelong_' . $request->kodcaw . '_' . $mula_date . '_' . $hingga_date . '.pdf'); + 'bakilelong', 'rugilelong','batchno','tlelong' + )); } - 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/LaporanLelong.vue b/resources/js/Akaun/LaporanLelong.vue index d6af7e0..92fccc8 100644 --- a/resources/js/Akaun/LaporanLelong.vue +++ b/resources/js/Akaun/LaporanLelong.vue @@ -1,128 +1,187 @@ + + \ No newline at end of file + }; + + + \ No newline at end of file diff --git a/resources/views/akaun/laporan_lelong.blade.php b/resources/views/akaun/laporan_lelong.blade.php index 567ab3c..79b779f 100644 --- a/resources/views/akaun/laporan_lelong.blade.php +++ b/resources/views/akaun/laporan_lelong.blade.php @@ -189,7 +189,6 @@ - @@ -197,73 +196,63 @@ -
- +
- - - - + + - + - - - - - + + - - - - - - - - - - + + + + + + +
LAPORAN LELONG LAPORAN LELONGAN
TARIKH CETAK: + TARIKH CETAK: @php $myDateTime = DateTime::createFromFormat('Y-m-d', $tarikh_cetak); - $formattedweddingdate = $myDateTime->format('d-m-Y'); - echo($formattedweddingdate); + echo $myDateTime ? $myDateTime->format('d-m-Y') : '-'; @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 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) @@ -293,22 +282,20 @@ - - - - - - - - - - - - + + + + + + + + + + + +
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
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
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 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)}}
-

- @@ -342,14 +329,15 @@ @endif -
- +
+
+
+
-           -           +
..................................................................