rekod gadai tebus hari sama
This commit is contained in:
@@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\LaporanKeseluruhan;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromArray;
|
||||
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
||||
use Maatwebsite\Excel\Concerns\WithCustomValueBinder;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithStrictNullComparison;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\Cell;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\DataType;
|
||||
use PhpOffice\PhpSpreadsheet\Cell\DefaultValueBinder;
|
||||
use PhpOffice\PhpSpreadsheet\Style\NumberFormat;
|
||||
use Maatwebsite\Excel\Concerns\WithColumnFormatting;
|
||||
|
||||
class GadaiTebusAllExportExcel extends DefaultValueBinder implements
|
||||
FromArray,
|
||||
WithStrictNullComparison,
|
||||
WithHeadings,
|
||||
ShouldAutoSize,
|
||||
WithCustomValueBinder,
|
||||
WithColumnFormatting
|
||||
{
|
||||
public $data;
|
||||
|
||||
public function __construct($data)
|
||||
{
|
||||
$this->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']
|
||||
]);
|
||||
}
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -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'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,6 +92,12 @@
|
||||
<h2 class="mx-auto text-center font-bold text-2xl uppercase">Baki Lelong Belum Tuntut</h2>
|
||||
</a>
|
||||
</div>
|
||||
<div
|
||||
class="bg-white ml-2 shadow border border-solid px-6 py-4 rounded-lg hover:bg-yellow-300 hover:transition-all mb-2 cursor-pointer">
|
||||
<a href="{{ route('reports.gadaitebus.index', ['startDate' => now()->toDateString(), 'endDate' => now()->toDateString()]) }}" class="">
|
||||
<h2 class="mx-auto text-center font-bold text-2xl uppercase">Transaksi Segera</h2>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,222 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('content')
|
||||
<div class="bg-gray-900 opacity-50 hidden fixed inset-0 z-10" id="sidebarBackdrop"></div>
|
||||
<div id="main-content" class="h-full w-full bg-gray-50 relative overflow-y-auto">
|
||||
<main>
|
||||
|
||||
<div class="pt-6 px-4">
|
||||
|
||||
<breadcrumb
|
||||
:items="[{ 'title': 'Laporan Keseluruhan', 'icon': 'fas fa-users', 'url': '{{ route('reports') }}' }, { 'title': 'GadaiTebus', 'icon': 'fas fa-users' }]">
|
||||
</breadcrumb>
|
||||
|
||||
<div class="container">
|
||||
<div class="flex w-full">
|
||||
<div class="xl:w-3/5 2xl:w-2/3 p-12 mx-auto">
|
||||
<div class="bg-yellow-600 text-gray-200 text-lg px-6 py-4 rounded-t-lg"><a href="/reports"
|
||||
class="router-link-active"><i class="fas fa-backspace text-white"></i></a> <span
|
||||
class="text-center mx-auto text-white font-bold">Laporan Transaksi Segera Gadai Tebus</span></div>
|
||||
<form method="get" id="formgadaitebus" action="{{ route('reports.gadaitebus.index') }}">
|
||||
<div class="rounded bg-white shadow p-6">
|
||||
<div class="pb-6"><label for="username"
|
||||
class="font-semibold text-gray-700 block pb-1">Tarikh</label>
|
||||
<div class="flex">
|
||||
<span
|
||||
class="text-gray-600 border border-2 rounded-l px-4 py-2 whitespace-no-wrap"
|
||||
style="background-color: rgb(249, 250, 251);">Mula</span>
|
||||
<input id="tarikhmula" name="startDate" type="date"
|
||||
value="{{ request()->startDate ?? $startDate }}"
|
||||
class="border border-2 border-l-0 rounded-r px-4 py-2 w-80r mr-2">
|
||||
<span
|
||||
class="text-gray-600 border border-2 rounded-l px-4 py-2 whitespace-no-wrap"
|
||||
style="background-color: rgb(249, 250, 251);">Hingga</span>
|
||||
<input id="tarikhhingga" name="endDate" type="date"
|
||||
value="{{ request()->endDate ?? $endDate }}"
|
||||
class="border border-2 border-l-0 rounded-r px-4 py-2 w-80r mr-2">
|
||||
<!-- Hidden Input to Determine Action -->
|
||||
<input type="hidden" name="action" id="formAction" value="search">
|
||||
|
||||
<button type="submit" onclick="setAction('search')" class="border border-yellow-600 text-yellow-600 font-montserrat py-2 px-8 font-medium rounded-xl hover:bg-yellow-600 hover:text-white transition-all duration-300 ml-5">
|
||||
<i class="fas fa-magnifying-glass mr-2"></i> Search
|
||||
</button>
|
||||
|
||||
<button type="submit" onclick="setAction('excel')" class="border border-yellow-600 text-yellow-600 py-2 px-8 font-medium rounded-xl hover:bg-yellow-600 hover:text-white transition-all duration-300 ml-2">
|
||||
<i class="fas fa-file-excel mr-2"></i> Excel
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div kodcaw="operasi">
|
||||
<div>
|
||||
<!---->
|
||||
<!---->
|
||||
</div>
|
||||
<div>
|
||||
<!---->
|
||||
<!---->
|
||||
</div>
|
||||
<div class="flex justify-between mb-2">
|
||||
|
||||
|
||||
</div>
|
||||
<table class="min-w-full leading-normal">
|
||||
<thead class="text-center">
|
||||
<tr>
|
||||
<th
|
||||
class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
||||
No
|
||||
</th>
|
||||
<th
|
||||
class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
||||
Kod Cawangan
|
||||
</th>
|
||||
<th
|
||||
class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
||||
Cawangan
|
||||
</th>
|
||||
<th
|
||||
class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
||||
Bil SAG
|
||||
</th>
|
||||
<th
|
||||
class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
||||
Pembiayaan(RM)
|
||||
</th>
|
||||
<th
|
||||
class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-left text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
||||
Muat Turun
|
||||
</th>
|
||||
|
||||
</tr>
|
||||
</thead>
|
||||
@php
|
||||
$totalbilgadai = 0;
|
||||
$totalpinjaman = 0;
|
||||
@endphp
|
||||
<tbody>
|
||||
@forelse ($gadaian as $gadai)
|
||||
@php
|
||||
$totalbilgadai += $gadai['total_gadai_tebus_samahari'];
|
||||
$totalpinjaman += $gadai['jumlah_pinjaman'];
|
||||
@endphp
|
||||
|
||||
<tr>
|
||||
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
||||
<div class="flex items-center">
|
||||
<div class="ml-3">
|
||||
<p class="text-gray-900 whitespace-no-wrap">{{ $loop->iteration }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
||||
<div class="flex items-center">
|
||||
<div class="ml-3">
|
||||
<p class="text-gray-900 whitespace-no-wrap">{{ $gadai['kodcaw'] }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
||||
<div class="flex items-center">
|
||||
<div class="ml-3">
|
||||
<p class="text-gray-900 whitespace-no-wrap">{{ $gadai['details_caw'] }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
||||
<div class="flex items-center">
|
||||
<div class="ml-3">
|
||||
<p class="text-gray-900 whitespace-no-wrap">{{ $gadai['total_gadai_tebus_samahari'] }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
|
||||
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
||||
<div class="flex items-center">
|
||||
<div class="ml-3">
|
||||
<p class="text-gray-900 whitespace-no-wrap">
|
||||
{{ number_format($gadai['jumlah_pinjaman'], 2) }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
||||
<div class="flex items-center">
|
||||
<div class="ml-3">
|
||||
<a href="{{ route('reports.gadaian.cawangan.excel', [$gadai['kodcaw'], 'startDate' => request()->startDate, 'endDate' => request()->endDate]) }}"
|
||||
target="_blank" rel="noopener noreferrer"
|
||||
class="border border-blue-600 text-blue-600 font-montserrat py-2 px-4 font-medium rounded-xl hover:bg-blue-600 hover:text-white transition-all duration-300">
|
||||
<i class="fas fa-download mr-2"></i>Download
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="6" class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
||||
<div class="flex items-center">
|
||||
<div class="ml-3">
|
||||
<p class="text-gray-900 whitespace-no-wrap">Data not available</p>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
<tr>
|
||||
<td colspan="3" class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
||||
<div class="flex items-center">
|
||||
<div class="ml-3">
|
||||
<p class="text-gray-900 whitespace-no-wrap">Jumlah Keseluruhan</p>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
||||
<div class="flex items-center">
|
||||
<div class="ml-3">
|
||||
<p class="text-gray-900 whitespace-no-wrap">{{ $totalbilgadai}}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
||||
<div class="flex items-center">
|
||||
<div class="ml-3">
|
||||
<p class="text-gray-900 whitespace-no-wrap">
|
||||
{{ number_format($totalpinjaman,2) }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
||||
<div class="flex items-center">
|
||||
<div class="ml-3">
|
||||
<p class="text-gray-900 whitespace-no-wrap">
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
@include('layouts.footer')
|
||||
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
<script>
|
||||
function setAction(action) {
|
||||
document.getElementById('formAction').value = action;
|
||||
document.getElementById('formgadaitebus').submit();
|
||||
}
|
||||
</script>
|
||||
@@ -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');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user