diff --git a/app/Exports/LaporanKeseluruhan/PelangganaktifAllExportExcel.php b/app/Exports/LaporanKeseluruhan/PelangganaktifAllExportExcel.php
new file mode 100644
index 0000000..853d0fa
--- /dev/null
+++ b/app/Exports/LaporanKeseluruhan/PelangganaktifAllExportExcel.php
@@ -0,0 +1,93 @@
+pelangganaktifData = $pelangganaktifData;
+ $this->startDate = $startDate;
+ $this->endDate = $endDate;
+ }
+
+ public function collection()
+ {
+ return collect($this->pelangganaktifData);
+ }
+
+ public function headings(): array
+ {
+ return [
+ 'No.',
+ 'Kod Caw',
+ 'Nama Cawangan',
+ 'Jumlah',
+ ];
+ }
+
+ public function map($row): array
+ {
+ $jumlah = is_numeric($row['total_pelanggan_aktif'] ?? null) ? (float) $row['total_pelanggan_aktif'] : 0;
+ $this->total += $jumlah;
+
+ return [
+ $this->counter++,
+ $row['kodcaw'] ?? '',
+ $row['details_caw'] ?? '',
+ number_format($jumlah, 2),
+ ];
+ }
+ public function startCell(): string
+ {
+ return 'A3'; // Mulakan heading di baris 3
+ }
+
+ public function registerEvents(): array
+ {
+ return [
+ AfterSheet::class => function (AfterSheet $event) {
+
+ // Tajuk laporan di A1:D1
+ $event->sheet->mergeCells('A1:D1');
+ $event->sheet->setCellValue('A1', 'LAPORAN PELANGGAN AKTIF');
+ $event->sheet->getStyle('A1')->getFont()->setSize(14)->setBold(true);
+ $event->sheet->getStyle('A1')->getAlignment()->setHorizontal('center');
+
+ // Tarikh di A2:D2
+ $tarikhMula = $this->startDate ? date('d/m/Y', strtotime($this->startDate)) : '-';
+ $tarikhTamat = $this->endDate ? date('d/m/Y', strtotime($this->endDate)) : '-';
+ $event->sheet->mergeCells('A2:D2');
+ $event->sheet->setCellValue('A2', "Tempoh: {$tarikhMula} hingga {$tarikhTamat}");
+ $event->sheet->getStyle('A2')->getFont()->setItalic(true);
+ $event->sheet->getStyle('A2')->getAlignment()->setHorizontal('center');
+
+ // Kira baris terakhir untuk jumlah keseluruhan
+ $lastRow = count($this->pelangganaktifData) + 3 + 1; // +1 untuk heading
+
+ $event->sheet->mergeCells("A{$lastRow}:C{$lastRow}");
+ $event->sheet->setCellValue("A{$lastRow}", 'Jumlah Keseluruhan');
+ $event->sheet->setCellValue("D{$lastRow}", number_format($this->total, 2));
+ $event->sheet->getStyle("A{$lastRow}:D{$lastRow}")->getFont()->setBold(true);
+ $event->sheet->getStyle("A{$lastRow}:D{$lastRow}")->getAlignment()->setHorizontal('right');
+ },
+ ];
+ }
+
+
+
+
+}
diff --git a/app/Http/Controllers/Reports/AnalisaController.php b/app/Http/Controllers/Reports/AnalisaController.php
index f508ca4..8293b60 100644
--- a/app/Http/Controllers/Reports/AnalisaController.php
+++ b/app/Http/Controllers/Reports/AnalisaController.php
@@ -10,6 +10,7 @@ use Illuminate\Support\Facades\Http;
use Maatwebsite\Excel\Facades\Excel;
use Illuminate\Support\Facades\Auth;
use App\Exports\LaporanKeseluruhan\PelangganbaruAllExportExcel;
+use App\Exports\LaporanKeseluruhan\PelangganaktifAllExportExcel;
class AnalisaController extends Controller
{
@@ -51,5 +52,43 @@ class AnalisaController extends Controller
return view('reports.pelangganbaru.index', compact('pelangganbaru', 'startDate', 'endDate'));
}
+ public function pelangganaktif(Request $request)
+ {
+ $current = new Carbon();
+ $request->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');
+
+ $pelangganaktif = Http::get($request->hostname . '/api/reports/pelangganaktif', [
+ 'startDate' => $getReportDate($request->startDate),
+ 'endDate' => $getReportDate($request->endDate),
+ ])->json();
+ // dd($pelangganbaru);
+
+ $startDate = $getReportDate($request->startDate);
+ $endDate = $getReportDate($request->endDate);
+
+ if ($action === 'excel') {
+ $file_title = sprintf("LaporanPelangganAktif(%s).xlsx", $kod_cawangan, $request->startDate, $request->endDate);
+ return Excel::download(new PelangganaktifAllExportExcel($pelangganaktif,$startDate,$endDate), $file_title);
+ }
+
+ $pelangganaktif = $pelangganaktif ?? [];
+
+ return view('reports.pelangganaktif.index', compact('pelangganaktif', 'startDate', 'endDate'));
+ }
+
}
diff --git a/resources/views/indexOverallReport.blade.php b/resources/views/indexOverallReport.blade.php
index 138f3c7..7b6c303 100644
--- a/resources/views/indexOverallReport.blade.php
+++ b/resources/views/indexOverallReport.blade.php
@@ -74,6 +74,12 @@
Pelanggan Baru
+
diff --git a/resources/views/reports/pelangganaktif/index.blade.php b/resources/views/reports/pelangganaktif/index.blade.php
new file mode 100644
index 0000000..6a724b1
--- /dev/null
+++ b/resources/views/reports/pelangganaktif/index.blade.php
@@ -0,0 +1,177 @@
+@extends('layouts.app')
+
+@section('content')
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
Laporan Pelanggan Aktif
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ |
+ No
+ |
+
+ Kod Cawangan
+ |
+
+ Cawangan
+ |
+
+ Jumlah Pelanggan
+ |
+
+
+ @php
+ $totalbilgadai = 0;
+ @endphp
+
+ @forelse ($pelangganaktif as $gadai)
+ @php
+ $totalbilgadai += $gadai['total_pelanggan_aktif'];
+ @endphp
+
+
+
+
+
+ {{ $loop->iteration }}
+
+
+ |
+
+
+
+ {{ $gadai['kodcaw'] }}
+
+
+ |
+
+
+
+ {{ $gadai['details_caw'] }}
+
+
+ |
+
+
+
+ {{ $gadai['total_pelanggan_aktif'] }}
+
+
+
+ |
+
+ @empty
+
+ |
+
+ |
+
+ @endforelse
+
+ |
+
+ |
+
+
+
+ {{ $totalbilgadai}}
+
+
+
+ |
+
+
+
+
+
+
+
+ @include('layouts.footer')
+
+
+@endsection
+
+
+
+
\ No newline at end of file
diff --git a/routes/reports.php b/routes/reports.php
index 47264dd..58bfdbf 100644
--- a/routes/reports.php
+++ b/routes/reports.php
@@ -33,4 +33,5 @@ Route::middleware(['roleChecker:admin,akaun,operasi,kpo, null'])->group(function
Route::get('outstanding/view', [OutstandingController::class, 'index'])->name('reports.outstanding.index');
Route::get('petibesi/view', [PetibesiController::class, 'index'])->name('reports.petibesi.index');
Route::get('pelangganbaru/view', [AnalisaController::class, 'index'])->name('reports.pelangganbaru.index');
+ Route::get('pelangganaktif/view', [AnalisaController::class, 'pelangganaktif'])->name('reports.pelangganaktif.index');
});