Merged in feature/nisha/laporan-wtd (pull request #142)
laporan_rumusan_wtd
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports;
|
||||
|
||||
use Illuminate\Contracts\View\View;
|
||||
use Maatwebsite\Excel\Concerns\FromView;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class WTDDetailExport implements FromView
|
||||
{
|
||||
protected $kodcaw;
|
||||
protected $startDate;
|
||||
protected $endDate;
|
||||
|
||||
public function __construct($kodcaw, $startDate, $endDate)
|
||||
{
|
||||
$this->kodcaw = $kodcaw;
|
||||
$this->startDate = $startDate;
|
||||
$this->endDate = $endDate;
|
||||
}
|
||||
|
||||
public function view(): View
|
||||
{
|
||||
$data = Http::get(config('api.url') . '/admin/wtd/summaryWtd', [
|
||||
'startDate' => $this->startDate,
|
||||
'endDate' => $this->endDate,
|
||||
])->json();
|
||||
|
||||
$branch = collect($data)->firstWhere('kodcaw', $this->kodcaw);
|
||||
$details = collect($branch['details'] ?? []);
|
||||
|
||||
return view('reports.wtd.excel', [
|
||||
'details' => $details, // data WTD
|
||||
'branch' => $branch,
|
||||
'generatedAt' => now()->format('d/m/Y H:i'),
|
||||
'startDate' => $this->startDate,
|
||||
'endDate' => $this->endDate,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Session;
|
||||
@@ -10,7 +9,8 @@ use Illuminate\Support\Facades\Http;
|
||||
use Carbon\Carbon;
|
||||
|
||||
use PDF;
|
||||
use Maatwebsite\Excel\Excel;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Exports\WTDDetailExport;
|
||||
|
||||
class WTDController extends Controller
|
||||
{
|
||||
@@ -178,4 +178,50 @@ class WTDController extends Controller
|
||||
|
||||
dd($response);
|
||||
}
|
||||
|
||||
public function summaryWtd(Request $request)
|
||||
{
|
||||
$current = Carbon::now();
|
||||
|
||||
$getReportDate = function ($date_string) use ($current) {
|
||||
return $date_string ? $date_string : $current->toDateString();
|
||||
};
|
||||
|
||||
$request->hostname = config('api.url');
|
||||
|
||||
$startDate = $getReportDate($request->startDate);
|
||||
$endDate = $getReportDate($request->endDate);
|
||||
|
||||
|
||||
|
||||
// $summarywtd = Http::get($request->hostname . '/admin/wtd/summaryWtd', [
|
||||
// 'startDate' => $startDate,
|
||||
// 'endDate' => $endDate,
|
||||
// ])->effectiveUri()->__toString();
|
||||
|
||||
// dd($summarywtd);
|
||||
|
||||
|
||||
$summarywtd = Http::get($request->hostname . '/admin/wtd/summaryWtd', [
|
||||
'startDate' => $startDate,
|
||||
'endDate' => $endDate,
|
||||
])->json();
|
||||
|
||||
|
||||
if (!is_array($summarywtd)) {
|
||||
$summarywtd = [];
|
||||
}
|
||||
|
||||
return view('reports.wtd.index', compact('summarywtd', 'startDate', 'endDate'));
|
||||
}
|
||||
|
||||
public function exportExcel(Request $request, $kodcaw)
|
||||
{
|
||||
return Excel::download(
|
||||
new WTDDetailExport(
|
||||
$kodcaw,
|
||||
$request->startDate,
|
||||
$request->endDate
|
||||
),"Detail_Laporan_WTD_{$kodcaw}.xlsx");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -110,6 +110,12 @@
|
||||
<h2 class="mx-auto text-center font-bold text-2xl uppercase">Saringan Gadaian</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.summary-wtd.index', ['startDate' => now()->toDateString(), 'endDate' => now()->toDateString()]) }}" class="">
|
||||
<h2 class="mx-auto text-center font-bold text-2xl uppercase">Selesai WTD</h2>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
<table>
|
||||
<tr>
|
||||
<td colspan="9" style="font-weight:bold; font-size:16px; text-align:center;">
|
||||
LAPORAN RUMUSAN WTD
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="9" style="text-align:center;">
|
||||
Cawangan : {{ $branch['details_caw'] ?? '-' }} ({{ $branch['kodcaw'] ?? '-' }})
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="9" style="text-align:center;">
|
||||
Tarikh : {{ $startDate }} hingga {{ $endDate }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="9" style="text-align:center;">
|
||||
Tarikh Dijana : {{ $generatedAt }}
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
|
||||
<table border="1">
|
||||
<thead>
|
||||
<tr style="font-weight:bold; background:#f3f3f3;">
|
||||
<th>Bil</th>
|
||||
<th>Batch WTD</th>
|
||||
<th>No Rujukan</th>
|
||||
<th>No KP</th>
|
||||
<th>Nama</th>
|
||||
<th>Tarikh Proses</th>
|
||||
<th>Jumlah (RM)</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
|
||||
@php
|
||||
$bil = 1;
|
||||
$sum_baki = 0;
|
||||
$jumlah = 0;
|
||||
@endphp
|
||||
|
||||
@foreach ($details as $item)
|
||||
|
||||
@php
|
||||
$jumlah = $item['jumlah'];
|
||||
@endphp
|
||||
|
||||
<tr>
|
||||
<td>{{ $bil++ }}</td>
|
||||
<td>{{ $item['batchno'] ?? 0 }}</td>
|
||||
<td>{{ $item['norujukan'] ?? null }}</td>
|
||||
<td>{{ $item['nokp'] ?? null }}</td>
|
||||
<td>{{ $item['nama_cust'] ?? null }}</td>
|
||||
<td>{{ $item['t_proses'] ?? null }}</td>
|
||||
<td>{{ number_format($jumlah, 2) }}</td>
|
||||
</tr>
|
||||
@php
|
||||
$sum_baki += $item['jumlah'];
|
||||
@endphp
|
||||
@endforeach
|
||||
|
||||
|
||||
<tr>
|
||||
<td colspan="6" style="font-weight:bold; background:#eee;">
|
||||
JUMLAH KESELURUHAN
|
||||
</td>
|
||||
<td style="font-weight:bold;">
|
||||
{{ number_format($sum_baki, 2) }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,165 @@
|
||||
@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': 'WTD', '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="/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 Selesai WTD</span>
|
||||
</div>
|
||||
<form method="get" id="formwtd" action="{{ route('reports.summary-wtd.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">
|
||||
<button
|
||||
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>
|
||||
</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-center text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
||||
Jumlah Surat
|
||||
</th>
|
||||
<th
|
||||
class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-center text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
||||
Jumlah WTD Dihantar
|
||||
</th>
|
||||
<th
|
||||
class="px-5 py-3 border-b-2 border-gray-200 bg-gray-100 text-center text-xs font-semibold text-gray-600 uppercase tracking-wider">
|
||||
Action
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
@php
|
||||
$totalsag = 0; // jumlah semua surat
|
||||
$totalbaki = 0;
|
||||
@endphp
|
||||
|
||||
<tbody>
|
||||
|
||||
@forelse ($summarywtd ?? [] as $wtd)
|
||||
@php
|
||||
// Jumlah semua surat
|
||||
$totalsag += $wtd['jumlah_surat'] ?? 0;
|
||||
$totalbaki += $wtd['sum_baki'] ?? 0;
|
||||
@endphp
|
||||
<tr>
|
||||
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
||||
<div class="ml-3">{{ $loop->iteration }}</div>
|
||||
</td>
|
||||
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
||||
<div class="ml-3">{{ $wtd['kodcaw'] }}</div>
|
||||
</td>
|
||||
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
||||
<div class="ml-3">{{ $wtd['details_caw'] }}</div>
|
||||
</td>
|
||||
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
||||
<div class="ml-3 text-right">{{ $wtd['jumlah_surat'] }}</div>
|
||||
</td>
|
||||
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
||||
<div class="ml-3 text-right">{{ number_format($wtd['sum_baki'], 2) }}</div>
|
||||
</td>
|
||||
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
||||
<div class="ml-3 text-center">
|
||||
<a href="{{ route('reports.wtd.cawangan.excel', [$wtd['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>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="11"
|
||||
class="px-5 py-5 border-b border-gray-200 bg-white text-sm text-center">
|
||||
Data not available
|
||||
</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
|
||||
<tr>
|
||||
<td colspan="3" class="px-5 py-5 border-b border-gray-200 bg-white text-sm">
|
||||
Jumlah Keseluruhan
|
||||
</td>
|
||||
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm text-right">
|
||||
{{ $totalsag }}
|
||||
</td>
|
||||
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm text-right">
|
||||
{{ number_format($totalbaki, 2) }}
|
||||
</td>
|
||||
<td class="px-5 py-5 border-b border-gray-200 bg-white text-sm text-right"></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
|
||||
</table>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
@include('layouts.footer')
|
||||
</div>
|
||||
@endsection
|
||||
@@ -14,6 +14,7 @@ use App\Http\Controllers\Reports\PetibesiController;
|
||||
use App\Http\Controllers\Reports\AnalisaController;
|
||||
use App\Http\Controllers\Reports\BakiLelongController;
|
||||
use App\Http\Controllers\SaringanGadaianController;
|
||||
use App\Http\Controllers\WTDController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::middleware(['roleChecker:admin,akaun,operasi,kpo,callcenter, null'])->group(function () {
|
||||
@@ -49,4 +50,8 @@ Route::middleware(['roleChecker:admin,akaun,operasi,kpo,callcenter, null'])->gro
|
||||
|
||||
Route::get('saringan-gadaian-index', [SaringanGadaianController::class, 'index'])->name('reports.saringan-gadaian.index');
|
||||
Route::get('saringan-gadaian-excel/{kodcaw}', [SaringanGadaianController::class, 'exportExcel'])->name('reports.gadaian.cawangan.excel');
|
||||
|
||||
Route::get('summary-wtd-index', [WTDController::class, 'summaryWtd'])->name('reports.summary-wtd.index');
|
||||
Route::get('summary-wtd-excel/{kodcaw}', [WTDController::class, 'exportExcel'])->name('reports.wtd.cawangan.excel');
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user