feat(laporan-user): refactor user report to display user data instead of permohonan
- Change data source from Permohonan to User model - Simplify search functionality to only search by name and NIK - Update table columns to show user information (NIK, name, roles) - Remove date range filters and complex search conditions - Add helper function getFilePath to handle storage paths
This commit is contained in:
@@ -15,6 +15,8 @@
|
|||||||
use Modules\Lpj\Models\Penilaian;
|
use Modules\Lpj\Models\Penilaian;
|
||||||
use Modules\Lpj\Models\TeamsUsers;
|
use Modules\Lpj\Models\TeamsUsers;
|
||||||
use Modules\Usermanagement\Models\User;
|
use Modules\Usermanagement\Models\User;
|
||||||
|
use Illuminate\Support\Facades\File;
|
||||||
|
use Illuminate\Support\Facades\Storage;
|
||||||
|
|
||||||
function formatTanggalIndonesia($date, $time = false)
|
function formatTanggalIndonesia($date, $time = false)
|
||||||
{
|
{
|
||||||
@@ -542,3 +544,37 @@
|
|||||||
return $notifikasi;
|
return $notifikasi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get full path to internal storage file or external storage file
|
||||||
|
*
|
||||||
|
* @param string $path
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
|
||||||
|
function getFilePath($path)
|
||||||
|
{
|
||||||
|
// define base path external storage (use .env) example: 'F:\path\to\storage' in windows
|
||||||
|
$externalBase = env('EXTERNAL_STORAGE_BASE_PATH', 'F:LPJ/lpj/LPJ Gambar/001/');
|
||||||
|
|
||||||
|
$segments = explode('/', $path);
|
||||||
|
|
||||||
|
if(strtoupper($segments[0]) === 'SURVEYOR'){
|
||||||
|
$year = $segments[1];
|
||||||
|
$month = ucfirst(strtolower($segments[2]));
|
||||||
|
$date = $segments[3];
|
||||||
|
$code = $segments[4];
|
||||||
|
$file = $segments[5] ?? '';
|
||||||
|
|
||||||
|
$extenalFullpath = $externalBase . $year . '/' . $month . '/' . $date . '/' . $code . '/' . $file;
|
||||||
|
|
||||||
|
if(File::exists($extenalFullpath)){
|
||||||
|
return $extenalFullpath;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if not found in external storage, try to find in internal storage
|
||||||
|
if (Storage::exists($path)) {
|
||||||
|
return Storage::url('app/' . $path);
|
||||||
|
}
|
||||||
|
return $path;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
namespace Modules\Lpj\Services;
|
namespace Modules\Lpj\Services;
|
||||||
|
|
||||||
use Modules\Lpj\Models\Permohonan;
|
use Modules\Lpj\Models\Permohonan;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Modules\Usermanagement\Models\User;
|
||||||
|
|
||||||
class LaporanUserService
|
class LaporanUserService
|
||||||
{
|
{
|
||||||
@@ -25,36 +27,15 @@ class LaporanUserService
|
|||||||
{
|
{
|
||||||
|
|
||||||
// Retrieve data from the database
|
// Retrieve data from the database
|
||||||
$query = Permohonan::query();
|
$query = User::query();
|
||||||
$query = $query->where('status', 'done');
|
|
||||||
|
|
||||||
// Apply search filter if provided
|
// Apply search filter if provided
|
||||||
if ($request->has('search') && !empty($request->get('search'))) {
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
$search = json_decode($request->get('search'));
|
$search = json_decode($request->get('search'));
|
||||||
|
|
||||||
if (isset($search->start_date) || isset($search->end_date)) {
|
|
||||||
$query->whereBetween('tanggal_permohonan', [
|
|
||||||
$search->start_date ?? '1900-01-01',
|
|
||||||
$search->end_date ?? now()->toDateString()
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Filter by branch if provided
|
|
||||||
if (isset($search->user_id) && !empty($search->user_id)) {
|
|
||||||
$query->where('user_id', $search->user_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isset($search->search)) {
|
if (isset($search->search)) {
|
||||||
|
|
||||||
$query->where(function ($q) use ($search) {
|
$query->where(function ($q) use ($search) {
|
||||||
$q->where('nomor_registrasi', 'LIKE', '%' . $search->search . '%');
|
$q->whereRaw('LOWER(name) LIKE ?', ['%' . strtolower($search) . '%']);
|
||||||
$q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search->search . '%');
|
$q->where('nik', 'LIKE', '%' . $search->search . '%');
|
||||||
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search->search . '%');
|
|
||||||
$q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search->search . '%');
|
|
||||||
$q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search->search . '%');
|
|
||||||
$q->orWhereRelation('jenisFasilitasKredit', 'name', 'LIKE', '%' . $search->search . '%');
|
|
||||||
$q->orWhereRelation('jenisPenilaian', 'name', 'LIKE', '%' . $search->search . '%');
|
|
||||||
$q->orWhere('status', 'LIKE', '%' . $search->search . '%');
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -82,28 +63,16 @@ class LaporanUserService
|
|||||||
$filteredRecords = $query->count();
|
$filteredRecords = $query->count();
|
||||||
|
|
||||||
// Get the data for the current page
|
// Get the data for the current page
|
||||||
$data = $query->with(['debiture.branch'])->get();
|
$data = $query->with(['branch', 'roles'])->get();
|
||||||
|
|
||||||
$data = $data->map(function ($permohonan) {
|
$data = $data->map(function ($user) {
|
||||||
|
|
||||||
$npw = 0;
|
|
||||||
|
|
||||||
|
|
||||||
if (isset($permohonan->penilai->lpj)) {
|
|
||||||
$lpj = json_decode($permohonan->penilai->lpj, true);
|
|
||||||
$npw = str_replace('.', '', $lpj['total_nilai_pasar_wajar'] ?? 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'id' => $permohonan->id,
|
'id' => $user->id,
|
||||||
'nomor_registrasi' => $permohonan->nomor_registrasi,
|
'nik' => $user->nik,
|
||||||
'branch' => $permohonan->debiture->branch?->name,
|
'name' => $user->name,
|
||||||
'name' => $permohonan->debiture?->name,
|
'level' => $user->roles->pluck('name')->implode(', '),
|
||||||
'pemohon' => $permohonan->creator?->name,
|
'approval_limit' => 0,
|
||||||
'tanggal_permohonan' => $permohonan->tanggal_permohonan,
|
|
||||||
'nama_penilai' => $permohonan->penilaian?->_user_penilai?->userPenilaiTeam?->name,
|
|
||||||
'tanggal_laporan' => $permohonan->approval_dd_at ?? $permohonan->approval_eo_at ?? '',
|
|
||||||
'nilai_pasar_wajar' => formatRupiah($npw, 2)
|
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -6,63 +6,27 @@
|
|||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
|
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
|
||||||
<!-- Filter Card -->
|
|
||||||
<div class="card border border-agi-100">
|
|
||||||
<div class="card-header bg-agi-50 py-5">
|
|
||||||
<h3 class="card-title"> Laporan User Penilai</h3>
|
|
||||||
</div>
|
|
||||||
<div class="card-body grid gap-4">
|
|
||||||
<!-- Search field at the top, full width -->
|
|
||||||
<div class="flex flex-col w-full">
|
|
||||||
<label class="text-sm font-medium mb-1">Pencarian</label>
|
|
||||||
<label class="input input-sm">
|
|
||||||
<i class="ki-filled ki-magnifier"></i>
|
|
||||||
<input placeholder="Search Laporan User" id="search" type="text" value="">
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Other filter fields in grid layout -->
|
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
|
||||||
<div class="flex flex-col">
|
|
||||||
<label class="text-base font-medium mb-1">Tanggal Awal</label>
|
|
||||||
<label class="input">
|
|
||||||
<input placeholder="Tanggal Awal" id="start_date" type="date">
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="flex flex-col">
|
|
||||||
<label class="text-base font-medium mb-1">Tanggal Akhir</label>
|
|
||||||
<label class="input">
|
|
||||||
<input placeholder="Tanggal Akhir" id="end_date" type="date">
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="flex flex-col">
|
|
||||||
<label class="text-base font-medium mb-1">User</label>
|
|
||||||
<select class="select tomselect" id="user_id" name="user_id">
|
|
||||||
|
|
||||||
</select>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Buttons row at the bottom -->
|
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mt-2">
|
|
||||||
<button class="btn btn-sm btn-primary" id="filter_tanggal">
|
|
||||||
<i class="ki-outline ki-filter fs-2 me-1"></i>
|
|
||||||
Terapkan Filter
|
|
||||||
</button>
|
|
||||||
<a class="btn btn-sm btn-light" href="{{ route('laporan-user.export') }}" id="export-btn">
|
|
||||||
<i class="ki-outline ki-file-down fs-2 me-1"></i>
|
|
||||||
Export to Excel
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<!-- Data Table Card -->
|
<!-- Data Table Card -->
|
||||||
<div class="card border border-agi-100 card-grid min-w-full" data-datatable="false" data-datatable-page-size="10" data-datatable-state-save="false" id="laporan-user-table" data-api-url="{{ route('laporan-user.datatables') }}">
|
<div class="card border border-agi-100 card-grid min-w-full" data-datatable="false" data-datatable-page-size="10" data-datatable-state-save="false" id="laporan-user-table" data-api-url="{{ route('laporan-user.datatables') }}">
|
||||||
<div class="card-header bg-agi-50 py-5 flex-wrap">
|
<div class="card-header bg-agi-50 py-5 flex-wrap">
|
||||||
|
|
||||||
<h3 class="card-title">
|
<h3 class="card-title">
|
||||||
Laporan User Pemohon
|
Laporan User
|
||||||
</h3>
|
</h3>
|
||||||
|
<div class="flex flex-wrap gap-2 lg:gap-5">
|
||||||
|
<div class="flex flex-wrap gap-2 lg:gap-5">
|
||||||
|
<label class="input input-sm">
|
||||||
|
<i class="ki-filled ki-magnifier"></i>
|
||||||
|
<input placeholder="Search Laporan User" id="search" type="text" value="">
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<a class="btn btn-sm btn-light" href="{{ route('laporan-user.export') }}" id="export-btn">
|
||||||
|
<i class="ki-outline ki-file-down fs-2 me-1"></i>
|
||||||
|
Export to Excel
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@@ -73,41 +37,20 @@
|
|||||||
<th class="w-14">
|
<th class="w-14">
|
||||||
<input class="checkbox checkbox-sm" data-datatable-check="true" type="checkbox"/>
|
<input class="checkbox checkbox-sm" data-datatable-check="true" type="checkbox"/>
|
||||||
</th>
|
</th>
|
||||||
<th class="min-w-[150px]" data-datatable-column="nomor_registrasi">
|
<th class="min-w-[150px]" data-datatable-column="nik">
|
||||||
<span class="sort"> <span class="sort-label"> Nomor Registrasi </span>
|
<span class="sort"> <span class="sort-label"> NIK</span>
|
||||||
<span class="sort-icon"> </span> </span>
|
<span class="sort-icon"> </span> </span>
|
||||||
</th>
|
</th>
|
||||||
<th class="min-w-[150px]" data-datatable-column="branch">
|
<th class="min-w-[150px]" data-datatable-column="name">
|
||||||
<span class="sort"> <span class="sort-label"> Cabang </span>
|
<span class="sort"> <span class="sort-label"> Nama User</span>
|
||||||
<span class="sort-icon"> </span> </span>
|
<span class="sort-icon"> </span> </span>
|
||||||
</th>
|
</th>
|
||||||
<th class="min-w-[150px]" data-datatable-column="name">
|
<th class="min-w-[150px]" data-datatable-column="level">
|
||||||
<span class="sort"> <span class="sort-label"> Nama Debitur </span>
|
<span class="sort"> <span class="sort-label"> Level Group </span>
|
||||||
<span class="sort-icon"> </span> </span>
|
<span class="sort-icon"> </span> </span>
|
||||||
</th>
|
</th>
|
||||||
<th class="min-w-[150px]" data-datatable-column="pemohon">
|
<th class="min-w-[150px]" data-datatable-column="approval_limit">
|
||||||
<span class="sort"> <span class="sort-label"> Pemohon </span>
|
<span class="sort"> <span class="sort-label"> Approval Limit </span>
|
||||||
<span class="sort-icon"> </span> </span>
|
|
||||||
</th>
|
|
||||||
|
|
||||||
|
|
||||||
<th class="min-w-[150px]" data-datatable-column="jenis_penilaian">
|
|
||||||
<span class="sort"> <span class="sort-label"> Tgl Terima </span>
|
|
||||||
<span class="sort-icon"> </span> </span>
|
|
||||||
</th>
|
|
||||||
<th class="min-w-[150px]" data-datatable-column="tujuan_penilaian">
|
|
||||||
<span class="sort"> <span class="sort-label"> Penilai </span>
|
|
||||||
<span class="sort-icon"> </span> </span>
|
|
||||||
</th>
|
|
||||||
|
|
||||||
<th class="min-w-[150px]" data-datatable-column="alamat_agunan">
|
|
||||||
<span class="sort"> <span class="sort-label"> Tgl Laporan </span>
|
|
||||||
<span class="sort-icon"> </span> </span>
|
|
||||||
</th>
|
|
||||||
|
|
||||||
|
|
||||||
<th class="min-w-[150px]" data-datatable-column="catatan">
|
|
||||||
<span class="sort"> <span class="sort-label"> Nilai Pasar Wajar </span>
|
|
||||||
<span class="sort-icon"> </span> </span>
|
<span class="sort-icon"> </span> </span>
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
@@ -155,40 +98,21 @@
|
|||||||
return checkbox.outerHTML.trim();
|
return checkbox.outerHTML.trim();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
nomor_registrasi: {
|
nik: {
|
||||||
title: 'Nomor Registrasi',
|
title: 'Nomor Registrasi',
|
||||||
},
|
|
||||||
branch: {
|
|
||||||
title: 'Cabang',
|
|
||||||
},
|
},
|
||||||
name: {
|
name: {
|
||||||
title: 'Nama Debitur',
|
title: 'Nama',
|
||||||
},
|
},
|
||||||
pemohon: {
|
level: {
|
||||||
title: 'Pemohon',
|
title: 'level',
|
||||||
},
|
},
|
||||||
tanggal_permohonan: {
|
approval_limit: {
|
||||||
title: 'Tanggal Permohonan',
|
title: 'Approval Limit',
|
||||||
render: (item, data) => {
|
render: (item, data) => {
|
||||||
return data.tanggal_permohonan ? window.formatTanggalIndonesia(data.tanggal_permohonan) : '-';
|
return data.tanggal_permohonan ? window.formatTanggalIndonesia(data.tanggal_permohonan) : '-';
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
nama_penilai: {
|
|
||||||
title: 'Nama Penilai',
|
|
||||||
},
|
|
||||||
|
|
||||||
tanggal_laporan: {
|
|
||||||
title: 'Tanggal Dokumen Diterima',
|
|
||||||
render: (item, data) => {
|
|
||||||
return data.tanggal_laporan ? window.formatTanggalIndonesia(data.tanggal_laporan) : '-';
|
|
||||||
},
|
|
||||||
},
|
|
||||||
nilai_pasar_wajar: {
|
|
||||||
title: 'Nilai Pasar Wajar',
|
|
||||||
render: (item, data) => {
|
|
||||||
return data.nilai_pasar_wajar ?? '-';
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -209,7 +133,6 @@
|
|||||||
if (startDate) {
|
if (startDate) {
|
||||||
filters.start_date = startDate;
|
filters.start_date = startDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (endDate) {
|
if (endDate) {
|
||||||
filters.end_date = endDate;
|
filters.end_date = endDate;
|
||||||
}
|
}
|
||||||
@@ -219,7 +142,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
dataTable.search(filters);
|
dataTable.search(filters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user