diff --git a/app/Exports/BasicDataSurveyorExport.php b/app/Exports/BasicDataSurveyorExport.php new file mode 100644 index 0000000..3137429 --- /dev/null +++ b/app/Exports/BasicDataSurveyorExport.php @@ -0,0 +1,58 @@ +model = $model; + } + + public function collection() + { + return $this->model::all(); + } + + public function map($row) + : array + { + return [ + $row->id, + $row->code, + $row->name, + $row->created_at + ]; + } + + public function headings() + : array + { + return [ + 'ID', + 'Code', + 'Name', + 'Created At' + ]; + } + + public function columnFormats() + : array + { + return [ + 'A' => NumberFormat::FORMAT_NUMBER, + 'D' => NumberFormat::FORMAT_DATE_DATETIME + ]; + } + } diff --git a/app/Http/Controllers/SurveyorController.php b/app/Http/Controllers/SurveyorController.php index 6b48f91..5e94681 100644 --- a/app/Http/Controllers/SurveyorController.php +++ b/app/Http/Controllers/SurveyorController.php @@ -5,8 +5,11 @@ namespace Modules\Lpj\Http\Controllers; use App\Http\Controllers\Controller; use Illuminate\Http\RedirectResponse; use Illuminate\Http\Request; +use Maatwebsite\Excel\Facades\Excel; +use Modules\Lpj\Exports\BasicDataSurveyorExport; use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\Auth; +use Illuminate\Support\Facades\Storage; use Illuminate\Http\Response; use Modules\Lpj\Models\Permohonan; use Modules\Lpj\Models\Branch; @@ -92,124 +95,77 @@ class SurveyorController extends Controller 'branch', 'tujuanPenilaian', 'penilaian', - 'documents', + 'documents.jenisJaminan', ])->findOrFail($id); - + $surveyor = $id; $branches = Branch::all(); $provinces = Province::all(); $bentukTanah = BentukTanah::all(); - $konturTanah = KonturTanah::all(); - $posisiKavling = PosisiKavling::all(); - $ketinggianTanah = KetinggianTanah::all(); - $kondisiFisikTanah = KondisiFisikTanah::all(); - $jenisBangunan = JenisBangunan::all(); - $kondisiBangunan = KondisiBangunan::all(); - $sifatBangunan = SifatBangunan::all(); - $spekKategoriBagunan = SpekKategoritBangunan::all(); - $spekBangunan = SpekBangunan::all(); - $saranaPelengkap = SaranaPelengkap::all(); - $arahMataAngin = ArahMataAngin::all(); - $jenisKendaraan = JenisKendaraan::all(); - $jenisKapal = JenisKapal::all(); - $jenisPesawat = JenisPesawat::all(); - $modelAlatBerat = ModelAlatBerat::all(); - - - $denah = Denah::where('permohonan_id', $id)->get(); - $fotojaminan = FotoJaminan::where('permohonan_id', $id)->get(); - $analisa = Analisa::with('analisaUnit', 'analisaTanahBangunan', 'analisaLingkungan', 'analisaFakta', 'jenisJaminan') - ->where('permohonan_id', $id) - ->get(); - - - - $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; - } - - - + + // Get all inspeksi data for this permohonan + $inspeksiData = Inspeksi::where('permohonan_id', $id) + ->get() + ->keyBy('jenis_jaminan_id') + ->map(function ($item) { + return [ + 'data_form' => json_decode($item->data_form, true), + 'foto_form' => json_decode($item->foto_form, true), + 'denah_form' => json_decode($item->denah_form, true), + 'data_pembanding' => json_decode($item->data_pembanding, true), + ]; + }); + return view('lpj::surveyor.detail', compact( - 'denah', - 'analisa', 'permohonan', 'surveyor', 'branches', 'provinces', 'bentukTanah', - 'konturTanah', - 'posisiKavling', - 'kondisiFisikTanah', - 'ketinggianTanah', - 'kondisiBangunan', - 'jenisBangunan', - 'sifatBangunan', - 'spekKategoriBagunan', - 'spekBangunan', - 'saranaPelengkap', - 'arahMataAngin', - 'forminspeksi', - 'formDenah', - 'formFoto', - 'jaminanId', - 'jenisKendaraan', - 'jenisKapal', - 'jenisPesawat', - 'modelAlatBerat' + 'inspeksiData' )); } + /** * Store form inspeksi. */ public function store(FormSurveyorRequest $request) { - $data = $request->validated(); - - - - if (!$data) { - return response()->json(['success' => false, 'message' => 'Invalid data'], 400); - } - try { - DB::beginTransaction(); + // Validate request data + $validatedData = $request->validated(); + + // Get action specific rules and process data + $processedData = $this->getActionSpecificRules( + $validatedData, + $request->input('type'), + $request + ); - $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 (!$inspeksi) { - Inspeksi::create([ + // Find or create inspeksi record + $inspeksi = Inspeksi::updateOrCreate( + [ 'permohonan_id' => $request->input('permohonan_id'), - 'data_form' => json_encode($rules), - 'name' => $request->input('type'), - 'jenis_jaminan_id' => $request->input('jenis_jaminan_id'), - ]); - } else { - $inspeksi->update(['data_form' => json_encode($rules)]); - } + 'jenis_jaminan_id' => $request->input('jenis_jaminan_id') + ], + [ + 'data_form' => json_encode($processedData), + 'name' => $request->input('type') + ] + ); - DB::commit(); + return response()->json([ + 'success' => true, + 'message' => 'Data berhasil disimpan', + 'data' => $processedData + ], 200); - return response()->json(['success' => true, 'message' => 'Data saved successfully', 'data' => $data], 200); - } catch (Exception $e) { - DB::rollBack(); - return response()->json(['success' => false, 'message' => 'Failed to save data: ' . $e->getMessage()], 500); + } catch (\Exception $e) { + return response()->json([ + 'success' => false, + 'message' => 'Gagal menyimpan data', + 'error' => $e->getMessage() + ], 500); } } @@ -284,8 +240,11 @@ class SurveyorController extends Controller ]); } - return response()->json(['success' => true, 'message' => 'Data berhasil disimpan', - 'data' => $formatJsonDenah], 200); + return response()->json([ + 'success' => true, + 'message' => 'Data berhasil disimpan', + 'data' => $formatJsonDenah + ], 200); } catch (Exception $e) { return response()->json(['success' => false, 'message' => 'Data gagal disimpan: ' . $e->getMessage()], 500); } @@ -294,7 +253,128 @@ class SurveyorController extends Controller public function storeFoto(Request $request) { - $validatedData = $request->validate([ + $validatedData = $this->validateFotoRequest($request); + try { + + $photoCategories = [ + 'rute_menuju_lokasi' => ['foto_rute', 'name_rute'], + 'object_jaminan' => ['foto_objek', 'name_objek', 'deskripsi_objek'], + 'lingkungan' => ['foto_lingkungan', 'name_lingkungan'], + 'foto_lantai_unit' => ['foto_lantai_unit', 'name_lantai_unit'], + 'foto_lantai_lainnya' => ['foto_lantai_lainnya', 'name_lantai_lainnya'], + 'foto_rute_lainnya' => ['foto_rute_lainnya', 'name_rute_lainnya'], + ]; + + $inspeksi = Inspeksi::firstOrNew([ + 'permohonan_id' => $request->input('permohonan_id'), + 'jenis_jaminan_id' => $request->input('jenis_jaminan_id') + ]); + + // Get existing foto_form data if it exists + $existingData = $inspeksi->exists && $inspeksi->foto_form + ? json_decode($inspeksi->foto_form, true) + : []; + + $formatFotojson = $existingData; // Start with existing data + + // Process each photo category + foreach ($photoCategories as $category => $fields) { + // Only update if new files are provided + if ($this->categoryHasNewFiles($request, $fields)) { + // Delete old files for this category only + if (isset($existingData[$category])) { + $this->deleteFilesForCategory($existingData[$category]); + } + $formatFotojson[$category] = $this->processPhotoCategory($request, $fields); + } + } + + // Process single files + $singleFiles = ['foto_basement', 'foto_gerbang', 'pendamping']; + foreach ($singleFiles as $file) { + if ($request->hasFile($file)) { + // Delete old file if exists + if (isset($existingData[$file])) { + $this->deleteFile($existingData[$file]); + } + $formatFotojson[$file] = $this->uploadFile($request->file($file), $file); + } + } + + // Update record + $inspeksi->foto_form = json_encode($formatFotojson); + $inspeksi->save(); + + + + 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); + } + } + + /** + * Process a photo category and its subcategories + */ + + private function processPhotoCategory(Request $request, array $fields) + { + $result = []; + $photoField = $fields[0]; + + if ($request->hasFile($photoField)) { + foreach ($request->file($photoField, []) as $key => $value) { + $item = []; + $item[$fields[1]] = $request->input($fields[1] . '.' . $key); + $item[$photoField] = $this->uploadFile($value, $photoField . '.' . $key); + + if (isset($fields[2])) { + $item[$fields[2]] = $request->input($fields[2] . '.' . $key); + } + + $result[] = $item; + } + } + + return $result; + } + + private function categoryHasNewFiles(Request $request, array $fields): bool +{ + $photoField = $fields[0]; // First element is usually the photo field + return $request->hasFile($photoField) || + (is_array($request->file($photoField)) && count($request->file($photoField)) > 0); +} + +private function deleteFilesForCategory($categoryData) +{ + if (!is_array($categoryData)) { + return; + } + + foreach ($categoryData as $item) { + if (isset($item['foto'])) { + $this->deleteOfFile($item['foto']); + } + } +} + +private function deleteOfFile($filePath) +{ + if ($filePath && Storage::exists($filePath)) { + Storage::delete($filePath); + } +} + + + + + /** + * Custom validation request for foto + */ + public function validateFotoRequest(Request $request) + { + return $request->validate([ 'permohonan_id' => 'required', 'jenis_jaminan_id' => 'required', 'pendamping' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:2048', @@ -316,164 +396,96 @@ class SurveyorController extends Controller 'foto_gerbang' => 'nullable|image|mimes:jpeg,png,jpg,gif,svg|max:2048', 'name_gerbang' => 'nullable|string|max:255', ]); - - try { - - $rute_menuju_lokasi = []; - $object_jaminan = []; - $lingkungan = []; - $foto_lantai_unit = []; - $foto_lantai_lainnya = []; - $foto_rute_lainnya = []; - - - foreach ($request->file('foto_rute', []) as $key => $value) { - $fotoRutePath = $this->uploadFile($request->file('foto_rute.' . $key), 'foto_rute.' . $key); - - $rute_menuju_lokasi[] = [ - 'name_rute' => $request->input('name_rute.' . $key), - 'foto_rute' => $fotoRutePath, - ]; - } - - foreach ($request->file('foto_objek', []) as $key => $value) { - $fotoObjekPath = $this->uploadFile($request->file('foto_objek.' . $key), 'foto_objek.' . $key); - $object_jaminan[] = [ - 'nama_objek' => $request->input('name_objek.' . $key), - 'foto_object' => $fotoObjekPath, - 'deskripsi_objek' => $request->input('deskripsi_objek.' . $key), - ]; - } - - foreach ($request->file('foto_lingkungan', []) as $key => $value) { - $fotoLingkunganPath = $this->uploadFile($request->file('foto_lingkungan.' . $key), 'foto_lingkungan.' . $key); - $lingkungan[] = [ - 'name_lingkungan' => $request->input('name_lingkungan.' . $key), - 'foto_lingkungan' => $fotoLingkunganPath, - - ]; - } - - foreach ($request->file('foto_lantai_unit', []) as $key => $value) { - $foto_lantai_unit_Path = $this->uploadFile($request->file('foto_lantai_unit.' . $key), 'foto_lantai_unit.' . $key); - $foto_lantai_unit[] = [ - 'name_lantai_unit' => $request->input('name_lantai_unit.' . $key), - 'foto_lantai_unit' => $foto_lantai_unit_Path, - - ]; - } - - foreach ($request->file('foto_rute_lainnya', []) as $key => $value) { - $foto_rute_lainnya_path = $this->uploadFile($request->file('foto_rute_lainnya.' . $key), 'foto_rute_lainnya.' . $key); - $foto_rute_lainnya[] = [ - 'name_rute_lainnya' => $request->input('name_rute_lainnya.' . $key), - 'foto_rute_lainnya' => $foto_rute_lainnya_path, - - ]; - } - - - foreach ($request->file('foto_lantai_lainnya', []) as $key => $value) { - $foto_lantai_lainnya_path = $this->uploadFile($request->file('foto_lantai_lainnya.' . $key), 'foto_lantai_lainnya.' . $key); - $foto_lantai_lainnya[] = [ - 'name_lantai_lainnya' => $request->input('name_lantai_lainnya.' . $key), - 'foto_lantai_lainnya' => $foto_lantai_lainnya_path, - - ]; - } - - - $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 = [ - 'rute_menuju_lokasi' => $rute_menuju_lokasi, - 'object_jaminan' => $object_jaminan, - 'lingkungan' => $lingkungan - ,'foto_lantai_unit' => $foto_lantai_unit, - 'foto_lantai_lainnya' => $foto_lantai_lainnya, - 'foto_rute_lainnya' => $foto_rute_lainnya, - 'foto_basement' => $basement, - 'foto_gerbang' => $gerbang, - 'pendamping' => $pendamping - ]; - - $inspeksi = Inspeksi::where('permohonan_id', $request->input('permohonan_id'))->where('jenis_jaminan_id', $request->input('jenis_jaminan_id'))->first(); - - if ($inspeksi) { - $inspeksi->update([ - 'foto_form' => json_encode($formatFotojson) - ]); - } else { - Inspeksi::create([ - 'permohonan_id' => $request->input('permohonan_id'), - 'foto_form' => json_encode($formatFotojson), - 'jenis_jaminan_id' => $request->input('jenis_jaminan_id') - ]); - } - - 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 submitSurveyor($id) - { - try { - // $cekButton = $this->checkButtonStatus($id); - // 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); - // } - } catch (Exception $e) { - return response()->json(['error' => 'Something went wrong', 'message' => $e->getMessage()], 500); +{ + try { + // Get button status check result + $buttonStatusCheck = $this->checkButtonStatus($id); + $buttonStatus = json_decode($buttonStatusCheck->getContent(), true); + + // Check if button should be disabled + if ($buttonStatus['buttonDisable']) { + return response()->json([ + 'success' => false, + 'message' => 'Form belum lengkap. Pastikan semua data telah diisi dengan benar.', + ], 422); } + + // If validation passes, update permohonan status + // $permohonan = Permohonan::findOrFail($id); + // $permohonan->update([ + // 'status' => 'done', + // 'submitted_at' => now() + // ]); + + return response()->json([ + 'success' => true, + 'message' => 'Form surveyor berhasil disubmit' + ], 200); + + } catch (\Exception $e) { + return response()->json([ + 'success' => false, + 'message' => 'Terjadi kesalahan', + 'error' => $e->getMessage() + ], 500); } +} + public function checkButtonStatus($id) { try { - - $inpeksi = Inspeksi::where('permohonan_id', $id)->first(); - - if ($inpeksi) { - $forminspeksi = json_decode($inpeksi->data_form, true); - $formFoto = json_decode($inpeksi->foto_form, true); - - $buttonDisable = false; - if ( - $formFoto && count($formFoto) > 0 && - $forminspeksi - ) { - $buttonDisable = false; - } else { - $buttonDisable = true; - } - - return response()->json(['buttonDisable' => $buttonDisable]); - } else { + // Get all inspeksi records for this permohonan + $inspeksiRecords = Inspeksi::where('permohonan_id', $id)->get(); + + if ($inspeksiRecords->isEmpty()) { return response()->json(['buttonDisable' => true]); } + + foreach ($inspeksiRecords as $inspeksi) { + $dataForm = json_decode($inspeksi->data_form, true); + $fotoForm = json_decode($inspeksi->foto_form, true); + $denahForm = json_decode($inspeksi->denah_form, true); + $dataPembanding = json_decode($inspeksi->data_pembanding, true); + + // Get jenis jaminan to check if it needs denah + $jenisJaminan = JenisJaminan::find($inspeksi->jenis_jaminan_id); + $isTanahBangunan = !in_array( + strtoupper($jenisJaminan->name ?? ''), + ['KAPAL', 'PESAWAT', 'KENDARAAN', 'ALAT BERAT'] + ); + + // Check if required forms are empty or incomplete + if (empty($dataForm) || empty($fotoForm)) { + return response()->json(['buttonDisable' => true]); + } + + if ($isTanahBangunan && empty($denahForm)) { + return response()->json(['buttonDisable' => true]); + } + + if (empty($dataPembanding)) { + return response()->json(['buttonDisable' => true]); + } + } + + // If we get here, all checks passed + return response()->json(['buttonDisable' => false]); + } catch (\Exception $e) { - // return response()->json(['buttonDisable' => true]); return response()->json([ 'error' => 'Something went wrong', - 'message' => $e->getMessage() + 'message' => $e->getMessage(), + 'buttonDisable' => true ], 500); } } + @@ -570,7 +582,7 @@ class SurveyorController extends Controller return response()->json(['success' => false, 'message' => 'Failed to save data: ' . $e->getMessage()], 500); } } - + /** * Form inspeksi. */ @@ -583,9 +595,9 @@ class SurveyorController extends Controller $link_url_region = Teams::with('regions', 'teamsUsers') - ->whereHas('teamsUsers', function ($query) { - $query->where('user_id', Auth::user()->id); - })->first(); + ->whereHas('teamsUsers', function ($query) { + $query->where('user_id', Auth::user()->id); + })->first(); $branches = Branch::all(); $provinces = Province::all(); @@ -793,13 +805,12 @@ class SurveyorController extends Controller if (!$modelClass) { return redirect() - ->route('basicdata.'. $type .'.index') + ->route('basicdata.' . $type . '.index') ->with('error', 'Invalid type specified.'); } if ($type == 'spek-bangunan') { $validate['spek_kategori_bagunan_id'] = $request->spek_kategori_bagunan_id; - } @@ -807,12 +818,11 @@ class SurveyorController extends Controller $modelClass::create($data); return redirect() - ->route('basicdata.' . $type .'.index') + ->route('basicdata.' . $type . '.index') ->with('success', 'created successfully'); - } catch (Exeception $e) { return redirect() - ->route('basicdata.' . $type .'.index') + ->route('basicdata.' . $type . '.index') ->with('error', $th->getMessage()); } } @@ -861,7 +871,6 @@ class SurveyorController extends Controller $spekKategoriBagunan = null; if ($type == 'spek-bangunan') { $spekKategoriBagunan = SpekKategoritBangunan::all(); - } @@ -877,7 +886,6 @@ class SurveyorController extends Controller if ($type == 'spek-bangunan') { $validate['spek_kategori_bagunan_id'] = $request->spek_kategori_bagunan_id; - } // Check if the provided type exists in the modelClasses @@ -914,23 +922,23 @@ class SurveyorController extends Controller 'penilaian', 'documents', ])->findOrFail($id); - + $jenisAssetUpdated = false; if ($request->input('types') == 'jenis_asset') { $this->updateJenisAsset($permohonan, $request); $jenisAssetUpdated = true; } - + if (in_array($request->input('types'), ['analisa_tanah', 'analisa_bangunan', 'analisa_unit'])) { $key = match ($request->input('types')) { 'analisa_tanah' => 'luas_tanah', 'analisa_bangunan' => 'luas_bangunan', 'analisa_unit' => 'luas_unit', }; - + $this->updateDetails($permohonan, $key, $request->input($key)); } - + return response()->json([ 'success' => true, 'message' => 'Data berhasil disimpan', @@ -940,8 +948,8 @@ class SurveyorController extends Controller return response()->json(['error' => 'Something went wrong', 'message' => $e->getMessage()], 500); } } - - + + private function updateJenisAsset($permohonan, $request) { $jenis_jaminan_id = $permohonan->debiture->documents->first()->jenis_jaminan_id; @@ -951,35 +959,35 @@ class SurveyorController extends Controller 'jenis_jaminan_id' => $request->input('jenis_asset'), ]); } - + private function updateDetails($permohonan, $key, $newValue) { $document = $permohonan->debiture->documents->first(); - + if (!$document) { throw new \Exception("Document not found"); } - + $detailsUpdate = DetailDokumenJaminan::where('dokumen_jaminan_id', $document->id)->first(); - + if (!$detailsUpdate) { throw new \Exception("DetailDokumenJaminan not found"); } - + $datas = json_decode($detailsUpdate->details, true) ?? []; - + if (is_numeric($newValue)) { $newValue = [$key => $newValue]; } - + if (!is_array($newValue)) { throw new \InvalidArgumentException("'{$key}' must be an array or valid JSON string"); } - + foreach ($newValue as $subKey => $value) { $datas[$subKey] = $value; // Update atau tambahkan key baru } - + $detailsUpdate->update([ 'details' => json_encode($datas), ]); @@ -1036,7 +1044,7 @@ class SurveyorController extends Controller } $filteredRecords = $query->count(); - $data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'jenisFasilitasKredit','penilaian'])->get(); + $data = $query->with(['user', 'debiture', 'branch', 'tujuanPenilaian', 'jenisFasilitasKredit', 'penilaian'])->get(); $pageCount = ceil($totalRecords / $size); @@ -1187,10 +1195,10 @@ class SurveyorController extends Controller $query->where('jenis_jaminan_id', $jaminanId); } ]) - ->whereHas('debiture.documents', function ($query) use ($jaminanId) { - $query->where('jenis_jaminan_id', $jaminanId); - }) - ->findOrFail($id); + ->whereHas('debiture.documents', function ($query) use ($jaminanId) { + $query->where('jenis_jaminan_id', $jaminanId); + }) + ->findOrFail($id); } @@ -1230,6 +1238,7 @@ class SurveyorController extends Controller 'fasilitas-objek' => FasilitasObjek::class, 'merupakan-daerah' => MerupakanDaerah::class, 'jenis-unit' => JenisUnit::class, + 'perkerasan-jalan' => PerkerasanJalan::class, ]; @@ -1301,88 +1310,137 @@ class SurveyorController extends Controller 'posisi-unit' => ['Posisi unit', 'posisi-unit'], 'bentuk-unit' => ['Bentuk unit', 'bentuk-unit'], 'fasilitas-objek' => ['Fasilitas Umum Dekat Objek', 'fasilitas-objek'], - ]; + ]; - private function getAssetData($data) + private function getAssetData(array $data): array { - return [ - 'asset' =>[ - '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, + $alamatData = [ '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, - ]]; + ]; + + return [ + 'asset' => [ + 'debitur_perwakilan' => $data['debitur_perwakilan'] ?? [], + 'jenis_asset' => [ + $data['jenis_asset'] => ($data['jenis_asset'] === 'sesuai') + ? $data['jenis_asset_name'] + : ($data['jenis_asset_tidak_sesuai'] ?? null) + ], + 'alamat' => [ + $data['alamat_sesuai'] => $alamatData + ], + 'hub_cadeb' => [ + $data['hub_cadeb'] => $this->getFieldData( + $data, + 'hub_cadeb', + true + ) + ], + 'hub_cadeb_penghuni' => [ + $data['hub_cadeb_penghuni'] => $this->getFieldData( + $data, + 'hub_cadeb_penghuni', + true + ) + ], + + 'kordinat_lng' => $data['kordinat_lng'] ?? null, + 'kordinat_lat' => $data['kordinat_lat'] ?? null, + ] + ]; } - private function getTanahData($data, $request): array + private function getTanahData(array $data): array { return [ 'tanah' => [ - - '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, - ], + 'luas_tanah' => $this->getFieldData( + $data, + 'luas_tanah', + true + ), + 'hadap_mata_angin' => $this->getFieldData( + $data, + 'hadap_mata_angin', + true + ), + 'bentuk_tanah' => $this->getFieldData( + $data, + 'bentuk_tanah', + false, + 'lainnya' + ), + 'kontur_tanah' => $data['kontur_tanah'] ?? [], + 'ketinggian_tanah' => [ + 'ketinggian' => $data['kontur_tanah'] ?? null, + 'lebih_tinggi' => $data['ketinggian_lebih_tinggi'] ?? null, + 'lebih_rendah' => $data['ketinggian_lebih_rendah'] ?? null + ], + 'kontur_jalan' => $data['kontur_jalan'] ?? null, + 'ketinggian_jalan' => $data['ketinggian_jalan'] ?? [], + 'posisi_kavling' => $this->getFieldData( + $data, + 'posisi_kavling', + false, + 'lainnya' + ), + 'tusuk_sate' => $data['tusuk_sate'] ?? null, + 'lockland' => $data['lockland'] ?? null, + 'kondisi_fisik_tanah' => $this->getFieldData( + $data, + 'kondisi_fisik_tanah', + false, + 'lainnya' + ) + ] ]; } + private function getBangunanData($data, $request): array { $data = $request->all(); $result = []; - // foreach ($data['nama_bagunan'] as $index => $bangunan) { - // $bangunanData = [ - // 'bangunan' => $bangunan, - // 'kategori' => [] - // ]; + foreach ($data['nama_bagunan'] as $index => $bangunan) { + $bangunanData = [ + 'bangunan' => $bangunan, + 'kategori' => [] + ]; - // foreach ($data['spek_kategori_bangunan'] as $kategoriIndex => $kategori) { - // if (isset($data['spek_bangunan'][$kategori])) { - // $bangunanData['kategori'][] = [ - // 'kategori' => $kategori, - // 'spesifikasi' => $data['spek_bangunan'][$kategori] - // ]; - // } - // } + foreach ($data['spek_kategori_bangunan'] as $kategoriIndex => $kategori) { + if (isset($data['spek_bangunan'][$kategori])) { + $bangunanData['kategori'][] = [ + 'kategori' => $kategori, + 'spesifikasi' => $data['spek_bangunan'][$kategori] + ]; + } + } - // $result[] = $bangunanData; - // } + $result[] = $bangunanData; + } return [ 'bangunan' => [ - '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_bangunan_input'] ?? null, - 'spesifikasi_bangunan' => $result ?? null, - // 'spek_bangunan' => $data['spek_bangunan'] ?? [], - 'sarana_pelengkap' => $data['sarana_pelengkap'] ?? [], - 'sarana_pelengkap_input' => $data['sarana_pelengkap_input'] ?? null, + 'luas_tanah_bagunan' => $this->getFieldData( + $data, + 'luas_tanah_bagunan', + true + ), + 'jenis_bangunan' => $data['jenis_bangunan'] ?? null, + 'kondisi_bangunan' => $data['kondisi_bangunan'] ?? null, + 'sifat_bangunan' => $data['sifat_bangunan'] ?? null, + 'sifat_bangunan_input' => $data['sifat_bangunan_input'] ?? null, + 'spesifikasi_bangunan' => $result ?? null, + 'sarana_pelengkap' => $this->mapArrayWithInputs( + $data['sarana_pelengkap'] ?? [], + $data['sarana_pelengkap_input'] ?? [] + ), ], ]; } @@ -1391,27 +1449,27 @@ class SurveyorController extends Controller { return [ 'lingkungan' => [ - '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, + '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, ] ]; } @@ -1420,24 +1478,26 @@ class SurveyorController extends Controller { $factData = [ 'fakta' => [ - 'fakta_positif' => $data['fakta_positif'] ?? null, - 'fakta_negatif' => $data['fakta_negatif'] ?? null, - 'rute_menuju' => $data['rute_menuju'] ?? null, - 'batas_batas' => $data['batas_batas'] ?? null, - 'batas_batas_input' => $data['batas_batas_input'] ?? 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, - 'keterangan' => $data['keterangan'] ?? null, + 'fakta_positif' => $data['fakta_positif'] ?? null, + 'fakta_negatif' => $data['fakta_negatif'] ?? null, + 'rute_menuju' => $data['rute_menuju'] ?? null, + 'batas_batas' => $this->mapArrayWithInputs( + $data['batas_batas'] ?? null, + $data['batas_batas_input'] ?? 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, + 'keterangan' => $data['keterangan'] ?? null, ] ]; @@ -1462,7 +1522,7 @@ class SurveyorController extends Controller $factData[$fotoType] = $dataForm[$fotoType] ?? null; } } - }else{ + } else { foreach ($fotoTypes as $fotoType) { $factData[$fotoType] = $this->updateOrDeleteFile($data, $request, $fotoType); } @@ -1852,8 +1912,11 @@ class SurveyorController extends Controller { return [ 'action' => $data['action'] ?? null, - 'luas_unit' => $data['luas_unit'] ?? null, - 'luas_unit_tidak_sesuai' => $data['luas_unit_tidak_sesuai'] ?? null, + 'luas_unit' => $this->getFieldData( + $data, + 'luas_unit', + true + ), 'jenis_unit' => $data['jenis_unit'] ?? null, 'kondisi_unit' => $data['kondisi_unit'] ?? null, 'posisi_unit' => $data['posisi_unit'] ?? null, @@ -1865,9 +1928,15 @@ class SurveyorController extends Controller + /** + * Helper untuk upload file + * + * @param $file + * @param $type + * @return path name + */ - // function upload file to storage private function uploadFile($file, $type) { if (!$file->isValid()) { @@ -1884,5 +1953,75 @@ class SurveyorController extends Controller return str_replace('public/', '', $path); } -} + /** + * Helper untuk memetakan array dengan inputannya + * + * @param array $keys Array kunci + * @param array $values Array nilai/input + * @return array + */ + private function mapArrayWithInputs(array $keys, array $values): array + { + $result = []; + + foreach ($keys as $index => $key) { + $result[$key] = $values[$index] ?? null; + } + + return $result; + } + + + + /** + * Helper method generic untuk mengambil data field + * + * @param array $data Array sumber data + * @param string $fieldName Nama field + * @param bool $checkKesesuaian Apakah perlu cek kesesuaian + * @param string|null $extraField Field tambahan (misal 'lainnya') + * @return array + */ + private function getFieldData( + array $data, + string $fieldName, + bool $checkKesesuaian = false, + ?string $extraField = null + ): array { + if ($checkKesesuaian) { + return [ + $data[$fieldName] ?? '' => ($data[$fieldName] ?? '') === 'sesuai' + ? ($data["{$fieldName}_sesuai"] ?? '') + : ($data["{$fieldName}_tidak_sesuai"] ?? '') + ]; + } + + $result = [ + $fieldName => $data[$fieldName] ?? null + ]; + + if ($extraField) { + $result[$extraField] = $data["{$fieldName}_{$extraField}"] ?? null; + } + + return $result; + } + + + public function export(string $type) + { + $modelClass = $this->getModelClass($type); + + if (!$modelClass) { + + return response()->json([ + 'message' => 'Invalid type provided.', + 'available_types' => array_keys($this->modelClasses), + ], 400); + } + + // Return Excel download + return Excel::download(new BasicDataSurveyorExport($modelClass), $type . '.xlsx'); + } +} diff --git a/app/Http/Requests/FormSurveyorRequest.php b/app/Http/Requests/FormSurveyorRequest.php index 0a3245b..3eeafe5 100644 --- a/app/Http/Requests/FormSurveyorRequest.php +++ b/app/Http/Requests/FormSurveyorRequest.php @@ -71,8 +71,10 @@ class FormSurveyorRequest extends FormRequest { return [ 'luas_tanah' => 'required', + 'luas_tanah_sesuai' => 'nullable', 'luas_tanah_tidak_sesuai' => 'nullable', 'hadap_mata_angin' => 'required', + 'hadap_mata_angin_sesuai' => 'nullable', 'hadap_mata_angin_tidak_sesuai' => 'nullable', 'bentuk_tanah' => 'nullable|array', 'bentuk_tanah_lainnya' => 'nullable', @@ -95,7 +97,9 @@ class FormSurveyorRequest extends FormRequest { return [ 'action' => 'required', + 'luas_tanah_bangunan_sesuai' => 'nullable', 'luas_tanah_bagunan' => 'required', + 'luas_tanah_bangunan_tidak_sesuai' => 'nullable', 'jenis_bangunan' => 'required', 'kondisi_bangunan' => 'nullable', 'sifat_bangunan' => 'required|array', @@ -116,6 +120,7 @@ class FormSurveyorRequest extends FormRequest return [ 'action' => 'required', 'luas_unit' => 'required', + 'luas_unit_sesuai' => 'nullable', 'luas_unit_tidak_sesuai' => 'nullable', 'jenis_unit' => 'required|array', 'kondisi_unit' => 'required|array', @@ -511,10 +516,19 @@ class FormSurveyorRequest extends FormRequest 'permohonan_id' => 'required', 'type' => 'required', 'debitur_perwakilan' => 'required|array', + 'jenis_asset_name' => 'nullable', 'jenis_asset' => 'required', 'jenis_asset_tidak_sesuai' => 'nullable', 'alamat_sesuai' => 'required', 'alamat_tidak_sesuai' => 'nullable', + + 'hub_cadeb' => 'required', + 'hub_cadeb_sesuai' => 'nullable', + 'hub_cadeb_tidak_sesuai' => 'nullable', + 'hub_cadeb_penghuni' => 'required', + 'hub_cadeb_penghuni_sesuai' => 'nullable', + 'hub_cadeb_penghuni_tidak_sesuai' => 'nullable', + 'nama_jalan' => 'nullable', 'desa_kelurahan' => 'nullable', 'kecamatan' => 'nullable', diff --git a/app/Http/Requests/SurveyorRequest.php b/app/Http/Requests/SurveyorRequest.php index 379d24b..ec41731 100644 --- a/app/Http/Requests/SurveyorRequest.php +++ b/app/Http/Requests/SurveyorRequest.php @@ -37,6 +37,7 @@ class SurveyorRequest extends FormRequest 'posisi-unit' => 'posisi_unit', 'bentuk-unit' => 'bentuk_unit', 'fasilitas-objek' => 'fasilitas_objek', + 'perkerasan-jalan' => 'perkerasan_jalan', ]; /** diff --git a/resources/views/surveyor/components/apartemen-kantor.blade.php b/resources/views/surveyor/components/apartemen-kantor.blade.php index 654f2d0..c965938 100644 --- a/resources/views/surveyor/components/apartemen-kantor.blade.php +++ b/resources/views/surveyor/components/apartemen-kantor.blade.php @@ -12,26 +12,44 @@
+ @if (isset($permohonan->debiture->documents)) + @foreach ($permohonan->debiture->documents as $item) + @php + $luas = $item->detail; + $details = json_decode($luas[0]->details, true); + $luas_unit = isset($details['luas_unit']) ? $details['luas_unit'] : 'N/A'; + @endphp + +

