diff --git a/app/Exports/LaporanKeseluruhan/OutstandingAllExportExcel.php b/app/Exports/LaporanKeseluruhan/OutstandingAllExportExcel.php
new file mode 100644
index 0000000..39f7911
--- /dev/null
+++ b/app/Exports/LaporanKeseluruhan/OutstandingAllExportExcel.php
@@ -0,0 +1,35 @@
+outstandingData = $outstandingData;
+ }
+
+ public function collection()
+ {
+ return collect($this->outstandingData);
+ }
+
+ public function headings(): array
+ {
+ return [
+ 'Kod Cawangan',
+ 'Cawangan',
+ 'Bil Pembiayaan (SAG LAMA)',
+ 'Jumlah Pembiayaan (RM)',
+ 'Bil Pembiayaan (SAG BARU)',
+ 'Jumlah Pembiayaan (RM)',
+ 'Jumlah Bilangan',
+ 'Jumlah Pembiayaan (RM)',
+ ];
+ }
+}
diff --git a/app/Http/Controllers/Reports/OutstandingController.php b/app/Http/Controllers/Reports/OutstandingController.php
new file mode 100644
index 0000000..eb9770b
--- /dev/null
+++ b/app/Http/Controllers/Reports/OutstandingController.php
@@ -0,0 +1,84 @@
+hostname = config('api.url');
+ // dd($request->hostname );
+ $kod_cawangan = $request->kod_cawangan;
+ $action = $request->input('action', 'search');
+ // dd($action);
+
+ $getReportDate = function ($date_string) use ($current) {
+ if ($date_string == null) {
+ return $current->toDateString();
+ }
+
+ return $date_string;
+ };
+
+ $request->hostname = config('api.url');
+
+ $outstanding = Http::get($request->hostname . '/api/reports/outstanding', [
+ 'endDate' => $getReportDate($request->endDate),
+ ])->json();
+
+ $endDate = $getReportDate($request->endDate);
+
+ if ($action === 'excel') {
+ $file_title = sprintf("LaporanOutstanding(%s).xlsx", $kod_cawangan, $request->endDate);
+ return Excel::download(new OutstandingAllExportExcel($outstanding), $file_title);
+ }
+
+ $outstanding = $outstanding ?? [];
+
+ return view('reports.outstanding.index', compact('outstanding', 'endDate'));
+ }
+
+ public function show(Request $request)
+ {
+ $current = Carbon::now();
+ $action = $request->input('action', 'search');
+
+ $getReportDate = function ($date_string) use ($current) {
+ return $date_string ? $date_string : $current->toDateString();
+ };
+
+ $hostname = config('api.url');
+
+ $response = Http::get("$hostname/api/reports/outstanding", [
+ 'endDate' => $getReportDate($request->endDate),
+ ]);
+
+ $outstanding = $response->json() ?? []; // Ensure it's an array
+
+ // Debugging: Check the response before using it
+ if (empty($outstanding)) {
+ return back()->with('error', 'Failed to fetch data from API.');
+ }
+
+ $endDate = $getReportDate($request->endDate);
+
+ if ($action === 'excel') {
+ // Ensure $kod_cawangan is defined (Modify as per your data structure)
+ $kod_cawangan = $request->input('kod_cawangan', 'DEFAULT');
+
+ $file_title = sprintf("LaporanOutstanding(%s).xlsx", $kod_cawangan, $endDate);
+ return Excel::download(new OutstandingAllExportExcel($outstanding), $file_title);
+ }
+ return view('reports.outstanding.index', compact('outstanding', 'endDate'));
+ }
+}
diff --git a/resources/views/indexOverallReport.blade.php b/resources/views/indexOverallReport.blade.php
index 1d2b3bf..206de5e 100644
--- a/resources/views/indexOverallReport.blade.php
+++ b/resources/views/indexOverallReport.blade.php
@@ -55,6 +55,13 @@
Laporan Aging
+
+
diff --git a/resources/views/reports/outstanding/index.blade.php b/resources/views/reports/outstanding/index.blade.php
new file mode 100644
index 0000000..a1482a4
--- /dev/null
+++ b/resources/views/reports/outstanding/index.blade.php
@@ -0,0 +1,124 @@
+@extends('layouts.app')
+
+@section('content')
+
+
+
+
+
+
+
+
+
+
+
+
+
+ | No |
+ Kod Cawangan |
+ Cawangan |
+ Bil Pembiayaan (SAG LAMA) |
+ Jumlah Pembiayaan (RM) |
+ Bil Pembiayaan (SAG BARU) |
+ Jumlah Pembiayaan (RM) |
+ Jumlah Bilangan |
+ Jumlah Pembiayaan (RM) |
+
+
+
+ @php
+ $totalbilgadai = 0; // LAMA
+ $totalbilgadai2 = 0; // BARU
+ $totalpinjaman = 0; // LAMA
+ $totalpinjaman2 = 0; // BARU
+
+ $totalAllGadaian = 0; // SEMUA
+ $totalAllPinjaman = 0; // SEMUA
+ @endphp
+
+ @forelse ($outstanding as $outs)
+ @php
+ $totalbilgadai += $outs['total_gadaian'];
+ $totalpinjaman += $outs['sum_pinjaman'];
+ $totalbilgadai2 += $outs['total_gadaian2'];
+ $totalpinjaman2 += $outs['sum_pinjaman2'];
+
+ $totalAllGadaian += $outs['total_gadaian_all'];
+ $totalAllPinjaman += $outs['sum_pinjaman_all'];
+ @endphp
+
+ | {{ $loop->iteration }} |
+ {{ $outs['kodcaw'] }} |
+ {{ $outs['details_caw'] }} |
+ {{ $outs['total_gadaian'] }} |
+ {{ number_format($outs['sum_pinjaman'], 2) }} |
+ {{ $outs['total_gadaian2'] }} |
+ {{ number_format($outs['sum_pinjaman2'], 2) }} |
+ {{ $outs['total_gadaian_all'] }} |
+ {{ number_format($outs['sum_pinjaman_all'], 2) }} |
+
+
+ @empty
+
+ | Data not available |
+
+ @endforelse
+
+ | Jumlah Keseluruhan |
+ {{ $totalbilgadai }} |
+ {{ number_format($totalpinjaman,2) }} |
+ {{ $totalbilgadai2 }} |
+ {{ number_format($totalpinjaman2,2) }} |
+ {{ $totalAllGadaian }} |
+ {{ number_format($totalAllPinjaman,2) }} |
+ |
+
+
+
+
+
+
+ @include('layouts.footer')
+
+@endsection
+
+
diff --git a/routes/reports.php b/routes/reports.php
index 56c6e9b..fc3093b 100644
--- a/routes/reports.php
+++ b/routes/reports.php
@@ -7,6 +7,7 @@ use App\Http\Controllers\Reports\RingkasanHarianController;
use App\Http\Controllers\Reports\StokAuditController;
use App\Http\Controllers\Reports\LelonganController;
use App\Http\Controllers\Reports\AgingController;
+use App\Http\Controllers\Reports\OutstandingController;
use Illuminate\Support\Facades\Route;
Route::middleware(['roleChecker:admin,akaun,operasi,kpo, null'])->group(function () {
@@ -27,4 +28,5 @@ Route::middleware(['roleChecker:admin,akaun,operasi,kpo, null'])->group(function
Route::get('laporan-ansuran/view', [AnsuranController::class, 'show'])->name('reports.ansuran.show');
Route::get('aging/view', [AgingController::class, 'index'])->name('reports.aging.index');
Route::get('laporan-aging/view', [AgingController::class, 'show'])->name('reports.aging.show');
+ Route::get('outstanding/view', [OutstandingController::class, 'index'])->name('reports.outstanding.index');
});