feat(dashboard/rekap-so): penambahan dashboard, rekap so

This commit is contained in:
majid
2025-06-20 09:12:50 +07:00
parent 887478c751
commit 3f979aef05
8 changed files with 715 additions and 32 deletions

View File

@@ -0,0 +1,36 @@
<?php
namespace Modules\Lpj\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Modules\Lpj\Services\DashboardService;
class DashboardController extends Controller
{
public $dashboardService;
public function __construct(DashboardService $dashboardService)
{
$this->dashboardService = $dashboardService;
}
/**
* Display a listing of the resource.
*/
public function index(Request $request)
{
// nilai default
$start_date = $request->input('start_date', now()->startOfYear()->format('Y-m-d'));
$end_date = $request->input('end_date', now()->format('Y-m-d'));
$validate = $request->validate([
'start_date' => 'nullable|date_format:Y-m-d',
'end_date' => 'nullable|date_format:Y-m-d',
]);
$dashboard = $this->dashboardService->getDashboardData($start_date, $end_date);
// dd($dashboard);
return view('lpj::dashboard.index', compact('dashboard'));
}
}

View File

@@ -0,0 +1,67 @@
<?php
namespace Modules\Lpj\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Modules\Lpj\Models\TujuanPenilaian;
class RekapHarianSoController extends Controller
{
/**
* Display a listing of the resource.
*/
public function index()
{
$tujuan_penilaian = TujuanPenilaian::all();
return view('lpj::rekap-harian-so.index', compact('tujuan_penilaian'));
}
/**
* Show the form for creating a new resource.
*/
public function create()
{
return view('lpj::create');
}
/**
* Store a newly created resource in storage.
*/
public function store(Request $request)
{
//
}
/**
* Show the specified resource.
*/
public function show($id)
{
return view('lpj::show');
}
/**
* Show the form for editing the specified resource.
*/
public function edit($id)
{
return view('lpj::edit');
}
/**
* Update the specified resource in storage.
*/
public function update(Request $request, $id)
{
//
}
/**
* Remove the specified resource from storage.
*/
public function destroy($id)
{
//
}
}

View File

@@ -0,0 +1,134 @@
<?php
namespace Modules\Lpj\Services;
use Modules\Lpj\Models\Laporan;
class DashboardService
{
public function getDashboardData($start_date, $end_date)
{
$countLpjInternal = $this->getTotalLpjInternal($start_date, $end_date);
$countLpjExternal = $this->getTotalLpjEksternal($start_date, $end_date);
$countResume = $this->getResumeCabang($start_date, $end_date);
return [
'count_lpj_internal' => $countLpjInternal,
'count_lpj_eksternal' => $countLpjExternal,
'count_resume' => $countResume
];
}
public function getTotalLpjInternal($start_date, $end_date)
{
$months = $this->getMonthly();
$regions = $this->getRegion();
$data = [];
foreach ($months as $index => $month) {
$monthNumber = $index + 1;
$data[$month] = [];
foreach ($regions as $region) {
if ($monthNumber > now()->month) {
$data[$month][$region] = [
'total_laporan' => 0,
'total_debiture' => 0,
];
} else {
$totalLaporan = Laporan::whereBetween('created_at', [$start_date, $end_date])
->count();
$data[$month][$region] = [
'total_laporan' => $totalLaporan,
'total_debiture' => 20,
];
}
}
}
return $data;
}
public function getPendapatanAppraisal()
{
}
public function getResumeCabang($start_date, $end_date)
{
$regions = $this->getRegion();
$status = ['batal', 'done'];
$data = [];
foreach ($status as $item) {
$data[$item] = [];
foreach ($regions as $region) {
$totalLaporan = Laporan::where('created_at', '>=', $start_date)->where('created_at', '<=', $end_date)->count();
$data[$item][$region] = [
'count_report' => $totalLaporan,
];
}
}
return $data;
}
public function getTotalLpjEksternal($start_date, $end_date)
{
$months = $this->getMonthly();
$data = [];
foreach ($months as $index => $month) {
$monthNumber = $index + 1;
if ($monthNumber > now()->month) {
$data[$month] = [
'total_laporan' => 0,
'total_debiture' => 0,
];
} else {
$totalLaporan = Laporan::where('created_at', '>=', $start_date)->where('created_at', '<=', $end_date)->count();
$data[$month] = [
'total_laporan' => $totalLaporan,
'total_debiture' => 20,
];
}
}
return $data;
}
private function getMonthly()
{
return [
'januari',
'februari',
'maret',
'april',
'mei',
'juni',
'juli',
'agustus',
'september',
'oktober',
'november',
'desember',
];
}
private function getRegion()
{
return [
'jabodetabek',
'non-jabodetabek',
];
}
}