{{ $luas_unit }} m2

+ @endforeach + + @endif +
- - -
+ style="{{ old('luas_unit', $forminspeksi['luas_unit'] ?? '') == 'tidak sesuai' ? '' : 'display: none;' }}"> + + +
@@ -94,8 +112,8 @@ {{ in_array($item->name, old('lantai', $forminspeksi['lantai'] ?? [])) ? 'checked' : '' }} /> {{ $item->name }} - @endforeach diff --git a/resources/views/surveyor/components/bangunan.blade.php b/resources/views/surveyor/components/bangunan.blade.php index b78b11b..284794c 100644 --- a/resources/views/surveyor/components/bangunan.blade.php +++ b/resources/views/surveyor/components/bangunan.blade.php @@ -7,7 +7,7 @@
- + @if (isset($permohonan->debiture->documents)) @foreach ($permohonan->debiture->documents as $item) @php @@ -15,9 +15,10 @@ $details = json_decode($luas[0]->details, true); $luas_bangunan = isset($details['luas_bangunan']) ? $details['luas_bangunan'] : 'N/A'; @endphp +

{{ $luas_bangunan }} m2

@endforeach - + @endif
@@ -60,20 +61,16 @@ - @if (strcasecmp($item->name, 'lainnya') == 0) -
- - -
- @endif + @if (strcasecmp($item->name, 'Lainnya') == 0) + + @endif @endforeach @endif
@@ -153,7 +150,7 @@ @if (@isset($spekKategoriBagunan)) @foreach ($spekKategoriBagunan as $item)
- diff --git a/resources/views/surveyor/components/card-tambah.blade.php b/resources/views/surveyor/components/card-tambah.blade.php index 23370f9..a720d4a 100644 --- a/resources/views/surveyor/components/card-tambah.blade.php +++ b/resources/views/surveyor/components/card-tambah.blade.php @@ -1,78 +1,93 @@
@foreach ($permohonan->debiture->documents as $dokumen) - @if (request()->has('form') && request('form') === 'denah') - - @elseif(request()->has('form') && request('form') === 'foto') - - @elseif(request()->has('form') && request('form') === 'inspeksi') - + @php + $jaminanId = $dokumen->jenisJaminan->id; + $currentInspeksi = $inspeksiData[$jaminanId] ?? null; + + $tanahBangunanTypes = ['KAPAL', 'PESAWAT', 'KENDARAAN', 'ALAT BERAT']; + + $href = [ + [ + 'label' => 'form inspeksi', + 'url' => route('surveyor.inspeksi', [ + 'id' => $permohonan->id, + 'jaminanId' => $jaminanId, + ]) . "?form=create-inspeksi&inspeksi={$permohonan->id}&jenis_jaminan={$jaminanId}", + 'show' => true, + 'icon' => !empty($currentInspeksi['data_form']), + ], + ]; - @elseif(request()->has('form') && request('form') === 'data-pembanding') - - @endif + if (!in_array(strtoupper($dokumen->jenisJaminan->name), $tanahBangunanTypes)) { + $href[] = [ + 'label' => 'denah tanah dan bangunan', + 'url' => route('surveyor.denah', [ + 'id' => $permohonan->id, + 'jaminanId' => $jaminanId, + ]) . "?form=create-denah&denah={$permohonan->id}&jenis_jaminan={$jaminanId}", + 'show' => true, + 'icon' => !empty($currentInspeksi['denah_form']), + ]; + } -
-
-
-
- - - - -
- -
+ $href = array_merge($href, [ + [ + 'label' => 'foto', + 'url' => route('surveyor.foto', [ + 'id' => $permohonan->id, + 'jaminanId' => $jaminanId, + ]) . "?form=create-foto&foto={$permohonan->id}&jenis_jaminan={$jaminanId}", + 'show' => true, + 'icon' => !empty($currentInspeksi['foto_form']), + ], + [ + 'label' => 'data pembanding', + 'url' => route('surveyor.data-pembanding', [ + 'id' => $permohonan->id, + 'jaminanId' => $jaminanId, + ]) . "?form=data-pembanding&pembanding={$permohonan->id}&jenis_jaminan={$jaminanId}", + 'show' => true, + 'icon' => !empty($currentInspeksi['data_pembanding']), + ], + ]); + @endphp + +
diff --git a/resources/views/surveyor/components/data-pembanding.blade.php b/resources/views/surveyor/components/data-pembanding.blade.php index 28b7f41..b90fed1 100644 --- a/resources/views/surveyor/components/data-pembanding.blade.php +++ b/resources/views/surveyor/components/data-pembanding.blade.php @@ -1,40 +1,33 @@ @extends('layouts.main') -{{-- @section('breadcrumbs') +@section('breadcrumbs') {{ Breadcrumbs::render(request()->route()->getName()) }} -@endsection --}} +@endsection @section('content') @include('lpj::assetsku.includenya')
-
-
-
-

