✨ feat(lpj): Perbaiki ekspor, pencarian, validasi tanggal, transaksi, logging, dan UI
- ActivityController: tambah default order `nomor_registrasi` desc; rapikan komentar & alur sorting - LaporanHasilPenilaianJaminanInternalExternalController: pencarian debitur case-insensitive via `LOWER(name)`; normalisasi angka LPJ (luas_tanah, nilai_bangunan, likuidasi, NPW); perapihan spacing - LaporanPenilaiJaminanController: validasi `start_date`/`end_date` dan buat nama file ekspor dinamis via `createNameLaporan`; gunakan `LaporanPenilaiJaminanExport($request)`; helper `getBranchId` - LaporanPenilaianJaminanController: standarisasi respons JSON datatables; tambah `export(Request)` dengan nama `laporan_penilaian_jaminan_<start>_<end>.xlsx` - NilaiPlafondController: bungkus proses datatables dalam transaksi DB (commit/rollback) dengan try/catch; tambah logging info/error; rapikan dan standarisasi respons JSON - PenilaiController: map data pembanding ke `pembanding1/2/3`; tambah `print_out_laporan` dan `showLaporanInspeksi` (penentuan route back); stub `showInspectionReportReview`; perapihan minor - Views debitur/components/debitur: perbaiki closing textarea, konsistensi event listener `function ()`, rapikan markup error - Views debitur/components/jaminan: fallback `dokumen_nomor[$index] ?? ''` untuk hindari undefined index - Views laporan/index: akses aman dengan optional chaining `?.`, fallback tanggal pada `formatDate`, akses `nilaiPlafond` aman - Views laporan-penilai-jaminan/index + show: JS toggle tab (Laporan vs Hasil Inspeksi), CSS `hidden-tab`, gaya floating button, perapihan - Views debitur/index: rapikan directive `@if` spacing pada tombol tambah - Views noc/penyelesaian: perbaiki route key ke `noc.datatables.penyelesaian`
This commit is contained in:
@@ -306,6 +306,7 @@ class ActivityController extends Controller
|
||||
$query = Permohonan::query();
|
||||
|
||||
// Apply search filter if provided
|
||||
$query = $query->orderBy('nomor_registrasi', 'desc');
|
||||
if ($request->has('search') && !empty($request->get('search'))) {
|
||||
$search = $request->get('search');
|
||||
$query->where(function ($q) use ($search) {
|
||||
@@ -324,7 +325,9 @@ class ActivityController extends Controller
|
||||
});
|
||||
}
|
||||
|
||||
// Default sorting if no sort provided
|
||||
|
||||
|
||||
// Apply sorting if provided
|
||||
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||
$order = $request->get('sortOrder');
|
||||
$column = $request->get('sortField');
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Modules\Lpj\Exports\LaporanHasilPenilaianJaminanInternalExternalExport;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
@@ -60,6 +61,7 @@
|
||||
$q->orWhereRelation('user', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('debiture', DB::raw('LOWER(name)'), 'LIKE', '%' . strtolower($search->search) . '%');
|
||||
$q->orWhereRelation('jenisFasilitasKredit', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('jenisPenilaian', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhere('status', 'LIKE', '%' . $search->search . '%');
|
||||
@@ -69,7 +71,7 @@
|
||||
|
||||
// Apply sorting if provided
|
||||
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||
$order = $request->get('sortOrder');
|
||||
$order = $request->get('sortOrder');
|
||||
$column = $request->get('sortField');
|
||||
$query->orderBy($column, $order);
|
||||
}
|
||||
@@ -104,12 +106,12 @@
|
||||
$lpj = json_decode($permohonan->penilai->lpj, true);
|
||||
$npw = str_replace('.', '', $lpj['total_nilai_pasar_wajar'] ?? 0);
|
||||
|
||||
$luas_tanah = $lpj['luas_tanah'] ?? 0;
|
||||
$luas_tanah = $lpj['luas_tanah'] ?? 0;
|
||||
$luas_bangunan = $lpj['luas_bangunan'] ?? 0;
|
||||
// Calculate nilai_tanah dynamically by looking for all keys that start with 'nilai_tanah_'
|
||||
$nilai_tanah = str_replace('.', '', $lpj['nilai_tanah_2'] ?? 0);
|
||||
|
||||
$nilai_bangunan = str_replace('.', '', $lpj['nilai_bangunan_2'] ?? 0);
|
||||
$nilai_bangunan = str_replace('.', '', $lpj['nilai_bangunan_2'] ?? 0);
|
||||
$nilai_liquidasi = str_replace('.', '', $lpj['likuidasi_nilai_2'] ?? 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,10 @@ use Modules\Lpj\Models\Permohonan;
|
||||
use Modules\Lpj\Models\StatusPermohonan;
|
||||
use Modules\Lpj\Exports\LaporanPenilaiJaminanExport;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Modules\Lpj\Models\Branch;
|
||||
use Modules\Lpj\Services\PreviewLaporanService;
|
||||
use Modules\Lpj\Models\Inspeksi;
|
||||
use Modules\Lpj\Models\Penilai;
|
||||
|
||||
class LaporanPenilaiJaminanController extends Controller
|
||||
{
|
||||
@@ -16,59 +20,31 @@ class LaporanPenilaiJaminanController extends Controller
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
|
||||
protected $previewLaporanService;
|
||||
|
||||
public function __construct(PreviewLaporanService $previewLaporanService)
|
||||
{
|
||||
$this->previewLaporanService = $previewLaporanService;
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$status_permohonan = StatusPermohonan::all();
|
||||
return view('lpj::laporan-penilai-jaminan.index', compact('status_permohonan'));
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
public function show($permohonan_id, $dokumen_id, $jaminan_id)
|
||||
{
|
||||
return view('lpj::laporan-penilai-jaminan.show');
|
||||
$back = route('laporan-penilai-jaminan.index');
|
||||
return $this->previewLaporanService->previewLaporan($permohonan_id, $dokumen_id, $jaminan_id, $back);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function dataForDatatables(Request $request)
|
||||
{
|
||||
@@ -93,91 +69,104 @@ class LaporanPenilaiJaminanController extends Controller
|
||||
// dd($startDate);
|
||||
// Retrieve data from the database
|
||||
$query = Permohonan::query();
|
||||
|
||||
$query = $query->where('status', 'done')->orderBy('tanggal_permohonan', 'desc');
|
||||
// Apply search filter if provided
|
||||
if ($request->has('search') && !empty($request->get('search'))) {
|
||||
$search = $request->get('search');
|
||||
$paramsSearch = json_decode($search);
|
||||
$search = json_decode($request->get('search'));
|
||||
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('nomor_registrasi', 'LIKE', '%' . $search . '%')
|
||||
->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%')
|
||||
->orWhereRelation('user', 'name', 'LIKE', '%' . $search . '%')
|
||||
->orWhereRelation('debiture', 'name', 'LIKE', '%' . $search . '%')
|
||||
->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search . '%')
|
||||
->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
|
||||
if (!empty($search->start_date) || !empty($search->end_date)) {
|
||||
$startDate = $search->start_date ?? '1900-01-01';
|
||||
$endDate = $search->end_date ?? now()->toDateString();
|
||||
|
||||
if (!empty($paramsSearch->tanggal_awal) && !empty($paramsSearch->tanggal_akhir)) {
|
||||
$q->whereBetween('tanggal_permohonan', [$paramsSearch->tanggal_awal, $paramsSearch->tanggal_akhir]);
|
||||
$query->where(function ($q) use ($startDate, $endDate) {
|
||||
|
||||
$q->whereHas('penilaian', function ($q2) use ($startDate, $endDate) {
|
||||
$q2->whereBetween('tanggal_kunjungan', [$startDate, $endDate]);
|
||||
});
|
||||
|
||||
// OR check if has penawaran with date in range
|
||||
$q->orWhereHas('penawaran', function ($q3) use ($startDate, $endDate) {
|
||||
$q3->whereBetween('tanggal_penilaian_sebelumnya', [$startDate, $endDate]);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (isset($search->branch_id) && !empty($search->branch_id)) {
|
||||
$query->where('branch_id', $search->branch_id);
|
||||
}
|
||||
|
||||
if (isset($search->laporan) && is_array($search->laporan) && !empty($search->laporan)) {
|
||||
foreach ($search->laporan as $type) {
|
||||
$query->whereHas('penilai', function ($q) use ($type) {
|
||||
$q->where('type_penilai', 'LIKE', '%' . $type . '%');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$statusKeywords = explode(',', $search);
|
||||
foreach ($statusKeywords as $keyword) {
|
||||
$q->orWhereRelation('penilai', 'type_penilai', 'LIKE', '%' . trim($keyword) . '%');
|
||||
}
|
||||
});
|
||||
// dd($search->search);
|
||||
|
||||
if (isset($search->search)) {
|
||||
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('nomor_registrasi', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhere('tanggal_permohonan', '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('debiture', DB::raw('LOWER(name)'), 'LIKE', '%' . strtolower($search->search) . '%');
|
||||
|
||||
$q->orWhereRelation('jenisFasilitasKredit', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('jenisPenilaian', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhere('status', 'LIKE', '%' . $search->search . '%');
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
$query->where('status', 'done');
|
||||
|
||||
|
||||
|
||||
// Default sorting if no sort provided
|
||||
// Apply sorting if provided
|
||||
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||
$order = $request->get('sortOrder');
|
||||
$column = $request->get('sortField');
|
||||
$query->orderBy($column, $order);
|
||||
} else {
|
||||
$query->orderBy('nomor_registrasi', 'asc');
|
||||
}
|
||||
|
||||
// Get total count of records before pagination
|
||||
|
||||
// Get the total count of records
|
||||
$totalRecords = $query->count();
|
||||
|
||||
// Pagination
|
||||
// Apply pagination if provided
|
||||
if ($request->has('page') && $request->has('size')) {
|
||||
$page = (int) $request->get('page', 1);
|
||||
$size = (int) $request->get('size', 10);
|
||||
$offset = ($page - 1) * $size;
|
||||
$page = $request->get('page');
|
||||
$size = $request->get('size');
|
||||
$offset = ($page - 1) * $size; // Calculate the offset
|
||||
|
||||
$query->skip($offset)->take($size);
|
||||
}
|
||||
|
||||
// Get filtered count
|
||||
// Get the filtered count of records
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
|
||||
|
||||
$totalRecords = $query->count();
|
||||
|
||||
// Pagination
|
||||
if ($request->has('page') && $request->has('size')) {
|
||||
$page = (int) $request->get('page', 1);
|
||||
$size = (int) $request->get('size', 10);
|
||||
$offset = ($page - 1) * $size;
|
||||
$query->skip($offset)->take($size);
|
||||
}
|
||||
|
||||
// Get filtered count
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get data with necessary relationships
|
||||
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'penilaian', 'dokumenjaminan.jenisJaminan','nilaiPlafond', 'penilai'])->get();
|
||||
$data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'penilaian', 'dokumenjaminan.jenisJaminan','nilaiPlafond', 'penilai', 'dokumenjaminan.inspeksi'])->get();
|
||||
|
||||
// Calculate total pages
|
||||
$pageCount = ceil($totalRecords / $request->get('size', 10));
|
||||
// Calculate the page count
|
||||
$pageCount = ceil($totalRecords / $size);
|
||||
|
||||
// Calculate the current page number
|
||||
$currentPage = max(1, $request->get('page', 1));
|
||||
|
||||
|
||||
|
||||
// Calculate total pages
|
||||
$pageCount = ceil($totalRecords / $request->get('size', 10));
|
||||
|
||||
// Return the response data as a JSON object
|
||||
return response()->json([
|
||||
'draw' => $request->get('draw'),
|
||||
'recordsTotal' => $totalRecords,
|
||||
'recordsFiltered' => $filteredRecords,
|
||||
'pageCount' => $pageCount,
|
||||
'page' => $request->get('page', 1),
|
||||
'page' => $currentPage,
|
||||
'totalCount' => $totalRecords,
|
||||
'data' => $data,
|
||||
]);
|
||||
@@ -185,15 +174,53 @@ class LaporanPenilaiJaminanController extends Controller
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
$tanggalAwal = $request->input('tanggal_awal');
|
||||
$tanggalAkhir = $request->input('tanggal_akhir');
|
||||
$status = $request->input('status');
|
||||
$selectedIds = $request->input('selected_ids');
|
||||
$startDate = $request->input('start_date');
|
||||
$endDate = $request->input('end_date');
|
||||
|
||||
// Validate the date format
|
||||
if (isset($startDate) && isset($endDate)) {
|
||||
$startDate = date('Y-m-d', strtotime($startDate));
|
||||
$endDate = date('Y-m-d', strtotime($endDate));
|
||||
|
||||
if ($startDate > $endDate) {
|
||||
return redirect()->back()->with('error', 'Tanggal awal tidak boleh lebih kecil dari tanggal akhir');
|
||||
}
|
||||
}
|
||||
// name the file
|
||||
$filename = $this->createNameLaporan($request);
|
||||
|
||||
$filename = 'laporan_penilai_jaminan_' . date('YmdHis') . '.xlsx';
|
||||
return Excel::download(
|
||||
new LaporanPenilaiJaminanExport($tanggalAwal, $tanggalAkhir, $status, $selectedIds),
|
||||
new LaporanPenilaiJaminanExport($request),
|
||||
$filename
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
public function createNameLaporan($request)
|
||||
{
|
||||
$startDate = $request->start_date ?? null;
|
||||
$endDate = $request->end_date ?? null;
|
||||
$branchId = $request->branch_id ?? null;
|
||||
$laporan = $request->laporan ?? null;
|
||||
|
||||
// Initialize filename parts
|
||||
$parts = ['Laporan Penilai Jaminan'];
|
||||
if ($startDate && $endDate) {
|
||||
$parts[] = "{$startDate}_{$endDate}";
|
||||
}
|
||||
if ($laporan) {
|
||||
$parts[] = $laporan;
|
||||
}
|
||||
if ($branchId) {
|
||||
$parts[] = $this->getBranchId($branchId);
|
||||
}
|
||||
// Return concatenated filename with extension
|
||||
return implode('_', $parts) . '.xlsx';
|
||||
}
|
||||
|
||||
public function getBranchId($branchId)
|
||||
{
|
||||
$branchesName = Branch::find($branchId)->name ?? null;
|
||||
return $branchesName;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,161 +1,180 @@
|
||||
<?php
|
||||
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
namespace Modules\Lpj\Http\Controllers;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Lpj\Exports\LaporanPenilaianJaminanExport;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use App\Http\Controllers\Controller;
|
||||
use Illuminate\Http\Request;
|
||||
use Modules\Lpj\Exports\LaporanPenilaianJaminanExport;
|
||||
use Modules\Lpj\Models\Permohonan;
|
||||
use Modules\Lpj\Models\Penilaian;
|
||||
use Modules\Lpj\Models\PenawaranTender;
|
||||
use Maatwebsite\Excel\Facades\Excel;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
|
||||
class LaporanPenilaianJaminanController extends Controller
|
||||
class LaporanPenilaianJaminanController extends Controller
|
||||
{
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Display a listing of the resource.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
return view('lpj::laporan_penilaian_jaminan.index');
|
||||
}
|
||||
|
||||
public function dataForDatatables(Request $request)
|
||||
{
|
||||
if (is_null($this->user) || !$this->user->can('laporan-admin-kredit.view')) {
|
||||
//abort(403, 'Sorry! You are not allowed to view laporan admin kredit.');
|
||||
}
|
||||
|
||||
// Retrieve data from the database
|
||||
$query = Permohonan::query();
|
||||
$query = $query->where('status', 'done');
|
||||
|
||||
// Apply search filter if provided
|
||||
if ($request->has('search') && !empty($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->branch_id) && !empty($search->branch_id)) {
|
||||
$query->where('branch_id', $search->branch_id);
|
||||
}
|
||||
|
||||
if (isset($search->penilai_id) && !empty($search->penilai_id)) {
|
||||
$query->whereHas('penilaian._user_penilai.userPenilaiTeam', function($q) use ($search) {
|
||||
$q->where('user_id', $search->penilai_id);
|
||||
});
|
||||
}
|
||||
|
||||
if (isset($search->search)) {
|
||||
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('nomor_registrasi', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhere('tanggal_permohonan', '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 . '%');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Apply sorting if provided
|
||||
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||
$order = $request->get('sortOrder');
|
||||
$column = $request->get('sortField');
|
||||
$query->orderBy($column, $order);
|
||||
}
|
||||
|
||||
// Get the total count of records
|
||||
$totalRecords = $query->count();
|
||||
|
||||
// Apply pagination if provided
|
||||
if ($request->has('page') && $request->has('size')) {
|
||||
$page = $request->get('page');
|
||||
$size = $request->get('size');
|
||||
$offset = ($page - 1) * $size; // Calculate the offset
|
||||
|
||||
$query->skip($offset)->take($size);
|
||||
}
|
||||
|
||||
// Get the filtered count of records
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get the data for the current page
|
||||
$data = $query->with(['debiture.branch'])->get();
|
||||
|
||||
$data = $data->map(function ($permohonan) {
|
||||
$luas_tanah = 0;
|
||||
$luas_bangunan = 0;
|
||||
$nilai_tanah = 0;
|
||||
$nilai_bangunan = 0;
|
||||
$npw = 0;
|
||||
$nilai_liquidasi = 0;
|
||||
if (isset($permohonan->penilai->lpj)) {
|
||||
$lpj = json_decode($permohonan->penilai->lpj, true);
|
||||
$npw = str_replace('.', '', $lpj['total_nilai_pasar_wajar'] ?? 0);
|
||||
|
||||
$luas_tanah = $lpj['luas_tanah'] ?? 0;
|
||||
$luas_bangunan = $lpj['luas_bangunan'] ?? 0;
|
||||
// Calculate nilai_tanah dynamically by looking for all keys that start with 'nilai_tanah_'
|
||||
$nilai_tanah = str_replace('.', '', $lpj['nilai_tanah_2'] ?? 0);
|
||||
|
||||
$nilai_bangunan = str_replace('.', '', $lpj['nilai_bangunan_2'] ?? 0);
|
||||
$nilai_liquidasi = str_replace('.', '', $lpj['likuidasi_nilai_2'] ?? 0);
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $permohonan->id,
|
||||
'nomor_registrasi' => $permohonan->nomor_registrasi,
|
||||
'tanggal_permohonan' => $permohonan->tanggal_permohonan,
|
||||
'branch' => $permohonan->debiture?->branch?->name,
|
||||
'name' => $permohonan->debiture?->name,
|
||||
'pemohon' => $permohonan->creator?->name,
|
||||
'tujuan_penilaian' => $permohonan->tujuanPenilaian?->name,
|
||||
'jenis_agunan' => $permohonan->documents?->pluck('jenisJaminan.name')->unique()->implode(', '),
|
||||
'alamat_agunan' => $permohonan->documents?->map(function ($document) {
|
||||
return formatAlamat($document);
|
||||
})->unique()->implode(', '),
|
||||
'luas_tanah' => $luas_tanah . ' m²',
|
||||
'nilai_tanah' => formatRupiah($nilai_tanah,2),
|
||||
'luas_bangunan' => $luas_bangunan . ' m²',
|
||||
'nilai_bangunan' => formatRupiah($nilai_bangunan,2),
|
||||
'tanggal_laporan' => $permohonan->approval_dd_at ?? $permohonan->approval_eo_at ?? '',
|
||||
'tanggal_review' => $permohonan->penilaian?->tanggal_kunjungan ?? '',
|
||||
'nilai_pasar_wajar' => formatRupiah($npw,2),
|
||||
'nilai_likuidasi' => formatRupiah($nilai_liquidasi,2),
|
||||
'nama_penilai' => $permohonan->penilaian?->_user_penilai?->userPenilaiTeam?->name,
|
||||
];
|
||||
});
|
||||
|
||||
// Calculate the page count
|
||||
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||
|
||||
// Calculate the current page number
|
||||
$currentPage = $request->get('page', 1);
|
||||
|
||||
// Return the response data as a JSON object
|
||||
return response()->json([
|
||||
'draw' => $request->get('draw'),
|
||||
'recordsTotal' => $totalRecords,
|
||||
'recordsFiltered' => $filteredRecords,
|
||||
'pageCount' => $pageCount,
|
||||
'page' => $currentPage,
|
||||
'totalCount' => $totalRecords,
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
return Excel::download(new LaporanPenilaianJaminanExport($request), 'laporan_penilaian_jaminan.xlsx');
|
||||
}
|
||||
return view('lpj::laporan_penilaian_jaminan.index');
|
||||
}
|
||||
|
||||
public function dataForDatatables(Request $request)
|
||||
{
|
||||
if (is_null($this->user) || !$this->user->can('laporan-admin-kredit.view')) {
|
||||
//abort(403, 'Sorry! You are not allowed to view laporan admin kredit.');
|
||||
}
|
||||
|
||||
// Retrieve data from the database
|
||||
$query = Permohonan::query();
|
||||
$query = $query->where('status', 'done');
|
||||
|
||||
// Apply search filter if provided
|
||||
if ($request->has('search') && !empty($request->get('search'))) {
|
||||
$search = json_decode($request->get('search'));
|
||||
|
||||
|
||||
if (!empty($search->start_date) || !empty($search->end_date)) {
|
||||
$startDate = $search->start_date ?? '1900-01-01';
|
||||
$endDate = $search->end_date ?? now()->toDateString();
|
||||
|
||||
$query->where(function ($q) use ($startDate, $endDate) {
|
||||
$q->whereHas('penilaian', function ($q2) use ($startDate, $endDate) {
|
||||
$q2->whereBetween('tanggal_kunjungan', [$startDate, $endDate]);
|
||||
})
|
||||
->orWhereHas('penawaran', function ($q3) use ($startDate, $endDate) {
|
||||
$q3->whereBetween('tanggal_penilaian_sebelumnya', [$startDate, $endDate]);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Filter by branch if provided
|
||||
if (isset($search->branch_id) && !empty($search->branch_id)) {
|
||||
$query->where('branch_id', $search->branch_id);
|
||||
}
|
||||
|
||||
if (isset($search->penilai_id) && !empty($search->penilai_id)) {
|
||||
$query->whereHas('penilaian._user_penilai.userPenilaiTeam', function ($q) use ($search) {
|
||||
$q->where('user_id', $search->penilai_id);
|
||||
});
|
||||
}
|
||||
|
||||
if (isset($search->search)) {
|
||||
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('nomor_registrasi', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhere('tanggal_permohonan', '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('debiture', DB::raw('LOWER(name)'), 'LIKE', '%' . strtolower($search->search) . '%');
|
||||
|
||||
$q->orWhereRelation('jenisFasilitasKredit', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhereRelation('jenisPenilaian', 'name', 'LIKE', '%' . $search->search . '%');
|
||||
$q->orWhere('status', 'LIKE', '%' . $search->search . '%');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Apply sorting if provided
|
||||
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||
$order = $request->get('sortOrder');
|
||||
$column = $request->get('sortField');
|
||||
$query->orderBy($column, $order);
|
||||
}
|
||||
|
||||
// Get the total count of records
|
||||
$totalRecords = $query->count();
|
||||
|
||||
// Apply pagination if provided
|
||||
if ($request->has('page') && $request->has('size')) {
|
||||
$page = $request->get('page');
|
||||
$size = $request->get('size');
|
||||
$offset = ($page - 1) * $size; // Calculate the offset
|
||||
|
||||
$query->skip($offset)->take($size);
|
||||
}
|
||||
|
||||
// Get the filtered count of records
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get the data for the current page
|
||||
$data = $query->with(['debiture.branch'])->get();
|
||||
|
||||
$data = $data->map(function ($permohonan) {
|
||||
$luas_tanah = 0;
|
||||
$luas_bangunan = 0;
|
||||
$nilai_tanah = 0;
|
||||
$nilai_bangunan = 0;
|
||||
$npw = 0;
|
||||
$nilai_liquidasi = 0;
|
||||
if (isset($permohonan->penilai->lpj)) {
|
||||
$lpj = json_decode($permohonan->penilai->lpj, true);
|
||||
$npw = str_replace('.', '', $lpj['total_nilai_pasar_wajar'] ?? 0);
|
||||
|
||||
$luas_tanah = $lpj['luas_tanah'] ?? 0;
|
||||
$luas_bangunan = $lpj['luas_bangunan'] ?? 0;
|
||||
// Calculate nilai_tanah dynamically by looking for all keys that start with 'nilai_tanah_'
|
||||
$nilai_tanah = str_replace('.', '', $lpj['nilai_tanah_2'] ?? 0);
|
||||
|
||||
$nilai_bangunan = str_replace('.', '', $lpj['nilai_bangunan_2'] ?? 0);
|
||||
$nilai_liquidasi = str_replace('.', '', $lpj['likuidasi_nilai_2'] ?? 0);
|
||||
}
|
||||
|
||||
return [
|
||||
'id' => $permohonan->id,
|
||||
'nomor_registrasi' => $permohonan->nomor_registrasi,
|
||||
'tanggal_permohonan' => $permohonan->tanggal_permohonan,
|
||||
'branch' => $permohonan->debiture?->branch?->name,
|
||||
'name' => $permohonan->debiture?->name,
|
||||
'pemohon' => $permohonan->creator?->name,
|
||||
'tujuan_penilaian' => $permohonan->tujuanPenilaian?->name,
|
||||
'jenis_agunan' => $permohonan->documents?->pluck('jenisJaminan.name')->unique()->implode(', '),
|
||||
'alamat_agunan' => $permohonan->documents?->map(function ($document) {
|
||||
return formatAlamat($document);
|
||||
})->unique()->implode(', '),
|
||||
'luas_tanah' => $luas_tanah . ' m²',
|
||||
'nilai_tanah' => formatRupiah($nilai_tanah, 2),
|
||||
'luas_bangunan' => $luas_bangunan . ' m²',
|
||||
'nilai_bangunan' => formatRupiah($nilai_bangunan, 2),
|
||||
'tanggal_laporan' => $permohonan->approval_dd_at ?? $permohonan->approval_eo_at ?? '',
|
||||
'tanggal_review' => $permohonan->penilaian?->tanggal_kunjungan ?? '',
|
||||
'nilai_pasar_wajar' => formatRupiah($npw, 2),
|
||||
'nilai_likuidasi' => formatRupiah($nilai_liquidasi, 2),
|
||||
'nama_penilai' => $permohonan->penilaian?->_user_penilai?->userPenilaiTeam?->name,
|
||||
];
|
||||
});
|
||||
|
||||
// Calculate the page count
|
||||
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||
|
||||
// Calculate the current page number
|
||||
$currentPage = $request->get('page', 1);
|
||||
|
||||
// Return the response data as a JSON object
|
||||
return response()->json([
|
||||
'draw' => $request->get('draw'),
|
||||
'recordsTotal' => $totalRecords,
|
||||
'recordsFiltered' => $filteredRecords,
|
||||
'pageCount' => $pageCount,
|
||||
'page' => $currentPage,
|
||||
'totalCount' => $totalRecords,
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
public function export(Request $request)
|
||||
{
|
||||
$startDate = $request->start_date;
|
||||
$endDate = $request->end_date;
|
||||
// name of the file
|
||||
$fileName = 'laporan_penilaian_jaminan_' . $startDate . '_' . $endDate . '.xlsx';
|
||||
return Excel::download(new LaporanPenilaianJaminanExport($request), $fileName);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -17,224 +17,238 @@
|
||||
public $user;
|
||||
|
||||
/**
|
||||
* Tampilkan halaman daftar Nilai Plafond.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
* Menampilkan halaman daftar Nilai Plafond.
|
||||
* Log setiap akses dan sebelum return view.
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
Log::info('[NilaiPlafondController@index] Return view index nilai_plafond');
|
||||
return view('lpj::nilai_plafond.index');
|
||||
Log::info('NilaiPlafondController@index: akses halaman index');
|
||||
return \view('lpj::nilai_plafond.index');
|
||||
}
|
||||
|
||||
/**
|
||||
* Simpan data Nilai Plafond baru ke database.
|
||||
* Menggunakan transaksi untuk menjamin konsistensi data.
|
||||
*
|
||||
* @param NilaiPlafondRequest $request
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* Menyimpan data Nilai Plafond baru termasuk field biaya.
|
||||
* Gunakan validasi dari NilaiPlafondRequest, log proses, dan bungkus dengan transaksi DB.
|
||||
*/
|
||||
public function store(NilaiPlafondRequest $request)
|
||||
{
|
||||
Log::info('NilaiPlafondController@store: mulai proses simpan');
|
||||
$validate = $request->validated();
|
||||
|
||||
if ($validate) {
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
// Save to database
|
||||
$created = NilaiPlafond::create($validate);
|
||||
$record = NilaiPlafond::create($validate);
|
||||
DB::commit();
|
||||
Log::info('[NilaiPlafondController@store] NilaiPlafond created', ['id' => $created->id, 'payload' => $validate]);
|
||||
return redirect()
|
||||
|
||||
Log::info('NilaiPlafondController@store: simpan berhasil', ['id' => $record->id]);
|
||||
return \redirect()
|
||||
->route('basicdata.nilai-plafond.index')
|
||||
->with('success', 'Nilai Plafond berhasil dibuat');
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::error('[NilaiPlafondController@store] Failed to create nilai plafond', ['error' => $e->getMessage(), 'payload' => $validate]);
|
||||
return redirect()
|
||||
Log::error('NilaiPlafondController@store: simpan gagal', ['error' => $e->getMessage()]);
|
||||
|
||||
return \redirect()
|
||||
->route('basicdata.nilai-plafond.create')
|
||||
->with('error', 'Gagal membuat Nilai Plafond');
|
||||
}
|
||||
}
|
||||
|
||||
Log::warning('[NilaiPlafondController@store] Validation failed');
|
||||
return redirect()
|
||||
->route('basicdata.nilai-plafond.create')
|
||||
->with('error', 'Validasi gagal');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tampilkan form pembuatan Nilai Plafond.
|
||||
*
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
* Menampilkan form pembuatan Nilai Plafond.
|
||||
* Log akses sebelum return view.
|
||||
*/
|
||||
public function create()
|
||||
{
|
||||
Log::info('[NilaiPlafondController@create] Return view create nilai_plafond');
|
||||
return view('lpj::nilai_plafond.create');
|
||||
Log::info('NilaiPlafondController@create: akses halaman create');
|
||||
return \view('lpj::nilai_plafond.create');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tampilkan form edit Nilai Plafond berdasarkan ID.
|
||||
*
|
||||
* @param int $id
|
||||
* @return \Illuminate\Contracts\View\View
|
||||
* Menampilkan form edit Nilai Plafond berdasarkan ID.
|
||||
* Gunakan transaksi untuk pembacaan data dan logging.
|
||||
*/
|
||||
public function edit($id)
|
||||
{
|
||||
$nilaiPlafond = NilaiPlafond::find($id);
|
||||
Log::info('[NilaiPlafondController@edit] Return view edit nilai_plafond', ['id' => $id]);
|
||||
return view('lpj::nilai_plafond.create', compact('nilaiPlafond'));
|
||||
Log::info('NilaiPlafondController@edit: mulai proses edit', ['id' => $id]);
|
||||
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
$nilaiPlafond = NilaiPlafond::find($id);
|
||||
DB::commit();
|
||||
|
||||
Log::info('NilaiPlafondController@edit: data ditemukan', ['id' => $id]);
|
||||
return \view('lpj::nilai_plafond.create', compact('nilaiPlafond'));
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::error('NilaiPlafondController@edit: gagal mengambil data', ['id' => $id, 'error' => $e->getMessage()]);
|
||||
return \redirect()
|
||||
->route('basicdata.nilai-plafond.index')
|
||||
->with('error', 'Gagal mengambil data Nilai Plafond');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Update data Nilai Plafond pada database.
|
||||
* Menggunakan transaksi untuk menjamin konsistensi data.
|
||||
*
|
||||
* @param NilaiPlafondRequest $request
|
||||
* @param int $id
|
||||
* @return \Illuminate\Http\RedirectResponse
|
||||
* Memperbarui data Nilai Plafond termasuk field biaya.
|
||||
* Validasi input, logging, dan gunakan transaksi DB.
|
||||
*/
|
||||
public function update(NilaiPlafondRequest $request, $id)
|
||||
{
|
||||
Log::info('NilaiPlafondController@update: mulai proses update', ['id' => $id]);
|
||||
$validate = $request->validated();
|
||||
|
||||
if ($validate) {
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
// Update in database
|
||||
$nilaiPlafond = NilaiPlafond::find($id);
|
||||
if (!$nilaiPlafond) {
|
||||
Log::warning('NilaiPlafondController@update: data tidak ditemukan', ['id' => $id]);
|
||||
DB::rollBack();
|
||||
return \redirect()
|
||||
->route('basicdata.nilai-plafond.index')
|
||||
->with('error', 'Data Nilai Plafond tidak ditemukan');
|
||||
}
|
||||
|
||||
$nilaiPlafond->update($validate);
|
||||
DB::commit();
|
||||
Log::info('[NilaiPlafondController@update] NilaiPlafond updated', ['id' => $id, 'payload' => $validate]);
|
||||
return redirect()
|
||||
|
||||
Log::info('NilaiPlafondController@update: update berhasil', ['id' => $id]);
|
||||
return \redirect()
|
||||
->route('basicdata.nilai-plafond.index')
|
||||
->with('success', 'Nilai Plafond berhasil diperbarui');
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::error('[NilaiPlafondController@update] Failed to update nilai plafond', ['id' => $id, 'error' => $e->getMessage(), 'payload' => $validate]);
|
||||
return redirect()
|
||||
Log::error('NilaiPlafondController@update: update gagal', ['id' => $id, 'error' => $e->getMessage()]);
|
||||
|
||||
return \redirect()
|
||||
->route('basicdata.nilai-plafond.edit', $id)
|
||||
->with('error', 'Gagal memperbarui Nilai Plafond');
|
||||
}
|
||||
}
|
||||
|
||||
Log::warning('[NilaiPlafondController@update] Validation failed', ['id' => $id]);
|
||||
return redirect()
|
||||
->route('basicdata.nilai-plafond.edit', $id)
|
||||
->with('error', 'Validasi gagal');
|
||||
}
|
||||
|
||||
/**
|
||||
* Hapus data Nilai Plafond dari database.
|
||||
* Menggunakan transaksi untuk menjamin konsistensi data.
|
||||
*
|
||||
* @param int $id
|
||||
* @return void
|
||||
* Menghapus data Nilai Plafond berdasarkan ID.
|
||||
* Logging setiap langkah dan gunakan transaksi DB.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
Log::info('NilaiPlafondController@destroy: mulai proses hapus', ['id' => $id]);
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
// Delete from database
|
||||
$nilaiPlafond = NilaiPlafond::find($id);
|
||||
if (!$nilaiPlafond) {
|
||||
DB::rollBack();
|
||||
Log::warning('NilaiPlafondController@destroy: data tidak ditemukan', ['id' => $id]);
|
||||
return \response()->json(['success' => false, 'message' => 'Data Nilai Plafond tidak ditemukan']);
|
||||
}
|
||||
|
||||
$nilaiPlafond->delete();
|
||||
DB::commit();
|
||||
Log::info('[NilaiPlafondController@destroy] NilaiPlafond deleted', ['id' => $id]);
|
||||
|
||||
echo json_encode(['success' => true, 'message' => 'Nilai Plafond berhasil dihapus']);
|
||||
Log::info('NilaiPlafondController@destroy: hapus berhasil', ['id' => $id]);
|
||||
return \response()->json(['success' => true, 'message' => 'Nilai Plafond berhasil dihapus']);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::error('[NilaiPlafondController@destroy] Failed to delete nilai plafond', ['id' => $id, 'error' => $e->getMessage()]);
|
||||
echo json_encode(['success' => false, 'message' => 'Gagal menghapus Nilai Plafond']);
|
||||
Log::error('NilaiPlafondController@destroy: hapus gagal', ['id' => $id, 'error' => $e->getMessage()]);
|
||||
return \response()->json(['success' => false, 'message' => 'Gagal menghapus Nilai Plafond']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Endpoint data untuk DataTables custom.
|
||||
* Menyediakan pencarian, sorting, dan pagination.
|
||||
*
|
||||
* @param Request $request
|
||||
* @return \Illuminate\Http\JsonResponse
|
||||
* Menyediakan data untuk datatables dengan pencarian, sortir, dan paginasi.
|
||||
* Logging proses dan gunakan transaksi DB untuk konsistensi pembacaan.
|
||||
*/
|
||||
public function dataForDatatables(Request $request)
|
||||
{
|
||||
Log::info('NilaiPlafondController@dataForDatatables: mulai proses');
|
||||
|
||||
if (is_null($this->user) || !$this->user->can('nilai_plafond.view')) {
|
||||
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||
}
|
||||
|
||||
// Retrieve data from the database
|
||||
$query = NilaiPlafond::query();
|
||||
DB::beginTransaction();
|
||||
try {
|
||||
// Retrieve data from the database
|
||||
$query = NilaiPlafond::query();
|
||||
|
||||
// Apply search filter if provided
|
||||
if ($request->has('search') && !empty($request->get('search'))) {
|
||||
$search = $request->get('search');
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('code', 'LIKE', "%$search%");
|
||||
$q->orWhere('name', 'LIKE', "%$search%");
|
||||
// CAST ke TEXT agar LIKE bekerja di PostgreSQL
|
||||
$q->orWhereRaw('CAST(biaya AS TEXT) LIKE ?', ["%$search%"]);
|
||||
});
|
||||
// Apply search filter if provided
|
||||
if ($request->has('search') && !empty($request->get('search'))) {
|
||||
$search = $request->get('search');
|
||||
$query->where(function ($q) use ($search) {
|
||||
$q->where('code', 'LIKE', "%$search%");
|
||||
$q->orWhere('name', 'LIKE', "%$search%");
|
||||
});
|
||||
}
|
||||
|
||||
// Apply sorting if provided
|
||||
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||
$order = $request->get('sortOrder');
|
||||
$column = $request->get('sortField');
|
||||
$query->orderBy($column, $order);
|
||||
}
|
||||
|
||||
// Get the total count of records
|
||||
$totalRecords = $query->count();
|
||||
|
||||
// Apply pagination if provided
|
||||
if ($request->has('page') && $request->has('size')) {
|
||||
$page = $request->get('page');
|
||||
$size = $request->get('size');
|
||||
$offset = ($page - 1) * $size; // Calculate the offset
|
||||
|
||||
$query->skip($offset)->take($size);
|
||||
}
|
||||
|
||||
// Get the filtered count of records
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get the data for the current page
|
||||
$data = $query->get();
|
||||
|
||||
// Calculate the page count
|
||||
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||
|
||||
// Calculate the current page number
|
||||
$currentPage = 0 + 1;
|
||||
|
||||
DB::commit();
|
||||
Log::info('NilaiPlafondController@dataForDatatables: proses selesai, mengembalikan data');
|
||||
|
||||
// Return the response data as a JSON object
|
||||
return \response()->json([
|
||||
'draw' => $request->get('draw'),
|
||||
'recordsTotal' => $totalRecords,
|
||||
'recordsFiltered' => $filteredRecords,
|
||||
'pageCount' => $pageCount,
|
||||
'page' => $currentPage,
|
||||
'totalCount' => $totalRecords,
|
||||
'data' => $data,
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
DB::rollBack();
|
||||
Log::error('NilaiPlafondController@dataForDatatables: gagal memproses data', ['error' => $e->getMessage()]);
|
||||
return \response()->json([
|
||||
'draw' => $request->get('draw'),
|
||||
'recordsTotal' => 0,
|
||||
'recordsFiltered' => 0,
|
||||
'pageCount' => 0,
|
||||
'page' => 1,
|
||||
'totalCount' => 0,
|
||||
'data' => [],
|
||||
]);
|
||||
}
|
||||
|
||||
// Apply sorting if provided
|
||||
if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
|
||||
$order = $request->get('sortOrder');
|
||||
$column = $request->get('sortField');
|
||||
$query->orderBy($column, $order);
|
||||
}
|
||||
|
||||
// Get the total count of records
|
||||
$totalRecords = $query->count();
|
||||
|
||||
// Apply pagination if provided
|
||||
if ($request->has('page') && $request->has('size')) {
|
||||
$page = $request->get('page');
|
||||
$size = $request->get('size');
|
||||
$offset = ($page - 1) * $size; // Calculate the offset
|
||||
|
||||
$query->skip($offset)->take($size);
|
||||
}
|
||||
|
||||
// Get the filtered count of records
|
||||
$filteredRecords = $query->count();
|
||||
|
||||
// Get the data for the current page
|
||||
$data = $query->get();
|
||||
|
||||
// Calculate the page count
|
||||
$pageCount = ceil($totalRecords / $request->get('size'));
|
||||
|
||||
// Calculate the current page number
|
||||
$currentPage = 0 + 1;
|
||||
|
||||
Log::info('[NilaiPlafondController@dataForDatatables] Return datatables payload', [
|
||||
'recordsTotal' => $totalRecords,
|
||||
'recordsFiltered' => $filteredRecords,
|
||||
'pageCount' => $pageCount,
|
||||
'page' => $currentPage,
|
||||
]);
|
||||
|
||||
// Return the response data as a JSON object
|
||||
return response()->json([
|
||||
'draw' => $request->get('draw'),
|
||||
'recordsTotal' => $totalRecords,
|
||||
'recordsFiltered' => $filteredRecords,
|
||||
'pageCount' => $pageCount,
|
||||
'page' => $currentPage,
|
||||
'totalCount' => $totalRecords,
|
||||
'data' => $data,
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Export data Nilai Plafond ke file Excel.
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\BinaryFileResponse
|
||||
* Mengekspor data Nilai Plafond ke Excel.
|
||||
* Log akses sebelum proses download.
|
||||
*/
|
||||
public function export()
|
||||
{
|
||||
Log::info('[NilaiPlafondController@export] Export nilai_plafond to Excel');
|
||||
Log::info('NilaiPlafondController@export: mulai proses export');
|
||||
return Excel::download(new NilaiPlafondExport, 'nilai_plafond.xlsx');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,18 +26,21 @@ use Modules\Lpj\Http\Requests\FormSurveyorRequest;
|
||||
use Modules\Lpj\Models\Authorization;
|
||||
use Modules\Lpj\Models\Debiture;
|
||||
use Modules\Lpj\Services\SaveFormInspesksiService;
|
||||
use Modules\Lpj\Services\PreviewLaporanService;
|
||||
|
||||
class PenilaiController extends Controller
|
||||
{
|
||||
public $user;
|
||||
protected $surveyorController;
|
||||
protected $inspeksiService;
|
||||
protected $previewLaporanService;
|
||||
|
||||
|
||||
public function __construct(SurveyorController $surveyorController, SaveFormInspesksiService $inspeksiService)
|
||||
public function __construct(SurveyorController $surveyorController, SaveFormInspesksiService $inspeksiService, PreviewLaporanService $previewLaporanService)
|
||||
{
|
||||
$this->surveyorController = $surveyorController;
|
||||
$this->inspeksiService = $inspeksiService;
|
||||
$this->previewLaporanService = $previewLaporanService;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -548,13 +551,7 @@ class PenilaiController extends Controller
|
||||
return view('lpj::penilai.components.call-report', compact('permohonan', 'basicData', 'nomorLaporan', 'forminspeksi', 'cities', 'districts', 'villages', 'cekAlamat', 'callReport'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove the specified resource from storage.
|
||||
*/
|
||||
public function destroy($id)
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
|
||||
public function dataForDatatables(Request $request)
|
||||
{
|
||||
@@ -701,15 +698,17 @@ class PenilaiController extends Controller
|
||||
'lokasi_lengkap' => $data->lokasi_lengkap ?? '',
|
||||
];
|
||||
|
||||
// Extract data pembanding
|
||||
if (isset($dataPembanding['data_pembanding'])) {
|
||||
foreach ($dataPembanding['data_pembanding'] as $index => $pembanding) {
|
||||
if ($index == 0) {
|
||||
$exportData['pembanding1'] = $pembanding;
|
||||
} elseif ($index == 1) {
|
||||
$exportData['pembanding2'] = $pembanding;
|
||||
} elseif ($index == 2) {
|
||||
$exportData['pembanding3'] = $pembanding;
|
||||
if(isset($dataPembanding)){
|
||||
// Extract data pembanding
|
||||
if (isset($dataPembanding['data_pembanding'])) {
|
||||
foreach ($dataPembanding['data_pembanding'] as $index => $pembanding) {
|
||||
if ($index == 0) {
|
||||
$exportData['pembanding1'] = $pembanding;
|
||||
} elseif ($index == 1) {
|
||||
$exportData['pembanding2'] = $pembanding;
|
||||
} elseif ($index == 2) {
|
||||
$exportData['pembanding3'] = $pembanding;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1276,8 +1275,6 @@ class PenilaiController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function print_out(Request $request)
|
||||
{
|
||||
$documentId = $request->query('documentId');
|
||||
@@ -1393,6 +1390,15 @@ class PenilaiController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function print_out_laporan($permohonan_id, $document_id, $jaminan_id)
|
||||
{
|
||||
// jika tidak ada id kembalikan ke halaman sebelumnya
|
||||
if (!$permohonan_id || !$document_id || !$jaminan_id) {
|
||||
return redirect()->back()->with('error', 'Laporan tidak valid');
|
||||
}
|
||||
return $this->previewLaporanService->printOutLaporan($permohonan_id, $document_id, $jaminan_id);
|
||||
}
|
||||
|
||||
private function getViewLaporan($tipe)
|
||||
{
|
||||
$viewMap = [
|
||||
@@ -1772,4 +1778,24 @@ class PenilaiController extends Controller
|
||||
'message' => 'Berhasil Revisi Ke surveyor',
|
||||
], 200);
|
||||
}
|
||||
|
||||
public function showLaporanInspeksi(
|
||||
$permohonan_id,
|
||||
$dokumen_id,
|
||||
$jaminan_id,
|
||||
Request $request)
|
||||
{
|
||||
if ($request->type == 'penilai') {
|
||||
$back = route('penilai.show', $permohonan_id);
|
||||
}else{
|
||||
$back = route('surveyor.show', $permohonan_id);
|
||||
}
|
||||
|
||||
return $this->previewLaporanService->previewLaporan($permohonan_id, $dokumen_id, $jaminan_id, $back);
|
||||
}
|
||||
|
||||
public function showInspectionReportReview($permohonan_id, $dokumen_id, $jaminan_id)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
<form action="{{ isset($debitur->id) ? route('debitur.update', $debitur->id) : route('debitur.store') }}" method="POST"
|
||||
id="debitur-form" class="grid gap-5">
|
||||
@if (isset($debitur->id))
|
||||
<form action="{{ isset($debitur->id) ? route('debitur.update', $debitur->id) : route('debitur.store') }}" method="POST" id="debitur-form" class="grid gap-5">
|
||||
@if(isset($debitur->id))
|
||||
<input type="hidden" name="id" value="{{ $debitur->id }}">
|
||||
@method('PUT')
|
||||
@endif
|
||||
@@ -11,13 +10,11 @@
|
||||
<span class="text-danger">*</span>
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
@if (auth()->user()->hasRole(['administrator']))
|
||||
<select class="input tomselect w-full @error('branch_id') border-danger bg-danger-light @enderror"
|
||||
name="branch_id" id="branch_id">
|
||||
@if(auth()->user()->hasRole('administrator'))
|
||||
<select class="input tomselect w-full @error('branch_id') border-danger bg-danger-light @enderror" name="branch_id" id="branch_id">
|
||||
<option value="">Pilih Cabang</option>
|
||||
@foreach ($branches as $branch)
|
||||
<option value="{{ $branch->id }}"
|
||||
{{ (isset($debitur) && $branch->id == $debitur->branch_id) || old('branch_id') == $branch->id ? 'selected' : '' }}>
|
||||
@foreach($branches as $branch)
|
||||
<option value="{{ $branch->id }}" {{ (isset($debitur) && $branch->id == $debitur->branch_id) || (old('branch_id') == $branch->id) ? 'selected' : '' }}>
|
||||
{{ $branch->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
@@ -27,7 +24,7 @@
|
||||
<input type="text" class="w-full input" value="{{ auth()->user()->branch->name }}" readonly>
|
||||
@endif
|
||||
@error('branch_id')
|
||||
<em class="text-sm alert text-danger">{{ $message }}</em>
|
||||
<em class="text-sm alert text-danger">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
@@ -36,13 +33,12 @@
|
||||
CIF
|
||||
<span class="text-danger">
|
||||
*
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('cif') border-danger bg-danger-light @enderror" type="number" id="cif"
|
||||
name="cif" value="{{ $debitur->cif ?? '0000000000' }}">
|
||||
<input class="input @error('cif') border-danger bg-danger-light @enderror" type="number" id="cif" name="cif" value="{{ $debitur->cif ?? '0000000000' }}">
|
||||
@error('cif')
|
||||
<em class="text-sm alert text-danger">{{ $message }}</em>
|
||||
<em class="text-sm alert text-danger">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
@@ -51,10 +47,9 @@
|
||||
Nomor Rekening
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('nomor_rekening') border-danger bg-danger-light @enderror" type="number"
|
||||
name="nomor_rekening" value="{{ $debitur->nomor_rekening ?? '' }}">
|
||||
<input class="input @error('nomor_rekening') border-danger bg-danger-light @enderror" type="number" name="nomor_rekening" value="{{ $debitur->nomor_rekening ?? '' }}">
|
||||
@error('nomor_rekening')
|
||||
<em class="text-sm alert text-danger">{{ $message }}</em>
|
||||
<em class="text-sm alert text-danger">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
@@ -63,13 +58,12 @@
|
||||
Nama Debitur
|
||||
<span class="text-danger">
|
||||
*
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input required class="input @error('name') border-danger bg-danger-light @enderror" type="text"
|
||||
name="name" value="{{ $debitur->name ?? '' }}">
|
||||
<input required class="input @error('name') border-danger bg-danger-light @enderror" type="text" name="name" value="{{ $debitur->name ?? '' }}">
|
||||
@error('name')
|
||||
<em class="text-sm alert text-danger">{{ $message }}</em>
|
||||
<em class="text-sm alert text-danger">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
@@ -78,22 +72,20 @@
|
||||
NPWP
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('npwp') border-danger bg-danger-light @enderror" type="number" name="npwp"
|
||||
value="{{ $debitur->npwp ?? '' }}">
|
||||
<input class="input @error('npwp') border-danger bg-danger-light @enderror" type="number" name="npwp" value="{{ $debitur->npwp ?? '' }}">
|
||||
@error('npwp')
|
||||
<em class="text-sm alert text-danger">{{ $message }}</em>
|
||||
<em class="text-sm alert text-danger">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex hidden flex-wrap gap-2.5 items-baseline lg:flex-nowrap">
|
||||
<div class="flex flex-wrap gap-2.5 items-baseline lg:flex-nowrap">
|
||||
<label class="form-label max-w-56">
|
||||
Email
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('email') border-danger bg-danger-light @enderror" type="email" name="email"
|
||||
value="{{ $debitur->email ?? '' }}">
|
||||
<input class="input @error('email') border-danger bg-danger-light @enderror" type="email" name="email" value="{{ $debitur->email ?? '' }}">
|
||||
@error('email')
|
||||
<em class="text-sm alert text-danger">{{ $message }}</em>
|
||||
<em class="text-sm alert text-danger">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
@@ -102,30 +94,27 @@
|
||||
No Handphone
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input class="input @error('phone') border-danger bg-danger-light @enderror" type="number" name="phone"
|
||||
value="{{ $debitur->phone ?? '' }}">
|
||||
<input class="input @error('phone') border-danger bg-danger-light @enderror" type="number" name="phone" value="{{ $debitur->phone ?? '' }}">
|
||||
@error('phone')
|
||||
<em class="text-sm alert text-danger">{{ $message }}</em>
|
||||
<em class="text-sm alert text-danger">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2.5 items-baseline lg:flex-nowrap">
|
||||
<label class="gap-1 form-label max-w-56">
|
||||
Alamat KTP
|
||||
Alamat
|
||||
<span class="text-danger">
|
||||
*
|
||||
</span>
|
||||
</span>
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<div class="flex flex-col gap-2 w-full lg:flex-row">
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<select required id="province_code" name="province_code"
|
||||
class="select w-full @error('province_code') border-danger bg-danger-light @enderror">
|
||||
<select required id="province_code" name="province_code" class="select w-full @error('province_code') border-danger bg-danger-light @enderror">
|
||||
<option value="">Select Province</option>
|
||||
@foreach ($provinces as $province)
|
||||
@if (isset($debitur))
|
||||
<option value="{{ $province->code }}"
|
||||
{{ isset($debitur->province_code) && $debitur->province_code == $province->code ? 'selected' : '' }}>
|
||||
@foreach($provinces as $province)
|
||||
@if(isset($debitur))
|
||||
<option value="{{ $province->code }}" {{ isset($debitur->province_code) && $debitur->province_code == $province->code?'selected' : '' }}>
|
||||
{{ $province->name }}
|
||||
</option>
|
||||
@else
|
||||
@@ -136,18 +125,16 @@
|
||||
@endforeach
|
||||
</select>
|
||||
@error('province_code')
|
||||
<em class="text-sm alert text-danger">{{ $message }}</em>
|
||||
<em class="text-sm alert text-danger">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<select required id="city_code" name="city_code"
|
||||
class="select w-full @error('city_code') border-danger bg-danger-light @enderror">
|
||||
<select required id="city_code" name="city_code" class="select w-full @error('city_code') border-danger bg-danger-light @enderror">
|
||||
<option value="">Select City</option>
|
||||
@if (isset($cities))
|
||||
@foreach ($cities as $city)
|
||||
@if (isset($debitur))
|
||||
<option value="{{ $city->code }}"
|
||||
{{ isset($debitur->city_code) && $debitur->city_code == $city->code ? 'selected' : '' }}>
|
||||
@if(isset($cities))
|
||||
@foreach($cities as $city)
|
||||
@if(isset($debitur))
|
||||
<option value="{{ $city->code }}" {{ isset($debitur->city_code) && $debitur->city_code == $city->code?'selected' : '' }}>
|
||||
{{ $city->name }}
|
||||
</option>
|
||||
@else
|
||||
@@ -160,20 +147,18 @@
|
||||
@endif
|
||||
</select>
|
||||
@error('city_code')
|
||||
<em class="text-sm alert text-danger">{{ $message }}</em>
|
||||
<em class="text-sm alert text-danger">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-col gap-2 mt-2 w-full lg:flex-row lg:mt-5">
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<select required id="district_code" name="district_code"
|
||||
class="select w-full @error('district_code') border-danger bg-danger-light @enderror">
|
||||
<select required id="district_code" name="district_code" class="select w-full @error('district_code') border-danger bg-danger-light @enderror">
|
||||
<option value="">Select District</option>
|
||||
@if (isset($districts))
|
||||
@foreach ($districts as $district)
|
||||
@if (isset($debitur))
|
||||
<option value="{{ $district->code }}"
|
||||
{{ isset($debitur->district_code) && $debitur->district_code == $district->code ? 'selected' : '' }}>
|
||||
@if(isset($districts))
|
||||
@foreach($districts as $district)
|
||||
@if(isset($debitur))
|
||||
<option value="{{ $district->code }}" {{ isset($debitur->district_code) && $debitur->district_code == $district->code?'selected' : '' }}>
|
||||
{{ $district->name }}
|
||||
</option>
|
||||
@else
|
||||
@@ -186,18 +171,16 @@
|
||||
@endif
|
||||
</select>
|
||||
@error('district_code')
|
||||
<em class="text-sm alert text-danger">{{ $message }}</em>
|
||||
<em class="text-sm alert text-danger">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<select required id="village_code" name="village_code"
|
||||
class="select w-full @error('district_code') border-danger bg-danger-light @enderror">
|
||||
<select required id="village_code" name="village_code" class="select w-full @error('district_code') border-danger bg-danger-light @enderror">
|
||||
<option value="">Select Village</option>
|
||||
@if (isset($villages))
|
||||
@foreach ($villages as $village)
|
||||
@if (isset($debitur))
|
||||
<option value="{{ $village->code }}"
|
||||
{{ isset($debitur->village_code) && $debitur->village_code == $village->code ? 'selected' : '' }}>
|
||||
@if(isset($villages))
|
||||
@foreach($villages as $village)
|
||||
@if(isset($debitur))
|
||||
<option value="{{ $village->code }}" {{ isset($debitur->village_code) && $debitur->village_code == $village->code?'selected' : '' }}>
|
||||
{{ $village->name }}
|
||||
</option>
|
||||
@else
|
||||
@@ -210,23 +193,20 @@
|
||||
@endif
|
||||
</select>
|
||||
@error('district_code')
|
||||
<em class="text-sm alert text-danger">{{ $message }}</em>
|
||||
<em class="text-sm alert text-danger">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input required class="input @error('postal_code') border-danger bg-danger-light @enderror"
|
||||
type="number" id="postal_code" name="postal_code"
|
||||
value="{{ $debitur->postal_code ?? '' }}" placeholder="Postal Code">
|
||||
<input required class="input @error('postal_code') border-danger bg-danger-light @enderror" type="number" id="postal_code" name="postal_code" value="{{ $debitur->postal_code ?? '' }}" placeholder="Postal Code">
|
||||
@error('postal_code')
|
||||
<em class="text-sm alert text-danger">{{ $message }}</em>
|
||||
<em class="text-sm alert text-danger">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-row mt-2 w-full lg:mt-5">
|
||||
<textarea required class="textarea @error('address') border-danger bg-danger-light @enderror" rows="3"
|
||||
id="address" name="address" placeholder="Alamat Lengkap">{{ $debitur->address ?? '' }}</textarea>
|
||||
<textarea required class="textarea @error('address') border-danger bg-danger-light @enderror" rows="3" id="address" name="address" placeholder="Alamat Lengkap">{{ $debitur->address ?? '' }}</textarea>
|
||||
@error('address')
|
||||
<em class="text-sm alert text-danger">{{ $message }}</em>
|
||||
<em class="text-sm alert text-danger">{{ $message }}</em>
|
||||
@enderror
|
||||
</div>
|
||||
</div>
|
||||
@@ -239,7 +219,7 @@
|
||||
</form>
|
||||
@push('scripts')
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const form = document.getElementById('debitur-form');
|
||||
const nameInput = form.querySelector('input[name="name"]');
|
||||
const provinceSelect = form.querySelector('#province_code');
|
||||
@@ -339,7 +319,7 @@
|
||||
return isValid;
|
||||
}
|
||||
|
||||
form.addEventListener('submit', function(event) {
|
||||
form.addEventListener('submit', function (event) {
|
||||
const isValid =
|
||||
validateBranch() &&
|
||||
validateCIF() &&
|
||||
@@ -356,7 +336,7 @@
|
||||
}
|
||||
});
|
||||
|
||||
submitButton.addEventListener('click', function(event) {
|
||||
submitButton.addEventListener('click', function (event) {
|
||||
if (!validateAllFields()) {
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@
|
||||
@foreach($dokumen_jaminan as $index => $dokumen)
|
||||
<div class="flex items-center justify-between flex-wrap my-2.5 gap-2">
|
||||
<span class="text-2xs text-gray-600 uppercase pl-3">
|
||||
{{ $loop->index+1 }}. Nomor : {{ $dokumen_nomor[$index] }}
|
||||
{{ $loop->index+1 }}. Nomor : {{ $dokumen_nomor[$index] ?? '' }}
|
||||
</span>
|
||||
<div>
|
||||
@if(in_array(Auth::user()->roles[0]->name,['administrator','pemohon-eo']))
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
|
||||
@section('content')
|
||||
<div class="grid">
|
||||
<div class="min-w-full border card border-agi-100 card-grid" data-datatable="false" data-datatable-page-size="10"
|
||||
data-datatable-state-save="false" id="debitur-table" data-api-url="{{ route('debitur.datatables') }}">
|
||||
<div class="min-w-full border card border-agi-100 card-grid" data-datatable="false" data-datatable-page-size="10" data-datatable-state-save="false" id="debitur-table" data-api-url="{{ route('debitur.datatables') }}">
|
||||
<div class="flex-wrap py-5 card-header bg-agi-50">
|
||||
<h3 class="card-title">
|
||||
Daftar Debitur
|
||||
@@ -21,7 +20,7 @@
|
||||
<div class="flex flex-wrap gap-2.5">
|
||||
<div class="h-[24px] border border-r-gray-200"></div>
|
||||
<a class="btn btn-sm btn-light" href="{{ route('debitur.export') }}"> Export to Excel </a>
|
||||
@if (auth()->user()->hasAnyRole(['administrator', 'pemohon-ao']))
|
||||
@if(auth()->user()->hasAnyRole(['administrator', 'pemohon-ao']))
|
||||
<a class="btn btn-sm btn-primary" href="{{ route('debitur.create') }}"> Tambah Debitur </a>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
@@ -44,111 +44,119 @@
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
|
||||
<div class="card border border-agi-100 card-grid min-w-full" data-datatable="false" data-datatable-page-size="10"
|
||||
<div class="grid gap-5 mx-auto w-full lg:gap-7.5">
|
||||
|
||||
|
||||
<!-- Filter Card -->
|
||||
<div class="border card border-agi-100">
|
||||
<div class="py-5 card-header bg-agi-50">
|
||||
<h3 class="card-title">Filter Laporan</h3>
|
||||
</div>
|
||||
<div class="grid gap-4 card-body">
|
||||
<!-- Search field at the top, full width -->
|
||||
<div class="flex flex-col w-full">
|
||||
<label class="mb-1 text-sm font-medium">Pencarian</label>
|
||||
<label class="input input-sm">
|
||||
<i class="ki-filled ki-magnifier"></i>
|
||||
<input placeholder="Search Laporan Penilaian Jaminan" id="search" type="text" value="">
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<!-- Other filter fields in grid layout -->
|
||||
<div class="grid grid-cols-1 gap-4 md:grid-cols-2 lg:grid-cols-4">
|
||||
<div class="flex flex-col">
|
||||
<label class="mb-1 text-base font-medium">Tanggal Awal</label>
|
||||
<label class="input">
|
||||
<input placeholder="Tanggal Awal" id="start_date" type="date">
|
||||
</label>
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<label class="mb-1 text-base font-medium">Tanggal Akhir</label>
|
||||
<label class="input">
|
||||
<input placeholder="Tanggal Akhir" id="end_date" type="date">
|
||||
</label>
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
<label class="mb-1 text-base font-medium">Cabang</label>
|
||||
<select class="select tomselect" id="branch_filter">
|
||||
<option value="">Semua Cabang</option>
|
||||
@foreach (\Modules\Basicdata\Models\Branch::where('status', 1)->get() as $branch)
|
||||
<option value="{{ $branch->id }}">{{ $branch->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
<div class="flex flex-col">
|
||||
|
||||
<label class="mb-1 text-base font-medium">Laporan</label>
|
||||
<select class="select tomselect" name="laporan[]" id="laporan" multiple>
|
||||
<option value="">Semua Laporan</option>
|
||||
@php
|
||||
$status_laporan = ['Standar', 'Sederhana', 'Memo', 'Resume', 'Call Report', 'RAP'];
|
||||
@endphp
|
||||
@foreach ($status_laporan as $item)
|
||||
<option value="{{ strtolower($item) }}">{{ $item }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Buttons row at the bottom -->
|
||||
<div class="grid grid-cols-1 gap-4 mt-2 md:grid-cols-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>
|
||||
<button class="btn btn-sm btn-light" id="export-btn">
|
||||
<i class="ki-outline ki-file-down fs-2 me-1"></i>
|
||||
Export to Excel
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="min-w-full border card border-agi-100 card-grid" data-datatable="false" data-datatable-page-size="10"
|
||||
data-datatable-state-save="false" id="laporan-penilai-jaminan-table"
|
||||
data-api-url="{{ route('laporan-penilai-jaminan.datatables') }}">
|
||||
<div class="card-header bg-agi-50 py-5 flex-wrap">
|
||||
<div class="flex-wrap py-5 card-header bg-agi-50">
|
||||
<h3 class="card-title">
|
||||
Daftar Laporan Penilai Jaminan
|
||||
</h3>
|
||||
<div class="flex flex-wrap gap-2 lg:gap-5">
|
||||
<div class="flex">
|
||||
<label class="input">
|
||||
Start Date
|
||||
<input placeholder="Tanggal Awal" id="tanggal_awal" type="date">
|
||||
</label>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<label class="input">
|
||||
End Date
|
||||
<input placeholder="Tanggal Akhir" id="tanggal_akhir" type="date">
|
||||
</label>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<button class="btn btn-primary" id="filter_tanggal">Filter</button>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<label class="input "> <i class="ki-filled ki-magnifier"> </i>
|
||||
<input placeholder="Search Laporan" id="search" type="text" value="">
|
||||
</label>
|
||||
</div>
|
||||
<div class="flex">
|
||||
<!-- Custom dropdown for status filter -->
|
||||
<div class="dropdown" data-dropdown="true" data-dropdown-trigger="click">
|
||||
<button class="dropdowns-toggle btn btn-light inline-flex justify-between w-full items-center">
|
||||
Pilih Type Laporan
|
||||
<i class="ki-outline ki-down dropdown-open:hidden">
|
||||
</i>
|
||||
<i class="ki-outline ki-up hidden dropdown-open:block">
|
||||
</i>
|
||||
</button>
|
||||
<div
|
||||
class="dropdowns-content w-full max-w-56 py-2 absolute mt-2 origin-top-right z-50 bg-white rounded-md shadow-lg ring-1 ring-black ring-opacity-5">
|
||||
<div class="menu menu-default flex flex-col w-full">
|
||||
<!-- Checkbox untuk All Status -->
|
||||
<div class="menu-item">
|
||||
<label class="menu-link flex items-center px-4 py-2 text-sm text-gray-700">
|
||||
<input id="select-all" type="checkbox"
|
||||
class="form-checkbox h-4 w-4 text-blue-600">
|
||||
<span class="ml-2">All Status</span>
|
||||
</label>
|
||||
</div>
|
||||
<!-- Dinamis Status dari Backend -->
|
||||
@php
|
||||
$status_laporan = [
|
||||
'Standar',
|
||||
'Sederhana',
|
||||
'Memo',
|
||||
'Resume',
|
||||
'Call Report',
|
||||
'RAP',
|
||||
];
|
||||
@endphp
|
||||
@foreach ($status_laporan as $item)
|
||||
<div class="menu-item">
|
||||
<label class="menu-link flex items-center px-4 py-2 text-sm text-gray-700">
|
||||
<input type="checkbox"
|
||||
class="form-checkbox status-checkbox h-4 w-4 text-blue-600"
|
||||
value="{{ strtolower($item) }}">
|
||||
<span class="ml-2">{{ $item }}</span>
|
||||
</label>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex flex-wrap gap-2.5">
|
||||
<div class="h-[24px] border border-r-gray-200"></div>
|
||||
<button class="btn btn-light" id="export-button">
|
||||
Export Excel
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="card-body">
|
||||
<div class="scrollable-x-auto">
|
||||
<table class="table table-auto table-border align-middle text-gray-700 font-medium text-sm"
|
||||
<table class="table text-sm font-medium text-gray-700 align-middle table-auto table-border"
|
||||
data-datatable-table="true">
|
||||
<thead>
|
||||
<tr>
|
||||
<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"
|
||||
id="check-all" />
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="nomor_registrasi">
|
||||
<span class="sort"><span class="sort-label">Nomor Registrasi</span>
|
||||
<span class="sort-icon"></span>
|
||||
</span>
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="tanggal_permohonan">
|
||||
<span class="sort"> <span class="sort-label"> Tanggal Permohonan </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="branch">
|
||||
<span class="sort"> <span class="sort-label"> Cabang </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="user_id">
|
||||
<span class="sort"><span class="sort-label">User Pemohon</span>
|
||||
<span class="sort"><span class="sort-label">Pemohon</span>
|
||||
<span class="sort-icon"></span>
|
||||
</span>
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="debitur_id">
|
||||
<span class="sort"><span class="sort-label">Debitur</span>
|
||||
<span class="sort"><span class="sort-label">Nama Debitur</span>
|
||||
<span class="sort-icon"></span>
|
||||
</span>
|
||||
</th>
|
||||
@@ -157,29 +165,34 @@
|
||||
<span class="sort-icon"></span>
|
||||
</span>
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="tujuan_penilaian_id">
|
||||
<span class="sort"><span class="sort-label">Jenis Jaminan</span>
|
||||
<span class="sort-icon"></span>
|
||||
</span>
|
||||
<th class="min-w-[150px]" data-datatable-column="jenis_agunan">
|
||||
<span class="sort"> <span class="sort-label"> Jenis Jaminan </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
|
||||
<th class="min-w-[150px]" data-datatable-column="laporan">
|
||||
<span class="sort"><span class="sort-label">Laporan</span>
|
||||
<span class="sort-icon"></span>
|
||||
</span>
|
||||
</th>
|
||||
|
||||
<th class="" data-datatable-column="actions">
|
||||
<span class="sort"><span class="sort-label">Actions</span>
|
||||
<span class="sort-icon"></span>
|
||||
</span>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
<div
|
||||
class="card-footer justify-center md:justify-between flex-col md:flex-row gap-3 text-gray-600 text-2sm font-medium">
|
||||
<div class="flex items-center gap-2">
|
||||
class="flex-col gap-3 justify-center font-medium text-gray-600 card-footer md:justify-between md:flex-row text-2sm">
|
||||
<div class="flex gap-2 items-center">
|
||||
Show
|
||||
<select class="select select-sm w-16" data-datatable-size="true" name="perpage"> </select> per
|
||||
<select class="w-16 select select-sm" data-datatable-size="true" name="perpage"> </select> per
|
||||
page
|
||||
</div>
|
||||
<div class="flex items-center gap-4">
|
||||
<div class="flex gap-4 items-center">
|
||||
<span data-datatable-info="true"> </span>
|
||||
<div class="pagination" data-datatable-pagination="true">
|
||||
</div>
|
||||
@@ -191,34 +204,49 @@
|
||||
|
||||
<!-- Form tersembunyi untuk export -->
|
||||
<form id="export-form" action="{{ route('laporan-penilai-jaminan.export') }}" method="GET" class="hidden">
|
||||
<input type="hidden" name="tanggal_awal" id="export_tanggal_awal">
|
||||
<input type="hidden" name="tanggal_akhir" id="export_tanggal_akhir">
|
||||
<input type="hidden" name="start_date" id="export_tanggal_awal">
|
||||
<input type="hidden" name="end_date" id="export_tanggal_akhir">
|
||||
<input type="hidden" name="status" id="export_status">
|
||||
<input type="hidden" name="branch_id" id="export_branch_id">
|
||||
<input type="hidden" name="laporan" id="export_laporan">
|
||||
<input type="hidden" name="selected_ids" id="export_selected_ids">
|
||||
<input type="hidden" name="export_type" id="export_type" value="all">
|
||||
<input type="hidden" id="export_search" name="search">
|
||||
</form>
|
||||
@endsection
|
||||
|
||||
|
||||
@push('scripts')
|
||||
<script type="module">
|
||||
const element = document.querySelector('#laporan-penilai-jaminan-table');
|
||||
|
||||
const searchInput = document.getElementById('search');
|
||||
const tanggalAwalInput = document.getElementById('tanggal_awal');
|
||||
const tanggalAkhirInput = document.getElementById('tanggal_akhir');
|
||||
const startDateInput = document.getElementById('start_date');
|
||||
const endDateInput = document.getElementById('end_date');
|
||||
const branchFilter = document.getElementById('branch_filter');
|
||||
const laporanFilter = document.getElementById('laporan');
|
||||
const filterTanggalButton = document.getElementById('filter_tanggal');
|
||||
const selectAllCheckbox = document.getElementById('select-all');
|
||||
const exportButton = document.getElementById('export-btn');
|
||||
|
||||
const selectAllCheckbox = document.getElementById('check-all');
|
||||
const statusCheckboxes = document.querySelectorAll('.status-checkbox');
|
||||
|
||||
// Export elements
|
||||
const exportForm = document.getElementById('export-form');
|
||||
const exportButton = document.getElementById('export-button');
|
||||
const exportTanggalAwal = document.getElementById('export_tanggal_awal');
|
||||
const exportTanggalAkhir = document.getElementById('export_tanggal_akhir');
|
||||
const exportStartDate = document.getElementById('export_tanggal_awal');
|
||||
const exportEndDate = document.getElementById('export_tanggal_akhir');
|
||||
const exportBranchId = document.getElementById('export_branch_id');
|
||||
const exportLaporan = document.getElementById('export_laporan');
|
||||
const exportStatus = document.getElementById('export_status');
|
||||
const exportSelectedIds = document.getElementById('export_selected_ids');
|
||||
const exportType = document.getElementById('export_type');
|
||||
|
||||
const exportSearch = document.getElementById('export_search');
|
||||
const apiUrl = element.getAttribute('data-api-url');
|
||||
|
||||
// Simple pagination state management
|
||||
let currentPage = 1;
|
||||
let isReturningFromDetail = false;
|
||||
|
||||
const dataTableOptions = {
|
||||
apiEndpoint: apiUrl,
|
||||
pageSize: 5,
|
||||
@@ -245,12 +273,24 @@
|
||||
nomor_registrasi: {
|
||||
title: 'Nomor Registrasi',
|
||||
},
|
||||
|
||||
tanggal_permohonan: {
|
||||
title: 'Tanggal Permohonan',
|
||||
render: (item, data) => {
|
||||
return data.tanggal_permohonan ? window.formatTanggalIndonesia(data.tanggal_permohonan) :
|
||||
'-';
|
||||
},
|
||||
},
|
||||
branch: {
|
||||
title: 'Cabang',
|
||||
render: (item, data) => {
|
||||
return data.branch && data.branch.name ? `${data.branch.name}` : '-';
|
||||
},
|
||||
},
|
||||
user_id: {
|
||||
title: 'User Pemohon',
|
||||
render: (item, data) => {
|
||||
return data.user && data.user.name ? `${data.user.name}` : '-';
|
||||
},
|
||||
return data?.user?.name ?? data?.mig_nama_ao ?? '-';
|
||||
}
|
||||
},
|
||||
debitur_id: {
|
||||
title: 'Debitur',
|
||||
@@ -265,18 +305,18 @@
|
||||
`${data.tujuan_penilaian.name}` : '-';
|
||||
},
|
||||
},
|
||||
jenis_jaminan_id: {
|
||||
jenis_agunan: {
|
||||
title: 'Jenis Jaminan',
|
||||
render: (item, data) => {
|
||||
const jenisJaminan = data.dokumenjaminan.map(d => d.jenis_jaminan.name).join(', ');
|
||||
return jenisJaminan || '-';
|
||||
}
|
||||
return data.dokumenjaminan.map((item) => {
|
||||
return item.jenis_jaminan ? item.jenis_jaminan.name : '-';
|
||||
}).join(', ');
|
||||
},
|
||||
},
|
||||
laporan: {
|
||||
title: 'Status',
|
||||
render: (item, data) => {
|
||||
let badgeClass = '';
|
||||
|
||||
const statusLaporan = data.penilai?.type_penilai || '-';
|
||||
|
||||
switch (statusLaporan.toLowerCase()) {
|
||||
@@ -302,17 +342,114 @@
|
||||
return `<span class="badge ${badgeClass}">${statusLaporan}</span>`;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
title: 'Action',
|
||||
render: (item, data) => {
|
||||
const status = data.status;
|
||||
const dokumenjaminan = data.dokumenjaminan || [];
|
||||
|
||||
return `
|
||||
<div class="flex flex-nowrap gap-1 justify-center">
|
||||
${
|
||||
['done'].includes(status) ?
|
||||
dokumenjaminan.map(dokumen => {
|
||||
return `
|
||||
<a class="btn btn-sm btn-primary" href="surveyor/print-out-inspeksi/${data.id}/${dokumen.id}/${dokumen.jenis_jaminan_id}">
|
||||
<i class="ki-outline ki-printer"></i>Inspeksi
|
||||
</a>
|
||||
<a class="btn btn-sm btn-info detail-btn" href="laporan-penilai-jaminan/show/${data.id}/${dokumen.id}/${dokumen.jenis_jaminan_id}">
|
||||
<i class="ki-filled ki-eye"></i>Lihat
|
||||
</a>
|
||||
<a class="btn btn-sm btn-success" href="penilai/print-out-laporan/${data.id}/${dokumen.id}/${dokumen.jenis_jaminan_id}">
|
||||
<i class="ki-filled ki-printer"></i>Laporan
|
||||
</a>
|
||||
`;
|
||||
}).join('') : ''
|
||||
}
|
||||
</div>
|
||||
`;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
};
|
||||
|
||||
let dataTable = new KTDataTable(element, dataTableOptions);
|
||||
const fromDetail = true;
|
||||
if (fromDetail) {
|
||||
isReturningFromDetail = true;
|
||||
console.log('Returning from detail page');
|
||||
// Remove the parameter from URL
|
||||
window.history.replaceState({}, document.title, window.location.pathname);
|
||||
setTimeout(() => {
|
||||
restoreCurrentPage();
|
||||
isReturningFromDetail = false;
|
||||
}, 500);
|
||||
}
|
||||
|
||||
function getCurrentPageFromDOM() {
|
||||
const activePage = document.querySelector('.pagination .btn.active');
|
||||
if (activePage) {
|
||||
const pageText = activePage.textContent.trim();
|
||||
const pageNum = parseInt(pageText);
|
||||
return isNaN(pageNum) ? 1 : pageNum;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
function saveCurrentPage() {
|
||||
const page = getCurrentPageFromDOM();
|
||||
currentPage = page;
|
||||
sessionStorage.setItem('currentTablePage', currentPage.toString());
|
||||
}
|
||||
|
||||
function restoreCurrentPage() {
|
||||
const savedPage = sessionStorage.getItem('currentTablePage');
|
||||
if (savedPage && savedPage !== '1') {
|
||||
currentPage = parseInt(savedPage);
|
||||
console.log('Restoring to page:', currentPage);
|
||||
|
||||
// Use the goPage method to navigate to the saved page
|
||||
dataTable.goPage(currentPage);
|
||||
}
|
||||
}
|
||||
|
||||
// Listen for pagination events to track current page
|
||||
element.addEventListener('pagination', function(e) {
|
||||
const page = e.detail.page;
|
||||
currentPage = page;
|
||||
console.log('Page changed to:', page);
|
||||
});
|
||||
|
||||
// Alternative: Listen for pagination button clicks
|
||||
document.addEventListener('click', function(e) {
|
||||
if (e.target.matches('.pagination .btn') && !e.target.closest('.detail-btn')) {
|
||||
setTimeout(() => {
|
||||
currentPage = getCurrentPageFromDOM();
|
||||
console.log('Current page updated to:', currentPage);
|
||||
}, 100);
|
||||
}
|
||||
});
|
||||
|
||||
// Detail page redirection
|
||||
document.addEventListener('click', function(e) {
|
||||
if (e.target.closest('.detail-btn')) {
|
||||
e.preventDefault();
|
||||
|
||||
// Save current page before navigating
|
||||
const currentPageNum = getCurrentPageFromDOM();
|
||||
currentPage = currentPageNum;
|
||||
sessionStorage.setItem('currentTablePage', currentPage.toString());
|
||||
console.log('Saving page before detail navigation:', currentPage);
|
||||
|
||||
const link = e.target.closest('.detail-btn');
|
||||
const href = link.getAttribute('href');
|
||||
window.location.href = href;
|
||||
}
|
||||
});
|
||||
|
||||
// Search functionality
|
||||
searchInput.addEventListener('input', function() {
|
||||
const searchValue = this.value.trim();
|
||||
dataTable.search(searchValue, true);
|
||||
applyDateFilter();
|
||||
});
|
||||
|
||||
// Filter by date range
|
||||
@@ -321,20 +458,30 @@
|
||||
});
|
||||
|
||||
function applyDateFilter() {
|
||||
const tanggalAwal = tanggalAwalInput.value;
|
||||
const tanggalAkhir = tanggalAkhirInput.value;
|
||||
const startDate = startDateInput.value;
|
||||
const endDate = endDateInput.value;
|
||||
const branch = branchFilter.value;
|
||||
const laporan = Array.from(laporanFilter.selectedOptions).map(option => option.value);
|
||||
|
||||
let filters = {};
|
||||
if (searchInput.value) {
|
||||
filters.search = searchInput.value;
|
||||
}
|
||||
|
||||
if (tanggalAwal) {
|
||||
filters.tanggal_awal = tanggalAwal
|
||||
if (startDate) {
|
||||
filters.start_date = startDate;
|
||||
}
|
||||
|
||||
if (tanggalAkhir) {
|
||||
filters.tanggal_akhir = tanggalAkhir
|
||||
if (endDate) {
|
||||
filters.end_date = endDate;
|
||||
}
|
||||
|
||||
if (branch) {
|
||||
filters.branch_id = branch;
|
||||
}
|
||||
|
||||
if (laporan.length > 0) {
|
||||
filters.laporan = laporan;
|
||||
}
|
||||
|
||||
dataTable.search(filters);
|
||||
@@ -361,10 +508,8 @@
|
||||
|
||||
if (selectedStatuses.length === 0) {
|
||||
dataTable.search('');
|
||||
console.log(selectedStatuses);
|
||||
} else {
|
||||
dataTable.search(selectedStatuses.join(','), true);
|
||||
console.log(selectedStatuses);
|
||||
}
|
||||
|
||||
dataTable.reload();
|
||||
@@ -374,30 +519,33 @@
|
||||
selectAllCheckbox.checked = allChecked;
|
||||
}
|
||||
|
||||
// Single export button functionality
|
||||
// Export functionality
|
||||
exportButton.addEventListener('click', function(e) {
|
||||
e.preventDefault();
|
||||
|
||||
// Check if any rows are selected
|
||||
const selectedIds = getSelectedRowIds();
|
||||
|
||||
// Determine export type based on context
|
||||
if (selectedIds.length > 0) {
|
||||
// If rows are selected, export those
|
||||
exportData({
|
||||
selected_ids: selectedIds,
|
||||
export_type: 'selected'
|
||||
});
|
||||
} else if (tanggalAwalInput.value && tanggalAkhirInput.value || getSelectedStatuses().length > 0) {
|
||||
// If filters are applied but no rows selected, export filtered data
|
||||
} else if (startDateInput.value && endDateInput.value || getSelectedStatuses().length > 0) {
|
||||
exportData({
|
||||
tanggal_awal: tanggalAwalInput.value,
|
||||
tanggal_akhir: tanggalAkhirInput.value,
|
||||
start_date: startDateInput.value,
|
||||
end_date: endDateInput.value,
|
||||
branch_id: branchFilter.value,
|
||||
laporan: Array.from(laporanFilter.selectedOptions).map(option => option.value),
|
||||
status: getSelectedStatuses(),
|
||||
search: searchInput.value,
|
||||
export_type: 'filtered'
|
||||
});
|
||||
} else if (searchInput.value) {
|
||||
exportData({
|
||||
search: searchInput.value,
|
||||
export_type: 'filtered'
|
||||
});
|
||||
} else {
|
||||
// If no selection and no filters, export all
|
||||
exportData({
|
||||
export_type: 'all'
|
||||
});
|
||||
@@ -405,14 +553,14 @@
|
||||
});
|
||||
|
||||
function exportData(filters = {}) {
|
||||
// Set filter values in the hidden form
|
||||
exportTanggalAwal.value = filters.tanggal_awal || '';
|
||||
exportTanggalAkhir.value = filters.tanggal_akhir || '';
|
||||
exportStartDate.value = filters.start_date || '';
|
||||
exportEndDate.value = filters.end_date || '';
|
||||
exportStatus.value = filters.status ? filters.status.join(',') : '';
|
||||
exportBranchId.value = filters.branch_id || '';
|
||||
exportLaporan.value = filters.laporan ? filters.laporan.join(',') : '';
|
||||
exportSelectedIds.value = filters.selected_ids ? filters.selected_ids.join(',') : '';
|
||||
exportType.value = filters.export_type || 'all';
|
||||
|
||||
// Submit the form
|
||||
exportSearch.value = filters.search || '';
|
||||
exportForm.submit();
|
||||
}
|
||||
|
||||
@@ -426,5 +574,12 @@
|
||||
const checkboxes = document.querySelectorAll('[data-datatable-row-check="true"]:checked');
|
||||
return Array.from(checkboxes).map(checkbox => checkbox.value);
|
||||
}
|
||||
|
||||
// Save page before leaving (only when not going to detail)
|
||||
window.addEventListener('beforeunload', function() {
|
||||
if (!isReturningFromDetail) {
|
||||
saveCurrentPage();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
117
resources/views/laporan-penilai-jaminan/show.blade.php
Normal file
117
resources/views/laporan-penilai-jaminan/show.blade.php
Normal file
@@ -0,0 +1,117 @@
|
||||
@extends('layouts.main')
|
||||
|
||||
@section('breadcrumbs')
|
||||
{{-- {{ Breadcrumbs::render(request()->route()->getName()) }} --}}
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
|
||||
<div class="card">
|
||||
<div class="card-header py-5 flex-wrap">
|
||||
<div class="card-title flex flex-row gap-1.5">
|
||||
<button id="tab-laporan" class="btn btn-sm btn-primary">Laporan</button>
|
||||
<button id="tab-hasil" class="btn btn-sm btn-light">Hasil Inspeksi</button>
|
||||
</div>
|
||||
<div class="flex items-wrap gap-2.5">
|
||||
<a href="{{ route('laporan-penilai-jaminan.index') }}" class="btn btn-xs btn-info"><i
|
||||
class="ki-filled ki-exit-left"></i>
|
||||
Back</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
@php
|
||||
$permohonan_id = request()->segment(3);
|
||||
$dokumen_id = request()->segment(4);
|
||||
$jenis_jaminan_id = request()->segment(5);
|
||||
@endphp
|
||||
|
||||
<div id="laporan" class="tab-content">
|
||||
<div class="floating-button">
|
||||
<a href="penilai/print-out-laporan/{{ $permohonan_id }}/{{ $dokumen_id }}/{{ $jenis_jaminan_id }}" class="btn btn-primary">
|
||||
Cetak Laporan
|
||||
<i class="ki-filled ki-printer"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@php
|
||||
$laporan = [
|
||||
'sederhana' => 'lpj::penilai.components.print-out-sederhana',
|
||||
'standar' => 'lpj::penilai.components.print-out-standar',
|
||||
'resume' => 'lpj::penilai.components.print-resume',
|
||||
'memo' => 'lpj::penilai.components.print-memo',
|
||||
'rap' => 'lpj::penilai.components.print-out-rap',
|
||||
'call-report' => 'penilai.components.print-out-call-report',
|
||||
];
|
||||
@endphp
|
||||
@if (array_key_exists($lpj->type_penilai, $laporan))
|
||||
@include($laporan[$lpj->type_penilai])
|
||||
@else
|
||||
<p>Tipe laporan tidak ditemukan.</p>
|
||||
@endif
|
||||
</div>
|
||||
<div id="hasil-inspeksi" class="tab-content hidden-tab">
|
||||
<div class="floating-button">
|
||||
<a href="surveyor/print-out-inspeksi/{{ $permohonan_id }}/{{ $dokumen_id }}/{{ $jenis_jaminan_id }}"
|
||||
class="btn btn-primary">
|
||||
Cetak Laporan
|
||||
<i class="ki-filled ki-printer"></i>
|
||||
</a>
|
||||
</div>
|
||||
@include('lpj::surveyor.components.print-out.main')
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const tabLaporan = document.getElementById('tab-laporan');
|
||||
const tabHasil = document.getElementById('tab-hasil');
|
||||
const laporanContent = document.getElementById('laporan');
|
||||
const hasilContent = document.getElementById('hasil-inspeksi');
|
||||
|
||||
tabLaporan.addEventListener('click', () => {
|
||||
tabLaporan.classList.add('btn-primary');
|
||||
tabLaporan.classList.remove('btn-light');
|
||||
tabHasil.classList.add('btn-light');
|
||||
tabHasil.classList.remove('btn-primary');
|
||||
laporanContent.classList.remove('hidden-tab');
|
||||
hasilContent.classList.add('hidden-tab');
|
||||
});
|
||||
|
||||
tabHasil.addEventListener('click', () => {
|
||||
tabHasil.classList.add('btn-primary');
|
||||
tabHasil.classList.remove('btn-light');
|
||||
tabLaporan.classList.add('btn-light');
|
||||
tabLaporan.classList.remove('btn-primary');
|
||||
laporanContent.classList.add('hidden-tab');
|
||||
hasilContent.classList.remove('hidden-tab');
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.hidden-tab {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.floating-button {
|
||||
position: fixed;
|
||||
bottom: 20px;
|
||||
right: 20px;
|
||||
z-index: 1000;
|
||||
}
|
||||
|
||||
.floating-button .btn {
|
||||
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
|
||||
border-radius: 50px;
|
||||
padding: 10px 20px;
|
||||
}
|
||||
|
||||
.floating-button .btn:hover {
|
||||
transform: scale(1.05);
|
||||
transition: transform 0.2s ease-in-out;
|
||||
}
|
||||
</style>
|
||||
|
||||
{{-- @include('lpj::surveyor.js.utils') --}}
|
||||
@endsection
|
||||
@@ -151,7 +151,7 @@
|
||||
user_id: {
|
||||
title: 'User Pemohon',
|
||||
render: (item, data) => {
|
||||
return `${data.user.name}`;
|
||||
return `${data.user?.name}`;
|
||||
},
|
||||
},
|
||||
tujuan_penilaian_id: {
|
||||
@@ -180,16 +180,16 @@
|
||||
jenis_fasilitas_kredit_id: {
|
||||
title: 'Fasilitas Kredit',
|
||||
render: (item, data) => {
|
||||
return `${data.jenis_fasilitas_kredit.name}`;
|
||||
return `${data.jenis_fasilitas_kredit?.name}`;
|
||||
}
|
||||
},
|
||||
tanggal_survei: {
|
||||
title: 'Tanggal Survei',
|
||||
render: (item, data) => {
|
||||
if (data.penilaian.waktu_penilaian) {
|
||||
return `${formatDate(new Date(data.penilaian.waktu_penilaian))}`;
|
||||
if (data.penilaian?.waktu_penilaian) {
|
||||
return `${formatDate(new Date(data.penilaian?.waktu_penilaian))}`;
|
||||
}
|
||||
return `${formatDate(new Date(data.penilaian.created_at))}`;
|
||||
return `${formatDate(new Date(data.penilaian?.created_at))}`;
|
||||
},
|
||||
},
|
||||
due_date_sla: {
|
||||
@@ -197,10 +197,10 @@
|
||||
render: (item, data) => {
|
||||
const tujuan_penilaian = data.tujuan_penilaian.name;
|
||||
const tipe_laporan = data.penilai?.type;
|
||||
const nilai_plafond = data.penilaian.nilaiPlafond?.name;
|
||||
let waktu_penilaian = new Date(data.penilaian.created_at);
|
||||
if (data.penilaian.waktu_penilaian) {
|
||||
waktu_penilaian = new Date(data.penilaian.waktu_penilaian);
|
||||
const nilai_plafond = data.penilaian?.nilaiPlafond?.name;
|
||||
let waktu_penilaian = new Date(data.penilaian?.created_at);
|
||||
if (data.penilaian?.waktu_penilaian) {
|
||||
waktu_penilaian = new Date(data.penilaian?.waktu_penilaian);
|
||||
}
|
||||
|
||||
if (tujuan_penilaian.name === "RAP") {
|
||||
|
||||
@@ -6,8 +6,7 @@
|
||||
|
||||
@section('content')
|
||||
<div class="grid gap-5 mx-auto w-full lg:gap-7.5">
|
||||
<div class="min-w-full border card border-agi-100 card-grid" data-datatable="false" data-datatable-page-size="10"
|
||||
data-datatable-state-save="false" id="noc-table" data-api-url="{{ route('noc.datatables.penyelesaian') }}">
|
||||
<div class="min-w-full border card border-agi-100 card-grid" data-datatable="false" data-datatable-page-size="10" data-datatable-state-save="false" id="noc-table" data-api-url="{{ route('noc.datatables.penyelesaian') }}">
|
||||
<div class="flex-wrap py-5 card-header bg-agi-50">
|
||||
<h3 class="card-title">
|
||||
Daftar NOC Penyelesaian
|
||||
|
||||
Reference in New Issue
Block a user