tambah laporan outstanding
This commit is contained in:
@@ -0,0 +1,35 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Exports\LaporanKeseluruhan;
|
||||||
|
|
||||||
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||||
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||||
|
|
||||||
|
class OutstandingAllExportExcel implements FromCollection, WithHeadings
|
||||||
|
{
|
||||||
|
protected $outstandingData;
|
||||||
|
|
||||||
|
public function __construct($outstandingData)
|
||||||
|
{
|
||||||
|
$this->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)',
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,84 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Reports;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use Carbon\Carbon;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\App;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use Maatwebsite\Excel\Facades\Excel;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use App\Exports\LaporanKeseluruhan\OutstandingAllExportExcel;
|
||||||
|
|
||||||
|
class OutstandingController extends Controller
|
||||||
|
{
|
||||||
|
public function index(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');
|
||||||
|
|
||||||
|
$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'));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -55,6 +55,13 @@
|
|||||||
<h2 class="mx-auto text-center font-bold text-2xl uppercase">Laporan Aging</h2>
|
<h2 class="mx-auto text-center font-bold text-2xl uppercase">Laporan Aging</h2>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</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.outstanding.index', ['startDate' => now()->toDateString(), 'endDate' => now()->toDateString()]) }}" class="">
|
||||||
|
<h2 class="mx-auto text-center font-bold text-2xl uppercase">Outstanding</h2>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,124 @@
|
|||||||
|
@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': 'Outstanding', 'icon': 'fas fa-users' }]">
|
||||||
|
</breadcrumb>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<div class="flex w-full">
|
||||||
|
<div class="xl:w-2/3 2xl:w-1/2 p-8 mx-auto">
|
||||||
|
<div class="bg-yellow-600 text-gray-200 text-lg px-6 py-4 rounded-t-lg">
|
||||||
|
<a href="{{ route('reports') }}" class="router-link-active">
|
||||||
|
<i class="fas fa-backspace text-white"></i>
|
||||||
|
</a>
|
||||||
|
<span class="text-center mx-auto text-white font-bold">Outstanding</span>
|
||||||
|
</div>
|
||||||
|
<form method="get" id="formoutstanding" action="{{ route('reports.outstanding.index') }}">
|
||||||
|
<input type="hidden" id="formAction" name="action" value="search"> <!-- Hidden field to store action -->
|
||||||
|
<div class="rounded bg-white shadow p-6">
|
||||||
|
<div class="pb-6">
|
||||||
|
<label class="font-semibold text-gray-700 block pb-1">Tarikh Hingga</label>
|
||||||
|
<div class="flex space-x-2">
|
||||||
|
<input name="endDate" type="date"
|
||||||
|
value="{{ request()->endDate ?? $endDate }}"
|
||||||
|
class="border border-2 rounded px-4 py-2 w-full" placeholder="Hingga">
|
||||||
|
|
||||||
|
<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">
|
||||||
|
<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-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-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-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-xs font-semibold text-gray-600 uppercase tracking-wider">Bil Pembiayaan (SAG LAMA)</th>
|
||||||
|
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-xs font-semibold text-gray-600 uppercase tracking-wider">Jumlah Pembiayaan (RM)</th>
|
||||||
|
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-xs font-semibold text-gray-600 uppercase tracking-wider">Bil Pembiayaan (SAG BARU)</th>
|
||||||
|
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-xs font-semibold text-gray-600 uppercase tracking-wider">Jumlah Pembiayaan (RM)</th>
|
||||||
|
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-xs font-semibold text-gray-600 uppercase tracking-wider">Jumlah Bilangan</th>
|
||||||
|
<th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-xs font-semibold text-gray-600 uppercase tracking-wider">Jumlah Pembiayaan (RM)</th>
|
||||||
|
<!-- <th class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-xs font-semibold text-gray-600 uppercase tracking-wider">Action</th> -->
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
@php
|
||||||
|
$totalbilgadai = 0; // LAMA
|
||||||
|
$totalbilgadai2 = 0; // BARU
|
||||||
|
$totalpinjaman = 0; // LAMA
|
||||||
|
$totalpinjaman2 = 0; // BARU
|
||||||
|
|
||||||
|
$totalAllGadaian = 0; // SEMUA
|
||||||
|
$totalAllPinjaman = 0; // SEMUA
|
||||||
|
@endphp
|
||||||
|
<tbody>
|
||||||
|
@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
|
||||||
|
<tr>
|
||||||
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">{{ $loop->iteration }}</td>
|
||||||
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">{{ $outs['kodcaw'] }}</td>
|
||||||
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">{{ $outs['details_caw'] }}</td>
|
||||||
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">{{ $outs['total_gadaian'] }}</td>
|
||||||
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">{{ number_format($outs['sum_pinjaman'], 2) }}</td>
|
||||||
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">{{ $outs['total_gadaian2'] }}</td>
|
||||||
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">{{ number_format($outs['sum_pinjaman2'], 2) }}</td>
|
||||||
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">{{ $outs['total_gadaian_all'] }}</td>
|
||||||
|
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">{{ number_format($outs['sum_pinjaman_all'], 2) }}</td>
|
||||||
|
|
||||||
|
</tr>
|
||||||
|
@empty
|
||||||
|
<tr>
|
||||||
|
<td colspan="8" class="px-5 py-5 border-b border-gray-200 bg-white text-sm text-center text-gray-500">Data not available</td>
|
||||||
|
</tr>
|
||||||
|
@endforelse
|
||||||
|
<tr class="font-semibold bg-gray-50">
|
||||||
|
<td colspan="3" class="px-5 py-5 border-b border-gray-200 text-sm">Jumlah Keseluruhan</td>
|
||||||
|
<td class="px-5 py-5 border-b border-gray-200 text-sm">{{ $totalbilgadai }}</td>
|
||||||
|
<td class="px-5 py-5 border-b border-gray-200 text-sm">{{ number_format($totalpinjaman,2) }}</td>
|
||||||
|
<td class="px-5 py-5 border-b border-gray-200 text-sm">{{ $totalbilgadai2 }}</td>
|
||||||
|
<td class="px-5 py-5 border-b border-gray-200 text-sm">{{ number_format($totalpinjaman2,2) }}</td>
|
||||||
|
<td class="px-5 py-5 border-b border-gray-200 text-sm">{{ $totalAllGadaian }}</td>
|
||||||
|
<td class="px-5 py-5 border-b border-gray-200 text-sm">{{ number_format($totalAllPinjaman,2) }}</td>
|
||||||
|
<td class="px-5 py-5 border-b border-gray-200 text-sm"></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
@include('layouts.footer')
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
|
|
||||||
|
<script>
|
||||||
|
function setAction(action) {
|
||||||
|
document.getElementById('formAction').value = action;
|
||||||
|
document.getElementById('formoutstanding').submit();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
@@ -7,6 +7,7 @@ use App\Http\Controllers\Reports\RingkasanHarianController;
|
|||||||
use App\Http\Controllers\Reports\StokAuditController;
|
use App\Http\Controllers\Reports\StokAuditController;
|
||||||
use App\Http\Controllers\Reports\LelonganController;
|
use App\Http\Controllers\Reports\LelonganController;
|
||||||
use App\Http\Controllers\Reports\AgingController;
|
use App\Http\Controllers\Reports\AgingController;
|
||||||
|
use App\Http\Controllers\Reports\OutstandingController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
Route::middleware(['roleChecker:admin,akaun,operasi,kpo, null'])->group(function () {
|
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('laporan-ansuran/view', [AnsuranController::class, 'show'])->name('reports.ansuran.show');
|
||||||
Route::get('aging/view', [AgingController::class, 'index'])->name('reports.aging.index');
|
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('laporan-aging/view', [AgingController::class, 'show'])->name('reports.aging.show');
|
||||||
|
Route::get('outstanding/view', [OutstandingController::class, 'index'])->name('reports.outstanding.index');
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user