diff --git a/app/Exports/LaporanKeseluruhan/GadaiTebusAllExportExcel.php b/app/Exports/LaporanKeseluruhan/GadaiTebusAllExportExcel.php new file mode 100644 index 0000000..aeebeac --- /dev/null +++ b/app/Exports/LaporanKeseluruhan/GadaiTebusAllExportExcel.php @@ -0,0 +1,123 @@ +data = $data; + } + + public function headings(): array + { + return [ + ['Laporan Gadai Tebus Keseluruhan'], // Title row + ['Bil', + 'Cawangan', + 'Bilangan SAG', + 'Jumlah Pembiayaan (RM)', + ] + ]; + } + + public function array(): array + { + if (empty($this->data)) { + return []; + } + + $formattedData = []; + $total_gadai_tebus_samahari = 0; + $jumlah_pinjaman = 0; + $counter = 1; + + foreach ($this->data as $data) { + $formattedData[] = [ + $counter++, // Numbering (Integer) + $data['details_caw'] ?? 'N/A', + (int) ($data['total_gadai_tebus_samahari'] ?? 0), // Integer + (float) ($data['jumlah_pinjaman'] ?? 0), // Decimal + ]; + + // Update totals + $total_gadai_tebus_samahari += (int) $data['total_gadai_tebus_samahari']; + $jumlah_pinjaman += (float) $data['jumlah_pinjaman']; + } + + // Append total row (without numbering) + $formattedData[] = [ + '', // No numbering for total row + 'Jumlah Keseluruhan', + $total_gadai_tebus_samahari, + $jumlah_pinjaman, + ]; + + return $formattedData; + } + + public function columnWidths(): array + { + return [ + 'A' => 5, // Bil + 'B' => 25, // Cawangan + 'C' => 20, // Bilangan SAG + 'D' => 20, // Jumlah + ]; + } + + public function columnFormats(): array + { + return [ + 'C' => NumberFormat::FORMAT_NUMBER, + 'D' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1, + ]; + } + + public function bindValue(Cell $cell, $value) + { + if (is_numeric($value) && !is_string($value)) { + $cell->setValueExplicit((float) $value, DataType::TYPE_NUMERIC); + return true; + } + + return parent::bindValue($cell, $value); + } + + public function registerEvents(): array + { + return [ + AfterSheet::class => function (AfterSheet $event) { + $sheet = $event->sheet; + + // Merge the title row across all columns (A1 to G1) + $sheet->mergeCells('A1:G1'); + + // Style the title (bold, center) + $sheet->getStyle('A1')->applyFromArray([ + 'font' => ['bold' => true, 'size' => 14], + 'alignment' => ['horizontal' => 'center', 'vertical' => 'center'] + ]); + } + ]; + } +} diff --git a/app/Http/Controllers/Reports/GadaianController.php b/app/Http/Controllers/Reports/GadaianController.php index ca625bc..9528925 100644 --- a/app/Http/Controllers/Reports/GadaianController.php +++ b/app/Http/Controllers/Reports/GadaianController.php @@ -10,6 +10,7 @@ use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Http; use Maatwebsite\Excel\Facades\Excel; +use App\Exports\LaporanKeseluruhan\GadaiTebusAllExportExcel; class GadaianController extends Controller { @@ -66,4 +67,36 @@ class GadaianController extends Controller $file_title = sprintf("LaporanGadaian %s (%s - %s).xlsx", $kod_cawangan, $request->startDate, $request->endDate); return Excel::download(new GadaianExport($data), $file_title); } + + public function gadaitebus(Request $request) + { + $current = new Carbon(); + $action = $request->input('action', 'search'); + $kod_cawangan = $request->kod_cawangan; + + $getReportDate = function ($date_string) use ($current) { + if ($date_string == null) { + return $current->toDateString(); + } + + return $date_string; + }; + + $request->hostname = config('api.url'); + + $gadaian = Http::get($request->hostname . '/api/reports/gadaitebus', [ + 'startDate' => $getReportDate($request->startDate), + 'endDate' => $getReportDate($request->endDate), + ])->json(); + + $startDate = $getReportDate($request->startDate); + $endDate = $getReportDate($request->endDate); + + if ($action === 'excel') { + $file_title = sprintf("LaporanGadaiTebus %s (%s - %s).xlsx", $kod_cawangan, $request->startDate, $request->endDate); + return Excel::download(new GadaiTebusAllExportExcel($gadaian), $file_title); + } + + return view('reports.gadaitebus.index', compact('gadaian', 'startDate', 'endDate')); + } } diff --git a/resources/views/indexOverallReport.blade.php b/resources/views/indexOverallReport.blade.php index 2d9671f..8131006 100644 --- a/resources/views/indexOverallReport.blade.php +++ b/resources/views/indexOverallReport.blade.php @@ -92,6 +92,12 @@

Baki Lelong Belum Tuntut

+
+ +

Transaksi Segera

+
+
diff --git a/resources/views/reports/gadaitebus/index.blade.php b/resources/views/reports/gadaitebus/index.blade.php new file mode 100644 index 0000000..d37ba8b --- /dev/null +++ b/resources/views/reports/gadaitebus/index.blade.php @@ -0,0 +1,222 @@ +@extends('layouts.app') + +@section('content') + +
+
+ +
+ + + + +
+
+
+
Laporan Transaksi Segera Gadai Tebus
+
+
+
+
+ Mula + + Hingga + + + + + + + +
+ +
+
+
+
+
+
+
+
+ + +
+
+ + +
+
+ + +
+ + + + + + + + + + + + + @php + $totalbilgadai = 0; + $totalpinjaman = 0; + @endphp + + @forelse ($gadaian as $gadai) + @php + $totalbilgadai += $gadai['total_gadai_tebus_samahari']; + $totalpinjaman += $gadai['jumlah_pinjaman']; + @endphp + + + + + + + + + + + + @empty + + + + @endforelse + + + + + + + + + +
+ No + + Kod Cawangan + + Cawangan + + Bil SAG + + Pembiayaan(RM) + + Muat Turun +
+
+
+

{{ $loop->iteration }}

+
+
+
+
+
+

{{ $gadai['kodcaw'] }}

+
+
+
+
+
+

{{ $gadai['details_caw'] }}

+
+
+
+
+
+

{{ $gadai['total_gadai_tebus_samahari'] }} +

+
+
+
+
+
+

+ {{ number_format($gadai['jumlah_pinjaman'], 2) }}

+
+
+
+ +
+
+
+

Data not available

+
+
+
+
+
+

Jumlah Keseluruhan

+
+
+
+
+
+

{{ $totalbilgadai}} +

+
+
+
+
+
+

+ {{ number_format($totalpinjaman,2) }}

+
+
+
+
+
+

+

+
+
+
+
+
+
+ @include('layouts.footer') + +
+@endsection + + \ No newline at end of file diff --git a/routes/reports.php b/routes/reports.php index d300bff..bfb8e31 100644 --- a/routes/reports.php +++ b/routes/reports.php @@ -42,4 +42,5 @@ Route::middleware(['roleChecker:admin,akaun,operasi,kpo,callcenter, null'])->gro Route::get('bakilelongbelumtuntut/{kod_cawangan}', [BakiLelongController::class, 'downloadBakiLelongBelumTuntutCawanganExcel'])->name('reports.bakilelongbelumtuntut.cawangan.excel'); Route::get('bayaran-online/view', BayaranOnlineController::class)->name('reports.bayaran-online.index'); Route::get('bayaran-online-details/view', BayaranOnlineDetailController::class)->name('reports.bayaran-online-detail.index'); + Route::get('gadaitebus', [GadaianController::class, 'gadaitebus'])->name('reports.gadaitebus.index'); });