diff --git a/app/Exports/GadaiTebusMasaExport.php b/app/Exports/GadaiTebusMasaExport.php new file mode 100644 index 0000000..12c43ea --- /dev/null +++ b/app/Exports/GadaiTebusMasaExport.php @@ -0,0 +1,47 @@ +cawangan_detail = $data['cawangan_detail']; + $this->query = $data['query']; + $this->gadaian = $data['gadaian']; + $this->summary_gadaian = $data['summary_gadaian']; + } + + public function sheets(): array + { + // Sheet untuk senarai penuh gadaian (gabung semua teller) + $full_gadaian_data = []; + + foreach ($this->gadaian as $teller => $data) { + if (isset($data['gadaian']) && is_array($data['gadaian'])) { + foreach ($data['gadaian'] as $item) { + $item['teller'] = $teller; // optional: simpan info teller + $full_gadaian_data[] = $item; + } + } + } + + $sheets[] = new GadaiTebusMasaFullExport( + $this->cawangan_detail, + $this->query, + $this->gadaian, + $full_gadaian_data + ); + + return $sheets; + } + +} diff --git a/app/Exports/GadaiTebusMasaFullExport.php b/app/Exports/GadaiTebusMasaFullExport.php new file mode 100644 index 0000000..ee6b6b1 --- /dev/null +++ b/app/Exports/GadaiTebusMasaFullExport.php @@ -0,0 +1,55 @@ +cawangan_detail = $cawangan_detail; + $this->query = $query; + $this->gadaian_full_data = $gadaian_full_data; + } + + public function view(): View + { + return view('exports.gadaian.full', [ + 'cawangan_detail' => $this->cawangan_detail, + 'query' => $this->query, + 'gadaian_data' => $this->gadaian_full_data, + ]); + } + + public function title(): string + { + return 'SENARAI GADAI TEBUS PENUH'; + } + + public function columnFormats(): array + { + return [ + 'E' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1, // Berat + 'F' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1, // Nilai Marhun + 'G' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1, // Pinjaman + 'H' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1, // Keuntungan + 'I' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1, // caj lelong + 'J' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1, // baki + 'K' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1, // baki + 'L' => NumberFormat::FORMAT_NUMBER_COMMA_SEPARATED1, // baki + + + + ]; + } +} diff --git a/app/Http/Controllers/Reports/GadaianController.php b/app/Http/Controllers/Reports/GadaianController.php index 9528925..4cc5577 100644 --- a/app/Http/Controllers/Reports/GadaianController.php +++ b/app/Http/Controllers/Reports/GadaianController.php @@ -11,6 +11,7 @@ use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Http; use Maatwebsite\Excel\Facades\Excel; use App\Exports\LaporanKeseluruhan\GadaiTebusAllExportExcel; +use App\Exports\GadaiTebusMasaExport; class GadaianController extends Controller { @@ -99,4 +100,79 @@ class GadaianController extends Controller return view('reports.gadaitebus.index', compact('gadaian', 'startDate', 'endDate')); } + + public function gadaitebusmasa(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("LaporanGadaiTebusMasa %s (%s - %s).xlsx", $kod_cawangan, $request->startDate, $request->endDate); + return Excel::download(new GadaiTebusMasaAllExportExcel($gadaian), $file_title); + } + + return view('reports.gadaitebusmasa.index', compact('gadaian', 'startDate', 'endDate')); + } + + public function downloadGadaiTebusMasaCawanganExcel(Request $request) + { + $api_url = $request->hostname; + $auth_user = Auth::user(); + $current = Carbon::now(); + $tarikh_cetak = $current->toDateString(); + + $getReportDate = function ($date_string) use ($current) { + return $date_string ?? $current->toDateString(); + }; + + $request->hostname = config('api.url'); + $kod_cawangan = $request->kod_cawangan; + // dd($kod_cawangan); + + $data = Http::get($request->hostname . '/api/reports/gadaitebusmasa/' . $kod_cawangan, [ + 'startDate' => $getReportDate($request->startDate), + 'endDate' => $getReportDate($request->endDate), + ])->json(); + + $byTeller = $request->input('by_teller', 1); // default ikut teller + + if (!$byTeller) { + // Gabung semua data jadi satu baris + $gabung = [ + 'teller' => 'Keseluruhan', + 'jumlah_lelongan' => 0, + 'jumlah_baki' => 0, + ]; + + foreach ($data as $item) { + $gabung['jumlah_lelongan'] += $item['jumlah_lelongan'] ?? 0; + $gabung['jumlah_baki'] += $item['jumlah_baki'] ?? 0; + } + + $data = [$gabung]; + } + + + $file_title = sprintf("LaporanGadaiTebusMasaCawangan %s (%s - %s).xlsx", $kod_cawangan, $request->startDate, $request->endDate); + return Excel::download(new GadaiTebusMasaExport($data), $file_title); + } } diff --git a/resources/views/exports/gadaian/full.blade.php b/resources/views/exports/gadaian/full.blade.php new file mode 100644 index 0000000..4f040cf --- /dev/null +++ b/resources/views/exports/gadaian/full.blade.php @@ -0,0 +1,91 @@ + + + + + + + + + {{-- ruang kosong sebelum header kolum --}} + + + + + + + + + + + + + + + + + + @php + $total_berat = 0; + $total_nilaimarhun = 0; + $total_pinjaman = 0; + @endphp + @foreach ($gadaian_data as $index => $item) + @php + $total_berat += (float) $item['berat']; + $total_nilaimarhun += (float) $item['nilai_marhun']; + $total_pinjaman += (float) $item['pinjaman']; + @endphp + + + + + + + + + + + + + + + + + + @endforeach + + + + + + + + + + + +
+ SENARAI GADAI TEBUS MASA +
+ Cawangan: {{ $cawangan_detail['nama'] ?? '-' }} | + Tarikh: {{ $query['tarikh'] ?? now()->format('d/m/Y') }} +
 
#No RujukanNamaNo KPBerat (g)Nilai Marhun (RM)Pembiayaan (RM)Tarikh GadaiMasa GadaiMasa TebusBeza Minit
{{ $index + 1 }}{{ $item['no_rujukan'] ?? '' }}{{ $item['nama'] ?? '' }}'{{ $item['no_kp'] ?? '' }}{{ $item['berat'] ?? 0 }}{{ $item['nilai_marhun'] ?? 0 }}{{ $item['pinjaman'] ?? 0 }}{{ $item['t_gadai'] ?? 0 }}{{ $item['masa'] ?? 0 }}{{ $item['masa_tebus'] ?? 0 }} + @php + $beza_str = $item['beza_minit'] ?? '00:00:00'; // contoh: "01:03:12", "-00:45:00" + + try { + $sign = Str::startsWith($beza_str, '-') ? '-' : ''; + $time = ltrim($beza_str, '-'); + + [$jam, $minit, $saat] = explode(':', $time); + + // Pastikan jam & minit sebagai integer + $jam = (int) $jam; + $minit = (int) $minit; + + echo $sign . $jam . ' jam ' . $minit . ' minit'; + } catch (\Exception $e) { + echo '-'; + } + @endphp +
Jumlah{{ number_format($total_berat, 2) }}{{ number_format($total_nilaimarhun, 2) }}{{ number_format($total_pinjaman, 2) }}
diff --git a/resources/views/indexOverallReport.blade.php b/resources/views/indexOverallReport.blade.php index 8131006..70f93b4 100644 --- a/resources/views/indexOverallReport.blade.php +++ b/resources/views/indexOverallReport.blade.php @@ -98,6 +98,12 @@

Transaksi Segera

+
+ +

Transaksi Segera(By Masa)

+
+
diff --git a/resources/views/reports/gadaitebusmasa/index.blade.php b/resources/views/reports/gadaitebusmasa/index.blade.php new file mode 100644 index 0000000..b7f554e --- /dev/null +++ b/resources/views/reports/gadaitebusmasa/index.blade.php @@ -0,0 +1,220 @@ +@extends('layouts.app') + +@section('content') + +
+
+ +
+ + + + +
+
+
+
Laporan Transaksi Segera Gadai Tebus Masa
+
+
+
+
+ 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 bfb8e31..29312eb 100644 --- a/routes/reports.php +++ b/routes/reports.php @@ -43,4 +43,6 @@ Route::middleware(['roleChecker:admin,akaun,operasi,kpo,callcenter, null'])->gro 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'); + Route::get('gadaitebusmasa', [GadaianController::class, 'gadaitebusmasa'])->name('reports.gadaitebusmasa.index'); + Route::get('gadaitebusmasa/{kod_cawangan}', [GadaianController::class, 'downloadGadaiTebusMasaCawanganExcel'])->name('reports.gadaitebusmasa.cawangan.excel'); });