🔧(backend): Perbaikan & optimasi controller serta view untuk modul penilai dan surveyor
- PenilaiController: tambah eager loading relasi `penawaran` untuk kurangi N+1 query - RegistrasiFinalController: ubah filter status dari `spk` → `registrasi-final` - SurveyorController: perbaiki pengecekan jenisPenilaian dengan `in_array` (support External/Eksternal, case-insensitive) - SurveyorController: ubah field `tanggal_laporan` → `tgl_final_laporan` sesuai DB baru - SurveyorController: sanitasi koordinat lat/lon dengan menghapus koma untuk valid format - SurveyorController: perbaiki exception handling (`Exeception` → `\Exception`, `$th` → `$e`, tambah namespace lengkap) - SurveyorController: konsistensi penggunaan `Auth::user()` alih-alih `auth()->user()` - View pembayaran/index.blade.php: tambahkan safe navigation `data.debiture?.name` untuk hindari null error - View penilai/index.blade.php: cleanup baris kosong & perbaiki logika status pakai `data.penawaran?.status`
This commit is contained in:
@@ -622,7 +622,8 @@ class PenilaiController extends Controller
|
|||||||
'jenisfasilitasKredit',
|
'jenisfasilitasKredit',
|
||||||
'penilaian.userPenilai',
|
'penilaian.userPenilai',
|
||||||
'penilai',
|
'penilai',
|
||||||
'nilaiPlafond'
|
'nilaiPlafond',
|
||||||
|
'penawaran'
|
||||||
])->get();
|
])->get();
|
||||||
|
|
||||||
// Calculate the page count
|
// Calculate the page count
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
$query =PenawaranTender::query()
|
$query =PenawaranTender::query()
|
||||||
->select('penawaran.*', 'tujuan_penilaian_kjpp.name as tujuan_penilaian_kjpp_name')
|
->select('penawaran.*', 'tujuan_penilaian_kjpp.name as tujuan_penilaian_kjpp_name')
|
||||||
->leftJoin('tujuan_penilaian_kjpp', 'tujuan_penilaian_kjpp.id','=','penawaran.tujuan_penilaian_kjpp_id')
|
->leftJoin('tujuan_penilaian_kjpp', 'tujuan_penilaian_kjpp.id','=','penawaran.tujuan_penilaian_kjpp_id')
|
||||||
->where('penawaran.status','=','spk')
|
->where('penawaran.status','=','registrasi-final')
|
||||||
->withCount('penawarandetails');
|
->withCount('penawarandetails');
|
||||||
|
|
||||||
// Apply search filter if provided
|
// Apply search filter if provided
|
||||||
|
|||||||
@@ -794,12 +794,12 @@ class SurveyorController extends Controller
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
if ($permohonan->jenisPenilaian->name == "External") {
|
if (in_array(strtolower($permohonan->jenisPenilaian->name), ['external', 'eksternal'])) {
|
||||||
LaporanExternal::updateOrCreate(
|
LaporanExternal::updateOrCreate(
|
||||||
['permohonan_id' => $permohonan->id],
|
['permohonan_id' => $permohonan->id],
|
||||||
[
|
[
|
||||||
'nomor_laporan' => $permohonan->nomor_registrasi,
|
'nomor_laporan' => $permohonan->nomor_registrasi,
|
||||||
'tanggal_laporan' => now(),
|
'tgl_final_laporan' => now(),
|
||||||
'created_by' => Auth::id(),
|
'created_by' => Auth::id(),
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
@@ -1396,6 +1396,11 @@ class SurveyorController extends Controller
|
|||||||
}
|
}
|
||||||
public function storeDataPembanding(Request $request)
|
public function storeDataPembanding(Request $request)
|
||||||
{
|
{
|
||||||
|
$request->merge([
|
||||||
|
'kordinat_lat' => $request->get('kordinat_lat') ? str_replace(',', '', $request->get('kordinat_lat')) : null,
|
||||||
|
'kordinat_lng' => $request->get('kordinat_lng') ? str_replace(',', '', $request->get('kordinat_lng')) : null,
|
||||||
|
]);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
|
|
||||||
@@ -1847,10 +1852,10 @@ class SurveyorController extends Controller
|
|||||||
return redirect()
|
return redirect()
|
||||||
->route('basicdata.' . $type . '.index')
|
->route('basicdata.' . $type . '.index')
|
||||||
->with('success', 'created successfully');
|
->with('success', 'created successfully');
|
||||||
} catch (Exeception $e) {
|
} catch (\Exception $e) {
|
||||||
return redirect()
|
return redirect()
|
||||||
->route('basicdata.' . $type . '.index')
|
->route('basicdata.' . $type . '.index')
|
||||||
->with('error', $th->getMessage());
|
->with('error', $e->getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2116,7 +2121,7 @@ class SurveyorController extends Controller
|
|||||||
|
|
||||||
public function dataForDatatablesData(Request $request, $type)
|
public function dataForDatatablesData(Request $request, $type)
|
||||||
{
|
{
|
||||||
if (is_null(auth()->user()) || !$this->user->can('jenis_aset.view')) {
|
if (is_null(Auth::user()) || !$this->user->can('jenis_aset.view')) {
|
||||||
//abort(403, 'Sorry! You are not allowed to view users.');
|
//abort(403, 'Sorry! You are not allowed to view users.');
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2156,7 +2161,7 @@ class SurveyorController extends Controller
|
|||||||
if (array_key_exists($type, $models)) {
|
if (array_key_exists($type, $models)) {
|
||||||
$query = $models[$type]::query();
|
$query = $models[$type]::query();
|
||||||
} else {
|
} else {
|
||||||
throw new InvalidArgumentException("Invalid type: $type");
|
throw new \InvalidArgumentException("Invalid type: $type");
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($request->has('search') && !empty($request->get('search'))) {
|
if ($request->has('search') && !empty($request->get('search'))) {
|
||||||
@@ -2229,9 +2234,9 @@ class SurveyorController extends Controller
|
|||||||
$model = $modelClass::findOrFail($id);
|
$model = $modelClass::findOrFail($id);
|
||||||
$model->delete();
|
$model->delete();
|
||||||
return response()->json(['success' => true, 'message' => 'deleted successfully']);
|
return response()->json(['success' => true, 'message' => 'deleted successfully']);
|
||||||
} catch (ModelNotFoundException $e) {
|
} catch (\Illuminate\Database\Eloquent\ModelNotFoundException $e) {
|
||||||
return response()->json(['success' => false, 'message' => 'not found.'], 404);
|
return response()->json(['success' => false, 'message' => 'not found.'], 404);
|
||||||
} catch (Exception $e) {
|
} catch (\Exception $e) {
|
||||||
return response()->json(['success' => false, 'message' => 'Failed to delete.'], 500);
|
return response()->json(['success' => false, 'message' => 'Failed to delete.'], 500);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2387,14 +2392,14 @@ class SurveyorController extends Controller
|
|||||||
$path = $file->storeAs("public/surveyor/{$request->type}", $fileName);
|
$path = $file->storeAs("public/surveyor/{$request->type}", $fileName);
|
||||||
|
|
||||||
if ($path === false) {
|
if ($path === false) {
|
||||||
throw new Exception("Failed to store file for {$fileKey}");
|
throw new \Exception("Failed to store file for {$fileKey}");
|
||||||
}
|
}
|
||||||
if (isset($data[$fileKey]) && $data[$fileKey]) {
|
if (isset($data[$fileKey]) && $data[$fileKey]) {
|
||||||
$this->deleteFile($data[$fileKey]);
|
$this->deleteFile($data[$fileKey]);
|
||||||
}
|
}
|
||||||
return str_replace('public/', '', $path);
|
return str_replace('public/', '', $path);
|
||||||
} else {
|
} else {
|
||||||
throw new Exception("Invalid file upload for {$fileKey}");
|
throw new \Exception("Invalid file upload for {$fileKey}");
|
||||||
}
|
}
|
||||||
} elseif (isset($data[$fileKey]) && $data[$fileKey]) {
|
} elseif (isset($data[$fileKey]) && $data[$fileKey]) {
|
||||||
return $data[$fileKey];
|
return $data[$fileKey];
|
||||||
@@ -2423,14 +2428,14 @@ class SurveyorController extends Controller
|
|||||||
public function uploadFile($file, $type)
|
public function uploadFile($file, $type)
|
||||||
{
|
{
|
||||||
if (!$file->isValid()) {
|
if (!$file->isValid()) {
|
||||||
throw new Exception("Invalid file upload for {$type}");
|
throw new \Exception("Invalid file upload for {$type}");
|
||||||
}
|
}
|
||||||
|
|
||||||
$fileName = time() . '_' . $file->getClientOriginalName();
|
$fileName = time() . '_' . $file->getClientOriginalName();
|
||||||
$path = $file->storeAs("public/surveyor/{$type}", $fileName);
|
$path = $file->storeAs("public/surveyor/{$type}", $fileName);
|
||||||
|
|
||||||
if ($path === false) {
|
if ($path === false) {
|
||||||
throw new Exception("Failed to store file for {$type}");
|
throw new \Exception("Failed to store file for {$type}");
|
||||||
}
|
}
|
||||||
|
|
||||||
return str_replace('public/', '', $path);
|
return str_replace('public/', '', $path);
|
||||||
|
|||||||
@@ -195,7 +195,7 @@
|
|||||||
debitur_id: {
|
debitur_id: {
|
||||||
title: 'Debitur',
|
title: 'Debitur',
|
||||||
render: (item, data) => {
|
render: (item, data) => {
|
||||||
return `${data.debiture.name}`;
|
return `${data.debiture?.name}`;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
status_bayar: {
|
status_bayar: {
|
||||||
|
|||||||
@@ -218,9 +218,6 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return formatDate(waktu_penilaian);
|
return formatDate(waktu_penilaian);
|
||||||
|
|
||||||
},
|
},
|
||||||
@@ -228,7 +225,11 @@
|
|||||||
status: {
|
status: {
|
||||||
title: 'Status',
|
title: 'Status',
|
||||||
render: (item, data) => {
|
render: (item, data) => {
|
||||||
return `<span class="flex justify-center uppercase badge badge-sm badge-default">${data.status.replace(/-/g, ' ')}</span>`;
|
if (data.penawaran) {
|
||||||
|
return `<span class="flex justify-center uppercase badge badge-sm badge-default">${data.penawaran?.status.replace(/-/g, ' ')}</span>`;
|
||||||
|
}
|
||||||
|
|
||||||
|
//return `<span class="flex justify-center uppercase badge badge-sm badge-default">${data.status.replace(/-/g, ' ')}</span>`;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
@@ -238,7 +239,7 @@
|
|||||||
.status === 'paparan' || data.status === 'proses-paparan' || data.status ===
|
.status === 'paparan' || data.status === 'proses-paparan' || data.status ===
|
||||||
'paparan' || data.status == 'revisi-laporan' || data.status === 'done' || data
|
'paparan' || data.status == 'revisi-laporan' || data.status === 'done' || data
|
||||||
.status === 'revisi-paparan' || data.status === 'unfreeze-sla' || data.status ===
|
.status === 'revisi-paparan' || data.status === 'unfreeze-sla' || data.status ===
|
||||||
'reject-freeze') {
|
'reject-freeze' || data.penawaran?.status === 'registrasi-final') {
|
||||||
return `
|
return `
|
||||||
<div class="flex flex-nowrap gap-1.5 justify-center">
|
<div class="flex flex-nowrap gap-1.5 justify-center">
|
||||||
<a class="btn btn-sm btn-icon btn-clear btn-info" href="penilai/${data.id}/show">
|
<a class="btn btn-sm btn-icon btn-clear btn-info" href="penilai/${data.id}/show">
|
||||||
|
|||||||
Reference in New Issue
Block a user