tambah laporan keseluruhan pelanggan baru
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exports\LaporanKeseluruhan;
|
||||
|
||||
use Maatwebsite\Excel\Concerns\FromCollection;
|
||||
use Maatwebsite\Excel\Concerns\WithHeadings;
|
||||
use Maatwebsite\Excel\Concerns\WithMapping;
|
||||
use Maatwebsite\Excel\Concerns\WithEvents;
|
||||
use Maatwebsite\Excel\Events\AfterSheet;
|
||||
use Maatwebsite\Excel\Concerns\WithCustomStartCell;
|
||||
|
||||
class PelangganbaruAllExportExcel implements FromCollection, WithHeadings, WithMapping, WithEvents, WithCustomStartCell
|
||||
{
|
||||
protected $pelangganbaruData;
|
||||
protected $total = 0;
|
||||
protected $counter = 1;
|
||||
protected $startDate;
|
||||
protected $endDate;
|
||||
|
||||
public function __construct($pelangganbaruData, $startDate = null, $endDate = null)
|
||||
{
|
||||
$this->pelangganbaruData = $pelangganbaruData;
|
||||
$this->startDate = $startDate;
|
||||
$this->endDate = $endDate;
|
||||
}
|
||||
|
||||
public function collection()
|
||||
{
|
||||
return collect($this->pelangganbaruData);
|
||||
}
|
||||
|
||||
public function headings(): array
|
||||
{
|
||||
return [
|
||||
'No.',
|
||||
'Kod Caw',
|
||||
'Nama Cawangan',
|
||||
'Jumlah',
|
||||
];
|
||||
}
|
||||
|
||||
public function map($row): array
|
||||
{
|
||||
$jumlah = is_numeric($row['total_pelanggan_baru'] ?? null) ? (float) $row['total_pelanggan_baru'] : 0;
|
||||
$this->total += $jumlah;
|
||||
|
||||
return [
|
||||
$this->counter++,
|
||||
$row['kodcaw'] ?? '',
|
||||
$row['details_caw'] ?? '',
|
||||
number_format($jumlah, 2),
|
||||
];
|
||||
}
|
||||
public function startCell(): string
|
||||
{
|
||||
return 'A3'; // Mulakan heading di baris 3
|
||||
}
|
||||
|
||||
public function registerEvents(): array
|
||||
{
|
||||
return [
|
||||
AfterSheet::class => function (AfterSheet $event) {
|
||||
|
||||
// Tajuk laporan di A1:D1
|
||||
$event->sheet->mergeCells('A1:D1');
|
||||
$event->sheet->setCellValue('A1', 'LAPORAN PELANGGAN BARU');
|
||||
$event->sheet->getStyle('A1')->getFont()->setSize(14)->setBold(true);
|
||||
$event->sheet->getStyle('A1')->getAlignment()->setHorizontal('center');
|
||||
|
||||
// Tarikh di A2:D2
|
||||
$tarikhMula = $this->startDate ? date('d/m/Y', strtotime($this->startDate)) : '-';
|
||||
$tarikhTamat = $this->endDate ? date('d/m/Y', strtotime($this->endDate)) : '-';
|
||||
$event->sheet->mergeCells('A2:D2');
|
||||
$event->sheet->setCellValue('A2', "Tempoh: {$tarikhMula} hingga {$tarikhTamat}");
|
||||
$event->sheet->getStyle('A2')->getFont()->setItalic(true);
|
||||
$event->sheet->getStyle('A2')->getAlignment()->setHorizontal('center');
|
||||
|
||||
// Kira baris terakhir untuk jumlah keseluruhan
|
||||
$lastRow = count($this->pelangganbaruData) + 3 + 1; // +1 untuk heading
|
||||
|
||||
$event->sheet->mergeCells("A{$lastRow}:C{$lastRow}");
|
||||
$event->sheet->setCellValue("A{$lastRow}", 'Jumlah Keseluruhan');
|
||||
$event->sheet->setCellValue("D{$lastRow}", number_format($this->total, 2));
|
||||
$event->sheet->getStyle("A{$lastRow}:D{$lastRow}")->getFont()->setBold(true);
|
||||
$event->sheet->getStyle("A{$lastRow}:D{$lastRow}")->getAlignment()->setHorizontal('right');
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?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\PelangganbaruAllExportExcel;
|
||||
|
||||
class AnalisaController 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');
|
||||
|
||||
$pelangganbaru = Http::get($request->hostname . '/api/reports/pelangganbaru', [
|
||||
'startDate' => $getReportDate($request->startDate),
|
||||
'endDate' => $getReportDate($request->endDate),
|
||||
])->json();
|
||||
// dd($pelangganbaru);
|
||||
|
||||
$startDate = $getReportDate($request->startDate);
|
||||
$endDate = $getReportDate($request->endDate);
|
||||
|
||||
if ($action === 'excel') {
|
||||
$file_title = sprintf("LaporanPelangganBaru(%s).xlsx", $kod_cawangan, $request->startDate, $request->endDate);
|
||||
return Excel::download(new PelangganbaruAllExportExcel($pelangganbaru,$startDate,$endDate), $file_title);
|
||||
}
|
||||
|
||||
$pelangganbaru = $pelangganbaru ?? [];
|
||||
|
||||
return view('reports.pelangganbaru.index', compact('pelangganbaru', 'startDate', 'endDate'));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -68,6 +68,12 @@
|
||||
<h2 class="mx-auto text-center font-bold text-2xl uppercase">Peti Besi Cawangan</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.pelangganbaru.index', ['startDate' => now()->toDateString(), 'endDate' => now()->toDateString()]) }}" class="">
|
||||
<h2 class="mx-auto text-center font-bold text-2xl uppercase">Pelanggan Baru</h2>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -0,0 +1,266 @@
|
||||
@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': 'Pelanggan Baru', '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 Pelanggan Baru</span></div>
|
||||
<form method="get" id="formpelangganbaru" action="{{ route('reports.pelangganbaru.index') }}">
|
||||
<input type="hidden" name="action" id="formAction" value="search">
|
||||
<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 justify-center">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span class="text-gray-600 border border-2 rounded-l px-4 py-2 bg-gray-100">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">
|
||||
|
||||
<span class="text-gray-600 border border-2 rounded-l px-4 py-2 bg-gray-100">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">
|
||||
|
||||
<button type="submit" onclick="setAction('search')"
|
||||
class="border border-yellow-600 text-yellow-600 font-montserrat py-2 px-6 font-medium rounded-xl hover:bg-yellow-600 hover:text-white transition-all duration-300">
|
||||
<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-6 font-medium rounded-xl hover:bg-yellow-600 hover:text-white transition-all duration-300">
|
||||
<i class="fas fa-file-excel mr-2"></i> Excel
|
||||
</button>
|
||||
</div>
|
||||
</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 Pembiayaan
|
||||
</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">
|
||||
Berat (g)
|
||||
</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">
|
||||
Nilai Marhun(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">
|
||||
Pinjaman(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">
|
||||
Action
|
||||
</th> -->
|
||||
</tr>
|
||||
</thead>
|
||||
@php
|
||||
$totalbilgadai = 0;
|
||||
$totalberat = 0;
|
||||
$totalnm = 0;
|
||||
$totalpinjaman = 0;
|
||||
@endphp
|
||||
<tbody>
|
||||
@forelse ($pelangganbaru as $gadai)
|
||||
@php
|
||||
$totalbilgadai += $gadai['total_pelanggan_baru'];
|
||||
$totalberat += $gadai['sum_berat'];
|
||||
$totalnm += $gadai['sum_nilai_marhun'];
|
||||
$totalpinjaman += $gadai['sum_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_pelanggan_baru'] }}
|
||||
</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['sum_berat'], 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">
|
||||
{{ number_format($gadai['sum_nilai_marhun'], 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">
|
||||
{{ number_format($gadai['sum_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($totalberat,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">
|
||||
{{ number_format($totalnm,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">
|
||||
{{ 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
|
||||
|
||||
|
||||
<!-- JavaScript to Change Action -->
|
||||
<script>
|
||||
function setAction(action) {
|
||||
document.getElementById('formAction').value = action;
|
||||
document.getElementById('formAging').submit();
|
||||
}
|
||||
</script>
|
||||
@@ -9,6 +9,7 @@ use App\Http\Controllers\Reports\LelonganController;
|
||||
use App\Http\Controllers\Reports\AgingController;
|
||||
use App\Http\Controllers\Reports\OutstandingController;
|
||||
use App\Http\Controllers\Reports\PetibesiController;
|
||||
use App\Http\Controllers\Reports\AnalisaController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::middleware(['roleChecker:admin,akaun,operasi,kpo, null'])->group(function () {
|
||||
@@ -31,4 +32,5 @@ Route::middleware(['roleChecker:admin,akaun,operasi,kpo, null'])->group(function
|
||||
Route::get('laporan-aging/view', [AgingController::class, 'show'])->name('reports.aging.show');
|
||||
Route::get('outstanding/view', [OutstandingController::class, 'index'])->name('reports.outstanding.index');
|
||||
Route::get('petibesi/view', [PetibesiController::class, 'index'])->name('reports.petibesi.index');
|
||||
Route::get('pelangganbaru/view', [AnalisaController::class, 'index'])->name('reports.pelangganbaru.index');
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user