diff --git a/app/Http/Controllers/DokumenJaminanController.php b/app/Http/Controllers/DokumenJaminanController.php
index 6c2411f..51364d9 100644
--- a/app/Http/Controllers/DokumenJaminanController.php
+++ b/app/Http/Controllers/DokumenJaminanController.php
@@ -383,7 +383,8 @@
public function bulkDownload()
{
$dokumenIds = request()->get('jaminan'); // Expecting an array of dokumen_jaminan_id
- $documents = DetailDokumenJaminan::where('dokumen_jaminan_id', $dokumenIds)->get();
+ $documents = DokumenJaminan::where('id', $dokumenIds)->with(['jenisJaminan', 'detail','debiture'])->get();
+
if ($documents->isEmpty()) {
return redirect()->back()->with('error', 'No documents found for the provided IDs.');
}
@@ -394,18 +395,24 @@
if ($zip->open($zipFilePath, ZipArchive::CREATE) === true) {
foreach ($documents as $document) {
- if($document->dokumen_jaminan) {
- $files = is_array(json_decode($document->dokumen_jaminan)) ? json_decode(
- $document->dokumen_jaminan,
- ) : [$document->dokumen_jaminan];
+ $jenisJaminan = $document->debiture->permohonan->nomor_registrasi ?? 'Uncategorized';
+ $folderName = $this->sanitizeFolderName($jenisJaminan);
- foreach ($files as $file) {
- $filePath = storage_path('app/public/' . $file);
- if (file_exists($filePath)) {
- $zip->addFile($filePath, basename($filePath));
- } else {
- // Log or display an error message for missing files
- return redirect()->back()->with('error', 'File not found: ' . $filePath);
+ foreach ($document->detail as $detail) {
+ if($detail->dokumen_jaminan) {
+ $folderJaminanName = $this->sanitizeFolderName($detail->jenisLegalitasJaminan->name?? 'Uncategorized');
+ $files = is_array(json_decode($detail->dokumen_jaminan))
+ ? json_decode($detail->dokumen_jaminan)
+ : [$detail->dokumen_jaminan];
+
+ foreach ($files as $file) {
+ $filePath = storage_path('app/public/' . $file);
+ if (file_exists($filePath)) {
+ $zip->addFile($filePath, $folderName . '/' .$folderJaminanName.'/'.basename($filePath));
+ } else {
+ // Log or display an error message for missing files
+ \Log::warning('File not found: ' . $filePath);
+ }
}
}
}
@@ -423,7 +430,13 @@
'Content-Type' => 'application/zip',
'Content-Disposition' => 'attachment; filename="' . $zipFileName . '"',
'Content-Length' => filesize($zipFilePath),
- ])->deleteFileAfterSend(false);
+ ])->deleteFileAfterSend(true);
+ }
+
+ private function sanitizeFolderName($name)
+ {
+ // Remove any characters that are not allowed in folder names
+ return preg_replace('/[^a-zA-Z0-9_\-]/', '_', $name);
}
diff --git a/app/Http/Controllers/PermohonanController.php b/app/Http/Controllers/PermohonanController.php
index 2f9f357..3a0956d 100644
--- a/app/Http/Controllers/PermohonanController.php
+++ b/app/Http/Controllers/PermohonanController.php
@@ -225,6 +225,10 @@
// Get the total count of records
$totalRecords = $query->count();
+ $size = $request->get('size', 10);
+ if ($size == 0) {
+ $size = 10;
+ }
// Apply pagination if provided
if ($request->has('page') && $request->has('size')) {
@@ -239,13 +243,13 @@
$filteredRecords = $query->count();
// Get the data for the current page
- $data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian'])->get();
+ $data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian','penilaian'])->get();
// Calculate the page count
- $pageCount = ceil($totalRecords / $request->get('size'));
+ $pageCount = ceil($totalRecords / $size);
// Calculate the current page number
- $currentPage = 0 + 1;
+ $currentPage = max(1, $request->get('page', 1));
// Return the response data as a JSON object
return response()->json([
diff --git a/app/Http/Controllers/RegistrasiController.php b/app/Http/Controllers/RegistrasiController.php
index 99e5f4f..6b69cd0 100644
--- a/app/Http/Controllers/RegistrasiController.php
+++ b/app/Http/Controllers/RegistrasiController.php
@@ -4,28 +4,14 @@
use App\Http\Controllers\Controller;
use Exception;
- use Illuminate\Http\Request;
- use Maatwebsite\Excel\Facades\Excel;
- // use Modules\Location\Models\City;
- // use Modules\Location\Models\District;
- // use Modules\Location\Models\Province;
- // use Modules\Location\Models\Village;
- // use Modules\Lpj\Exports\DebitureExport;
- // use Modules\Lpj\Http\Requests\DebitureRequest;
- // use Modules\Lpj\Http\Requests\DokumenJaminanRequest;
- // use Modules\Lpj\Models\Branch;
- // use Modules\Lpj\Models\Debiture;
- // use Modules\Lpj\Models\DokumenJaminan;
- // use Modules\Lpj\Models\JenisJaminan;
- // use Modules\Lpj\Models\JenisLegalitasJaminan;
- // use Modules\Lpj\Models\PemilikJaminan;
- use Modules\Lpj\Models\Permohonan;
- use Modules\Lpj\Models\JenisPenilaian;
- use Modules\Lpj\Models\Regions;
use Illuminate\Http\JsonResponse;
- use Illuminate\Support\Facades\Validator;
+ use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth;
-
+ use Illuminate\Support\Facades\Validator;
+ use Maatwebsite\Excel\Facades\Excel;
+ use Modules\Lpj\Models\JenisPenilaian;
+ use Modules\Lpj\Models\Permohonan;
+ use Modules\Lpj\Models\Regions;
class RegistrasiController extends Controller
{
@@ -43,7 +29,7 @@
}
// Retrieve data from the database
- $query = Permohonan::query()->where('status','=','preregister');
+ $query = Permohonan::query()->where('status', '=', 'preregister');
// Apply search filter if provided
if ($request->has('search') && !empty($request->get('search'))) {
@@ -101,143 +87,132 @@
'data' => $data,
]);
}
-
+
public function edit($id)
{
return view('lpj::registrasi.edit', compact('id'));
}
- public function setData(Request $request): JsonResponse
- {
- $data = array();
- $datas = array();
+ public function setData(Request $request)
+ : JsonResponse {
+ $data = [];
+ $datas = [];
if (request()->ajax()) {
- $id = $request->id;
+ $id = $request->id;
$datas = Permohonan::find($id);
-
+
if ($datas) {
- $jenisPenilaians=null;
- $regions=null;
- $regions=Regions::pluck('name', 'id');
- $jenisPenilaians=JenisPenilaian::pluck('name', 'id');
-
- $data['status'] = 'success';
- $data['regions'] = $regions;
- $data['jenisPenilaians'] = $jenisPenilaians;
- $data['datas'] = $datas;
- $data['message'] ['message_success'] = array("data successfully found");
+ $jenisPenilaians = null;
+ $regions = null;
+ $regions = Regions::pluck('name', 'id');
+ $jenisPenilaians = JenisPenilaian::pluck('name', 'id');
+
+ $data['status'] = 'success';
+ $data['regions'] = $regions;
+ $data['jenisPenilaians'] = $jenisPenilaians;
+ $data['datas'] = $datas;
+ $data['message'] ['message_success'] = ["data successfully found"];
} else {
- $data['status'] = 'error';
- $data['datas'] = null;
- $data['message'] ['message_data'] = array("data not found");
+ $data['status'] = 'error';
+ $data['datas'] = null;
+ $data['message'] ['message_data'] = ["data not found"];
}
} else {
- $data['status'] = 'error';
- $data['message'] ['message_ajax'] = array("no ajax request");
+ $data['status'] = 'error';
+ $data['message'] ['message_ajax'] = ["no ajax request"];
}
return response()->json($data);
}
- public function update(Request $request, $id): JsonResponse
- {
+ public function update(Request $request, $id)
+ : JsonResponse {
// init
- $data = array();
- $dataku = array();
+ $data = [];
+ $dataku = [];
$tindakan = null;
if (request()->ajax()) {
$validator = RegistrasiController::rulesEditnya($request, $id);
-
+
if ($validator['fails']) {
$data['message'] = $validator['errors'];
- $data['status'] = 'error';
- }
- else
- {
+ $data['status'] = 'error';
+ } else {
try {
+ $tindakan = $request->tindakan;
+ $dataku = [
+ 'registrasi_by' => Auth::id(),
+ 'registrasi_at' => now(),
+ ];
- $tindakan=$request->tindakan;
- $dataku = ['registrasi_by' => Auth::id(),
- 'registrasi_at' => now()
- ];
-
- if($tindakan==0)
- {
- $dataku['jenis_penilaian_id'] =$request->jenis_penilaian;
- $dataku['region_id'] =$request->region;
- $dataku['status'] = 'registered';
- if($request->catatan2)
- $dataku['registrasi_catatan'] =$request->catatan2;
- }
- else
- {
- $dataku['registrasi_catatan'] =$request->catatan;
- $dataku['status'] = 'revisi';
+ if ($tindakan == 0) {
+ $dataku['jenis_penilaian_id'] = $request->jenis_penilaian;
+ $dataku['region_id'] = $request->region;
+ $dataku['status'] = 'registered';
+ if ($request->catatan2) {
+ $dataku['registrasi_catatan'] = $request->catatan2;
+ }
+ } else {
+ $dataku['registrasi_catatan'] = $request->catatan;
+ $dataku['status'] = 'revisi';
}
- $data['dataku'] =$dataku;
-
+ $data['dataku'] = $dataku;
+
$modal = Permohonan::find($id);
-
+
$modal->update($dataku);
- //
- $data['status'] = 'success';
- $data['message'] ['message_success'] = array('Regitrasi '.$modal->nomor_registrasi.' successfully');
+ //
+ $data['status'] = 'success';
+ $data['message'] ['message_success'] = ['Regitrasi ' . $modal->nomor_registrasi . ' successfully'];
} catch (Exception $e) {
-
- $data['status'] = 'error';
- $data['message'] ['message_try_catch'] = array('Regitrasi updated failed.');
+ $data['status'] = 'error';
+ $data['message'] ['message_try_catch'] = ['Regitrasi updated failed.'];
}
}
-
} else {
- $data['status'] = 'error';
- $data['message'] ['message_ajax'] = array("no ajax request");
+ $data['status'] = 'error';
+ $data['message'] ['message_ajax'] = ["no ajax request"];
}
return response()->json($data);
-
}
public function rulesEditnya($request, $id)
{
- $tindakan=null;
- $jenis_penilaian=null;
- $validate_catatan='';
- $tindakan=$request->tindakan;
- $jenis_penilaian=$request->jenis_penilaian;
-
+ $tindakan = null;
+ $jenis_penilaian = null;
+ $validate_catatan = '';
+ $tindakan = $request->tindakan;
+ $jenis_penilaian = $request->jenis_penilaian;
+
$validateIt = [
// 'name' diambil dari definisi parameter yang di kirim pada POST Data
'tindakan' => 'required',
];
$messageIt = [
- 'tindakan.required' => 'Silahkan pilih Tindakan'
+ 'tindakan.required' => 'Silahkan pilih Tindakan',
];
- if($tindakan==0)
- {
- $validateIt['jenis_penilaian'] = ['required'];
- $messageIt ['jenis_penilaian.required']= 'Silahkan pilih Jenis Penilaian';
+ if ($tindakan == 0) {
+ $validateIt['jenis_penilaian'] = ['required'];
+ $messageIt ['jenis_penilaian.required'] = 'Silahkan pilih Jenis Penilaian';
- // INTERNAL
- if(1==$jenis_penilaian)
- {
- $validateIt['region'] = ['required'];
- $messageIt ['region.required']= 'Silahkan pilih Region';
+ // INTERNAL
+ if (1 == $jenis_penilaian) {
+ $validateIt['region'] = ['required'];
+ $messageIt ['region.required'] = 'Silahkan pilih Region';
}
- }
- elseif($tindakan==1)
- {
- $validateIt['catatan'] = ['required'];
- $messageIt ['catatan.required']= 'Silahkan isi Catatan';
+ } elseif ($tindakan == 1) {
+ $validateIt['catatan'] = ['required'];
+ $messageIt ['catatan.required'] = 'Silahkan isi Catatan';
}
$validator = Validator::make($request->all(), $validateIt, $messageIt);
- $data['fails'] = $validator->fails();
+ $data['fails'] = $validator->fails();
$data['errors'] = $validator->errors();
return $data;
@@ -245,8 +220,8 @@
public function show($id)
{
- $permohonan = Permohonan::find($id);
- return view('lpj::registrasi.show', compact('id','permohonan'));
+ $permohonan = Permohonan::find($id);
+ return view('lpj::registrasi.show', compact('id', 'permohonan'));
}
}
diff --git a/app/Http/Controllers/SurveyorController.php b/app/Http/Controllers/SurveyorController.php
index 3d68811..3c86379 100644
--- a/app/Http/Controllers/SurveyorController.php
+++ b/app/Http/Controllers/SurveyorController.php
@@ -25,6 +25,7 @@ use Modules\Lpj\Models\SpekKategoritBangunan;
use Modules\Lpj\Models\SaranaPelengkap;
use Modules\Lpj\Models\ArahMataAngin;
use Modules\Lpj\Models\Analisa;
+use Modules\Lpj\Models\Penilaian;
use Modules\Lpj\Models\PerkerasanJalan;
use Modules\Lpj\Models\AnalisaFakta;
use Modules\Lpj\Models\AnalisaLingkungan;
@@ -93,29 +94,8 @@ class SurveyorController extends Controller
$saranaPelengkap = SaranaPelengkap::all();
$arahMataAngin = ArahMataAngin::all();
- $jenisJaminanIds = $permohonan->debiture->documents;
- $buttonDisable = false;
- foreach ($jenisJaminanIds as $jenisJaminanId) {
- $denah = Denah::where('permohonan_id', $id)
- ->where('jenis_jaminan_id', $jenisJaminanId->jenis_jaminan_id)
- ->first();
-
- $fotojaminan = FotoJaminan::where('permohonan_id', $id)
- ->where('jenis_jaminan_id', $jenisJaminanId->jenis_jaminan_id)
- ->first();
-
- $analisa = Analisa::where('permohonan_id', $id)
- ->where('jenis_jaminan_id', $jenisJaminanId->jenis_jaminan_id)
- ->first();
-
- // cek jika tidak ada
- if (!$denah || !$fotojaminan || !$analisa) {
- $buttonDisable = true;
- break;
- }
- }
$denah = Denah::where('permohonan_id', $id)->get();
$fotojaminan = FotoJaminan::where('permohonan_id', $id)->get();
@@ -123,13 +103,28 @@ class SurveyorController extends Controller
->where('permohonan_id', $id)
->get();
- $inpeksi = Inspeksi::where('permohonan_id', $id)->get();
- $forminspeksi = json_decode($inpeksi[0]->data_form, true);
+
+
+ $jenisJaminanIds = $permohonan->debiture->documents->pluck('jenisJaminan.id')->toArray(); // Convert to array
+
+ $jaminanId = $jenisJaminanIds[0];
+ $inpeksi = Inspeksi::where('permohonan_id', $id)
+ ->whereIn('jenis_jaminan_id', $jenisJaminanIds)
+ ->first();
+
+ if ($inpeksi) {
+ $forminspeksi = json_decode($inpeksi->data_form, true);
+ $formFoto = json_decode($inpeksi->foto_form, true);
+ $formDenah = json_decode($inpeksi->denah_form, true);
+ } else {
+ $forminspeksi = null;
+ $formFoto = null;
+ $formDenah = null;
+ }
+
return view('lpj::surveyor.detail', compact(
- 'buttonDisable',
- 'fotojaminan',
'denah',
'analisa',
'permohonan',
@@ -147,7 +142,11 @@ class SurveyorController extends Controller
'spekKategoriBagunan',
'spekBangunan',
'saranaPelengkap',
- 'arahMataAngin'
+ 'arahMataAngin',
+ 'forminspeksi',
+ 'formDenah',
+ 'formFoto',
+ 'jaminanId'
));
}
/**
@@ -155,158 +154,75 @@ class SurveyorController extends Controller
*/
public function store(FormSurveyorRequest $request)
{
-
$data = $request->validated();
- if ($data) {
- try {
+ if (!$data) {
+ return response()->json(['success' => false, 'message' => 'Invalid data'], 400);
+ }
+ try {
+ DB::beginTransaction();
- $formatTanahJson = [
- 'debitur_perwakilan' => $data['debitur_perwakilan'] ?? [],
- 'jenis_asset' => $data['jenis_asset'] ?? null,
- 'jenis_asset_tidak_sesuai' => $data['jenis_asset_tidak_sesuai'] ?? null,
- 'alamat_sesuai' => $data['alamat_sesuai'] ?? null,
- 'alamat_tidak_sesuai' => $data['alamat_tidak_sesuai'] ?? null,
- 'nama_jalan' => $data['nama_jalan'] ?? null,
- 'desa_kelurahan' => $data['desa_kelurahan'] ?? null,
- 'kecamatan' => $data['kecamatan'] ?? null,
- 'kota_kabupaten' => $data['kota_kabupaten'] ?? null,
- 'provinsi' => $data['provinsi'] ?? null,
- 'kordinat_lng' => $data['kordinat_lng'] ?? null,
- 'kordinat_lat' => $data['kordinat_lat'] ?? null,
- 'luas_tanah' => $data['luas_tanah'] ?? null,
- 'luas_tanah_tidak_sesuai' => $data['luas_tanah_tidak_sesuai'] ?? null,
- 'hadap_mata_angin' => $data['hadap_mata_angin'] ?? null,
- 'hadap_mata_angin_tidak_sesuai' => $data['hadap_mata_angin_tidak_sesuai'] ?? null,
- 'bentuk_tanah' => $data['bentuk_tanah'] ?? null,
- 'bentuk_tanah_lainnya' => $data['bentuk_tanah_lainnya'] ?? null,
- 'kontur_tanah' => $data['kontur_tanah'] ?? [],
- 'ketinggian_tanah' => $data['ketinggian_tanah'] ?? [],
- 'ketinggian_tanah_tidak_sesuai' => $data['ketinggian_tanah_tidak_sesuai'] ?? [],
- 'posisi_kavling' => $data['posisi_kavling'] ?? [],
- 'posisi_kavling_lainnya' => $data['posisi_kavling_lainnya'] ?? null,
- 'tusuk_sate' => $data['tusuk_sate'] ?? null,
- 'lockland' => $data['lockland'] ?? null,
- 'kondisi_fisik_tanah' => $data['kondisi_fisik_tanah'] ?? [],
- 'kondisi_fisik_tanah_lainnya' => $data['kondisi_fisik_tanah_lainnya'] ?? null,
- ];
-
-
- $formatBangunanJson = [
- 'luas_tanah_bangunan' => $data['luas_tanah_bangunan'] ?? null,
- 'jenis_bangunan' => $data['jenis_bangunan'] ?? null,
- 'kondisi_bangunan' => $data['kondisi_bangunan'] ?? null,
- 'sifat_bangunan' => $data['sifat_bangunan'] ?? null,
- 'sifat_bangunan_input' => $data['sifat_bagunan_input'] ?? null,
- 'spek_kategori_bagunan' => $data['spek_kategori_bagunan'] ?? null,
- 'spek_bangunan' => $data['spek_bangunan'] ?? null,
- 'sarana_pelengkap' => $data['sarana_pelengkap'] ?? [],
- 'sarana_pelengkap_input' => $data['sarana_pelengkap_input'] ?? null,
- ];
-
-
- $formatLingkunganJson = [
- 'jarak_jalan_utama' => $data['jarak_jalan_utama'] ?? null,
- 'jalan_linkungan' => $data['jalan_linkungan'] ?? null,
- 'jarak_cbd_point' => $data['jarak_cbd_point'] ?? null,
- 'nama_cbd_point' => $data['nama_cbd_point'] ?? null,
- 'lebar_perkerasan_jalan' => $data['lebar_perkerasan_jalan'] ?? null,
- 'perkerasan_jalan' => $data['perkerasan_jalan'] ?? null,
- 'lalu_lintas' => $data['lalu_lintas'] ?? null,
- 'gol_mas_sekitar' => $data['gol_mas_sekitar'] ?? null,
- 'tingkat_keramaian' => $data['tingkat_keramaian'] ?? null,
- 'terletak_diarea' => $data['terletak_diarea'] ?? null,
- 'disekitar_lokasi' => $data['disekitar_lokasi'] ?? null,
- 'kondisi_bangunan_sekitar' => $data['kondisi_bangunan_sekitar'] ?? null,
- 'sifat_bangunan_sekitar' => $data['sifat_bangunan_sekitar'] ?? null,
- 'dekat_makam' => $data['dekat_makam'] ?? null,
- 'jarak_makam' => $data['jarak_makam'] ?? null,
- 'nama_makam' => $data['nama_makam'] ?? null,
- 'dekat_tps' => $data['dekat_tps'] ?? null,
- 'jarak_tps' => $data['jarak_tps'] ?? null,
- 'nama_tps' => $data['nama_tps'] ?? null,
- 'merupakan_daerah' => $data['merupakan_daerah'] ?? null,
- 'fasilitas_dekat_object' => $data['fasilitas_dekat_object'] ?? null,
-
- ];
-
-
- $formatFaktaJson = [
- 'fakta_positif' => $data['fakta_positif'] ?? null,
- 'fakta_negatif' => $data['fakta_negatif'] ?? null,
- 'rute_menuju' => $data['rute_menuju'] ?? null,
- 'batas_batas' => $data['batas_batas'] ?? null,
- 'kondisi_lingkungan' => $data['kondisi_lingkungan'] ?? null,
- 'kondisi_lain_bangunan' => $data['kondisi_lain_bangunan'] ?? null,
- 'informasi_dokument' => $data['informasi_dokument'] ?? null,
- 'peruntukan' => $data['peruntukan'] ?? null,
- 'kdb' => $data['kdb'] ?? null,
- 'kdh' => $data['kdh'] ?? null,
- 'gsb' => $data['gsb'] ?? null,
- 'max_lantai' => $data['max_lantai'] ?? null,
- 'klb' => $data['klb'] ?? null,
- 'gss' => $data['gss'] ?? null,
- 'pelebaran_jalan' => $data['pelebaran_jalan'] ?? null,
- 'nama_petugas' => $data['nama_petugas'] ?? null,
- 'lat' => $data['lat'] ?? null,
- 'lng' => $data['lng'] ?? null,
- 'foto_gistaru' => $data['foto_gistaru'] = $this->uploadFile($request->file('foto_gistaru'), $request->type) ?? null,
- 'foto_bhumi' => $data['foto_bhumi'] = $this->uploadFile($request->file('foto_bhumi'), $request->type) ?? null,
- 'foto_argis_region' => $data['foto_argis_region'] = $this->uploadFile($request->file('foto_argis_region'), $request->type) ?? null,
- 'foto_tempat' => $data['foto_tempat'] = $this->uploadFile($request->file('foto_tempat'), $request->type) ?? null,
- 'keterangan' => $data['keterangan'] ?? null,
- ];
-
- $mergeData = array_merge($formatTanahJson, $formatBangunanJson, $formatLingkunganJson, $formatFaktaJson);
+ $action = $request->input('type');
+ $rules = $this->getActionSpecificRules($data, $action, $request);
+ $inspeksi = Inspeksi::where('permohonan_id', $request->input('permohonan_id'))->where('jenis_jaminan_id', $request->input('jenis_jaminan_id'))->first();
+ if ($request->input('permohonan_id') == $inspeksi->permohonan_id && $request->input('jenis_jaminan_id') == $inspeksi->jenis_jaminan_id) {
+ $inspeksi->update(['data_form' => json_encode($rules)]);
+ } else {
Inspeksi::create([
'permohonan_id' => $request->permohonan_id,
- 'data_form' => json_encode($mergeData),
+ 'data_form' => json_encode($rules),
'name' => $request->type,
-
+ 'jenis_jaminan_id' => $request->input('jenis_jaminan_id'),
]);
- return response()->json(['success' => true, 'message' => 'Data berhasil disimpan',
- 'data' => $mergeData], 200);
- } catch (Exception $e) {
+ }
- return response()->json(['success' => false, 'message' => 'Data gagal disimpan: ' . $e->getMessage()], 500);
+ DB::commit();
+
+ return response()->json(['success' => true, 'message' => 'Data saved successfully', 'data' => $rules], 200);
+ } catch (Exception $e) {
+ DB::rollBack();
+ return response()->json(['success' => false, 'message' => 'Failed to save data: ' . $e->getMessage()], 500);
+ }
+ }
+
+ private function getActionSpecificRules($data, $action, $request): array
+ {
+ $pisah = explode(',', $action);
+
+ $allRules = [
+ 'tanah' => $this->getTanahData($data, $request),
+ 'bangunan' => $this->getBangunanData($data, $request),
+ 'kapal' => $this->getKapalData($data, $request),
+ 'kendaraan' => $this->getKendaraanData($data, $request),
+ 'mesin' => $this->getMesinData($data, $request),
+ 'pesawat' => $this->getPesawatData($data, $request),
+ 'alat-berat' => $this->getAlatBeratData($data, $request),
+ 'apartemen-kantor' => $this->getUnitData($data, $request),
+ 'lingkungan' => $this->getLingkunganData($data, $request),
+ 'fakta' => $this->getFactData($data, $request),
+ ];
+
+ $rules = [];
+ $hasAssetDescriptionRules = false;
+
+ foreach ($pisah as $act) {
+ if (isset($allRules[$act])) {
+ $rules = array_merge($rules, $allRules[$act]);
+ if ($act == 'tanah' || $act == 'bangunan') {
+ $hasAssetDescriptionRules = true;
+ }
}
}
- }
- private function handleTanahBangunan(array $validatedData, FormSurveyorRequest $request)
- {
- $analisaTanahBangunan = AnalisaTanahBagunan::create($validatedData);
- if ($analisaTanahBangunan) {
- $this->createSpekBangunanAnalisa($request, $analisaTanahBangunan);
+ if ($hasAssetDescriptionRules) {
+ $rules = array_merge($rules, $this->getAssetData($data));
}
+
+ return $rules;
}
- private function handleUnit(array $validatedData)
- {
- AnalisaUnit::create($validatedData);
- }
-
- private function createSpekBangunanAnalisa($request, $analisaTanahBangunan)
- {
- foreach ($request->input('kategori', []) as $spek) {
- $spek['analisa_tanah_bangunan_id'] = $analisaTanahBangunan->id;
- $spekBangunan = SpekBangunanAnalisa::create($spek);
-
- if ($spekBangunan) {
- $this->createSpekBangunanAnalisaDetails($request, $spekBangunan);
- }
- }
- }
-
- private function createSpekBangunanAnalisaDetails($request, $spekBangunan)
- {
- foreach ($request->input('name', []) as $detail) {
- $detail['spek_bangunan_analisa_id'] = $spekBangunan->id;
- SpekBagunanAnalisaDetail::create($detail);
- }
- }
public function storeDenah(Request $request)
{
@@ -319,26 +235,31 @@ class SurveyorController extends Controller
'jenis_jaminan_id' => 'required'
]);
-
$validatedData['foto_denah'] = $this->uploadFile($request->file('foto_denah'), 'foto_denah');
- Denah::create($validatedData);
- return redirect()->route('surveyor.show', [
- 'id' => $validatedData['permohonan_id'],
- 'form' => 'denah'
- ])->with('success', 'Data foto berhasil disimpan');
+ $formatJsonDenah = [
+ 'foto_denah' => $validatedData['foto_denah'],
+ 'luas' => $validatedData['luas'],
+ ];
+
+
+ $inspeksi = Inspeksi::where('permohonan_id', $request->input('permohonan_id'))->where('jenis_jaminan_id', $request->input('jenis_jaminan_id'))->first();
+ if ($request->input('permohonan_id') == $inspeksi->permohonan_id && $request->input('jenis_jaminan_id') == $inspeksi->jenis_jaminan_id) {
+ $inspeksi->update([
+ 'denah_form' => json_encode($formatJsonDenah)
+ ]);
+ } else {
+ Inspeksi::create([
+ 'permohonan_id' => $request->input('permohonan_id'),
+ 'denah_form' => json_encode($formatFotojson)
+ ]);
+ }
+
+ return response()->json(['success' => true, 'message' => 'Data berhasil disimpan',
+ 'data' => $formatJsonDenah], 200);
} catch (Exception $e) {
- $failureRedirectUrl = route('surveyor.denah', [
- 'id' => $validatedData['permohonan_id'],
- 'jenis_jaminan_id' => $validatedData['jenis_jaminan_id']
- ]);
-
- $failureRedirectUrl .= '?form=create-denah&denah=' . $validatedData['permohonan_id'] . '&jenis_jaminan=' . $validatedData['jenis_jaminan_id'];
-
- return redirect($failureRedirectUrl)
- ->withInput()
- ->with(['error' => 'Gagal menyimpan data: ' . $e->getMessage()]);
+ return response()->json(['success' => false, 'message' => 'Data gagal disimpan: ' . $e->getMessage()], 500);
}
}
@@ -349,7 +270,6 @@ class SurveyorController extends Controller
$validatedData = $request->validate([
'permohonan_id' => 'required',
'jenis_jaminan_id' => 'required',
- 'analisa_type' => 'required|in:tanah_bangunan,unit',
'pendamping' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
'foto_objek.*' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048',
'name_objek.*' => 'required|string|max:255',
@@ -370,8 +290,6 @@ class SurveyorController extends Controller
'name_gerbang' => 'nullable|string|max:255',
]);
- // DB::beginTransaction();
-
try {
$rute_menuju_lokasi = [];
@@ -440,6 +358,7 @@ class SurveyorController extends Controller
$basement = $this->uploadFile($request->file('foto_basement'), 'foto_basement');
$gerbang = $this->uploadFile($request->file('foto_gerbang'), 'foto_gerbang');
+ $pendamping = $this->uploadFile($request->file('pendamping'), 'pendamping');
$formatFotojson = [
@@ -450,290 +369,130 @@ class SurveyorController extends Controller
'foto_lantai_lainnya' => $foto_lantai_lainnya,
'foto_rute_lainnya' => $foto_rute_lainnya,
'basement' => $basement,
- 'gerbang' => $gerbang
+ 'gerbang' => $gerbang,
+ 'pendamping' => $pendamping
];
- $inspeksi = Inspeksi::where('permohonan_id', $request->input('permohonan_id'))->first();
- if($request->input('permohonan_id') == $inspeksi->permohonan_id){
+
+ $inspeksi = Inspeksi::where('permohonan_id', $request->input('permohonan_id'))->where('jenis_jaminan_id', $request->input('jenis_jaminan_id'))->first();
+ if ($request->input('permohonan_id') == $inspeksi->permohonan_id && $request->input('jenis_jaminan_id') == $inspeksi->jenis_jaminan_id) {
$inspeksi->update([
'foto_form' => json_encode($formatFotojson)
]);
- }else {
-
+ } else {
Inspeksi::create([
'permohonan_id' => $request->input('permohonan_id'),
'foto_form' => json_encode($formatFotojson)
]);
}
-
- // DB::commit();
-
return response()->json(['success' => true, 'message' => 'Data berhasil disimpan', 'data' => $formatFotojson], 200);
} catch (Exception $e) {
-
return response()->json(['success' => false, 'message' => 'Failed to upload: ' . $e->getMessage()], 500);
}
}
-
-
- public function update(FormSurveyorRequest $request, $id)
+ public function submitSurveyor($id,$jaminanId)
{
- $validatedData = $request->validated();
-
- DB::beginTransaction();
-
try {
- // Update Analisa entity
- $analisa = Analisa::findOrFail($id);
- $analisa->update($validatedData);
-
- if ($analisa) {
- $validatedData['analisa_id'] = $analisa->id;
- $analisaTanahBangunan = AnalisaTanahBagunan::where('analisa_id', $analisa->id)->firstOrFail();
- $analisaTanahBangunan->update($validatedData);
-
- if ($analisaTanahBangunan) {
- $this->updateSpekBangunanAnalisa($request, $analisaTanahBangunan);
- }
-
- $analisaLingkungan = AnalisaLingkungan::where('analisa_id', $analisa->id)->firstOrFail();
- $analisaLingkungan->update($validatedData);
-
- if ($request->hasFile('foto_tempat')) {
- $validatedData['foto_tempat'] = $this->uploadFile($request->file('foto_tempat'), 'foto_tempat');
- }
-
- $analisaFakta = AnalisaFakta::where('analisa_id', $analisa->id)->firstOrFail();
- $analisaFakta->update($validatedData);
+ $cekButton = $this->checkButtonStatus($id)->getData();
+ if (!$cekButton->buttonDisable) {
+ $permohonan = Permohonan::find($id);
+ $permohonan->update([
+ 'status' => 'done',
+ ]);
+ return response()->json(['success' => true, 'message' => 'Form surveyor submitted successfully'], 200);
+ } else {
+ return response()->json(['error' => 'Something went wrong'], 400);
}
-
- DB::commit();
- return redirect()->route('surveyor.show', [
- 'id' => $validatedData['permohonan_id'],
- 'form' => 'inspeksi'
- ])->with('success', 'Data form surveyor berhasil diperbarui');
} catch (Exception $e) {
- DB::rollback();
- return response()->json(['error' => 'Failed to update data', 'details' => $e->getMessage()], 500);
+ return response()->json(['error' => 'Something went wrong', 'message' => $e->getMessage()], 500);
}
}
- private function updateSpekBangunanAnalisa($request, $analisaTanahBangunan)
+
+
+ public function checkButtonStatus($id)
{
+ try {
- SpekBangunanAnalisa::where('analisa_tanah_bangunan_id', $analisaTanahBangunan->id)->delete();
+ $inpeksi = Inspeksi::where('permohonan_id', $id)->first();
- foreach ($request->input('kategori', []) as $spek) {
- $spek['analisa_tanah_bangunan_id'] = $analisaTanahBangunan->id;
- $spekBangunan = SpekBangunanAnalisa::create($spek);
+ if ($inpeksi) {
+ $forminspeksi = json_decode($inpeksi->data_form, true);
+ $formFoto = json_decode($inpeksi->foto_form, true);
- if ($spekBangunan) {
- $this->updateSpekBangunanAnalisaDetails($request, $spekBangunan);
+ $buttonDisable = false;
+ if (
+ $formFoto && count($formFoto) > 0 &&
+ $forminspeksi
+ ) {
+ $buttonDisable = false;
+ } else {
+ $buttonDisable = true;
+ }
+
+ return response()->json(['buttonDisable' => $buttonDisable]);
+ } else {
+ return response()->json(['buttonDisable' => true]);
}
- }
- }
-
- private function updateSpekBangunanAnalisaDetails($request, $spekBangunan)
- {
- // Delete existing SpekBagunanAnalisaDetail records
- SpekBagunanAnalisaDetail::where('spek_bangunan_analisa_id', $spekBangunan->id)->delete();
-
- // Create new SpekBagunanAnalisaDetail records
- foreach ($request->input('name', []) as $detail) {
- $detail['spek_bangunan_analisa_id'] = $spekBangunan->id;
- SpekBagunanAnalisaDetail::create($detail);
+ } catch (\Exception $e) {
+ return response()->json(['buttonDisable' => true]);
}
}
- public function updateDenah(Request $request, $id): RedirectResponse
+
+ public function storeJadwal(Request $request)
{
+ try {
- }
- private function processObjekUploads(Request $request, FotoJaminan $fotojaminan)
- {
- $fotoObjek = $request->file('foto_objek');
- $nameObjek = $request->input('name_objek');
- $analisaType = $request->input('analisa_type'); // Tambahkan input untuk tipe analisa
-
- if (!is_array($fotoObjek) || !is_array($nameObjek) || count($fotoObjek) !== count($nameObjek)) {
- throw new Exception("Mismatched foto_objek and name_objek inputs");
- }
-
- // Definisikan labels berdasarkan tipe analisa
- $objekLabels = [];
- if ($analisaType === 'tanah_bangunan') {
- $objekLabels = [
- 'Tampak Samping Kiri',
- 'Tampak Samping Kanan',
- 'Nomor Rumah/Unit'
- ];
- } elseif ($analisaType === 'unit') {
- $objekLabels = [
- 'Tampak Loby',
- 'Tampak Lift',
- 'Tampak Samping Kiri Unit',
- 'Tampak Samping Kanan Unit',
- 'Tampak Depan Unit',
- 'Nomor Unit'
- ];
- }
-
- foreach ($fotoObjek as $index => $foto) {
- if (!isset($nameObjek[$index])) {
- throw new Exception("Missing description for foto_objek at index {$index}");
- }
-
- // Pastikan index ada dalam objekLabels
- $label = isset($objekLabels[$index]) ? $objekLabels[$index] : "Foto {$index}";
-
- $path = $this->uploadFile($foto, 'objek');
- ObjekJaminan::create([
- 'foto_jaminan_id' => $fotojaminan->id,
- 'name_objek' => $label . ': ' . $nameObjek[$index],
- 'foto_objek' => $path,
+ $validate = $request->validate([
+ 'id' => 'required',
+ 'waktu_penilaian' => 'required',
+ 'deskripsi_penilaian' => 'required'
]);
- }
- }
- private function processUploads($type, Request $request, FotoJaminan $fotojaminan)
- {
- $files = $request->file("foto_{$type}");
- $names = $request->input("name_{$type}");
+ // return response()->json([
+ // 'daa'=>$validate
+ // ]);
+ $id = $request->input('id');
+ $penilaian = Penilaian::findOrFail($id);
- if (!is_array($files) || !is_array($names) || count($files) !== count($names)) {
- throw new Exception("Mismatched foto_{$type} and name_{$type} inputs");
- }
+ $penilaian->update([
+ 'waktu_penilaian' => $validate['waktu_penilaian'],
+ 'deskripsi_penilaian' => $validate['deskripsi_penilaian'],
- foreach ($files as $index => $file) {
- if (!isset($names[$index])) {
- throw new Exception("Missing description for {$type} at index {$index}");
- }
-
- $path = $this->uploadFile($file, $type);
-
- $data = [
- 'foto_jaminan_id' => $fotojaminan->id,
- "name_{$type}" => $names[$index],
- "foto_{$type}" => $path,
- ];
-
- switch ($type) {
- case 'rute':
- RuteJaminan::create($data);
- break;
- case 'lingkungan':
- Lingkungan::create($data);
- break;
- }
- }
- }
-
- private function processLantaiUnitUploads(Request $request, FotoJaminan $fotojaminan)
- {
- $lantaiFiles = $request->file('foto_lantai_unit');
- $lantaiNames = $request->input('name_lantai_unit');
-
- if (!$lantaiFiles) {
- return;
- }
-
- if (!is_array($lantaiFiles) || !is_array($lantaiNames) || count($lantaiFiles) !== count($lantaiNames)) {
- throw new Exception("Mismatched foto_lantai_unit and name_lantai_unit inputs");
- }
-
- foreach ($lantaiFiles as $index => $file) {
- $path = $this->uploadFile($file, 'lantai');
- LantaiUnit::create([
- 'objek_jaminan_id' => $fotojaminan->id,
- 'name_lantai_unit' => "Lantai " . ($index + 1),
- 'foto_lantai_unit' => $path,
]);
+
+ return redirect()
+ ->route('surveyor.index')
+ ->with('success', 'Jadwal berhasil dibuat.');
+ } catch (\Exception $e) {
+ return redirect()
+ ->route('surveyor.index')
+ ->with('error', 'Gagal membuat jadwal: ' . $e->getMessage());
}
}
- private function uploadFile($file, $type)
+ public function storeAproved($id)
{
- if (!$file->isValid()) {
- throw new Exception("Invalid file upload for {$type}");
+ try {
+
+
+ $penilaian = Penilaian::findOrFail($id);
+
+ $penilaian->update([
+ 'authorized_status' => 1,
+ ]);
+
+ return redirect()
+ ->route('permohonan.index')
+ ->with('success', 'Jadwal berhasil di aprove.');
+ } catch (\Exception $e) {
+ return redirect()
+ ->route('permohonan.index')
+ ->with('error', 'Gagal membuat jadwal: ' . $e->getMessage());
}
-
- $fileName = time() . '_' . $file->getClientOriginalName();
- $path = $file->storeAs("public/surveyor/{$type}", $fileName);
-
- if ($path === false) {
- throw new Exception("Failed to store file for {$type}");
- }
-
- return str_replace('public/', '', $path);
- }
-
-
- public function dataForDatatables(Request $request)
- {
- if (is_null($this->user) || !$this->user->can('debitur.view')) {
- // abort(403, 'Sorry! You are not allowed to view users.');
- }
-
- $query = Permohonan::query();
-
- if ($request->has('search') && !empty($request->get('search'))) {
- $search = $request->get('search');
- $query->where(function ($q) use ($search) {
- $q->where('nomor_registrasi', 'LIKE', '%' . $search . '%');
- $q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%');
- $q->orWhereRelation('user', 'name', 'LIKE', '%' . $search . '%');
- $q->orWhereRelation('debiture', 'name', 'LIKE', '%' . $search . '%');
- $q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search . '%');
- $q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
- $q->orWhere('status', 'LIKE', '%' . $search . '%');
- });
- }
-
- $query->whereRaw('LOWER(status) = ?', ['assign']);
-
- $query->whereHas('penilaian.userPenilai', function ($q) {
- $q->where('user_id', Auth::user()->id);
- $q->where('role', 'surveyor');
- });
-
-
- if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
- $order = $request->get('sortOrder');
- $column = $request->get('sortField');
- $query->orderBy($column, $order);
- }
-
- $totalRecords = $query->count();
-
- $size = $request->get('size', 10);
- if ($size == 0) {
- $size = 10;
- }
-
- if ($request->has('page') && $request->has('size')) {
- $page = $request->get('page', 1);
- $offset = ($page - 1) * $size;
-
- $query->skip($offset)->take($size);
- }
-
- $filteredRecords = $query->count();
- $data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'jenisFasilitasKredit'])->get();
-
- $pageCount = ceil($totalRecords / $size);
-
- $currentPage = max(1, $request->get('page', 1));
- return response()->json([
- 'draw' => $request->get('draw'),
- 'recordsTotal' => $totalRecords,
- 'recordsFiltered' => $filteredRecords,
- 'pageCount' => $pageCount,
- 'page' => $currentPage,
- 'totalCount' => $totalRecords,
- 'data' => $data,
- ]);
}
/**
* Form inspeksi.
@@ -777,18 +536,18 @@ class SurveyorController extends Controller
$perkerasanJalan = PerkerasanJalan::all();
- $analisa = Analisa::with('analisaTanahBangunan', 'analisaLingkungan', 'analisaFakta', 'jenisJaminan')
- ->where('permohonan_id', $id)
- ->where('jenis_jaminan_id', $jaminanId)
- ->first();
+ // return response()->json([
+ // 'per'=>
+ // $permohonan]);
- $inpeksi = Inspeksi::where('permohonan_id', $id)->get();
- $forminspeksi = json_decode($inpeksi[0]->data_form, true);
-
+ $inpeksi = Inspeksi::where('permohonan_id', $id)->where('jenis_jaminan_id', $jaminanId)->first();
+ $forminspeksi = null;
+ if ($inpeksi) {
+ $forminspeksi = json_decode($inpeksi->data_form, true);
+ }
return view('lpj::surveyor.components.inspeksi', compact(
- 'analisa',
'permohonan',
'surveyor',
'branches',
@@ -824,9 +583,16 @@ class SurveyorController extends Controller
{
$permohonan = $this->getPermohonanJaminanId($id, $jaminanId);
- $denah = Denah::where('permohonan_id', $id)->where('jenis_jaminan_id', $jaminanId)->first();
+ $denah = null;
- return view('lpj::surveyor.components.denah', compact('permohonan', 'denah'));
+ $inpeksi = Inspeksi::where('permohonan_id', $id)->where('jenis_jaminan_id', $jaminanId)->first();
+ $formDenah = null;
+ if ($inpeksi) {
+ $formDenah = json_decode($inpeksi->denah_form, true);
+ }
+
+ // return response()->json($formDenah);
+ return view('lpj::surveyor.components.denah', compact('permohonan', 'denah', 'formDenah'));
}
/**
@@ -840,11 +606,22 @@ class SurveyorController extends Controller
$branches = Branch::all();
$provinces = Province::all();
- // $fotoJaminan = FotoJaminan::with(['objekJaminan', 'lantaiUnit' ,'ruteJaminan', 'lingkungan'])->where('permohonan_id', $id)->where('jenis_jaminan_id', $jaminanId)->first();
+
+ $inpeksi = Inspeksi::where('permohonan_id', $id)->where('jenis_jaminan_id', $jaminanId)->first();
+
+ $formFoto = null;
+ if ($inpeksi) {
+ $formFoto = json_decode($inpeksi->foto_form, true);
+ }
$fotoJaminan = null;
- return view('lpj::surveyor.components.foto', compact('permohonan', 'surveyor', 'branches', 'provinces', 'fotoJaminan'));
+ // return response()->json([
+ // 'inspeksi' => $formFoto,
+
+ // ]);
+
+ return view('lpj::surveyor.components.foto', compact('permohonan', 'surveyor', 'branches', 'provinces', 'fotoJaminan', 'formFoto'));
}
/**
@@ -1010,6 +787,73 @@ class SurveyorController extends Controller
}
+ public function dataForDatatables(Request $request)
+ {
+ if (is_null($this->user) || !$this->user->can('debitur.view')) {
+ // abort(403, 'Sorry! You are not allowed to view users.');
+ }
+
+ $query = Permohonan::query();
+
+ if ($request->has('search') && !empty($request->get('search'))) {
+ $search = $request->get('search');
+ $query->where(function ($q) use ($search) {
+ $q->where('nomor_registrasi', 'LIKE', '%' . $search . '%');
+ $q->orWhere('tanggal_permohonan', 'LIKE', '%' . $search . '%');
+ $q->orWhereRelation('user', 'name', 'LIKE', '%' . $search . '%');
+ $q->orWhereRelation('debiture', 'name', 'LIKE', '%' . $search . '%');
+ $q->orWhereRelation('tujuanPenilaian', 'name', 'LIKE', '%' . $search . '%');
+ $q->orWhereRelation('branch', 'name', 'LIKE', '%' . $search . '%');
+ $q->orWhere('status', 'LIKE', '%' . $search . '%');
+ });
+ }
+
+ $query->whereRaw('LOWER(status) = ?', ['assign']);
+
+ $query->whereHas('penilaian.userPenilai', function ($q) {
+ $q->where('user_id', Auth::user()->id);
+ $q->where('role', 'surveyor');
+ });
+
+
+ if ($request->has('sortOrder') && !empty($request->get('sortOrder'))) {
+ $order = $request->get('sortOrder');
+ $column = $request->get('sortField');
+ $query->orderBy($column, $order);
+ }
+
+ $totalRecords = $query->count();
+
+ $size = $request->get('size', 10);
+ if ($size == 0) {
+ $size = 10;
+ }
+
+ if ($request->has('page') && $request->has('size')) {
+ $page = $request->get('page', 1);
+ $offset = ($page - 1) * $size;
+
+ $query->skip($offset)->take($size);
+ }
+
+ $filteredRecords = $query->count();
+ $data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'jenisFasilitasKredit','penilaian'])->get();
+
+ $pageCount = ceil($totalRecords / $size);
+
+ $currentPage = max(1, $request->get('page', 1));
+ return response()->json([
+ 'draw' => $request->get('draw'),
+ 'recordsTotal' => $totalRecords,
+ 'recordsFiltered' => $filteredRecords,
+ 'pageCount' => $pageCount,
+ 'page' => $currentPage,
+ 'totalCount' => $totalRecords,
+ 'data' => $data,
+ ]);
+ }
+
+
public function dataForDatatablesData(Request $request, $type)
{
@@ -1129,6 +973,7 @@ class SurveyorController extends Controller
'branch',
'tujuanPenilaian',
'penilaian',
+ 'debiture.documents.jenisJaminan',
'debiture.documents' => function ($query) use ($jaminanId) {
$query->where('jenis_jaminan_id', $jaminanId);
}
@@ -1139,26 +984,8 @@ class SurveyorController extends Controller
->findOrFail($id);
}
- public function submitSurveyor(Request $request, $id)
- {
- $permohonan = Permohonan::find($id);
- $permohonan->update([
- 'status' => 'done',
- ]);
- return redirect()
- ->route('surveyor.index')
- ->with('success', 'form surveyor submitted successfully');
-
- }
-
-
- public function validateSubmit()
- {
-
- }
-
private function getModelClass(string $type): ?string
{
@@ -1236,4 +1063,216 @@ class SurveyorController extends Controller
'perkerasan-jalan' => ['Perkerasan jalan', 'perkerasan-jalan']
];
+ private function getAssetData($data)
+ {
+ return [
+ 'debitur_perwakilan' => $data['debitur_perwakilan'] ?? [],
+ 'jenis_asset' => $data['jenis_asset'] ?? null,
+ 'jenis_asset_tidak_sesuai' => $data['jenis_asset_tidak_sesuai'] ?? null,
+ 'alamat_sesuai' => $data['alamat_sesuai'] ?? null,
+ 'alamat_tidak_sesuai' => $data['alamat_tidak_sesuai'] ?? null,
+ 'nama_jalan' => $data['nama_jalan'] ?? null,
+ 'desa_kelurahan' => $data['desa_kelurahan'] ?? null,
+ 'kecamatan' => $data['kecamatan'] ?? null,
+ 'kota_kabupaten' => $data['kota_kabupaten'] ?? null,
+ 'provinsi' => $data['provinsi'] ?? null,
+ 'kordinat_lng' => $data['kordinat_lng'] ?? null,
+ 'kordinat_lat' => $data['kordinat_lat'] ?? null,
+ ];
+ }
+
+
+ private function getTanahData($data, $request): array
+ {
+ return [
+ 'luas_tanah' => $data['luas_tanah'] ?? null,
+ 'luas_tanah_tidak_sesuai' => $data['luas_tanah_tidak_sesuai'] ?? null,
+ 'hadap_mata_angin' => $data['hadap_mata_angin'] ?? null,
+ 'hadap_mata_angin_tidak_sesuai' => $data['hadap_mata_angin_tidak_sesuai'] ?? null,
+ 'bentuk_tanah' => $data['bentuk_tanah'] ?? null,
+ 'bentuk_tanah_lainnya' => $data['bentuk_tanah_lainnya'] ?? null,
+ 'kontur_tanah' => $data['kontur_tanah'] ?? [],
+ 'ketinggian_tanah' => $data['ketinggian_tanah'] ?? [],
+ 'ketinggian_tanah_tidak_sesuai' => $data['ketinggian_tanah_tidak_sesuai'] ?? [],
+ 'kontur_jalan' => $data['kontur_jalan'] ?? null,
+ 'ketinggian_jalan' => $data['ketinggian_jalan'] ?? [],
+ 'posisi_kavling' => $data['posisi_kavling'] ?? [],
+ 'posisi_kavling_lainnya' => $data['posisi_kavling_lainnya'] ?? null,
+ 'tusuk_sate' => $data['tusuk_sate'] ?? null,
+ 'lockland' => $data['lockland'] ?? null,
+ 'kondisi_fisik_tanah' => $data['kondisi_fisik_tanah'] ?? [],
+ 'kondisi_fisik_tanah_lainnya' => $data['kondisi_fisik_tanah_lainnya'] ?? null,
+ ];
+ }
+
+ private function getBangunanData($data, $request): array
+ {
+ return [
+ 'luas_tanah_bagunan' => $data['luas_tanah_bagunan'] ?? null,
+ 'jenis_bangunan' => $data['jenis_bangunan'] ?? null,
+ 'kondisi_bangunan' => $data['kondisi_bangunan'] ?? null,
+ 'sifat_bangunan' => $data['sifat_bangunan'] ?? null,
+ 'sifat_bangunan_input' => $data['sifat_bagunan_input'] ?? null,
+ 'spek_kategori_bagunan' => $data['spek_kategori_bagunan'] ?? null,
+ 'spek_bangunan' => $data['spek_bangunan'] ?? null,
+ 'sarana_pelengkap' => $data['sarana_pelengkap'] ?? [],
+ 'sarana_pelengkap_input' => $data['sarana_pelengkap_input'] ?? null,
+ ];
+ }
+
+ private function getLingkunganData($data, $request): array
+ {
+ return [
+ 'jarak_jalan_utama' => $data['jarak_jalan_utama'] ?? null,
+ 'jalan_linkungan' => $data['jalan_linkungan'] ?? null,
+ 'jarak_cbd_point' => $data['jarak_cbd_point'] ?? null,
+ 'nama_cbd_point' => $data['nama_cbd_point'] ?? null,
+ 'lebar_perkerasan_jalan' => $data['lebar_perkerasan_jalan'] ?? null,
+ 'perkerasan_jalan' => $data['perkerasan_jalan'] ?? null,
+ 'lalu_lintas' => $data['lalu_lintas'] ?? null,
+ 'gol_mas_sekitar' => $data['gol_mas_sekitar'] ?? null,
+ 'tingkat_keramaian' => $data['tingkat_keramaian'] ?? null,
+ 'terletak_diarea' => $data['terletak_diarea'] ?? null,
+ 'disekitar_lokasi' => $data['disekitar_lokasi'] ?? null,
+ 'kondisi_bangunan_sekitar' => $data['kondisi_bangunan_sekitar'] ?? null,
+ 'sifat_bangunan_sekitar' => $data['sifat_bangunan_sekitar'] ?? null,
+ 'dekat_makam' => $data['dekat_makam'] ?? null,
+ 'jarak_makam' => $data['jarak_makam'] ?? null,
+ 'nama_makam' => $data['nama_makam'] ?? null,
+ 'dekat_tps' => $data['dekat_tps'] ?? null,
+ 'jarak_tps' => $data['jarak_tps'] ?? null,
+ 'nama_tps' => $data['nama_tps'] ?? null,
+ 'merupakan_daerah' => $data['merupakan_daerah'] ?? null,
+ 'fasilitas_dekat_object' => $data['fasilitas_dekat_object'] ?? null,
+ ];
+ }
+
+ private function getFactData($data, $request): array
+ {
+ $factData = [
+ 'fakta_positif' => $data['fakta_positif'] ?? null,
+ 'fakta_negatif' => $data['fakta_negatif'] ?? null,
+ 'rute_menuju' => $data['rute_menuju'] ?? null,
+ 'batas_batas' => $data['batas_batas'] ?? null,
+ 'kondisi_lingkungan' => $data['kondisi_lingkungan'] ?? null,
+ 'kondisi_lain_bangunan' => $data['kondisi_lain_bangunan'] ?? null,
+ 'informasi_dokument' => $data['informasi_dokument'] ?? null,
+ 'peruntukan' => $data['peruntukan'] ?? null,
+ 'kdb' => $data['kdb'] ?? null,
+ 'kdh' => $data['kdh'] ?? null,
+ 'gsb' => $data['gsb'] ?? null,
+ 'max_lantai' => $data['max_lantai'] ?? null,
+ 'klb' => $data['klb'] ?? null,
+ 'gss' => $data['gss'] ?? null,
+ 'pelebaran_jalan' => $data['pelebaran_jalan'] ?? null,
+ 'nama_petugas' => $data['nama_petugas'] ?? null,
+ 'lat' => $data['lat'] ?? null,
+ 'lng' => $data['lng'] ?? null,
+ 'keterangan' => $data['keterangan'] ?? null,
+ ];
+
+ $factData['foto_gistaru'] = $this->updateOrDeleteFile($data, $request, 'foto_gistaru');
+ $factData['foto_bhumi'] = $this->updateOrDeleteFile($data, $request, 'foto_bhumi');
+ $factData['foto_argis_region'] = $this->updateOrDeleteFile($data, $request, 'foto_argis_region');
+ $factData['foto_tempat'] = $this->updateOrDeleteFile($data, $request, 'foto_tempat');
+
+ return $factData;
+ }
+
+ private function updateOrDeleteFile($data, $request, $fileKey)
+ {
+ if ($request->hasFile($fileKey)) {
+ $file = $request->file($fileKey);
+ if ($file->isValid()) {
+ $fileName = time() . '_' . $file->getClientOriginalName();
+ $path = $file->storeAs("public/surveyor/{$request->type}", $fileName);
+ if ($path === false) {
+ throw new Exception("Failed to store file for {$fileKey}");
+ }
+ if (isset($data[$fileKey]) && $data[$fileKey]) {
+ $this->deleteFile($data[$fileKey]);
+ }
+ return str_replace('public/', '', $path);
+ } else {
+ throw new Exception("Invalid file upload for {$fileKey}");
+ }
+ } elseif (isset($data[$fileKey]) && $data[$fileKey]) {
+ return $data[$fileKey];
+ } else {
+ return null;
+ }
+ }
+
+ private function deleteFile($filePath)
+ {
+ $fullPath = storage_path('app/public/' . $filePath);
+ if (file_exists($fullPath)) {
+ unlink($fullPath);
+ }
+ }
+ private function getKapalData($data): array
+ {
+ return [
+ 'keterangan' => $data['keterangan']
+ ];
+ }
+
+ private function getKendaraanData($data): array
+ {
+ return [
+ 'keterangan' => $data['keterangan']
+ ];
+ }
+
+ private function getMesinData($data): array
+ {
+ return [
+ 'keterangan' => $data['keterangan']
+ ];
+ }
+
+ private function getPesawatData($data): array
+ {
+ return [
+ 'keterangan' => $data['keterangan']
+ ];
+ }
+
+
+ private function getAlatBeratData($data): array
+ {
+ return [
+ 'keterangan' => $data['keterangan']
+ ];
+ }
+
+
+ private function getUnitData($data): array
+ {
+ return [
+ 'keterangan' => $data['keterangan']
+ ];
+ }
+
+
+
+
+
+ // function upload file to storage
+ private function uploadFile($file, $type)
+ {
+ if (!$file->isValid()) {
+ throw new Exception("Invalid file upload for {$type}");
+ }
+
+ $fileName = time() . '_' . $file->getClientOriginalName();
+ $path = $file->storeAs("public/surveyor/{$type}", $fileName);
+
+ if ($path === false) {
+ throw new Exception("Failed to store file for {$type}");
+ }
+
+ return str_replace('public/', '', $path);
+ }
+
}
diff --git a/app/Http/Requests/FormSurveyorRequest.php b/app/Http/Requests/FormSurveyorRequest.php
index e003a36..d724c72 100644
--- a/app/Http/Requests/FormSurveyorRequest.php
+++ b/app/Http/Requests/FormSurveyorRequest.php
@@ -19,75 +19,50 @@ class FormSurveyorRequest extends FormRequest
*/
public function rules(): array
{
- $commonRules = $this->getBangunanRules();
+
$actionSpecificRules = $this->getActionSpecificRules();
-
- return array_merge($commonRules, $actionSpecificRules);
return $actionSpecificRules;
}
- /**
- * Get common rules that apply to all actions.
- */
- private function getCommonRules(): array
- {
- return [
- 'fakta_positif' => 'nullable|array',
- 'fakta_negatif' => 'nullable|array',
- 'rute_menuju' => 'nullable',
- 'batas_batas' => 'nullable|array',
- 'kondisi_linkungan' => 'nullable|array',
- 'kondisi_lain_bangunan' => 'nullable|array',
- 'informasi_dokument' => 'nullable',
- 'peruntukan' => 'nullable',
- 'kdb' => 'nullable',
- 'kdh' => 'nullable',
- 'gsb' => 'nullable',
- 'max_lantai' => 'nullable',
- 'klb' => 'nullable',
- 'gss' => 'nullable',
- 'pelebaran_jalan' => 'nullable',
- 'nama_petugas' => 'nullable',
- 'lat' => 'nullable|numeric',
- 'lng' => 'nullable|numeric',
- 'foto_gistaru' => 'nullable',
- 'foto_bhumi' => 'nullable',
- 'foto_argis_region' => 'nullable',
- 'foto_tempat' => 'nullable',
- 'keterangan' => 'nullable',
- ];
- }
-
/**
* Get rules specific to the action.
*/
private function getActionSpecificRules(): array
{
$action = $this->input('action');
+ $pisah = explode(',', $action);
- switch ($action) {
- case 'tanah':
- return $this->getTanahRules();
- case 'unit':
- return $this->getUnitRules();
- case 'kapal':
- return $this->getUnitRules();
- case 'kendaraan':
- return $this->getUnitRules();
- case 'mesin':
- return $this->getUnitRules();
- case 'bangunan':
- return $this->getTanahBangunanRules();
- case 'tanah_bangunan':
- return array_merge($this->getAssetDescriptionRules(),$this->getTanahRules(), $this->getBangunanRules(), $this->getLinkunganRules(), $this->getCommonRules());
+ $allRules = [
+ 'tanah' => $this->getTanahRules(),
+ 'bangunan' => $this->getBangunanRules(),
+ 'kapal' => $this->getKapalRules(),
+ 'kendaraan' => $this->getKendaraanRules(),
+ 'mesin' => $this->getMesinRules(),
+ 'pesawat' => $this->getLinkunganRules(),
+ 'alat-berat' => $this->getLinkunganRules(),
+ 'apartemen-kantor' => $this->getUnitRules(),
+ 'lingkungan' => $this->getLinkunganRules(),
+ 'fakta' => $this->getCommonRules(),
+ ];
- case 'alat-berat':
- return $this->getUnitRules();
- default:
- return [];
+ $rules = [];
+ $hasAssetDescriptionRules = false;
+
+ foreach ($pisah as $act) {
+ if (isset($allRules[$act])) {
+ $rules = array_merge($rules, $allRules[$act]);
+ if ($act == 'tanah' || $act == 'bangunan') {
+ $hasAssetDescriptionRules = true;
+ }
+ }
}
- }
+ if ($hasAssetDescriptionRules) {
+ $rules = array_merge($rules, $this->getAssetDescriptionRules());
+ }
+
+ return $rules;
+ }
/**
* Get rules specific to tanah action.
*/
@@ -133,9 +108,9 @@ class FormSurveyorRequest extends FormRequest
];
}
- /**
- * Get rules specific to unit action.
- */
+ /**
+ * Get rules specific to unit action.
+ */
private function getUnitRules(): array
{
return [
@@ -164,7 +139,7 @@ class FormSurveyorRequest extends FormRequest
'jarak_cbd_point' => 'nullable',
'nama_cbd_point' => 'nullable',
'lebar_perkerasan_jalan' => 'nullable',
- 'perkerasan_jalan' => 'nullable',
+ 'perkerasan_jalan.*' => 'nullable',
'lalu_lintas' => 'nullable',
'gol_mas_sekitar' => 'nullable',
'tingkat_keramaian' => 'nullable',
@@ -223,24 +198,57 @@ class FormSurveyorRequest extends FormRequest
private function getAssetDescriptionRules(): array
-{
- return [
- 'permohonan_id' => 'required',
- 'type' => 'required',
- 'debitur_perwakilan' => 'required|array',
- 'jenis_asset' => 'required',
- 'jenis_asset_tidak_sesuai' => 'nullable',
- 'alamat_sesuai' => 'required',
- 'alamat_tidak_sesuai' => 'nullable',
- 'nama_jalan' => 'nullable',
- 'desa_kelurahan' => 'nullable',
- 'kecamatan' => 'nullable',
- 'kota_kabupaten' => 'nullable',
- 'provinsi' => 'nullable',
- 'kordinat_lng' => 'nullable',
- 'kordinat_lat' => 'nullable',
- ];
-}
+ {
+ return [
+ 'permohonan_id' => 'required',
+ 'type' => 'required',
+ 'debitur_perwakilan' => 'required|array',
+ 'jenis_asset' => 'required',
+ 'jenis_asset_tidak_sesuai' => 'nullable',
+ 'alamat_sesuai' => 'required',
+ 'alamat_tidak_sesuai' => 'nullable',
+ 'nama_jalan' => 'nullable',
+ 'desa_kelurahan' => 'nullable',
+ 'kecamatan' => 'nullable',
+ 'kota_kabupaten' => 'nullable',
+ 'provinsi' => 'nullable',
+ 'kordinat_lng' => 'nullable',
+ 'kordinat_lat' => 'nullable',
+ ];
+ }
+
+ /**
+ * Get common rules that apply to all actions.
+ */
+ private function getCommonRules(): array
+ {
+ return [
+ 'fakta_positif' => 'nullable|array',
+ 'fakta_negatif' => 'nullable|array',
+ 'rute_menuju' => 'nullable',
+ 'batas_batas' => 'nullable|array',
+ 'kondisi_lingkungan' => 'nullable|array',
+ 'kondisi_lain_bangunan' => 'nullable|array',
+ 'informasi_dokument' => 'nullable',
+ 'peruntukan' => 'nullable',
+ 'kdb' => 'nullable',
+ 'kdh' => 'nullable',
+ 'gsb' => 'nullable',
+ 'max_lantai' => 'nullable',
+ 'klb' => 'nullable',
+ 'gss' => 'nullable',
+ 'pelebaran_jalan' => 'nullable',
+ 'nama_petugas' => 'nullable',
+ 'lat' => 'nullable|numeric',
+ 'lng' => 'nullable|numeric',
+ 'foto_gistaru' => 'nullable',
+ 'foto_bhumi' => 'nullable',
+ 'foto_argis_region' => 'nullable',
+ 'foto_tempat' => 'nullable',
+ 'keterangan' => 'nullable',
+ ];
+ }
+
}
diff --git a/app/Http/Requests/JenisJaminanRequest.php b/app/Http/Requests/JenisJaminanRequest.php
index 6f0325c..96d9653 100644
--- a/app/Http/Requests/JenisJaminanRequest.php
+++ b/app/Http/Requests/JenisJaminanRequest.php
@@ -19,6 +19,7 @@
'name' => 'required|max:255',
'slug' => 'required|max:255',
'jenis_legalitas_jaminan_id' => 'nullable',
+ 'form_kategori.*' => 'required',
];
}
diff --git a/app/Models/Debiture.php b/app/Models/Debiture.php
index 8980513..3080ecb 100644
--- a/app/Models/Debiture.php
+++ b/app/Models/Debiture.php
@@ -60,4 +60,8 @@
return $this->hasMany(DokumenJaminan::class);
}
+ public function permohonan(){
+ return $this->hasOne(Permohonan::class, 'debiture_id', 'id' );
+ }
+
}
diff --git a/app/Models/Inspeksi.php b/app/Models/Inspeksi.php
index 16c3629..ebbe399 100644
--- a/app/Models/Inspeksi.php
+++ b/app/Models/Inspeksi.php
@@ -14,7 +14,17 @@ class Inspeksi extends Model
/**
* The attributes that are mass assignable.
*/
- protected $fillable = ['data_form', 'foto_form', 'denah_form','permohonan_id', 'name', 'status', 'authorized_status', 'authorized_at', 'authorized_by', 'created_by', 'updated_by', 'deleted_by'];
+ protected $fillable = ['data_form', 'foto_form', 'denah_form','permohonan_id', 'name', 'status', 'authorized_status', 'authorized_at', 'authorized_by', 'created_by', 'updated_by', 'deleted_by','jenis_jaminan_id'];
+
+ public function permohonan()
+ {
+ return $this->belongsTo(Permohonan::class, 'permohonan_id');
+ }
+
+ public function jenis_jaminan()
+ {
+ return $this->belongsTo(JenisJaminan::class, 'jenis_jaminan_id');
+ }
// protected static function newFactory(): InspeksiFactory
// {
diff --git a/app/Models/JenisJaminan.php b/app/Models/JenisJaminan.php
index e8f4e17..0adc1b4 100644
--- a/app/Models/JenisJaminan.php
+++ b/app/Models/JenisJaminan.php
@@ -5,5 +5,5 @@ namespace Modules\Lpj\Models;
class JenisJaminan extends Base
{
protected $table = 'jenis_jaminan';
- protected $fillable = ['code', 'name', 'slug', 'jenis_legalitas_jaminan_id'];
+ protected $fillable = ['code', 'name', 'slug', 'jenis_legalitas_jaminan_id', 'form_kategori'];
}
diff --git a/app/Models/Penilaian.php b/app/Models/Penilaian.php
index 1de2dc5..7648592 100644
--- a/app/Models/Penilaian.php
+++ b/app/Models/Penilaian.php
@@ -19,7 +19,7 @@ class Penilaian extends Model
protected $fillable = [
'jenis_penilaian_id', 'penilaian_id', 'tanggal_kunjungan', 'keterangan','nomor_registrasi',
'status', 'authorized_status', 'authorized_at', 'authorized_by', 'created_at',
- 'created_by', 'updated_at', 'updated_by', 'deleted_at', 'deleted_by'
+ 'created_by', 'updated_at', 'updated_by', 'deleted_at', 'deleted_by','waktu_penilaian', 'deskripsi_penilaian'
];
public function jenis_penilaian()
diff --git a/app/Models/Permohonan.php b/app/Models/Permohonan.php
index 1dd7bdd..60c9303 100644
--- a/app/Models/Permohonan.php
+++ b/app/Models/Permohonan.php
@@ -3,6 +3,7 @@
namespace Modules\Lpj\Models;
use Modules\Lpj\Database\Factories\PermohonanFactory;
+use Modules\Lpj\Services\PermohonanHistoryService;
use Modules\Usermanagement\Models\User;
class Permohonan extends Base
@@ -38,8 +39,66 @@ class Permohonan extends Base
'registrasi_at',
'jenis_penilaian_id',
'region_id',
+ 'attachment'
];
+ protected static function boot()
+ {
+ parent::boot();
+
+ static::creating(function ($permohonan) {
+ static::handleFileUpload($permohonan);
+ });
+
+ static::updating(function ($permohonan) {
+ static::handleFileUpload($permohonan);
+ });
+
+ static::created(function ($permohonan) {
+ static::createHistory($permohonan, 'created');
+ });
+
+ static::updated(function ($permohonan) {
+ static::createHistory($permohonan, 'updated');
+ });
+ }
+
+ protected static function handleFileUpload($permohonan)
+ {
+ if (request()->hasFile('attachment')) {
+ $file = request()->file('attachment');
+ $fileName = time() . '_' . $file->getClientOriginalName();
+ $filePath = $file->storeAs('permohonan_attachments', $fileName, 'public');
+
+ // Delete old file if it exists
+ if ($permohonan->attachment) {
+ Storage::disk('public')->delete($permohonan->attachment);
+ }
+
+ $permohonan->attachment = $filePath;
+ }
+ }
+
+ protected static function createHistory($permohonan, $action)
+ {
+ $historyService = app(PermohonanHistoryService::class);
+
+ $status = $permohonan->status;
+ $keterangan = request()->input('keterangan'); // Get keterangan from request
+ $beforeRequest = $action === 'updated' ? $permohonan->getOriginal() : [];
+ $afterRequest = $permohonan->toArray();
+ $file = $permohonan->attachment ? Storage::disk('public')->path($permohonan->attachment) : null;
+
+ $historyService->createHistory(
+ $permohonan,
+ $status,
+ $keterangan,
+ $beforeRequest,
+ $afterRequest,
+ $file
+ );
+ }
+
public function user()
{
return $this->belongsTo(User::class);
diff --git a/database/migrations/2024_11_13_071043_update_jenis_jaminan_table.php b/database/migrations/2024_11_13_071043_update_jenis_jaminan_table.php
new file mode 100644
index 0000000..2e2ee64
--- /dev/null
+++ b/database/migrations/2024_11_13_071043_update_jenis_jaminan_table.php
@@ -0,0 +1,28 @@
+json('form_kategori')->after('slug')->nullable();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::table('jenis_jaminan', function (Blueprint $table) {
+ $table->dropColumn('form_kategori');
+ });
+ }
+};
diff --git a/database/migrations/2024_11_13_101409_update_penilaian_table.php b/database/migrations/2024_11_13_101409_update_penilaian_table.php
new file mode 100644
index 0000000..d71ff4a
--- /dev/null
+++ b/database/migrations/2024_11_13_101409_update_penilaian_table.php
@@ -0,0 +1,30 @@
+datetime('waktu_penilaian')->nullable();
+ $table->text('deskripsi_penilaian')->nullable();
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::table('penilaian', function (Blueprint $table) {
+ $table->dropColumn('waktu_penilaian');
+ $table->dropColumn('deskripsi_penilaian');
+ });
+ }
+};
diff --git a/database/migrations/2024_11_13_153901_update_inspeksi_table.php b/database/migrations/2024_11_13_153901_update_inspeksi_table.php
new file mode 100644
index 0000000..552ed5c
--- /dev/null
+++ b/database/migrations/2024_11_13_153901_update_inspeksi_table.php
@@ -0,0 +1,29 @@
+unsignedBigInteger('jenis_jaminan_id')->nullable()->after('permohonan_id');
+ $table->foreign('jenis_jaminan_id')->references('id')->on('jenis_jaminan')->onDelete('cascade');
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ */
+ public function down(): void
+ {
+ Schema::table('inspeksi', function (Blueprint $table) {
+ $table->dropColumn('jenis_jaminan_id');
+ });
+ }
+};
diff --git a/resources/views/component/detail-jaminan.blade.php b/resources/views/component/detail-jaminan.blade.php
index 3435775..63b2817 100644
--- a/resources/views/component/detail-jaminan.blade.php
+++ b/resources/views/component/detail-jaminan.blade.php
@@ -1,3 +1,164 @@
+
+
+
+
+
+ Nomor Register Permohonan:
+
+
+ {{ $permohonan->nomor_registrasi }}
+
+
+
+
+
+ Pemohon:
+
+
+ {{ $permohonan->user->nik }} | {{ $permohonan->user->name }} | {{ $permohonan->user->branch->name }}
+
+
+
+
+
+ Tujan Permohonan:
+
+
+ {{ $permohonan->tujuanPenilaian->name }}
+
+
+
+
+
+ Nilai Plafond:
+
+
+ {{ $permohonan->nilaiPlafond->name }}
+
+
+
+
+
+ Status Bayar:
+
+
+ {{ str_replace('_',' ',$permohonan->status_bayar) }}
+
+
+
+
+
+ Nilai NJOP:
+
+
+ {{ formatRupiah($permohonan->niilai_njop) }}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @error('form_kategori')
+ {{ $message }}
+ @enderror
+
+
+
-
-
+
+
+
@push('scripts')
+@endpush
diff --git a/resources/views/surveyor/components/fakta.blade.php b/resources/views/surveyor/components/fakta.blade.php
index a27f17b..0609899 100644
--- a/resources/views/surveyor/components/fakta.blade.php
+++ b/resources/views/surveyor/components/fakta.blade.php
@@ -28,7 +28,7 @@
- @if ($analisaType != 'mesin' && $analisaType != 'kapal' && $analisaType != 'kendaraan' && $analisaType != 'pesawat')
+
Rute Menuju
@@ -84,9 +84,9 @@
Kondisi lain terkait lingkungan
-
+
-
+
- @endif
+
- @if ($analisaType != 'mesin' && $analisaType != 'kapal' && $analisaType != 'kendaraan' && $analisaType != 'pesawat')
+
- @endif
+
@endpush
diff --git a/resources/views/surveyor/components/lingkungan.blade.php b/resources/views/surveyor/components/lingkungan.blade.php
index c66fcf3..54e98d1 100644
--- a/resources/views/surveyor/components/lingkungan.blade.php
+++ b/resources/views/surveyor/components/lingkungan.blade.php
@@ -48,7 +48,9 @@
@if (isset($perkerasanJalan))
@foreach ($perkerasanJalan as $item)
-
+ name, isset($forminspeksi['perkerasan_jalan']) ? $forminspeksi['perkerasan_jalan'] : []) ? 'checked' : '' }} />
{{ $item->name }}
@endforeach
@@ -68,7 +70,9 @@
name, explode(',', old('lalu_lintas', $forminspeksi['lalu_lintas'] ?? ''))) ? 'checked' : '' }} />
+ {{ isset($forminspeksi['lalu_lintas']) && in_array($item->name, explode(',', is_array(old('lalu_lintas', $forminspeksi['lalu_lintas'] ?? '')) ? implode(',', old('lalu_lintas', $forminspeksi['lalu_lintas'] ?? '')) : old('lalu_lintas', $forminspeksi['lalu_lintas'] ?? ''))) ? 'checked' : '' }} />
+
+
{{ $item->name }}
@endforeach
@@ -87,7 +91,8 @@
name, explode(',', old('gol_mas_sekitar', $forminspeksi['gol_mas_sekitar'] ?? ''))) ? 'checked' : '' }} />
+ {{ isset($forminspeksi['gol_mas_sekitar']) && in_array($item->name, explode(',', is_array(old('gol_mas_sekitar', $forminspeksi['gol_mas_sekitar'] ?? '')) ? implode(',', old('gol_mas_sekitar', $forminspeksi['gol_mas_sekitar'] ?? '')) : old('gol_mas_sekitar', $forminspeksi['gol_mas_sekitar'] ?? ''))) ? 'checked' : '' }} />
+
{{ $item->name }}
@endforeach
@@ -107,7 +112,8 @@
name, explode(',', old('tingkat_keramaian', $forminspeksi['tingkat_keramaian'] ?? ''))) ? 'checked' : '' }} />
+ {{ isset($forminspeksi['tingkat_keramaian']) && in_array($item->name, explode(',', is_array(old('tingkat_keramaian', $forminspeksi['tingkat_keramaian'] ?? '')) ? implode(',', old('tingkat_keramaian', $forminspeksi['tingkat_keramaian'] ?? '')) : old('tingkat_keramaian', $forminspeksi['tingkat_keramaian'] ?? ''))) ? 'checked' : '' }} />
+
{{ $item->name }}
@endforeach
@@ -127,7 +133,8 @@
name, explode(',', old('terletak_diarea', $forminspeksi['terletak_diarea'] ?? ''))) ? 'checked' : '' }} />
+ {{ isset($forminspeksi['terletak_diarea']) && in_array($item->name, explode(',', is_array(old('terletak_diarea', $forminspeksi['terletak_diarea'] ?? '')) ? implode(',', old('terletak_diarea', $forminspeksi['terletak_diarea'] ?? '')) : old('terletak_diarea', $forminspeksi['terletak_diarea'] ?? ''))) ? 'checked' : '' }} />
+
{{ $item->name }}
@endforeach
@@ -220,7 +227,7 @@
name, explode(',', old('merupakan_daerah', $forminspeksi['merupakan_daerah'] ?? []))) ? 'checked' : '' }} />
+ {{ in_array($item->name, isset($forminspeksi['merupakan_daerah']) ? $forminspeksi['merupakan_daerah'] : []) ? 'checked' : '' }} />
{{ $item->name }}
@endforeach
@@ -255,7 +262,15 @@
name, $selectedFasilitas) ? 'checked' : '' }} />
+ {{ in_array(
+ $item->name,
+ is_array(old('fasilitas_dekat_object', $forminspeksi['fasilitas_dekat_object'] ?? ''))
+ ? old('fasilitas_dekat_object', $forminspeksi['fasilitas_dekat_object'] ?? [])
+ : explode(',', old('fasilitas_dekat_object', $forminspeksi['fasilitas_dekat_object'] ?? '')),
+ )
+ ? 'checked'
+ : '' }} />
+
{{ $item->name }}
@endforeach
diff --git a/resources/views/surveyor/components/tanah.blade.php b/resources/views/surveyor/components/tanah.blade.php
index c47792e..717ba96 100644
--- a/resources/views/surveyor/components/tanah.blade.php
+++ b/resources/views/surveyor/components/tanah.blade.php
@@ -134,8 +134,8 @@
@foreach ($konturTanah as $item)
name, old('kontur_tanah', $forminspeksi['kontur_tanah'] ?? [])) ? 'checked' : '' }} />
+ value="{{ $item->name }}"
+ {{ in_array($item->name, old('kontur_tanah', isset($forminspeksi['kontur_tanah']) ? $forminspeksi['kontur_tanah'] : [])) ? 'checked' : '' }} />
{{ $item->name }}
@endforeach
diff --git a/resources/views/surveyor/detail.blade.php b/resources/views/surveyor/detail.blade.php
index 24f60b1..0333a6b 100644
--- a/resources/views/surveyor/detail.blade.php
+++ b/resources/views/surveyor/detail.blade.php
@@ -58,7 +58,7 @@
- @include('lpj::component.detail-jaminan')
+ @include('lpj::component.detail-jaminan',['backLink'=>'surveyor.index'])
@endsection
@push('scripts')
+
+ };
+
+ let dataTable = new KTDataTable(element, dataTableOptions);
+
+ searchInput.addEventListener('input', function() {
+ const searchValue = this.value.trim();
+ dataTable.search(searchValue, true);
+ });
+
+ // statusFilter.addEventListener('change', function() {
+ // const selectedStatus = this.value;
+ // dataTable.search(selectedStatus);
+ // });
+
+ function convertDate(date) {
+ const createdAt = new Date(date);
+ const day = String(createdAt.getDate()).padStart(2, '0');
+ const month = String(createdAt.getMonth() + 1).padStart(2, '0');
+ const year = createdAt.getFullYear();
+ return `${day}-${month}-${year}`;
+ }
+
+
+
+
+
@endpush
+
+
+
+
+
+
+
+
+
diff --git a/routes/web.php b/routes/web.php
index eb0ae6d..1ad699b 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -462,13 +462,17 @@ Route::middleware(['auth'])->group(function () {
Route::get('{id}/show', [SurveyorController::class, 'show'])->name('show');
Route::post('store', [SurveyorController::class, 'store'])->name('store');
Route::post('storeDenah', [SurveyorController::class, 'storeDenah'])->name('storeDenah');
+ Route::put('storeJadwal', [SurveyorController::class, 'storeJadwal'])->name('storeJadwal');
+ Route::get('storeAproved/{id}', [SurveyorController::class, 'storeAproved'])->name('storeAproved');
Route::post('storeFoto', [SurveyorController::class, 'storeFoto'])->name('storeFoto');
+ Route::get('checkButtonStatus/{id}', [SurveyorController::class, 'checkButtonStatus'])->name('checkButtonStatus');
+
Route::get('datatables', [SurveyorController::class, 'dataForDatatables'])->name('datatables');
Route::get('inspeksi/{id}/{jaminanId}', [SurveyorController::class, 'formInspeksi'])->name('inspeksi');
Route::get('denah/{id}/{jaminanId}', [SurveyorController::class, 'denah'])->name('denah');
Route::get('foto/{id}/{jaminanId}', [SurveyorController::class, 'foto'])->name('foto');
Route::get('data-pembanding/{id}', [SurveyorController::class, 'dataPembanding'])->name('data-pembanding');
- Route::put('submitSurveyor/{id}', [SurveyorController::class, 'submitSurveyor'])->name('submitSurveyor');
+ Route::get('submitSurveyor/{id}', [SurveyorController::class, 'submitSurveyor'])->name('submitSurveyor');
});
Route::name('penilai.')->prefix('penilai')->group(function () {