- Data Pembanding -

- -
-
-
-
+
@csrf -
+
+

+ Data Pembanding +

+ +
- {{--
-
--}}
@endsection @push('scripts') @@ -126,19 +101,19 @@ function toggleAlamatVisibility(idSesuai, idTidakSesuai, selectedValue) { - // Ambil elemen berdasarkan ID - const alamatSesuai = document.getElementById(idSesuai); - const alamatTidakSesuai = document.getElementById(idTidakSesuai); + // Ambil elemen berdasarkan ID + const alamatSesuai = document.getElementById(idSesuai); + const alamatTidakSesuai = document.getElementById(idTidakSesuai); - // Periksa nilai yang dipilih dan tampilkan elemen yang sesuai - if (selectedValue === 'sesuai') { - alamatSesuai.style.display = 'grid'; // Tampilkan "Alamat Sesuai" - alamatTidakSesuai.style.display = 'none'; // Sembunyikan "Alamat Tidak Sesuai" - } else if (selectedValue === 'tidak sesuai') { - alamatSesuai.style.display = 'none'; // Sembunyikan "Alamat Sesuai" - alamatTidakSesuai.style.display = 'grid'; // Tampilkan "Alamat Tidak Sesuai" - } -} + // Periksa nilai yang dipilih dan tampilkan elemen yang sesuai + if (selectedValue === 'sesuai') { + alamatSesuai.style.display = 'grid'; // Tampilkan "Alamat Sesuai" + alamatTidakSesuai.style.display = 'none'; // Sembunyikan "Alamat Tidak Sesuai" + } else if (selectedValue === 'tidak sesuai') { + alamatSesuai.style.display = 'none'; // Sembunyikan "Alamat Sesuai" + alamatTidakSesuai.style.display = 'grid'; // Tampilkan "Alamat Tidak Sesuai" + } + } @@ -275,7 +250,11 @@ console.error('Terjadi error:', error); console.log('Status:', status); console.log('Response:', xhr.responseText); - toastrErrorBuild(error); + if (xhr.responseJSON.message) { + toastrErrorBuild(xhr.responseJSON.message); + } else { + toastrErrorBuild('Terjadi kesalahan'); + } } }); } diff --git a/resources/views/surveyor/components/lingkungan.blade.php b/resources/views/surveyor/components/lingkungan.blade.php index cc59d4b..d6d2e40 100644 --- a/resources/views/surveyor/components/lingkungan.blade.php +++ b/resources/views/surveyor/components/lingkungan.blade.php @@ -50,9 +50,15 @@ + @if (strcasecmp($item->name, 'Lainnya') == 0) + + @endif @endforeach @endif
@@ -133,10 +139,16 @@ + @if (strcasecmp($item->name, 'Lainnya') == 0) + + @endif @endforeach @endif
@@ -246,53 +258,34 @@
-
+
- + placeholder="Km" />
- + placeholder="Nama TPS" />
@@ -332,9 +325,15 @@ @php $selectedFasilitas = is_array( - old('fasilitas_dekat_object', $forminspeksi['lingkungan']['fasilitas_dekat_object'] ?? []), + old( + 'fasilitas_dekat_object', + $forminspeksi['lingkungan']['fasilitas_dekat_object'] ?? [], + ), ) - ? old('fasilitas_dekat_object', $forminspeksi['lingkungan']['fasilitas_dekat_object'] ?? []) + ? old( + 'fasilitas_dekat_object', + $forminspeksi['lingkungan']['fasilitas_dekat_object'] ?? [], + ) : explode( ',', old( @@ -353,10 +352,18 @@ : explode(',', old('fasilitas_dekat_object', $forminspeksi['lingkungan']['fasilitas_dekat_object'] ?? '')), ) ? 'checked' - : '' }} /> + : '' }} + onclick="toggleCheckboxVisibility('fasilitas_dekat_object', 'fasilitas_dekat_object_lainnya', ['Lainnya'])" + /> {{ $item->name }} + + @if (strcasecmp($item->name, 'Lainnya') == 0) + + @endif @endforeach @endif
@@ -367,4 +374,3 @@
- diff --git a/resources/views/surveyor/components/tanah.blade.php b/resources/views/surveyor/components/tanah.blade.php index 90e490f..99eb4f0 100644 --- a/resources/views/surveyor/components/tanah.blade.php +++ b/resources/views/surveyor/components/tanah.blade.php @@ -13,15 +13,15 @@
@if (isset($permohonan->debiture->documents)) - @foreach ($permohonan->debiture->documents as $item) - @php - $luas = $item->detail; - $details = json_decode($luas[0]->details, true); - $luas_tanah = isset($details['luas_tanah']) ? $details['luas_tanah'] : 'N/A'; - @endphp -

