perbaikan alamat, foto pembading, diskon, dan perbaikan tampilan kjjp

This commit is contained in:
majid
2024-12-16 15:36:59 +07:00
parent a602f83d44
commit 41552f695c
15 changed files with 910 additions and 523 deletions

View File

@@ -521,7 +521,7 @@ class KJPPController extends Controller
$filteredRecords = $query->count(); $filteredRecords = $query->count();
// Get the data for the current page // Get the data for the current page
$data = $query->get(); $data = $query->with('city')->get();
// Calculate the page count // Calculate the page count
$pageCount = ceil($totalRecords / $request->get('size')); $pageCount = ceil($totalRecords / $request->get('size'));

View File

@@ -9,7 +9,7 @@ use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Maatwebsite\Excel\Facades\Excel; use Maatwebsite\Excel\Facades\Excel;
use Modules\Lpj\Exports\KertasKerjaExport; use Modules\Lpj\Exports\KertasKerjaExport;
use App\Http\Controllers\SurveyorController; use Modules\Lpj\Http\Controllers\SurveyorController;
class PenilaiController extends Controller class PenilaiController extends Controller
{ {
@@ -62,22 +62,42 @@ class PenilaiController extends Controller
$basicData = $data->getCommonData(); $basicData = $data->getCommonData();
$permohonan = Permohonan::with(['debiture.documents.jenisjaminan', 'region.teams.teamsUsers.user', 'penilaian'])->find($id); $permohonan = Permohonan::with(['debiture.documents.jenisjaminan', 'region.teams.teamsUsers.user', 'penilaian'])->find($id);
return view('lpj::penilai.components.lpj-sederhana-standard', compact('permohonan', 'basicData')); $jaminanId = $permohonan->debiture->documents->first()->jenis_jaminan_id;
$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::penilai.components.lpj-sederhana-standard', compact('permohonan', 'basicData', 'forminspeksi'));
} }
public function standard($id) public function standard($id)
{ {
$permohonan = Permohonan::with(['debiture.documents.jenisjaminan', 'region.teams.teamsUsers.user', 'penilaian'])->find($id); $permohonan = Permohonan::with(['debiture.documents.jenisjaminan', 'region.teams.teamsUsers.user', 'penilaian'])->find($id);
return view('lpj::penilai.components.lpj-sederhana-standard', compact('permohonan'));
$jaminanId = $permohonan->debiture->documents->first()->jenis_jaminan_id;
$inpeksi = Inspeksi::where('permohonan_id', $id)->where('jenis_jaminan_id', $jaminanId)->first();
$forminspeksi = null;
if ($inpeksi) {
$forminspeksi = json_decode($inpeksi->data_form, true);
}
$data = new SurveyorController();
$basicData = $data->getCommonData();
return view('lpj::penilai.components.lpj-sederhana-standard', compact('permohonan', 'forminspeksi', 'basicData'));
} }
public function resume(){ public function resume()
{
return view('lpj::resume.index'); return view('lpj::resume.index');
} }
public function memo(){ public function memo()
{
return view('lpj::resume.index'); return view('lpj::resume.index');
} }
/** /**

View File

@@ -189,36 +189,36 @@ class SurveyorController extends Controller
'lingkungan' => 'getLingkunganData', 'lingkungan' => 'getLingkunganData',
'fakta' => 'getFactData' 'fakta' => 'getFactData'
]; ];
$rules = []; $rules = [];
$hasAssetDescriptionRules = false; $hasAssetDescriptionRules = false;
$pisah = array_filter( $pisah = array_filter(
explode(',', $action), explode(',', $action),
function($act) use ($allowedActions) { function($act) use ($allowedActions) {
return isset($allowedActions[trim($act)]); return isset($allowedActions[trim($act)]);
} }
); );
foreach ($pisah as $act) { foreach ($pisah as $act) {
$act = trim($act); $act = trim($act);
$method = $allowedActions[$act]; $method = $allowedActions[$act];
$actionRules = $this->$method($data, $request); $actionRules = $this->$method($data, $request);
$rules = array_merge($rules, $actionRules); $rules = array_merge($rules, $actionRules);
if (in_array($act, ['apartemen-kantor', 'tanah', 'bangunan'])) { if (in_array($act, ['apartemen-kantor', 'tanah', 'bangunan'])) {
$hasAssetDescriptionRules = true; $hasAssetDescriptionRules = true;
} }
} }
if ($hasAssetDescriptionRules) { if ($hasAssetDescriptionRules) {
$rules = array_merge($rules, $this->getAssetData($data)); $rules = array_merge($rules, $this->getAssetData($data));
} }
return $rules; return $rules;
} }
public function storeDenah(Request $request) public function storeDenah(Request $request)
{ {
@@ -234,7 +234,7 @@ class SurveyorController extends Controller
$maxSize = getMaxFileSize('Foto'); $maxSize = getMaxFileSize('Foto');
$validationRules['foto_denah'] = 'file|mimes:jpeg,jpg,png,pdf,svg|max:'. $maxSize; $validationRules['foto_denah'] = 'file|mimes:jpeg,jpg,png,pdf,svg|max:'. $maxSize;
} }
$validatedData = $request->validate($validationRules); $validatedData = $request->validate($validationRules);
$formatJsonDenah = [ $formatJsonDenah = [
@@ -252,7 +252,7 @@ class SurveyorController extends Controller
if ($inspeksi) { if ($inspeksi) {
$existingDenah = json_decode($inspeksi->denah_form, true) ?? []; $existingDenah = json_decode($inspeksi->denah_form, true) ?? [];
$updatedDenah = array_merge($existingDenah, $formatJsonDenah); $updatedDenah = array_merge($existingDenah, $formatJsonDenah);
$inspeksi->update([ $inspeksi->update([
@@ -555,7 +555,7 @@ class SurveyorController extends Controller
$penilaian->update([ $penilaian->update([
'authorized_status' => 1, 'authorized_status' => 1,
]); ]);
$data['status'] = 'success'; $data['status'] = 'success';
$data['message']= 'Jadwal '.$request->noReg.' berhasil di aprove'; $data['message']= 'Jadwal '.$request->noReg.' berhasil di aprove';
} catch (\Exception $e) { } catch (\Exception $e) {
@@ -591,7 +591,7 @@ class SurveyorController extends Controller
->first(); ->first();
if ($inspeksi) { if ($inspeksi) {
$existingData = $inspeksi->data_pembanding ?? []; $existingData = json_decode($inspeksi->data_pembanding, true) ?? [];
} }
} }
@@ -600,8 +600,8 @@ class SurveyorController extends Controller
$existingFoto = null; $existingFoto = null;
if ($existingData && isset($existingData[$i]['foto_objek'])) { if ($existingData && isset($existingData['data_pembanding'][$i]['foto_objek'])) {
$existingFoto = $existingData[$i]['foto_objek']; $existingFoto = $existingData['data_pembanding'][$i]['foto_objek'];
} }
// Penanganan foto pembanding // Penanganan foto pembanding
@@ -620,8 +620,8 @@ class SurveyorController extends Controller
return $dataPembanding; return $dataPembanding;
} }
private function formatSinglePembanding($request, $index) private function formatSinglePembanding($request, $index)
{ {
$fields = [ $fields = [
@@ -631,12 +631,12 @@ class SurveyorController extends Controller
'peruntukan', 'penawaran_transaksi', 'nomor_tlp', 'peruntukan', 'penawaran_transaksi', 'nomor_tlp',
'kordinat_lat', 'kordinat_lng', 'jenis_aset','foto_objek' 'kordinat_lat', 'kordinat_lng', 'jenis_aset','foto_objek'
]; ];
$pembanding = []; $pembanding = [];
foreach ($fields as $field) { foreach ($fields as $field) {
$inputName = "{$field}_pembanding"; $inputName = "{$field}_pembanding";
$inputValue = $request->input($inputName); $inputValue = $request->input($inputName);
// Pastikan input adalah array dan index valid // Pastikan input adalah array dan index valid
if (is_array($inputValue) && isset($inputValue[$index])) { if (is_array($inputValue) && isset($inputValue[$index])) {
$pembanding[$field] = $inputValue[$index]; $pembanding[$field] = $inputValue[$index];
@@ -645,10 +645,10 @@ class SurveyorController extends Controller
} }
} }
return $pembanding; return $pembanding;
} }
private function handleupdateOrDeleteFile($file, $type, $prefix) private function handleupdateOrDeleteFile($file, $type, $prefix)
@@ -680,54 +680,54 @@ class SurveyorController extends Controller
'status_nara_sumber', 'harga', 'nama_nara_sumber', 'status_nara_sumber', 'harga', 'nama_nara_sumber',
'kordinat_lat', 'kordinat_lng', 'jenis_aset', 'kordinat_lat', 'kordinat_lng', 'jenis_aset',
]; ];
$inspeksi = Inspeksi::where('permohonan_id', $request->input('permohonan_id')) $inspeksi = Inspeksi::where('permohonan_id', $request->input('permohonan_id'))
->where('jenis_jaminan_id', $request->input('jenis_jaminan_id')) ->where('jenis_jaminan_id', $request->input('jenis_jaminan_id'))
->first(); ->first();
if ($inspeksi) { if ($inspeksi) {
$needsSave = false; $needsSave = false;
// Handle foto_form // Handle foto_form
$fotoForm = json_decode($inspeksi->foto_form, true) ?: []; $fotoForm = json_decode($inspeksi->foto_form, true) ?: [];
if (!isset($fotoForm['object_jaminan'])) { if (!isset($fotoForm['object_jaminan'])) {
$fotoForm['object_jaminan'] = [['foto_objek' => null]]; $fotoForm['object_jaminan'] = [['foto_objek' => null]];
$needsSave = true; $needsSave = true;
} }
// Handle data_form // Handle data_form
$dataForm = json_decode($inspeksi->data_form, true) ?: []; $dataForm = json_decode($inspeksi->data_form, true) ?: [];
// Inisialisasi struktur data jika belum ada // Inisialisasi struktur data jika belum ada
if(!isset($dataForm['bangunan'])) { if(!isset($dataForm['bangunan'])) {
$dataForm['bangunan'] = []; $dataForm['bangunan'] = [];
$needsSave = true; $needsSave = true;
} }
if(!isset($dataForm['tanah'])) { if(!isset($dataForm['tanah'])) {
$dataForm['tanah'] = []; $dataForm['tanah'] = [];
$needsSave = true; $needsSave = true;
} }
if (!isset($dataForm['asset'])) { if (!isset($dataForm['asset'])) {
$dataForm['asset'] = []; $dataForm['asset'] = [];
$needsSave = true; $needsSave = true;
} }
// Update data dengan mempertahankan struktur sesuai/tidak sesuai // Update data dengan mempertahankan struktur sesuai/tidak sesuai
foreach ($fields as $field) { foreach ($fields as $field) {
if ($request->filled($field)) { if ($request->filled($field)) {
$newValue = $request->input($field); $newValue = $request->input($field);
// Fields untuk tanah // Fields untuk tanah
if (in_array($field, ['luas_tanah'])) { if (in_array($field, ['luas_tanah'])) {
$cekLuas = $dataForm['tanah']['luas_tanah'] == 'sesuai' ? 'sesuai' : 'tidak sesuai'; $cekLuas = $dataForm['tanah']['luas_tanah'] == 'sesuai' ? 'sesuai' : 'tidak sesuai';
$dataForm['tanah'][$field][$cekLuas] = $newValue; $dataForm['tanah'][$field][$cekLuas] = $newValue;
} }
// Fields untuk bangunan // Fields untuk bangunan
else if (in_array($field, ['luas_tanah_bagunan'])) { else if (in_array($field, ['luas_tanah_bagunan'])) {
$cekBanguan = $dataForm['bangunan']['luas_tanah_bagunan'] == 'sesuai' ? 'sesuai' : 'tidak sesuai'; $cekBanguan = $dataForm['bangunan']['luas_tanah_bagunan'] == 'sesuai' ? 'sesuai' : 'tidak sesuai';
$dataForm['bangunan'][$field][$cekBanguan] = $newValue; $dataForm['bangunan'][$field][$cekBanguan] = $newValue;
} }
// Fields untuk alamat dalam asset // Fields untuk alamat dalam asset
@@ -736,12 +736,12 @@ class SurveyorController extends Controller
if (!isset($dataForm['asset']['alamat'])) { if (!isset($dataForm['asset']['alamat'])) {
$dataForm['asset']['alamat'] = []; $dataForm['asset']['alamat'] = [];
} }
$alamatStatus = $dataForm['asset']['alamat'] == 'sesuai' ? 'sesuai' : 'tidak sesuai'; $alamatStatus = $dataForm['asset']['alamat'] == 'sesuai' ? 'sesuai' : 'tidak sesuai';
if (!isset($dataForm['asset']['alamat'][$alamatStatus])) { if (!isset($dataForm['asset']['alamat'][$alamatStatus])) {
$dataForm['asset']['alamat'][$alamatStatus] = []; $dataForm['asset']['alamat'][$alamatStatus] = [];
} }
$dataForm['asset']['alamat'][$alamatStatus][$field] = $newValue; $dataForm['asset']['alamat'][$alamatStatus][$field] = $newValue;
} }
// Jenis asset dalam asset // Jenis asset dalam asset
@@ -755,19 +755,19 @@ class SurveyorController extends Controller
else { else {
$dataForm['asset'][$field] = $newValue; $dataForm['asset'][$field] = $newValue;
} }
$needsSave = true; $needsSave = true;
} }
} }
if ($needsSave) { if ($needsSave) {
$inspeksi->foto_form = json_encode($fotoForm); $inspeksi->foto_form = json_encode($fotoForm);
$inspeksi->data_form = json_encode($dataForm); $inspeksi->data_form = json_encode($dataForm);
$inspeksi->save(); $inspeksi->save();
} }
$existingFoto = $fotoForm['object_jaminan'][0]['foto_objek'] ?? null; $existingFoto = $fotoForm['object_jaminan'][0]['foto_objek'] ?? null;
// Gabungkan data dari tanah, bangunan, dan asset // Gabungkan data dari tanah, bangunan, dan asset
$objekPenilaian = array_merge( $objekPenilaian = array_merge(
['foto_objek' => $existingFoto], ['foto_objek' => $existingFoto],
@@ -790,7 +790,7 @@ class SurveyorController extends Controller
return $carry; return $carry;
}, []) }, [])
); );
} else { } else {
// Inisialisasi data baru // Inisialisasi data baru
$objekPenilaian = array_reduce($fields, function ($carry, $field) use ($request) { $objekPenilaian = array_reduce($fields, function ($carry, $field) use ($request) {
@@ -798,10 +798,10 @@ class SurveyorController extends Controller
return $carry; return $carry;
}, ['foto_objek' => null]); }, ['foto_objek' => null]);
} }
return $objekPenilaian; return $objekPenilaian;
} }
private function saveInspeksi($formattedData) private function saveInspeksi($formattedData)
@@ -873,6 +873,7 @@ class SurveyorController extends Controller
'data_pembanding' => $this->formatDataPembanding($request) 'data_pembanding' => $this->formatDataPembanding($request)
]; ];
$inspeksi = $this->saveInspeksi($formattedData); $inspeksi = $this->saveInspeksi($formattedData);
DB::commit(); DB::commit();
@@ -1041,7 +1042,6 @@ class SurveyorController extends Controller
if (json_last_error() !== JSON_ERROR_NONE) { if (json_last_error() !== JSON_ERROR_NONE) {
throw new \Exception('Error decoding comparison data: ' . json_last_error_msg()); throw new \Exception('Error decoding comparison data: ' . json_last_error_msg());
} }
} }
$fotoForm = json_decode($inspeksi->foto_form, true); $fotoForm = json_decode($inspeksi->foto_form, true);
@@ -1055,8 +1055,6 @@ class SurveyorController extends Controller
$districts = District::where('city_code', $this->getCodeAlamat('city_code', $inspectionData))->get(); $districts = District::where('city_code', $this->getCodeAlamat('city_code', $inspectionData))->get();
$villages = Village::where('district_code', $this->getCodeAlamat('district_code', $inspectionData))->get(); $villages = Village::where('district_code', $this->getCodeAlamat('district_code', $inspectionData))->get();
return view('lpj::surveyor.components.data-pembanding', compact( return view('lpj::surveyor.components.data-pembanding', compact(
'permohonan', 'permohonan',
'id', 'id',
@@ -1068,7 +1066,8 @@ class SurveyorController extends Controller
'cities', 'cities',
'districts', 'districts',
'villages', 'villages',
'provinces' 'provinces',
'inspeksi'
)); ));
} catch (\Exception $e) { } catch (\Exception $e) {
@@ -1562,7 +1561,7 @@ class SurveyorController extends Controller
private function getCommonData() public function getCommonData()
{ {
return [ return [
'branches' => Branch::all(), 'branches' => Branch::all(),
@@ -1809,11 +1808,9 @@ class SurveyorController extends Controller
'jarak_tps' => $data['jarak_tps'] ?? null, 'jarak_tps' => $data['jarak_tps'] ?? null,
'nama_tps' => $data['nama_tps'] ?? null, 'nama_tps' => $data['nama_tps'] ?? null,
'merupakan_daerah' => $data['merupakan_daerah'] ?? null, 'merupakan_daerah' => $data['merupakan_daerah'] ?? null,
'fasilitas_dekat_object' => $this->getFieldData( 'fasilitas_dekat_object' => $this->mapArrayWithInputs(
$data, $data['fasilitas_dekat_object'] ?? [],
'fasilitas_dekat_object', $data['fasilitas_dekat_object_input'] ?? []
false,
'lainnya'
), ),
] ]
]; ];

View File

@@ -76,7 +76,7 @@ class FormSurveyorRequest extends FormRequest
'hadap_mata_angin' => 'required', 'hadap_mata_angin' => 'required',
'hadap_mata_angin_sesuai' => 'nullable', 'hadap_mata_angin_sesuai' => 'nullable',
'hadap_mata_angin_tidak_sesuai' => 'nullable', 'hadap_mata_angin_tidak_sesuai' => 'nullable',
'bentuk_tanah' => 'nullable|array', 'bentuk_tanah' => 'required|array',
'bentuk_tanah_lainnya' => 'nullable', 'bentuk_tanah_lainnya' => 'nullable',
'kontur_tanah' => 'required|array', 'kontur_tanah' => 'required|array',
'ketinggian_jalan' => 'required|array', 'ketinggian_jalan' => 'required|array',
@@ -102,8 +102,8 @@ class FormSurveyorRequest extends FormRequest
'luas_tanah_bangunan_sesuai' => 'nullable', 'luas_tanah_bangunan_sesuai' => 'nullable',
'luas_tanah_bagunan' => 'required', 'luas_tanah_bagunan' => 'required',
'luas_tanah_bangunan_tidak_sesuai' => 'nullable', 'luas_tanah_bangunan_tidak_sesuai' => 'nullable',
'jenis_bangunan' => 'required', 'jenis_bangunan' => 'required|array',
'kondisi_bangunan' => 'nullable', 'kondisi_bangunan' => 'required|array',
'sifat_bangunan' => 'required|array', 'sifat_bangunan' => 'required|array',
'sifat_bangunan_input' => 'nullable|array', 'sifat_bangunan_input' => 'nullable|array',
@@ -167,7 +167,7 @@ class FormSurveyorRequest extends FormRequest
'nama_tpu' => 'nullable', 'nama_tpu' => 'nullable',
'merupakan_daerah' => 'nullable', 'merupakan_daerah' => 'nullable',
'fasilitas_dekat_object' => 'nullable|array', 'fasilitas_dekat_object' => 'nullable|array',
'fasilitas_dekat_object_lainnya' => 'nullable', 'fasilitas_dekat_object_input' => 'nullable|array',
]; ];
} }

View File

@@ -2,7 +2,7 @@
namespace Modules\Lpj\Models; namespace Modules\Lpj\Models;
use Modules\Location\Models\Province; use Modules\Location\Models\City;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\HasMany; use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Factories\HasFactory;
@@ -25,4 +25,12 @@ class KJPP extends Model
{ {
return $this->hasMany(PenawaranDetailTender::class, 'kjpp_rekanan_id', 'id'); return $this->hasMany(PenawaranDetailTender::class, 'kjpp_rekanan_id', 'id');
} }
public function city()
{
return $this->belongsTo(City::class, 'city_code', 'code');
}
} }

View File

@@ -48,6 +48,14 @@
<span class="sort"> <span class="sort-label"> Jenis Kantor </span> <span class="sort"> <span class="sort-label"> Jenis Kantor </span>
<span class="sort-icon"> </span> </span> <span class="sort-icon"> </span> </span>
</th> </th>
<th class="min-w-[50px]" data-datatable-column="jenis_kantor">
<span class="sort"> <span class="sort-label"> Kota/Kabupaten </span>
<span class="sort-icon"> </span> </span>
</th>
<th class="min-w-[50px]" data-datatable-column="jenis_kantor">
<span class="sort"> <span class="sort-label"> Alamat </span>
<span class="sort-icon"> </span> </span>
</th>
<th class="min-w-[50px] text-center" data-datatable-column="actions">Action</th> <th class="min-w-[50px] text-center" data-datatable-column="actions">Action</th>
</tr> </tr>
</thead> </thead>
@@ -131,6 +139,15 @@
jenis_kantor: { jenis_kantor: {
title: 'Jenis Kantor', title: 'Jenis Kantor',
}, },
city: {
title: 'Kota/Kabupaten',
render: (item, data) => {
return data.city.name;
}
},
address: {
title: 'Alamat KJPP',
},
actions: { actions: {
title: 'Action', title: 'Action',
render: (item, data) => { render: (item, data) => {

View File

@@ -22,7 +22,7 @@
@endforeach @endforeach
@endif @endif
<div class="flex flex-wrap items-baseline w-full"> <div class="flex-wrap items-stretch">
<div class="grid grid-cols-2 md:grid-cols-3 gap-4 mt-2"> <div class="grid grid-cols-2 md:grid-cols-3 gap-4 mt-2">
<label class="form-label flex items-center gap-3 text-nowrap"> <label class="form-label flex items-center gap-3 text-nowrap">
<input type="radio" <input type="radio"
@@ -67,14 +67,18 @@
<!-- Jenis Bangunan --> <!-- Jenis Bangunan -->
<div class="flex items-stretch flex-wrap lg:flex-nowrap gap-2.5"> <div class="flex items-stretch flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">Jenis Bangunan</label> <label class="form-label max-w-56">Jenis Bangunan</label>
<div class="flex flex-wrap items-baseline w-full"> <div class="flex-wrap items-stretch">
<div class="flex flex-col items-start gap-4"> <div class="flex flex-col items-start gap-4">
@if (isset($basicData['jenisBangunan'])) @if (isset($basicData['jenisBangunan']))
@foreach ($basicData['jenisBangunan'] as $item) @foreach ($basicData['jenisBangunan'] as $item)
<label class="form-label flex items-center gap-2.5 text-nowrap"> <label class="form-label flex items-center gap-2.5 text-nowrap">
<input class="checkbox" name="jenis_bangunan[]" type="checkbox" <input class="checkbox" name="jenis_bangunan[]" type="checkbox"
value="{{ $item->name }}" value="{{ $item->name }}"
{{ old('jenis_bangunan') == $item->name || isset($forminspeksi['bangunan']['jenis_bangunan']) == $item->name ? 'checked' : '' }} {{ (is_array(old('jenis_bangunan')) && in_array($item->name, old('jenis_bangunan'))) ||
(isset($forminspeksi['bangunan']['jenis_bangunan']) &&
(is_array($forminspeksi['bangunan']['jenis_bangunan']) &&
in_array($item->name, $forminspeksi['bangunan']['jenis_bangunan'])))
? 'checked' : '' }}
onclick="toggleCheckboxVisibility('jenis_bangunan', 'jenis_bangunan_lainnya', ['lainnya'])" /> onclick="toggleCheckboxVisibility('jenis_bangunan', 'jenis_bangunan_lainnya', ['lainnya'])" />
{{ $item->name }} {{ $item->name }}
</label> </label>
@@ -86,16 +90,15 @@
@endforeach @endforeach
@endif @endif
</div> </div>
<em id="error-jenis_bangunan" class="alert text-danger text-sm"></em> <em id="error-jenis_bangunan" class="alert text-danger text-sm"></em>
</div> </div>
</div> </div>
<!-- Kondisi Bangunan --> <!-- Kondisi Bangunan -->
<div class="flex items-stretch flex-wrap lg:flex-nowrap gap-2.5"> <div class="flex items-stretch flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">Kondisi Bangunan</label> <label class="form-label max-w-56">Kondisi Bangunan</label>
<div class="flex flex-wrap items-baseline w-full"> <div class="flex-wrap items-stretch">
<div class="flex flex-col items-start gap-4"> <div class="flex flex-col items-start gap-4">
@if (isset($basicData['kondisiBangunan'])) @if (isset($basicData['kondisiBangunan']))
@foreach ($basicData['kondisiBangunan'] as $item) @foreach ($basicData['kondisiBangunan'] as $item)
@@ -128,7 +131,7 @@
<!-- Sifat Bangunan --> <!-- Sifat Bangunan -->
<div class="flex items-stretch flex-wrap lg:flex-nowrap gap-2.5"> <div class="flex items-stretch flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">Sifat Bangunan</label> <label class="form-label max-w-56">Sifat Bangunan</label>
<div class="flex flex-wrap items-baseline w-full"> <div class="flex-wrap items-stretch">
<div class="flex flex-col items-start gap-4"> <div class="flex flex-col items-start gap-4">
@if (isset($basicData['sifatBangunan'])) @if (isset($basicData['sifatBangunan']))
@foreach ($basicData['sifatBangunan'] as $item) @foreach ($basicData['sifatBangunan'] as $item)
@@ -249,13 +252,14 @@
<i class="ki-filled ki-plus"></i> <i class="ki-filled ki-plus"></i>
</button> </button>
</div> </div>
</div> </div>
<!-- Sarana pelengkap --> <!-- Sarana pelengkap -->
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5"> <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">Sarana pelengkap</label> <label class="form-label max-w-56">Sarana pelengkap</label>
<div class="flex flex-wrap items-baseline w-full"> <div class="flex-wrap items-stretch">
<div class="flex flex-col items-start gap-4"> <div class="flex flex-col items-start gap-4">
@if (isset($basicData['saranaPelengkap'])) @if (isset($basicData['saranaPelengkap']))
@foreach ($basicData['saranaPelengkap'] as $item) @foreach ($basicData['saranaPelengkap'] as $item)

View File

@@ -110,34 +110,63 @@
</select> </select>
</td> </td>
</tr> </tr>
<tr>
<td class="px-4 py-2">Luas Tanah ()</td>
@php
$cekLuas = $inspectionData['tanah']['luas_tanah'] == 'sesuai' ? 'sesuai' :'tidak sesuai';
@endphp @php
<td class="px-4 py-2"> $apartemenKantorData = explode(',', $inspeksi->name);
<input type="text" name="luas_tanah" class="input number-format" $isApartemenKantor = array_intersect($apartemenKantorData, [
value="{{ $inspectionData['tanah']['luas_tanah']['sesuai'] ?? $inspectionData['tanah']['luas_tanah']['tidak sesuai'] ?? '' }}"> 'tanah',
</td> 'bangunan',
<td class="px-4 py-2"> ]);
<input type="text" name="luas_tanah_pembanding[]" @endphp
class="input number-format">
</td> @if ($isApartemenKantor)
</tr> <tr>
<tr> <td class="px-4 py-2">Luas Tanah ()</td>
<td class="px-4 py-2">Luas Bangunan ()</td> @php
<td class="px-4 py-2"> $cekLuas =
isset($inspectionData['tanah']['luas_tanah']) == 'sesuai'
? 'sesuai'
: 'tidak sesuai';
@endphp
<td class="px-4 py-2">
<input type="text" name="luas_tanah" class="input number-format"
value="{{ $inspectionData['tanah']['luas_tanah']['sesuai'] ?? ($inspectionData['tanah']['luas_tanah']['tidak sesuai'] ?? '') }}">
</td>
<td class="px-4 py-2">
<input type="text" name="luas_tanah_pembanding[]"
class="input number-format">
</td>
</tr>
<tr>
<td class="px-4 py-2">Luas Bangunan ()</td>
<td class="px-4 py-2">
<input type="text" name="luas_tanah_bagunan"
class="input number-format"
value="{{ $inspectionData['bangunan']['luas_tanah_bagunan']['sesuai'] ?? ($inspectionData['bangunan']['luas_tanah_bagunan']['tidak sesuai'] ?? '') }}">
</td>
<td class="px-4 py-2">
<input type="text" name="luas_bangunan_pembanding[]"
class="input number-format">
</td>
</tr>
@else
<tr>
<td class="px-4 py-2">Luas Unit ()</td>
<td class="px-4 py-2">
<input type="text" name="luas_unit" class="input number-format"
value="{{ $inspectionData['unit']['luas_unit']['sesuai'] ?? ($inspectionData['unit']['luas_unit']['tidak sesuai'] ?? '') }}">
</td>
<td class="px-4 py-2">
<input type="text" name="luas_unit_pembanding[]"
class="input number-format">
</td>
</tr>
@endif
<input type="text" name="luas_tanah_bagunan" class="input number-format"
value="{{ $inspectionData['bangunan']['luas_tanah_bagunan']['sesuai'] ?? $inspectionData['bangunan']['luas_tanah_bagunan']['tidak sesuai'] ?? '' }}">
</td>
<td class="px-4 py-2">
<input type="text" name="luas_bangunan_pembanding[]"
class="input number-format">
</td>
</tr>
<!-- Informasi Harga --> <!-- Informasi Harga -->
<tr class="bg-gray-100"> <tr class="bg-gray-100">
@@ -374,15 +403,28 @@
<tr> <tr>
<td class="px-4 py-2">Diskon</td> <td class="px-4 py-2">Diskon</td>
<td class="px-4 py-2"> <td class="px-4 py-2">
<input type="text" name="diskon" class="input currency-format" <div class="input">
value="{{ $inspectionData['asset']['diskon'] ?? '' }}"> <input type="text" name="diskon" class=" currency-format"
value="{{ $inspectionData['asset']['diskon'] ?? '' }}">
<span class="btn btn-icon">
<i class="ki-outline ki-percentage"></i>
</span>
</div>
</td> </td>
<td class="px-4 py-2"> <td class=" px-4 py-2">
<input type="text" name="diskon_pembanding[]" <div class="input">
class="input currency-format"> <input type="text" name="diskon_pembanding[]"
class="currency-format">
<span class="btn btn-icon">
<i class="ki-outline ki-percentage"></i>
</i>
</span>
</div>
</td> </td>
</tr> </tr>
<tr> <tr style="display: none;">
<td class="px-4 py-2">Total</td> <td class="px-4 py-2">Total</td>
<td class="px-4 py-2"> <td class="px-4 py-2">
<input type="text" name="total" class="input currency-format" <input type="text" name="total" class="input currency-format"
@@ -434,27 +476,56 @@
// Fungsi calculate prices yang diperbaiki // Fungsi calculate prices yang diperbaiki
function calculatePrices(index) { function calculatePrices(type = 'main', index = null) {
const hargaInput = document.getElementsByName('harga_pembanding[]')[index]; let hargaInput, diskonInput, totalInput, hargaDiskonInput;
const diskonInput = document.getElementsByName('diskon_pembanding[]')[index];
const totalInput = document.getElementsByName('total_pembanding[]')[index];
const hargaDiskonInput = document.getElementsByName('harga_diskon_pembanding[]')[index];
if (hargaInput && diskonInput && totalInput && hargaDiskonInput) { // Tentukan input berdasarkan tipe (main atau pembanding)
// Ambil nilai numerik dari input if (type === 'main') {
const harga = parseFloat(hargaInput.value.replace(/[^\d]/g, '') || '0'); hargaInput = document.querySelector('input[name="harga"]');
const diskon = parseFloat(diskonInput.value.replace(/[^\d]/g, '') || '0'); diskonInput = document.querySelector('input[name="diskon"]');
totalInput = document.querySelector('input[name="total"]');
hargaDiskonInput = document.querySelector('input[name="harga_diskon"]');
} else {
// Untuk pembanding, gunakan array input dengan index
const hargaInputs = document.getElementsByName('harga_pembanding[]');
const diskonInputs = document.getElementsByName('diskon_pembanding[]');
const totalInputs = document.getElementsByName('total_pembanding[]');
const hargaDiskonInputs = document.getElementsByName('harga_diskon_pembanding[]');
// Hitung total dan harga setelah diskon // Pastikan index valid
const total = harga; if (index !== null && index < hargaInputs.length) {
const hargaSetelahDiskon = harga - (harga * (diskon / 100)); hargaInput = hargaInputs[index];
diskonInput = diskonInputs[index];
// Update nilai dengan format currency totalInput = totalInputs[index];
if (totalInput) totalInput.value = formatCurrency(total.toString()); hargaDiskonInput = hargaDiskonInputs[index];
if (hargaDiskonInput) hargaDiskonInput.value = formatCurrency(hargaSetelahDiskon.toString()); } else {
return; // Keluar jika index tidak valid
}
} }
// Validasi input
if (!hargaInput || !diskonInput || !totalInput || !hargaDiskonInput) {
return;
}
// Ambil nilai numerik dari input
const harga = parseFloat(hargaInput.value.replace(/[^\d]/g, '') || '0');
let diskon = parseFloat(diskonInput.value.replace(/[^\d]/g, '') || '0');
// Batasi diskon maksimal 100%
diskon = Math.min(diskon, 100);
diskonInput.value = formatCurrency(diskon.toString());
// Hitung total dan harga setelah diskon
const total = harga;
const hargaSetelahDiskon = harga - (harga * (diskon / 100));
// Update nilai dengan format currency
totalInput.value = formatCurrency(total.toString());
hargaDiskonInput.value = formatCurrency(hargaSetelahDiskon.toString());
} }
// Update fungsi fillPembandingData // Update fungsi fillPembandingData
function fillPembandingData(data, index) { function fillPembandingData(data, index) {
if (!data) return; if (!data) return;
@@ -543,12 +614,28 @@
// Update event listener untuk input harga dan diskon // Update event listener untuk input harga dan diskon
function initializePriceCalculation() { function initializePriceCalculation() {
document.querySelectorAll('[name="harga_pembanding[]"], [name="diskon_pembanding[]"]').forEach((input) => { // Event listener untuk input utama
input.addEventListener('input', function() { const mainHargaInput = document.querySelector('input[name="harga"]');
const inputs = document.getElementsByName(this.name); const mainDiskonInput = document.querySelector('input[name="diskon"]');
const index = Array.from(inputs).indexOf(this);
calculatePrices(index); if (mainHargaInput) {
}); mainHargaInput.addEventListener('input', () => calculatePrices('main'));
}
if (mainDiskonInput) {
mainDiskonInput.addEventListener('input', () => calculatePrices('main'));
}
// Event listener untuk input pembanding
const pembandingHargaInputs = document.getElementsByName('harga_pembanding[]');
const pembandingDiskonInputs = document.getElementsByName('diskon_pembanding[]');
pembandingHargaInputs.forEach((input, index) => {
input.addEventListener('input', () => calculatePrices('pembanding', index));
});
pembandingDiskonInputs.forEach((input, index) => {
input.addEventListener('input', () => calculatePrices('pembanding', index));
}); });
} }
@@ -657,18 +744,30 @@
if (input.classList.contains('currency-format')) { if (input.classList.contains('currency-format')) {
input.addEventListener('input', function() { input.addEventListener('input', function() {
formatCurrency(this); formatCurrency(this);
// Special handling for price-related inputs
if (input.name.includes('harga_pembanding') ||
input.name.includes('diskon_pembanding')) {
const inputs = document.getElementsByName(input.name);
const index = Array.from(inputs).indexOf(this);
calculatePrices(index);
}
}); });
} }
if (input.classList.contains('number-format')) {
// Specific handling for discount to limit to 100%
if (input.name.includes('diskon_pembanding')) {
input.addEventListener('input', function() { input.addEventListener('input', function() {
formatNumber(this); let value = parseFloat(this.value.replace(/[^\d]/g, '') || '0');
value = Math.min(value, 100);
this.value = formatCurrency(value.toString());
}); });
} }
}); });
} }
row.appendChild(newCell); row.appendChild(newCell);
}); });
initializePriceCalculation();
updateRemoveButtonVisibility(); updateRemoveButtonVisibility();
} }
@@ -913,8 +1012,6 @@
window.location.href = window.location.href =
'{{ route('surveyor.show', ['id' => $permohonan->id]) }}'; '{{ route('surveyor.show', ['id' => $permohonan->id]) }}';
} }
}); });
} else { } else {
@@ -925,6 +1022,7 @@
confirmButtonText: 'OK' confirmButtonText: 'OK'
}); });
} }
}, },
error: function(xhr, status, error) { error: function(xhr, status, error) {
hideLoadingSwal(); hideLoadingSwal();

View File

@@ -15,9 +15,10 @@
@foreach ($forminspeksi['fakta']['fakta_positif'] as $index => $positif) @foreach ($forminspeksi['fakta']['fakta_positif'] as $index => $positif)
<div class="fakta_positif flex items-center gap-2 mt-2 textarea-group w-full"> <div class="fakta_positif flex items-center gap-2 mt-2 textarea-group w-full">
<textarea class="textarea mt-2" name="fakta_positif[]" rows="3">{{ old("fakta_positif.$index", $positif) }}</textarea> <textarea class="textarea mt-2" name="fakta_positif[]" rows="3">{{ old("fakta_positif.$index", $positif) }}</textarea>
<button class="btn btn-danger btn-sm remove-btn" type="button"> <button class="btn btn-danger btn-sm remove-btn" type="button"
<i class="ki-outline ki-trash"></i> style="display: none;">
</button> <i class="ki-outline ki-trash"></i>
</button>
</div> </div>
@endforeach @endforeach
@else @else

View File

@@ -190,7 +190,8 @@
<span class="ml-2">Tidak</span> <span class="ml-2">Tidak</span>
</label> </label>
</div> </div>
<em id="error-alamat" class="alert text-danger text-sm"></em> <em id="error-alamat_sesuai" class="alert text-danger text-sm"></em>
<em id="error-alamat_sesuai" class="alert text-danger text-sm"></em>
</div> </div>
@php @php
@@ -217,7 +218,7 @@
</div> </div>
<div class="card-body"> <div class="card-body">
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5"> <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">Kordinat</label> <label class="form-label max-w-56">“Koordinat</label>
<div id="perwakilan" class="flex items-baseline w-full gap-5"> <div id="perwakilan" class="flex items-baseline w-full gap-5">
<div class="grid grid-cols-2 gap-4 items-center w-full"> <div class="grid grid-cols-2 gap-4 items-center w-full">
<input class="input" type="text" placeholder="Masukan Koordinat Latitude" type="text" <input class="input" type="text" placeholder="Masukan Koordinat Latitude" type="text"
@@ -230,7 +231,7 @@
<a target="_blank" href="https://www.google.com/maps" type="button" <a target="_blank" href="https://www.google.com/maps" type="button"
class="btn btn-md btn-outline btn-primary"> class="btn btn-md btn-outline btn-primary">
<i class="ki-filled ki-map"></i>Ambil <i class="ki-filled ki-map"></i>Ambil
Kordinat</a> Koordinat </a>
</div> </div>
</div> </div>
</div> </div>
@@ -340,9 +341,13 @@
<div> <div>
<div class="flex flex-wrap items-baseline w-full"> <div class="flex flex-wrap items-baseline w-full">
@foreach ($permohonan->debiture->documents as $dokumen) @foreach ($permohonan->debiture->documents as $dokumen)
{{ $dokumen->pemilik->hubungan_pemilik->name ?? '' }} @php
<input type="hidden" name="hub_cadeb_sesuai" $hubCadebPemilik = $dokumen->pemilik->hubungan_pemilik->name ?? 'N/A';
value="{{ $dokumen->pemilik->hubungan_pemilik->name }}" id=""> @endphp
{{ $hubCadebPemilik }}
<input type="hidden" name="hub_cadeb_sesuai" value="{{ $hubCadebPemilik }}"
id="">
@endforeach @endforeach
</div> </div>
@@ -375,10 +380,12 @@
<option value="">Select Hubungan Cadeb</option> <option value="">Select Hubungan Cadeb</option>
@if (isset($basicData['hubCadeb'])) @if (isset($basicData['hubCadeb']))
@foreach ($basicData['hubCadeb'] as $item) @foreach ($basicData['hubCadeb'] as $item)
<option value="{{ $item->name }}" @if ($item->name != $hubCadebPemilik)
{{ old('hub_cadeb_tidak_sesuai', $selectedData) == $item->name ? 'selected' : '' }}> <option value="{{ $item->name }}"
{{ $item->name }} {{ old('hub_cadeb_tidak_sesuai', $selectedData) == $item->name ? 'selected' : '' }}>
</option> {{ $item->name }}
</option>
@endif
@endforeach @endforeach
@endif @endif
</select> </select>
@@ -400,10 +407,12 @@
<div class="mt-2"> <div class="mt-2">
<div class="flex flex-wrap items-baseline w-full text-sm"> <div class="flex flex-wrap items-baseline w-full text-sm">
@foreach ($permohonan->debiture->documents as $dokumen) @foreach ($permohonan->debiture->documents as $dokumen)
{{ $dokumen->penghuni->hubungan_penghuni->name ?? 'N/A' }} @php
$hubCadebPenghuni = $dokumen->penghuni->hubungan_penghuni->name ?? 'N/A';
@endphp
{{ $hubCadebPenghuni }}
<input type="hidden" name="hub_cadeb_penghuni_sesuai" <input type="hidden" name="hub_cadeb_penghuni_sesuai"
value="{{ isset($dokumen->penghuni->hubungan_penghuni->name) ?? '' }}" value="{{ isset($hubCadebPenghuni) ?? '' }}" id="">
id="">
@endforeach @endforeach
</div> </div>
@@ -438,15 +447,17 @@
<option value="">Select Hubungan Cadeb</option> <option value="">Select Hubungan Cadeb</option>
@if (isset($basicData['hubPenghuni'])) @if (isset($basicData['hubPenghuni']))
@foreach ($basicData['hubPenghuni'] as $item) @foreach ($basicData['hubPenghuni'] as $item)
<option value="{{ $item->name }}" @if ($item->name != $hubCadebPenghuni)
{{ old('hub_penghuni_tidak_sesuai', $selectedData) == $item->name ? 'selected' : '' }}> <option value="{{ $item->name }}"
{{ $item->name }} {{ old('hub_penghuni_tidak_sesuai', $selectedData) == $item->name ? 'selected' : '' }}>
</option> {{ $item->name }}
</option>
@endif
@endforeach @endforeach
@endif @endif
</select> </select>
</div> </div>
<em id="error-hub_cadeb" class="alert text-danger text-sm"></em> <em id="error-hub_cadeb_penghuni" class="alert text-danger text-sm"></em>
</div> </div>
</div> </div>
</div> </div>
@@ -482,102 +493,238 @@
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full"> <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="address" class="form-label max-w-56">Jl.</label> <label for="address" class="form-label max-w-56">Jl.</label>
<div class="flex flex-wrap items-baseline w-full"> <div class="flex flex-wrap items-baseline w-full">
<input type="text" id="address" name="address" class="input w-full " <input type="text" id="address" name="address" class="input w-full "
value="{{ isset($permohonan->debiture->address) ? $permohonan->debiture->address : old('address') }}"> value="{{ isset($permohonan->debiture->address) ? $permohonan->debiture->address : old('address') }}">
</div> </div>
</div> </div>
<input type="hidden" name="province_code" <input type="hidden" name="province_code"
value="{{ isset($permohonan->debiture->province) ? $permohonan->debiture->province->code : '' }}"> value="{{ isset($permohonan->debiture->province) ? $permohonan->debiture->province->code : '' }}">
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full"> <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="province" class="form-label max-w-56">Provinsi</label> <label for="province" class="form-label max-w-56">Provinsi</label>
<div class="flex flex-wrap items-baseline w-full"> <div class="flex flex-wrap items-baseline w-full">
<input type="text" id="province" class="input w-full cursor-not-allowed" readonly <input type="text" id="province" class="input w-full cursor-not-allowed" readonly
value="{{ isset($permohonan->debiture->province) ? $permohonan->debiture->province->name : '' }}"> value="{{ isset($permohonan->debiture->province) ? $permohonan->debiture->province->name : '' }}">
</div> </div>
</div> </div>
<input type="hidden" name="city_code" <input type="hidden" name="city_code"
value="{{ isset($permohonan->debiture->city) ? $permohonan->debiture->city->code : '' }}"> value="{{ isset($permohonan->debiture->city) ? $permohonan->debiture->city->code : '' }}">
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full"> <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="city" class="form-label max-w-56">Kabupaten/Kota</label> <label for="city" class="form-label max-w-56">Kabupaten/Kota</label>
<div class="flex flex-wrap items-baseline w-full"> <div class="flex flex-wrap items-baseline w-full">
<input type="text" id="city" class="input w-full cursor-not-allowed" readonly <input type="text" id="city" class="input w-full cursor-not-allowed" readonly
value="{{ isset($permohonan->debiture->city) ? $permohonan->debiture->city->name : '' }}"> value="{{ isset($permohonan->debiture->city) ? $permohonan->debiture->city->name : '' }}">
</div> </div>
</div> </div>
<input type="hidden" name="district_code" <input type="hidden" name="district_code"
value="{{ isset($permohonan->debiture->district) ? $permohonan->debiture->district->code : '' }}"> value="{{ isset($permohonan->debiture->district) ? $permohonan->debiture->district->code : '' }}">
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full"> <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="district" class="form-label max-w-56">Kecamatan</label> <label for="district" class="form-label max-w-56">Kecamatan</label>
<div class="flex flex-wrap items-baseline w-full"> <div class="flex flex-wrap items-baseline w-full">
<input type="text" id="district" class="input w-full cursor-not-allowed" readonly <input type="text" id="district" class="input w-full cursor-not-allowed" readonly
value="{{ isset($permohonan->debiture->district) ? $permohonan->debiture->district->name : '' }}"> value="{{ isset($permohonan->debiture->district) ? $permohonan->debiture->district->name : '' }}">
</div> </div>
</div> </div>
<input type="hidden" name="village_code" <input type="hidden" name="village_code"
value="{{ isset($permohonan->debiture->village) ? $permohonan->debiture->village->code : '' }}"> value="{{ isset($permohonan->debiture->village) ? $permohonan->debiture->village->code : '' }}">
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full"> <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="village" class="form-label max-w-56">Desa/Kelurahan</label> <label for="village" class="form-label max-w-56">Desa/Kelurahan</label>
<div class="flex flex-wrap items-baseline w-full"> <div class="flex flex-wrap items-baseline w-full">
<input type="text" id="village" class="input w-full cursor-not-allowed" readonly <input type="text" id="village" class="input w-full cursor-not-allowed" readonly
value="{{ isset($permohonan->debiture->village) ? $permohonan->debiture->village->name : '' }}"> value="{{ isset($permohonan->debiture->village) ? $permohonan->debiture->village->name : '' }}">
</div> </div>
</div> </div>
</div> </div>
`; `;
} }
if (data == 'tidak sesuai') { if (data === 'tidak sesuai') {
createElementAlamat.innerHTML = ` createElementAlamat.innerHTML = `
<div class="grid gap-2.5 w-full"> <div class="grid gap-2.5 w-full">
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full"> <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="address" class="form-label max-w-56">Jl.</label> <label for="address" class="form-label max-w-56">Jl.</label>
<div class="flex flex-wrap items-baseline w-full"> <div class="flex flex-wrap items-baseline w-full">
<input type="text" id="address" name="address" class="input w-full" <input type="text" id="address" name="address" class="input w-full"
placeholder="Masukkan Jl." placeholder="Masukkan Jl." value="{{ old('address') }}">
value="{{ old('address') }}"> </div>
</div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="province_code" class="form-label max-w-56">Provinsi</label>
<div class="flex flex-wrap items-baseline w-full">
<select id="province_code" name="province_code" class="input w-full" onchange="getCity(this.value)">
<option value="">Select Province</option>
@foreach ($provinces as $province)
<option value="{{ $province->code }}"
@if (
(isset($cekAlamat['province_code']) && $cekAlamat['province_code'] == $province->code) ||
(!isset($cekAlamat['province_code']) &&
isset($debitur->province_code) &&
$debitur->province_code == $province->code)) selected @endif>
{{ $province->name }}
</option>
@endforeach
</select>
</div>
</div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="city_code" class="form-label max-w-56">Kota/Kabupaten</label>
<div class="flex flex-wrap items-baseline w-full">
<select id="city_code" name="city_code" class="select w-full" onchange="getDistrict(this.value)">
<option value="">Pilih Kota/Kabupaten</option>
</select>
</div>
</div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="district_code" class="form-label max-w-56">Kecamatan</label>
<div class="flex flex-wrap items-baseline w-full">
<select id="district_code" name="district_code" class="select w-full" onchange="getVillage(this.value)">
<option value="">Pilih Kecamatan</option>
</select>
</div>
</div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="village_code" class="form-label max-w-56">Kelurahan</label>
<div class="flex flex-wrap items-baseline w-full">
<select id="village_code" name="village_code" class="select w-full">
<option value="">Pilih Kelurahan</option>
</select>
</div>
</div> </div>
</div> </div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="province_code" class="form-label max-w-56">Provinsi</label>
<div class="flex flex-wrap items-baseline w-full">
<select id="province_code" name="province_code" class="input w-full" >
<option value="">Select Province</option>
@foreach ($provinces as $province)
<option value="{{ $province->code }}">{{ $province->name }}</option>
@endforeach
</select>
</div>
</div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="city_code" class="form-label max-w-56">Kota/Kabupaten</label>
<div class="flex flex-wrap items-baseline w-full">
<select id="city_code" name="city_code" class="select w-full" >
<option value="">Pilih Kota/Kabupaten</option>
</select>
</div>
</div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="district_code" class="form-label max-w-56">Kecamatan</label>
<div class="flex flex-wrap items-baseline w-full">
<select id="district_code" name="district_code" class="select w-full" >
<option value="">Pilih Kecamatan</option>
</select>
</div>
</div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 w-full">
<label for="village_code" class="form-label max-w-56">Kelurahan</label>
<div class="flex flex-wrap items-baseline w-full">
<select id="village_code" name="village_code" class="select w-full">
<option value="">Pilih Kelurahan</option>
</select>
</div>
</div>
</div>
`; `;
loadSavedLocationData();
}
}
document.addEventListener('DOMContentLoaded', () => {
loadSavedLocationData();
});
// Fungsi untuk memuat data lokasi yang tersimpan
async function loadSavedLocationData() {
const provinceCode = '{{ $cekAlamat['province_code'] ?? '' }}';
const cityCode = '{{ $cekAlamat['city_code'] ?? '' }}';
const districtCode = '{{ $cekAlamat['district_code'] ?? '' }}';
const villageCode = '{{ $cekAlamat['village_code'] ?? '' }}';
// Set province
const provinceSelect = document.getElementById('province_code');
if (provinceCode && provinceSelect) {
provinceSelect.value = provinceCode;
await getCity(provinceCode);
}
// Set city
const citySelect = document.getElementById('city_code');
if (cityCode && citySelect) {
citySelect.value = cityCode;
await getDistrict(cityCode);
}
// Set district
const districtSelect = document.getElementById('district_code');
if (districtCode && districtSelect) {
districtSelect.value = districtCode;
await getVillage(districtCode);
}
// Set village
const villageSelect = document.getElementById('village_code');
if (villageCode && villageSelect) {
villageSelect.value = villageCode;
}
}
// Modifikasi fungsi existing
async function getCity(provinceId) {
try {
const response = await fetch(`/locations/cities/province/${provinceId}`);
const data = await response.json();
const cityDropdown = document.getElementById('city_code');
if (cityDropdown) {
cityDropdown.innerHTML = '<option value="">Pilih Kota/Kabupaten</option>';
data.forEach(city => {
const option = document.createElement('option');
option.value = city.code;
option.textContent = city.name;
@if (isset($debitur->city_code))
if (city.code === '{{ $debitur->city_code }}') {
option.selected = true;
}
@endif
cityDropdown.appendChild(option);
});
// Reset dropdown kecamatan dan desa
document.getElementById('district_code').innerHTML = '<option value="">Pilih Kecamatan</option>';
document.getElementById('village_code').innerHTML = '<option value="">Pilih Kelurahan</option>';
}
} catch (error) {
console.error('Error fetching cities:', error);
}
}
// Lakukan hal serupa untuk getDistrict dan getVillage
async function getDistrict(cityId) {
try {
const response = await fetch(`/locations/districts/city/${cityId}`);
const data = await response.json();
const districtDropdown = document.getElementById('district_code');
if (districtDropdown) {
districtDropdown.innerHTML = '<option value="">Pilih Kecamatan</option>';
data.forEach(district => {
const option = document.createElement('option');
option.value = district.code;
option.textContent = district.name;
// Cek apakah ini adalah kecamatan yang sebelumnya dipilih
@if (isset($debitur->district_code))
if (district.code === '{{ $debitur->district_code }}') {
option.selected = true;
}
@endif
districtDropdown.appendChild(option);
});
// Reset dropdown desa
document.getElementById('village_code').innerHTML = '<option value="">Pilih Kelurahan</option>';
}
} catch (error) {
console.error('Error fetching districts:', error);
}
}
async function getVillage(districtId) {
try {
const response = await fetch(`/locations/villages/district/${districtId}`);
const data = await response.json();
const villageDropdown = document.getElementById('village_code');
if (villageDropdown) {
villageDropdown.innerHTML = '<option value="">Pilih Desa/Kelurahan</option>';
data.forEach(village => {
const option = document.createElement('option');
option.value = village.code;
option.textContent = village.name;
// Cek apakah ini adalah desa yang sebelumnya dipilih
@if (isset($debitur->village_code))
if (village.code === '{{ $debitur->village_code }}') {
option.selected = true;
}
@endif
villageDropdown.appendChild(option);
});
}
} catch (error) {
console.error('Error fetching villages:', error);
} }
} }
</script> </script>

View File

@@ -1,208 +1,228 @@
<!-- Informasi Tata Ruang --> <!-- Informasi Tata Ruang -->
<div class="card w-full bg-white"> <div class="card w-full bg-white">
<div class="card-header"> <div class="card-header">
<h3 class="card-title uppercase"> <h3 class="card-title uppercase">
Informasi Dinas Tata Ruang Informasi Dinas Tata Ruang
</h3> </h3>
</div> </div>
<div class="card-body"> <div class="card-body">
<!-- Informasi Tata Ruang Form --> <!-- Informasi Tata Ruang Form -->
<div class="grid gap-5"> <div class="grid gap-5">
@php @php
$inputDinasTata = [ $inputDinasTata = [
[ [
'label' => 'Peruntukan', 'label' => 'Peruntukan',
'name' => 'peruntukan', 'name' => 'peruntukan',
'index' => 0, 'index' => 0,
'value' => old( 'value' => old(
'peruntukan', 'peruntukan',
isset($forminspeksi['fakta']['peruntukan']) ? $forminspeksi['fakta']['peruntukan'] : '', isset($forminspeksi['fakta']['peruntukan']) ? $forminspeksi['fakta']['peruntukan'] : '',
), ),
], ],
[ [
'label' => 'KDB', 'label' => 'KDB',
'name' => 'kdb', 'name' => 'kdb',
'index' => 1, 'index' => 1,
'value' => old('kdb', isset($forminspeksi['fakta']['kdb']) ? $forminspeksi['fakta']['kdb'] : ''), 'value' => old(
], 'kdb',
[ isset($forminspeksi['fakta']['kdb']) ? $forminspeksi['fakta']['kdb'] : '',
'label' => 'KDH', ),
'name' => 'kdh', ],
'index' => 2, [
'value' => old('kdh', isset($forminspeksi['fakta']['kdh']) ? $forminspeksi['fakta']['kdh'] : ''), 'label' => 'KDH',
], 'name' => 'kdh',
[ 'index' => 2,
'label' => 'GSB', 'value' => old(
'name' => 'gsb', 'kdh',
'index' => 3, isset($forminspeksi['fakta']['kdh']) ? $forminspeksi['fakta']['kdh'] : '',
'value' => old('gsb', isset($forminspeksi['fakta']['gsb']) ? $forminspeksi['fakta']['gsb'] : ''), ),
], ],
[ [
'label' => 'Max Lantai', 'label' => 'GSB',
'name' => 'max_lantai', 'name' => 'gsb',
'index' => 4, 'index' => 3,
'value' => old( 'value' => old(
'max_lantai', 'gsb',
isset($forminspeksi['fakta']['max_lantai']) ? $forminspeksi['fakta']['max_lantai'] : '', isset($forminspeksi['fakta']['gsb']) ? $forminspeksi['fakta']['gsb'] : '',
), ),
], ],
[ [
'label' => 'KLB', 'label' => 'Max Lantai',
'name' => 'klb', 'name' => 'max_lantai',
'index' => 5, 'index' => 4,
'value' => old('klb', isset($forminspeksi['fakta']['klb']) ? $forminspeksi['fakta']['klb'] : ''), 'value' => old(
], 'max_lantai',
[ isset($forminspeksi['fakta']['max_lantai']) ? $forminspeksi['fakta']['max_lantai'] : '',
'label' => 'GSS', ),
'name' => 'gss', ],
'index' => 6, [
'value' => old('gss', isset($forminspeksi['fakta']['gss']) ? $forminspeksi['fakta']['gss'] : ''), 'label' => 'KLB',
], 'name' => 'klb',
[ 'index' => 5,
'label' => 'Pelebaran Jalan', 'value' => old(
'name' => 'pelebaran_jalan', 'klb',
'index' => 7, isset($forminspeksi['fakta']['klb']) ? $forminspeksi['fakta']['klb'] : '',
'value' => old( ),
'pelebaran_jalan', ],
isset($forminspeksi['fakta']['pelebaran_jalan']) ? $forminspeksi['fakta']['pelebaran_jalan'] : '', [
), 'label' => 'GSS',
], 'name' => 'gss',
[ 'index' => 6,
'label' => 'Nama Petugas TK', 'value' => old(
'name' => 'nama_petugas', 'gss',
'index' => 8, isset($forminspeksi['fakta']['gss']) ? $forminspeksi['fakta']['gss'] : '',
'value' => old( ),
'nama_petugas', ],
isset($forminspeksi['fakta']['nama_petugas']) ? $forminspeksi['fakta']['nama_petugas'] : '', [
), 'label' => 'Pelebaran Jalan',
], 'name' => 'pelebaran_jalan',
]; 'index' => 7,
@endphp 'value' => old(
'pelebaran_jalan',
isset($forminspeksi['fakta']['pelebaran_jalan'])
? $forminspeksi['fakta']['pelebaran_jalan']
: '',
),
],
[
'label' => 'Nama Petugas TK',
'name' => 'nama_petugas',
'index' => 8,
'value' => old(
'nama_petugas',
isset($forminspeksi['fakta']['nama_petugas'])
? $forminspeksi['fakta']['nama_petugas']
: '',
),
],
];
@endphp
@if (count($inputDinasTata) > 0) @if (count($inputDinasTata) > 0)
@foreach ($inputDinasTata as $item) @foreach ($inputDinasTata as $item)
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5"> <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">{{ $item['label'] }}</label> <label class="form-label max-w-56">{{ $item['label'] }}</label>
<div class="flex flex-wrap items-baseline w-full"> <div class="flex flex-wrap items-baseline w-full">
<input type="text" name="{{ $item['name'] }}" class="input" <input type="text" name="{{ $item['name'] }}" class="input"
placeholder="Masukkan {{ $item['label'] }}" value="{{ $item['value'] }}"> placeholder="Masukkan {{ $item['label'] }}" value="{{ $item['value'] }}">
@error($item['name']) @error($item['name'])
<em class="alert text-danger text-sm"></em> <em class="alert text-danger text-sm"></em>
@enderror @enderror
</div> </div>
</div> </div>
@endforeach @endforeach
@endif @endif
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5"> <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56"> <label class="form-label max-w-56">
<span class="form-label">Gistaru</span> <span class="form-label">Gistaru</span>
</label> </label>
<div class="input-group w-full flex gap-2"> <div class="input-group w-full flex gap-2">
<input class="name_rute" type="hidden" name="name_rute" value="rute"> <input class="name_rute" type="hidden" name="name_rute" value="rute">
<div class="w-full"> <div class="w-full">
<input id="inputGistaru" type="file" name="foto_gistaru" <input id="inputGistaru" type="file" name="foto_gistaru"
class="file-input file-input-bordered w-full" accept="image/*" class="file-input file-input-bordered w-full" accept="image/*"
onchange="previewImage(this, 'gistaru-preview')"> onchange="previewImage(this, 'gistaru-preview')">
<img id="gistaru-preview"
src="{{ asset('storage/' . (isset($forminspeksi['foto_gistaru']) ? $forminspeksi['foto_gistaru'] : '')) }}"
alt="Foto Gistaru" class="mt-2 max-w-full h-auto"
style="{{ isset($forminspeksi['foto_gistaru']) ? '' : 'display: none;' }}">
</div>
<a href="https://gistaru.atrbpn.go.id/rtronline" type="button" class="btn btn-light"
target="_blank">
<i class="ki-filled ki-map"></i> Gistaru
</a>
</div>
</div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5"> <img id="gistaru-preview"
<label class="form-label max-w-56"> src="{{ asset('storage/' . (isset($forminspeksi['foto_gistaru']) ? $forminspeksi['foto_gistaru'] : '')) }}"
<span class="form-label">Bhumi</span> alt="Foto Bhumi" class="mt-2 max-w-full h-auto"
</label> style="{{ isset($forminspeksi['foto_gistaru']) ? '' : 'display: none;' }}" />
<div class="input-group w-full flex gap-2">
<input class="name_rute" type="hidden" name="name_rute" value="rute">
<div class="w-full">
<input id="inputBhumi" type="file" name="foto_bhumi"
class="file-input file-input-bordered w-full" accept="image/*"
onchange="previewImage(this, 'bhumi-preview')">
<img id="bhumi-preview"
src="{{ asset('storage/' . (isset($forminspeksi['foto_bhumi']) ? $forminspeksi['foto_bhumi'] : '')) }}"
alt="Foto Bhumi" class="mt-2 max-w-full h-auto"
style="{{ isset($forminspeksi['foto_bhumi']) ? '' : 'display: none;' }}">
</div>
<a href="https://bhumi.atrbpn.go.id/peta" type="button" class="btn btn-light"
target="_blank">
<i class="ki-filled ki-map"></i> Bhumi
</a>
</div>
</div>
@if (isset($link_url_region->regions->url))
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5"> </div>
<label class="form-label max-w-56"> <a href="https://gistaru.atrbpn.go.id/rtronline" type="button" class="btn btn-light"
<span class="form-label">{{ $link_url_region->regions->name_url }}</span> target="_blank">
</label> <i class="ki-filled ki-map"></i> Gistaru
<div class="input-group w-full flex gap-2"> </a>
<input class="name_rute" type="hidden" name="name_rute" value="rute"> </div>
<div class="w-full"> </div>
<input id="inputArgisRegion" type="file" name="foto_argis_region"
class="file-input file-input-bordered w-full" accept="image/*"
onchange="previewImage(this, 'argis-region-preview')">
<img id="argis-region-preview"
src="{{ asset('storage/' . (isset($forminspeksi['foto_argis_region']) ? $forminspeksi['foto_argis_region'] : '')) }}"
alt="Foto Argis Region" class="mt-2 max-w-full h-auto"
style="{{ isset($forminspeksi['foto_argis_region']) ? '' : 'display: none;' }}">
</div>
<a href="{{ $link_url_region->regions->url }}" type="button" class="btn btn-light"
target="_blank">
<i class="ki-filled ki-map"></i>
{{ $link_url_region->regions->name_url }}
</a>
</div>
</div>
@endif
</div>
<!-- Upload Photo Button -->
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5" style="margin-top: 20px">
<label for="" class="form-label max-w-56 text-sm font-medium text-gray-700">Upload Photo</label>
<div class="w-full grid gap-5"> <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<div class="input-group w-full flex gap-2"> <label class="form-label max-w-56">
<input id="foto_tempat" type="file" name="foto_tempat" <span class="form-label ">Bhumi</span>
</label>
<div class="input-group w-full flex gap-2">
<input class="name_rute" type="hidden" name="name_rute" value="rute">
<div class="w-full grid gap-2">
class="file-input file-input-bordered w-full" accept="image/*"
onchange="previewImage(this, 'foto_tempat-preview')">
<button type="button" id="btnCamera" class="btn btn-light"
data-modal-toggle="#cameraModal">
<i class="ki-outline ki-abstract-33"></i> Camera
</button>
</div>
<img id="foto_tempat-preview" <input id="inputBhumi" type="file" name="foto_bhumi"
src="{{ asset('storage/' . (isset($forminspeksi['foto_tempat']) ? $forminspeksi['foto_tempat'] : '')) }}" class="file-input file-input-bordered w-full " accept="image/*"
alt="Foto Argis Region" class="mt-2 max-w-full h-auto" onchange="previewImage(this, 'bhumi-preview')">
style="{{ isset($forminspeksi['foto_tempat']) ? '' : 'display: none;' }}"> <img id="bhumi-preview"
</div> src="{{ asset('storage/' . (isset($forminspeksi['foto_bhumi']) ? $forminspeksi['foto_bhumi'] : '')) }}"
</div> alt="Foto Bhumi" class="mt-2 max-w-full h-auto"
style="{{ isset($forminspeksi['foto_bhumi']) ? '' : 'display: none;' }}" />
<!-- Notes Section --> </div>
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5" style="margin-top: 20px"> <a href="https://bhumi.atrbpn.go.id/peta" type="button" class="btn btn-light" target="_blank">
<i class="ki-filled ki-map"></i> Bhumi
<label class="form-label max-w-56">Catatan yang Perlu Diperhatikan </a>
</label> </div>
<div class="input-group w-full flex gap-2"> </div>
<textarea name="keterangan" class="textarea mt-2" placeholder="Masukkan catatan penting" rows="3">{{ old('keterangan', $forminspeksi['fakta']['keterangan'] ?? '') }}</textarea>
</div>
</div>
</div>
</div>
@include('lpj::surveyor.components.modal-kamera') @if (isset($link_url_region->regions->url))
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">
<span class="form-label">{{ $link_url_region->regions->name_url }}</span>
</label>
<div class="input-group w-full flex gap-2">
<input class="name_rute" type="hidden" name="name_rute" value="rute">
<div class="w-full">
<input id="inputArgisRegion" type="file" name="foto_argis_region"
class="file-input file-input-bordered w-full" accept="image/*"
onchange="previewImage(this, 'argis-region-preview')">
<img id="argis-region-preview"
src="{{ asset('storage/' . (isset($forminspeksi['foto_argis_region']) ? $forminspeksi['foto_argis_region'] : '')) }}"
alt="Foto Argis Region" class="mt-2 max-w-full h-auto"
style="{{ isset($forminspeksi['foto_argis_region']) ? '' : 'display: none;' }}">
</div>
<a href="{{ $link_url_region->regions->url }}" type="button" class="btn btn-light"
target="_blank">
<i class="ki-filled ki-map"></i>
{{ $link_url_region->regions->name_url }}
</a>
</div>
</div>
@endif
</div>
<!-- Upload Photo Button -->
@push('scripts') <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5" style="margin-top: 20px">
@include('lpj::surveyor.js.camera-editor') <label for="" class="form-label max-w-56 text-sm font-medium text-gray-700">Upload Photo</label>
@endpush
<div class="w-full grid gap-5">
<div class="input-group w-full flex gap-2">
<input id="foto_tempat" type="file" name="foto_tempat"
class="file-input file-input-bordered w-full" accept="image/*"
onchange="previewImage(this, 'foto_tempat-preview')">
<button type="button" id="btnCamera" class="btn btn-light" data-modal-toggle="#cameraModal">
<i class="ki-outline ki-abstract-33"></i> Camera
</button>
</div>
<img id="foto_tempat-preview"
src="{{ asset('storage/' . (isset($forminspeksi['foto_tempat']) ? $forminspeksi['foto_tempat'] : '')) }}"
alt="Foto Argis Region" class="mt-2 max-w-full h-auto"
style="{{ isset($forminspeksi['foto_tempat']) ? '' : 'display: none;' }}">
</div>
</div>
<!-- Notes Section -->
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5" style="margin-top: 20px">
<label class="form-label lg:form-label max-w-56 ">Catatan yang Perlu Diperhatikan
</label>
<div class="input-group w-full flex gap-2">
<textarea name="keterangan" class="textarea mt-2" placeholder="Masukkan catatan penting" rows="3">{{ old('keterangan', $forminspeksi['fakta']['keterangan'] ?? '') }}</textarea>
</div>
</div>
</div>
</div>
@include('lpj::surveyor.components.modal-kamera')
@push('scripts')
@include('lpj::surveyor.js.camera-editor')
@endpush

View File

@@ -200,8 +200,8 @@
confirmButtonText: 'OK' confirmButtonText: 'OK'
}).then((response) => { }).then((response) => {
if (response.isConfirmed) { if (response.isConfirmed) {
// window.location.href = window.location.href =
// '{{ route('surveyor.show', ['id' => $permohonan->id]) }}'; '{{ route('surveyor.show', ['id' => $permohonan->id]) }}';
} }
}); });
} else { } else {
@@ -231,52 +231,7 @@
}); });
} }
function previewImage(input, previewId) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
$('#' + previewId).attr('src', e.target.result).show();
}
reader.readAsDataURL(input.files[0]);
} else {
$('#' + previewId).hide();
}
}
function addClonableItem(containerId, itemClass) {
const container = document.getElementById(containerId);
if (!container) {
console.error(`Container with ID "${containerId}" not found.`);
return;
}
const template = container.querySelector(`.${itemClass}`);
if (!template) {
console.error(`Template with class "${itemClass}" not found in container "${containerId}".`);
return;
}
// Clone the template element
const newElement = template.cloneNode(true);
// Reset input fields
const inputs = newElement.querySelectorAll('input');
inputs.forEach(input => {
input.value = '';
});
// Make the delete button visible and bind the click event
const deleteButton = newElement.querySelector('.remove-btn');
if (deleteButton) {
deleteButton.style.display = 'inline-block';
deleteButton.addEventListener('click', () => {
newElement.remove();
});
}
// Append the cloned element to the container
container.appendChild(newElement);
}
// Ensure existing remove buttons are functional // Ensure existing remove buttons are functional
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {

View File

@@ -35,7 +35,10 @@
<div class="w-full mt-4"> <div class="w-full mt-4">
<label class="block text-sm font-medium text-gray-700">Lebar Perkerasan Jalan Depan objek</label> <label class="block text-sm font-medium text-gray-700">Lebar Perkerasan Jalan Depan objek</label>
@php @php
$lebarPerkerasanJalan = old('lebar_perkerasan_jalan', $forminspeksi['lingkungan']['lebar_perkerasan_jalan'] ?? ''); $lebarPerkerasanJalan = old(
'lebar_perkerasan_jalan',
$forminspeksi['lingkungan']['lebar_perkerasan_jalan'] ?? '',
);
@endphp @endphp
<input type="text" name="lebar_perkerasan_jalan" class="input mt-2" placeholder="Meter" <input type="text" name="lebar_perkerasan_jalan" class="input mt-2" placeholder="Meter"
value="{{ $lebarPerkerasanJalan }}"> value="{{ $lebarPerkerasanJalan }}">
@@ -50,28 +53,35 @@
@if (isset($basicData['perkerasanJalan'])) @if (isset($basicData['perkerasanJalan']))
@foreach ($basicData['perkerasanJalan'] as $item) @foreach ($basicData['perkerasanJalan'] as $item)
@php @php
$isChecked = in_array($item->name, isset($forminspeksi['lingkungan']['perkerasan_jalan']['perkerasan_jalan']) ? $forminspeksi['lingkungan']['perkerasan_jalan']['perkerasan_jalan'] : []); $isChecked = in_array(
$item->name,
isset($forminspeksi['lingkungan']['perkerasan_jalan']['perkerasan_jalan'])
? $forminspeksi['lingkungan']['perkerasan_jalan']['perkerasan_jalan']
: [],
);
@endphp @endphp
<label class="form-label flex items-center gap-2.5 text-nowrap"> <label class="form-label flex items-center gap-2.5 text-nowrap">
<input class="checkbox" name="perkerasan_jalan[]" type="checkbox" <input class="checkbox" name="perkerasan_jalan[]" type="checkbox"
value="{{ $item->name }}" value="{{ $item->name }}" {{ $isChecked ? 'checked' : '' }}
{{ $isChecked ? 'checked' : '' }} onclick="toggleCheckboxVisibility('perkerasan_jalan', 'perkerasan_jalan_lainnya', ['lainnya'])" />
onclick="toggleCheckboxVisibility('perkerasan_jalan', 'perkerasan_jalan_lainnya', ['lainnya'])"/>
{{ $item->name }} {{ $item->name }}
</label> </label>
@if (strcasecmp($item->name, 'Lainnya') == 0) @if (strcasecmp($item->name, 'Lainnya') == 0)
@php @php
$lainnyaValue = old('perkerasan_jalan_lainnya', isset($forminspeksi['lingkungan']['perkerasan_jalan']['lainnya']) ? $forminspeksi['lingkungan']['perkerasan_jalan']['lainnya'] : '');
@endphp
<input id="perkerasan_jalan_lainnya" type="text"
style="{{ isset($forminspeksi['lingkungan']['perkerasan_jalan']['lainnya']) && $forminspeksi['lingkungan']['perkerasan_jalan']['lainnya'] ? '' : 'display: none' }}"
name="perkerasan_jalan_lainnya" class="input w-full mt-2"
value="{{ $lainnyaValue }}"
placeholder="Masukkan lainnya..." />
@endif
$lainnyaValue = old(
'perkerasan_jalan_lainnya',
isset($forminspeksi['lingkungan']['perkerasan_jalan']['lainnya'])
? $forminspeksi['lingkungan']['perkerasan_jalan']['lainnya']
: '',
);
@endphp
<input id="perkerasan_jalan_lainnya" type="text"
style="{{ isset($forminspeksi['lingkungan']['perkerasan_jalan']['lainnya']) && $forminspeksi['lingkungan']['perkerasan_jalan']['lainnya'] ? '' : 'display: none' }}"
name="perkerasan_jalan_lainnya" class="input w-full mt-2"
value="{{ $lainnyaValue }}" placeholder="Masukkan lainnya..." />
@endif
@endforeach @endforeach
@endif @endif
</div> </div>
@@ -103,7 +113,7 @@
</div> </div>
<!-- Golongan Hidup Sekitar --> <!-- Golongan Hidup Sekitar -->
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5"> <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
<label class="form-label max-w-56">Golongan Masy Sekitar</label> <label class="form-label max-w-56">Golongan Masyarakat Sekitar</label>
<div class="flex flex-wrap items-baseline w-full"> <div class="flex flex-wrap items-baseline w-full">
<div class="flex flex-col items-start gap-4"> <div class="flex flex-col items-start gap-4">
@if (isset($basicData['golMasySekitar'])) @if (isset($basicData['golMasySekitar']))
@@ -159,16 +169,19 @@
{{ $item->name }} {{ $item->name }}
</label> </label>
@if (strcasecmp($item->name, 'Lainnya') == 0) @if (strcasecmp($item->name, 'Lainnya') == 0)
@php @php
$lainnyaValue = old('terletak_diarea_lainnya', isset($forminspeksi['lingkungan']['terletak_diarea']['lainnya']) ? $forminspeksi['lingkungan']['terletak_diarea']['lainnya'] : ''); $lainnyaValue = old(
@endphp 'terletak_diarea_lainnya',
<input id="terletak_diarea_lainnya" type="text" isset($forminspeksi['lingkungan']['terletak_diarea']['lainnya'])
style="{{ isset($forminspeksi['lingkungan']['terletak_diarea']['lainnya']) && $forminspeksi['lingkungan']['terletak_diarea']['lainnya'] ? '' : 'display: none' }}" ? $forminspeksi['lingkungan']['terletak_diarea']['lainnya']
name="terletak_diarea_lainnya" class="input w-full mt-2" : '',
value="{{ $lainnyaValue }}" );
placeholder="Masukkan lainnya..." /> @endphp
@endif <input id="terletak_diarea_lainnya" type="text"
style="{{ isset($forminspeksi['lingkungan']['terletak_diarea']['lainnya']) && $forminspeksi['lingkungan']['terletak_diarea']['lainnya'] ? '' : 'display: none' }}"
name="terletak_diarea_lainnya" class="input w-full mt-2"
value="{{ $lainnyaValue }}" placeholder="Masukkan lainnya..." />
@endif
@endforeach @endforeach
@endif @endif
</div> </div>
@@ -356,48 +369,37 @@
@if (isset($basicData['fasilitasObjek'])) @if (isset($basicData['fasilitasObjek']))
@foreach ($basicData['fasilitasObjek'] as $item) @foreach ($basicData['fasilitasObjek'] as $item)
@php @php
$isChecked = false;
$inputValue = '';
$selectedFasilitas = is_array( // Cek old input terlebih dahulu
old( if (old('fasilitas_dekat_object') && in_array($item->name, old('fasilitas_dekat_object'))) {
'fasilitas_dekat_object', $isChecked = true;
$forminspeksi['lingkungan']['fasilitas_dekat_object']['fasilitas_dekat_object'] ?? [], $oldInputIndex = array_search($item->name, old('fasilitas_dekat_object'));
), $inputValue = old('fasilitas_dekat_object_input')[$oldInputIndex] ?? '';
) }
? old( elseif (isset($forminspeksi['lingkungan']['fasilitas_dekat_object'])) {
'fasilitas_dekat_object', foreach ($forminspeksi['lingkungan']['fasilitas_dekat_object'] as $key => $value) {
$forminspeksi['lingkungan']['fasilitas_dekat_object']['fasilitas_dekat_object'] ?? [], if ($key === $item->name) {
) $isChecked = true;
: explode( $inputValue = $value;
',', break;
old( }
'fasilitas_dekat_object', }
$forminspeksi['lingkungan']['fasilitas_dekat_object']['fasilitas_dekat_object'] ?? '', }
),
);
@endphp @endphp
<label class="form-label flex items-center gap-2.5 text-nowrap">
<input class="checkbox" name="fasilitas_dekat_object[]" type="checkbox"
value="{{ $item->name }}"
{{ in_array(
$item->name,
is_array(old('fasilitas_dekat_object', $forminspeksi['lingkungan']['fasilitas_dekat_object']['fasilitas_dekat_object'] ?? ''))
? old('fasilitas_dekat_object', $forminspeksi['lingkungan']['fasilitas_dekat_object']['fasilitas_dekat_object'] ?? [])
: explode(',', old('fasilitas_dekat_object', $forminspeksi['lingkungan']['fasilitas_dekat_object']['fasilitas_dekat_object'] ?? '')),
)
? 'checked'
: '' }}
onclick="toggleCheckboxVisibility('fasilitas_dekat_object', 'fasilitas_dekat_object_lainnya', ['Lainnya'])"
/>
{{ $item->name }} <div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
</label> <label class="form-label max-w-56 gap-2.5" style="width: 500px">
<input class="checkbox" name="fasilitas_dekat_object[]" type="checkbox"
@if (strcasecmp($item->name, 'Lainnya') == 0) value="{{ $item->name }}"
<input id="fasilitas_dekat_object_lainnya" type="text" style="{{ in_array('Lainnya', $selectedFasilitas) ? '' : 'display: none' }}" {{ $isChecked ? 'checked' : '' }} />
name="fasilitas_dekat_object_lainnya" class="input w-full mt-2" {{ $item->name }}
value="{{ old('fasilitas_dekat_object_lainnya', $forminspeksi['lingkungan']['fasilitas_dekat_object']['lainnya'] ?? '') }}" </label>
placeholder="Masukkan lainnya..." /> <input type="text" name="fasilitas_dekat_object_input[]" class="input w-full"
@endif placeholder="Masukkan fasilitas {{ $item->name }}..."
value="{{ $inputValue }}">
</div>
@endforeach @endforeach
@endif @endif
</div> </div>
@@ -405,6 +407,9 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -24,7 +24,7 @@
@endforeach @endforeach
@endif @endif
<div class="flex-wrap items-stretch"> <div class="flex-wrap items-stretch">
<div class="flex flex-wrap items-baseline w-full">
<div class="grid grid-cols-3 md:grid-cols-3 gap-4 mt-2"> <div class="grid grid-cols-3 md:grid-cols-3 gap-4 mt-2">
<label class="form-label flex items-center gap-3 text-nowrap"> <label class="form-label flex items-center gap-3 text-nowrap">
<input type="radio" class="radio" name="luas_tanah" value="sesuai" <input type="radio" class="radio" name="luas_tanah" value="sesuai"
@@ -48,7 +48,7 @@
</div> </div>
</div> </div>
<em id="error-luas_tanah" class="alert text-danger text-sm"></em> <em id="error-luas_tanah" class="alert text-danger text-sm"></em>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -32,7 +32,7 @@
input.value = value; input.value = value;
} }
function formatCurrency(value) { function formatCurrency(value) {
if (!value) return ''; if (!value) return '';
@@ -52,4 +52,119 @@
return formattedValue; return formattedValue;
} }
function previewImage(input, previewId) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e) {
$('#' + previewId).attr('src', e.target.result).show();
}
reader.readAsDataURL(input.files[0]);
} else {
$('#' + previewId).hide();
}
}
function addClonableItem(containerId, itemClass) {
const container = document.getElementById(containerId);
if (!container) {
console.error(`Container with ID "${containerId}" not found.`);
return;
}
const template = container.querySelector(`.${itemClass}`);
if (!template) {
console.error(`Template with class "${itemClass}" not found in container "${containerId}".`);
return;
}
// Clone the template element
const newElement = template.cloneNode(true);
// Reset all input fields comprehensively
const inputs = newElement.querySelectorAll('input, select, textarea');
inputs.forEach(input => {
// Reset based on input type
switch (input.type) {
case 'text':
case 'number':
case 'email':
case 'tel':
case 'password':
case 'search':
case 'url':
case 'textarea':
input.value = '';
break;
case 'checkbox':
case 'radio':
input.checked = false;
break;
case 'select-one':
case 'select-multiple':
input.selectedIndex = 0;
break;
case 'file':
input.value = '';
break;
}
// Remove any error classes or validation states
input.classList.remove('is-invalid', 'error');
// Reset any custom attributes if needed
input.removeAttribute('data-previous-value');
});
// Reset select elements to their default state
const selects = newElement.querySelectorAll('select');
selects.forEach(select => {
select.selectedIndex = 0;
});
// Make the delete button visible and bind the click event
const deleteButton = newElement.querySelector('.remove-btn');
if (deleteButton) {
deleteButton.style.display = 'inline-block';
deleteButton.addEventListener('click', () => {
newElement.remove();
});
}
// Reset any custom data attributes
newElement.querySelectorAll('[data-clone-reset]').forEach(element => {
const resetValue = element.getAttribute('data-clone-reset');
if (resetValue) {
if (element.tagName === 'INPUT' || element.tagName === 'SELECT' || element.tagName ===
'TEXTAREA') {
element.value = resetValue;
} else {
element.textContent = resetValue;
}
}
});
// Optional: Regenerate unique IDs if needed
const elementsWithId = newElement.querySelectorAll('[id]');
elementsWithId.forEach(element => {
const originalId = element.id;
const newId = `${originalId}_${Date.now()}`;
element.id = newId;
// Update any labels or references
const labels = newElement.querySelectorAll(`label[for="${originalId}"]`);
labels.forEach(label => {
label.setAttribute('for', newId);
});
});
// Append the cloned element to the container
container.appendChild(newElement);
// Optional: Trigger any custom events or reinitialize plugins
const event = new Event('cloneAdded', {
bubbles: true
});
newElement.dispatchEvent(event);
}
</script> </script>