diff --git a/app/Http/Controllers/PenilaiController.php b/app/Http/Controllers/PenilaiController.php index e535ddb..7450414 100644 --- a/app/Http/Controllers/PenilaiController.php +++ b/app/Http/Controllers/PenilaiController.php @@ -309,7 +309,7 @@ class PenilaiController extends Controller $forminspeksi = json_decode($inspeksi->data_form, true); } - return view('lpj::penilai.components.paparan', compact('permohonan', 'formFoto', 'penilai', 'forminspeksi','inspeksi')); + return view('lpj::penilai.components.paparan', compact('permohonan', 'formFoto', 'penilai', 'forminspeksi', 'inspeksi')); } @@ -346,7 +346,7 @@ class PenilaiController extends Controller $rap = json_decode($resume->rap, true); } - return view('lpj::penilai.components.rap-penilai', compact('permohonan', 'rap', 'provinces', 'forminspeksi', 'noLpRAP','basicData')); + return view('lpj::penilai.components.rap-penilai', compact('permohonan', 'rap', 'provinces', 'forminspeksi', 'noLpRAP', 'basicData')); } @@ -396,7 +396,7 @@ class PenilaiController extends Controller $column = $request->get('sortField'); $query->orderBy($column, $order); } else { - $query->orderBy('updated_at','DESC'); + $query->orderBy('updated_at', 'DESC'); } // Get the total count of records @@ -605,7 +605,21 @@ class PenilaiController extends Controller $penilai = Penilai::where('permohonan_id', $id)->get(); + $rap = $penilai->some(function ($item) { + return strtolower($item->type_penilai) === 'rap'; + }); $allComplete = $penilai->every(function ($item) { + + if ($item->type_penilai === 'rap') { + return !empty($item->type_penilai) && ( + !empty($item->memo) || + !empty($item->resume) || + !empty($item->lpj) || + !empty($item->rap) + ); + } + + return !empty($item->type_penilai) && ( !empty($item->memo) || !empty($item->resume) || @@ -630,8 +644,7 @@ class PenilaiController extends Controller return response()->json([ 'success' => true, - 'message' => 'Berhasil Megirim reported ke so', - 'data' => $penilai, + 'message' => 'Berhasil Megirim reported ke so' ], 200); } catch (\Exception $e) { @@ -804,10 +817,11 @@ class PenilaiController extends Controller } } - public function storeRap(Request $request){ + public function storeRap(Request $request) + { DB::beginTransaction(); try { - $formRequest = new FormSurveyorRequest(); + $formRequest = new FormSurveyorRequest(); $formRequest->setContainer(app()); $formRequest->initialize( $request->all(), @@ -822,7 +836,7 @@ class PenilaiController extends Controller $validated = $formRequest->validateResolved(); $result = $this->surveyorController->store($formRequest); - $data =[ + $data = [ 'kepada' => $request->input('kepada'), 'dari' => $request->input('dari'), 'nomor_rap' => $request->input('nomor_rap'), @@ -931,7 +945,7 @@ class PenilaiController extends Controller 'tanggalLaporan', 'rap' )); - // return $pdf; + // return $pdf; $pdf->setPaper('A4', 'portrait'); return $pdf->stream(); } else { @@ -1081,278 +1095,278 @@ class PenilaiController extends Controller public function generateNoLaporan($permohonan, $documentId, $type) -{ - $typeMapping = ['lpj' => 'LPJ', 'memo' => 'MAK', 'rap' => 'RAP']; + { + $typeMapping = ['lpj' => 'LPJ', 'memo' => 'MAK', 'rap' => 'RAP']; - // Cek apakah data sudah ada - $laporan = Laporan::where([ - 'permohonan_id' => $permohonan->id, - 'dokumen_jaminan_id' => $documentId, - ])->first(); - - if ($laporan) { - - $nomorArray = explode('/', $laporan->nomor_laporan); - $nomorArray[2] = $typeMapping[$type] ?? 'RES'; - $laporan->update([ - 'nomor_laporan' => implode('/', $nomorArray) - ]); - } else { - - $laporan = Laporan::create([ + // Cek apakah data sudah ada + $laporan = Laporan::where([ 'permohonan_id' => $permohonan->id, 'dokumen_jaminan_id' => $documentId, - 'nomor_laporan' => implode('/', [ - $permohonan->debiture->branch->code, - generateLpjUniqueCode(3), - $typeMapping[$type] ?? 'RSM', - $permohonan->nomor_registrasi, - onRomawi(date('m')), - substr(date('Y'), -2) - ]) + ])->first(); + + if ($laporan) { + + $nomorArray = explode('/', $laporan->nomor_laporan); + $nomorArray[2] = $typeMapping[$type] ?? 'RES'; + $laporan->update([ + 'nomor_laporan' => implode('/', $nomorArray) + ]); + } else { + + $laporan = Laporan::create([ + 'permohonan_id' => $permohonan->id, + 'dokumen_jaminan_id' => $documentId, + 'nomor_laporan' => implode('/', [ + $permohonan->debiture->branch->code, + generateLpjUniqueCode(3), + $typeMapping[$type] ?? 'RSM', + $permohonan->nomor_registrasi, + onRomawi(date('m')), + substr(date('Y'), -2) + ]) + ]); + } + + return $laporan->nomor_laporan; + } + + + public function checkDataMemo($type, $statusLpj) + { + // Ambil data JSON dari statusLpj + $data = json_decode($statusLpj->memo, true) ?? []; + + $validationRules = [ + 'memo' => [ + 'kepada', + 'dari', + 'nomor_memo', + 'tanggal', + 'perihal', + 'jenis_asset_tidak_sesuai', + 'lokasi.lokasi', + 'lokasi.address', + 'lokasi.province_code', + 'lokasi.city_code', + 'lokasi.district_code', + 'lokasi.village_code', + 'lokasi.penilai', + 'terlampir', + 'hasil_survey', + 'kesimpulan_saran', + ], + ]; + + // Validasi data JSON + if (isset($validationRules[$type])) { + $missingFields = []; + + foreach ($validationRules[$type] as $field) { + $keys = explode('.', $field); + $value = $data; + + foreach ($keys as $key) { + if (!isset($value[$key])) { + $missingFields[] = $field; + break; + } + $value = $value[$key]; + } + } + + // Jika ada field yang kosong, kembalikan error + if (!empty($missingFields)) { + return response()->json([ + 'status' => null, + 'message' => "Silahkan lengkapi data memo terlebih dahulu.", + 'missing_fields' => $missingFields, + ], 400); + } + } + + // Jika data valid + return response()->json([ + 'status' => $type, + 'message' => "Data memo valid.", ]); } - return $laporan->nomor_laporan; -} -public function checkDataMemo($type, $statusLpj) -{ - // Ambil data JSON dari statusLpj - $data = json_decode($statusLpj->memo, true) ?? []; - $validationRules = [ - 'memo' => [ - 'kepada', - 'dari', - 'nomor_memo', - 'tanggal', - 'perihal', - 'jenis_asset_tidak_sesuai', - 'lokasi.lokasi', - 'lokasi.address', - 'lokasi.province_code', - 'lokasi.city_code', - 'lokasi.district_code', - 'lokasi.village_code', - 'lokasi.penilai', - 'terlampir', - 'hasil_survey', - 'kesimpulan_saran', - ], - ]; + public function checkDataResume($type, $statusLpj) + { + // Ambil data JSON dari statusLpj + $data = json_decode($statusLpj->resume, true) ?? []; - // Validasi data JSON - if (isset($validationRules[$type])) { - $missingFields = []; + $validationRules = [ + 'resume' => [ + 'fakta.fakta_positif', + 'fakta.fakta_negatif', + 'fisik', + 'sesuai_imb', + 'keterangan' + ], + ]; - foreach ($validationRules[$type] as $field) { - $keys = explode('.', $field); - $value = $data; + // Validasi data JSON + if (isset($validationRules[$type])) { + $missingFields = []; - foreach ($keys as $key) { - if (!isset($value[$key])) { - $missingFields[] = $field; - break; + foreach ($validationRules[$type] as $field) { + $keys = explode('.', $field); + $value = $data; + + foreach ($keys as $key) { + if (!isset($value[$key])) { + $missingFields[] = $field; + break; + } + $value = $value[$key]; } - $value = $value[$key]; + + // Validasi khusus untuk array fisik dan sesuai_imb + if ($field === 'fisik' || $field === 'sesuai_imb') { + if (empty($value) || !is_array($value)) { + $missingFields[] = $field; + continue; + } + + // Validasi struktur data di dalam array + foreach ($value as $item) { + $requiredKeys = ['sertifikat', 'luas_tanah', 'luas_bangunan', 'nilai']; + foreach ($requiredKeys as $requiredKey) { + if (!isset($item[$requiredKey])) { + $missingFields[] = $field . '.' . $requiredKey; + } + } + } + } + } + + // Jika ada field yang kosong, kembalikan error + if (!empty($missingFields)) { + return response()->json([ + 'status' => null, + 'message' => "Silahkan lengkapi data resume terlebih dahulu.", + 'missing_fields' => $missingFields, + ], 400); } } - // Jika ada field yang kosong, kembalikan error - if (!empty($missingFields)) { - return response()->json([ - 'status' => null, - 'message' => "Silahkan lengkapi data memo terlebih dahulu.", - 'missing_fields' => $missingFields, - ], 400); - } + // Jika data valid + return response()->json([ + 'status' => $type, + 'message' => "Data resume valid.", + ]); } - // Jika data valid - return response()->json([ - 'status' => $type, - 'message' => "Data memo valid.", - ]); -} + public function checkDataLpj($type, $statusLpj) + { + // Ambil data JSON dari statusLpj + $data = json_decode($statusLpj->lpj, true) ?? []; + $validationRules = [ + 'lpj' => [ + 'luas_tanah', + 'nilai_tanah_1', + 'nilai_tanah_2', + 'luas_bangunan', + 'nilai_bangunan_1', + 'nilai_bangunan_2', + 'total_nilai_pasar_wajar', + 'likuidasi', + 'likuidasi_nilai_1', + 'likuidasi_nilai_2', + 'asuransi_luas_bangunan', + 'asuransi_nilai_1', + 'asuransi_nilai_2', + 'npw_tambahan' + ], + ]; + // Validasi data JSON + if (isset($validationRules[$type])) { + $missingFields = []; - -public function checkDataResume($type, $statusLpj) -{ - // Ambil data JSON dari statusLpj - $data = json_decode($statusLpj->resume, true) ?? []; - - $validationRules = [ - 'resume' => [ - 'fakta.fakta_positif', - 'fakta.fakta_negatif', - 'fisik', - 'sesuai_imb', - 'keterangan' - ], - ]; - - // Validasi data JSON - if (isset($validationRules[$type])) { - $missingFields = []; - - foreach ($validationRules[$type] as $field) { - $keys = explode('.', $field); - $value = $data; - - foreach ($keys as $key) { - if (!isset($value[$key])) { - $missingFields[] = $field; - break; + foreach ($validationRules[$type] as $field) { + // Penanganan khusus untuk field yang boleh null + if (in_array($field, ['sarana_pelengkap_penilai', 'nilai_sarana_pelengkap_1', 'nilai_sarana_pelengkap_2'])) { + continue; } - $value = $value[$key]; - } - // Validasi khusus untuk array fisik dan sesuai_imb - if ($field === 'fisik' || $field === 'sesuai_imb') { - if (empty($value) || !is_array($value)) { + if (!isset($data[$field])) { $missingFields[] = $field; continue; } - // Validasi struktur data di dalam array - foreach ($value as $item) { - $requiredKeys = ['sertifikat', 'luas_tanah', 'luas_bangunan', 'nilai']; - foreach ($requiredKeys as $requiredKey) { - if (!isset($item[$requiredKey])) { - $missingFields[] = $field . '.' . $requiredKey; + // Validasi khusus untuk npw_tambahan + if ($field === 'npw_tambahan' && is_array($data[$field])) { + foreach ($data[$field] as $index => $item) { + $requiredKeys = ['name', 'luas', 'nilai_1', 'nilai_2']; + foreach ($requiredKeys as $key) { + if (!isset($item[$key])) { + $missingFields[] = "npw_tambahan[$index].$key"; + } } } } } - } - // Jika ada field yang kosong, kembalikan error - if (!empty($missingFields)) { - return response()->json([ - 'status' => null, - 'message' => "Silahkan lengkapi data resume terlebih dahulu.", - 'missing_fields' => $missingFields, - ], 400); - } - } - // Jika data valid - return response()->json([ - 'status' => $type, - 'message' => "Data resume valid.", - ]); -} - -public function checkDataLpj($type, $statusLpj) -{ - // Ambil data JSON dari statusLpj - $data = json_decode($statusLpj->lpj, true) ?? []; - - $validationRules = [ - 'lpj' => [ - 'luas_tanah', - 'nilai_tanah_1', - 'nilai_tanah_2', - 'luas_bangunan', - 'nilai_bangunan_1', - 'nilai_bangunan_2', - 'total_nilai_pasar_wajar', - 'likuidasi', - 'likuidasi_nilai_1', - 'likuidasi_nilai_2', - 'asuransi_luas_bangunan', - 'asuransi_nilai_1', - 'asuransi_nilai_2', - 'npw_tambahan' - ], - ]; - - // Validasi data JSON - if (isset($validationRules[$type])) { - $missingFields = []; - - foreach ($validationRules[$type] as $field) { - // Penanganan khusus untuk field yang boleh null - if (in_array($field, ['sarana_pelengkap_penilai', 'nilai_sarana_pelengkap_1', 'nilai_sarana_pelengkap_2'])) { - continue; - } - - if (!isset($data[$field])) { - $missingFields[] = $field; - continue; - } - - // Validasi khusus untuk npw_tambahan - if ($field === 'npw_tambahan' && is_array($data[$field])) { - foreach ($data[$field] as $index => $item) { - $requiredKeys = ['name', 'luas', 'nilai_1', 'nilai_2']; - foreach ($requiredKeys as $key) { - if (!isset($item[$key])) { - $missingFields[] = "npw_tambahan[$index].$key"; - } - } - } + // Jika ada field yang kosong, kembalikan error + if (!empty($missingFields)) { + return response()->json([ + 'status' => null, + 'message' => "Silahkan lengkapi data LPJ terlebih dahulu.", + 'missing_fields' => $missingFields, + ], 400); } } - - // Jika ada field yang kosong, kembalikan error - if (!empty($missingFields)) { - return response()->json([ - 'status' => null, - 'message' => "Silahkan lengkapi data LPJ terlebih dahulu.", - 'missing_fields' => $missingFields, - ], 400); - } - } - - // Jika data valid - return response()->json([ - 'status' => $type, - 'message' => "Data LPJ valid.", - ]); -} - -public function checkDataRap($type, $statusLpj) -{ - // Ambil data JSON dari statusLpj - $data = json_decode($statusLpj->rap, true) ?? []; - - $requiredFields = [ - 'dari', - 'kepada', - 'perihal', - 'tanggal', - 'nomor_rap' - ]; - - // Cek apakah ada field yang kosong - $missingFields = []; - foreach ($requiredFields as $field) { - if (!isset($data[$field]) || empty($data[$field])) { - $missingFields[] = $field; - } - } - - // Jika ada field yang kosong, kembalikan error - if (!empty($missingFields)) { + // Jika data valid return response()->json([ - 'status' => null, - 'message' => "Silahkan lengkapi data RAP terlebih dahulu.", - 'missing_fields' => $missingFields - ], 400); + 'status' => $type, + 'message' => "Data LPJ valid.", + ]); } - // Jika semua data terisi - return response()->json([ - 'status' => $type, - 'message' => "Data RAP valid." - ]); -} + public function checkDataRap($type, $statusLpj) + { + // Ambil data JSON dari statusLpj + $data = json_decode($statusLpj->rap, true) ?? []; + + $requiredFields = [ + 'dari', + 'kepada', + 'perihal', + 'tanggal', + 'nomor_rap' + ]; + + // Cek apakah ada field yang kosong + $missingFields = []; + foreach ($requiredFields as $field) { + if (!isset($data[$field]) || empty($data[$field])) { + $missingFields[] = $field; + } + } + + // Jika ada field yang kosong, kembalikan error + if (!empty($missingFields)) { + return response()->json([ + 'status' => null, + 'message' => "Silahkan lengkapi data RAP terlebih dahulu.", + 'missing_fields' => $missingFields + ], 400); + } + + // Jika semua data terisi + return response()->json([ + 'status' => $type, + 'message' => "Data RAP valid." + ]); + } } diff --git a/app/Http/Controllers/SurveyorController.php b/app/Http/Controllers/SurveyorController.php index f2c94fb..7f48c1c 100644 --- a/app/Http/Controllers/SurveyorController.php +++ b/app/Http/Controllers/SurveyorController.php @@ -455,7 +455,7 @@ class SurveyorController extends Controller // Simpan file dengan nama asli $path = $file->storeAs( - 'surveyor/lantai_unit', + 'surveyor/lantai_unit', $uniqueFileName . '/' . time() . '_' . $file->getClientOriginalName(), 'public' ); @@ -1020,15 +1020,15 @@ class SurveyorController extends Controller public function storeFreeze($id, Request $request) { try { - $permohonan = Permohonan::findOrFail($id); + $permohonan = Permohonan::findOrFail($id); - Authorization::updateOrCreate([ - 'permohonan_id' => $permohonan->id, - 'jenis' => 'sla' - ],[ - 'request' => 'freeze', - 'user_id' => Auth::user()->id - ]); + Authorization::updateOrCreate([ + 'permohonan_id' => $permohonan->id, + 'jenis' => 'sla' + ], [ + 'request' => 'freeze', + 'user_id' => Auth::user()->id + ]); return response()->json([ 'success' => true, @@ -2375,6 +2375,7 @@ class SurveyorController extends Controller $data['hub_cadeb_penghuni'] => ($data['hub_cadeb_penghuni'] == 'sesuai') ? $data['hub_cadeb_penghuni_sesuai'] : $data['hub_penghuni_tidak_sesuai'] ], 'pihak_bank' => $data['pihak_bank'] ?? null, + 'nomor_nib' => $data['nomor_nib'] ?? null, 'kordinat_lng' => $data['kordinat_lng'] ?? null, 'kordinat_lat' => $data['kordinat_lat'] ?? null, ] @@ -3181,4 +3182,56 @@ class SurveyorController extends Controller // Return Excel download return Excel::download(new BasicDataSurveyorExport($modelClass), $type . '.xlsx'); } + + + public function signature() + { + + } + + public function signatureStore(Request $request) + { + $validator = Validator::make($request->all(), [ + 'signature' => 'required', + 'type' => 'required|in:penilai,cabang,debitur,kjjp', + 'document_id' => 'nullable|string' + ]); + + if ($validator->fails()) { + return response()->json([ + 'success' => false, + 'message' => $validator->errors()->first() + ], 422); + } + + // Hapus prefix data:image/png;base64, + $image = explode(',', $request->signature)[1]; + $imageName = 'signatures/' . $request->type . '_' . time() . '.png'; + + // Simpan file + Storage::disk('public')->put($imageName, base64_decode($image)); + $existingData = $inspeksi->exists && $inspeksi->foto_form + ? json_decode($inspeksi->foto_form, true) + : []; + + $formatFotojson = $existingData; + $inspeksi = Inspeksi::save( + [ + 'permohonan_id' => $request->input('permohonan_id'), + 'dokument_id' => $request->input('dokument_id') + ], + [ + 'data_form' => json_encode($processedData), + ] + ); + } + public function signatureShow() + { + + } + public function signatureDestroy() + { + + } + } diff --git a/app/Http/Requests/FormSurveyorRequest.php b/app/Http/Requests/FormSurveyorRequest.php index 78eb0a9..cf7bc61 100644 --- a/app/Http/Requests/FormSurveyorRequest.php +++ b/app/Http/Requests/FormSurveyorRequest.php @@ -569,6 +569,7 @@ class FormSurveyorRequest extends FormRequest 'permohonan_id' => 'required', 'type' => 'required', 'nomor_registrasi' => 'required', + 'nomor_nib' => 'nullable', 'debitur_perwakilan' => 'required|array', 'jenis_asset_name' => 'nullable|', 'jenis_asset' => 'required', diff --git a/resources/views/component/form-penilai.blade.php b/resources/views/component/form-penilai.blade.php index f2f8652..4ccb04b 100644 --- a/resources/views/component/form-penilai.blade.php +++ b/resources/views/component/form-penilai.blade.php @@ -1,5 +1,6 @@
+ @if (isset($forminspeksi['asset']['debitur_perwakilan']) && !empty($forminspeksi['asset']['debitur_perwakilan'])) @@ -518,6 +519,13 @@
@include('lpj::component.detail-jaminan', ['status' => true]) +
+ +
+ +
+
@@ -609,7 +617,7 @@ {{ $labelNilai[$item] }} @@ -618,7 +626,7 @@ @@ -752,7 +760,7 @@
- @@ -762,7 +770,7 @@
-@include('lpj::surveyor.js.utils') + diff --git a/resources/views/penilai/components/print-out-sederhana.blade.php b/resources/views/penilai/components/print-out-sederhana.blade.php index 1e885e3..acfb95f 100644 --- a/resources/views/penilai/components/print-out-sederhana.blade.php +++ b/resources/views/penilai/components/print-out-sederhana.blade.php @@ -331,7 +331,11 @@ {{ ucwords(str_replace('_', ' ', $key)) ?? '' }} : - {{ $value ?? '' }} m2 + {{ $value ?? '' }} + @if ($key == 'luas_tanah' || $key == 'luas_bangunan') + M2 + @endif + @endforeach @endif @endif @@ -339,6 +343,11 @@ @endforeach @endif + + Nomor NIB + : + {{ $forminspeksi['asset']['nomor_nib']}} + Atas Nama : diff --git a/resources/views/surveyor/components/header.blade.php b/resources/views/surveyor/components/header.blade.php index ee878a7..f4d0db4 100644 --- a/resources/views/surveyor/components/header.blade.php +++ b/resources/views/surveyor/components/header.blade.php @@ -1,21 +1,21 @@
@php - $title = $title ?? 'Form Inspeksi'; - @endphp + $title = $title ?? 'Form Inspeksi'; + @endphp

- {{ $title }} + {{ $title }}

@if (isset($id)) - - Back - - @else - - Back - - @endif + + Back + + @else + + Back + + @endif {{-- Back --}} @@ -264,8 +264,17 @@

Status

-
+
@include('lpj::component.detail-jaminan', ['status' => true]) + +
+ +
+ +
+
+

Hubungan cadeb/debitur dengan Pemilik Jaminan

@@ -562,4 +571,4 @@ }); // Fungsi untuk memuat data lokasi yang tersimpan - @include('lpj::surveyor.js.utils') +@include('lpj::surveyor.js.utils')