{{ $luas_tanah }} m2

- @endforeach - + @foreach ($permohonan->debiture->documents as $item) + @php + $luas = $item->detail; + $details = json_decode($luas[0]->details, true); + $luas_tanah = isset($details['luas_tanah']) ? $details['luas_tanah'] : 'N/A'; + @endphp + +

{{ $luas_tanah }} m2

+ @endforeach @endif
@@ -29,21 +29,22 @@
- + - +
@@ -55,29 +56,40 @@
+
+ @if (isset($permohonan->debiture->documents)) + @foreach ($permohonan->debiture->documents as $item) + @php + $luas = $item->detail; + $details = json_decode($luas[0]->details, true); + $hadap_mata_angin = isset($details['hadap_mata_angin']) ? $details['hadap_mata_angin'] : 'N/A'; + @endphp + +

{{ $hadap_mata_angin }} m2

+ @endforeach + @endif
- + name="analisa_tanah_hadap_mata_angin_tidak_sesuai"> @if (isset($arahMataAngin)) @foreach ($arahMataAngin as $item) @@ -94,6 +106,7 @@
+
@@ -106,33 +119,22 @@ @foreach ($bentukTanah as $item)
@if (strcasecmp($item->name, 'lainnya') == 0) - + value="{{ old('bentuk_tanah_lainnya', $forminspeksi['tanah']['bentuk_tanah']['lainnya'] ?? '') }}" /> @endif
@endforeach @@ -149,20 +151,9 @@ @if (isset($konturTanah)) @foreach ($konturTanah as $item) @endforeach @@ -238,27 +229,18 @@
@if (isset($posisiKavling)) @foreach ($posisiKavling as $item) -
+
@if (strcasecmp($item->name, 'Lainnya') == 0) - + @endif
@endforeach @@ -319,7 +301,7 @@ @@ -330,7 +312,7 @@ + value="{{ old('kondisi_fisik_tanah_lainnya', isset($forminspeksi['tanah']['kondisi_fisik_tanah']['lainnya'])) }}">
@endif @endforeach diff --git a/resources/views/surveyor/data/index.blade.php b/resources/views/surveyor/data/index.blade.php index fc436c7..ecae761 100644 --- a/resources/views/surveyor/data/index.blade.php +++ b/resources/views/surveyor/data/index.blade.php @@ -19,7 +19,7 @@
- Export to Excel + Export to Excel @php $href = route('basicdata.createData', ['type' => $header[1]]); @@ -42,7 +42,7 @@ - Jenis Aset + {{ isset($header[0]) ? $header[0] : '' }} Action diff --git a/resources/views/surveyor/detail.blade.php b/resources/views/surveyor/detail.blade.php index 6a28dac..9b1896a 100644 --- a/resources/views/surveyor/detail.blade.php +++ b/resources/views/surveyor/detail.blade.php @@ -16,7 +16,7 @@ } @endpush - + @include('lpj::assetsku.includenya')
@@ -25,33 +25,12 @@
- @if (request()->has('form') && request('form') == 'denah') @include('lpj::surveyor.components.card-tambah') - @elseif(request()->has('form') && request('form') == 'data-pembanding') - @include('lpj::surveyor.components.card-tambah') - @elseif(request()->has('form') && request('form') == 'foto') - @include('lpj::surveyor.components.card-tambah') - @else - @include('lpj::surveyor.components.card-tambah') - @endIf