Merge branch 'feature/senior-officer' into staging
This commit is contained in:
@@ -557,10 +557,10 @@ class SurveyorController extends Controller
|
||||
$dataPembanding = [];
|
||||
$pembandingCount = count($request->input('address_pembanding', []));
|
||||
$fotoPembanding = $request->file('foto_objek_pembanding') ?? [];
|
||||
|
||||
|
||||
for ($i = 0; $i < $pembandingCount; $i++) {
|
||||
$pembanding = $this->formatSinglePembanding($request, $i);
|
||||
|
||||
|
||||
// Penanganan foto pembanding
|
||||
if (isset($fotoPembanding[$i]) && $fotoPembanding[$i]->isValid()) {
|
||||
$pembanding['foto_objek'] = $this->handleupdateOrDeleteFile(
|
||||
@@ -569,34 +569,34 @@ class SurveyorController extends Controller
|
||||
"pembanding_{$i}"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
$dataPembanding[] = $pembanding;
|
||||
}
|
||||
|
||||
|
||||
return $dataPembanding;
|
||||
}
|
||||
|
||||
private function handleupdateOrDeleteFile($file, $type, $prefix)
|
||||
{
|
||||
try {
|
||||
if ($file) {
|
||||
// Generate nama file unik
|
||||
$fileName = $prefix . '_' . uniqid() . '_' . time() . '.' . $file->getClientOriginalExtension();
|
||||
$path = "{$type}/" . date('Y/m');
|
||||
Storage::makeDirectory("public/{$path}");
|
||||
$filePath = $file->storeAs("public/{$path}", $fileName);
|
||||
return str_replace('public/', '', $filePath);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
\Log::error('File upload error: ' . $e->getMessage());
|
||||
throw new \Exception("Gagal mengupload file: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
{
|
||||
try {
|
||||
if ($file) {
|
||||
// Generate nama file unik
|
||||
$fileName = $prefix . '_' . uniqid() . '_' . time() . '.' . $file->getClientOriginalExtension();
|
||||
$path = "{$type}/" . date('Y/m');
|
||||
Storage::makeDirectory("public/{$path}");
|
||||
$filePath = $file->storeAs("public/{$path}", $fileName);
|
||||
return str_replace('public/', '', $filePath);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
\Log::error('File upload error: ' . $e->getMessage());
|
||||
throw new \Exception("Gagal mengupload file: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private function formatSinglePembanding($request, $index)
|
||||
{
|
||||
$fields = [
|
||||
@@ -606,16 +606,16 @@ class SurveyorController extends Controller
|
||||
'peruntukan', 'penawaran_transaksi', 'nomor_tlp',
|
||||
'kordinat_lat', 'kordinat_lng', 'jenis_aset',
|
||||
];
|
||||
|
||||
|
||||
$pembanding = [];
|
||||
foreach ($fields as $field) {
|
||||
$inputName = "{$field}_pembanding";
|
||||
$pembanding[$field] = $request->input($inputName)[$index] ?? null;
|
||||
}
|
||||
|
||||
|
||||
// Inisialisasi foto_objek sebagai null
|
||||
$pembanding['foto_objek'] = null;
|
||||
|
||||
|
||||
return $pembanding;
|
||||
}
|
||||
|
||||
@@ -718,10 +718,8 @@ class SurveyorController extends Controller
|
||||
|
||||
$branches = Branch::all();
|
||||
$provinces = Province::all();
|
||||
$debitur = Debiture::find($permohonan->debiture_id);
|
||||
$cities = City::where('province_code', $debitur->province_code)->get();
|
||||
$districts = District::where('city_code', $debitur->city_code)->get();
|
||||
$villages = Village::where('district_code', $debitur->district_code)->get();
|
||||
|
||||
|
||||
|
||||
$surveyor = $id;
|
||||
$basicData = $this->getCommonData();
|
||||
@@ -731,6 +729,28 @@ class SurveyorController extends Controller
|
||||
if ($inpeksi) {
|
||||
$forminspeksi = json_decode($inpeksi->data_form, true);
|
||||
}
|
||||
|
||||
// Default: gunakan data dari debitur
|
||||
$debitur = Debiture::find($permohonan->debiture_id);
|
||||
|
||||
$provinceCode = $debitur->province_code;
|
||||
$cityCode = $debitur->city_code;
|
||||
$districtCode = $debitur->district_code;
|
||||
|
||||
// Jika alamat tidak sesuai, override dengan kode dari alamat
|
||||
|
||||
$cekAlamat = $forminspeksi['asset']['alamat']['tidak sesuai'] ?? null;
|
||||
|
||||
if ($cekAlamat) {
|
||||
$provinceCode = $cekAlamat['province_code'] ?? $provinceCode;
|
||||
$cityCode = $cekAlamat['city_code'] ?? $cityCode;
|
||||
$districtCode = $cekAlamat['district_code'] ?? $districtCode;
|
||||
}
|
||||
|
||||
// Ambil data menggunakan kode yang telah ditentukan
|
||||
$cities = City::where('province_code', $provinceCode)->get();
|
||||
$districts = District::where('city_code', $cityCode)->get();
|
||||
$villages = Village::where('district_code', $districtCode)->get();
|
||||
return view('lpj::surveyor.components.inspeksi', compact(
|
||||
'permohonan',
|
||||
'surveyor',
|
||||
@@ -742,7 +762,8 @@ class SurveyorController extends Controller
|
||||
'villages',
|
||||
'link_url_region',
|
||||
'forminspeksi',
|
||||
'basicData'
|
||||
'basicData',
|
||||
'cekAlamat'
|
||||
));
|
||||
}
|
||||
|
||||
@@ -839,11 +860,11 @@ class SurveyorController extends Controller
|
||||
// Ambil data pendukung
|
||||
$data = $this->getCommonData();
|
||||
$provinces = Province::all();
|
||||
|
||||
|
||||
$cities = City::where('province_code', $this->getCodeAlamat('province_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(
|
||||
@@ -868,7 +889,8 @@ class SurveyorController extends Controller
|
||||
}
|
||||
|
||||
|
||||
public function getCodeAlamat($code, $inspectionData){
|
||||
public function getCodeAlamat($code, $inspectionData)
|
||||
{
|
||||
$cekAlamat = isset(
|
||||
$inspectionData['asset']['alamat']['sesuai'],
|
||||
)
|
||||
@@ -1443,18 +1465,10 @@ class SurveyorController extends Controller
|
||||
$data['alamat_sesuai'] => $alamatData
|
||||
],
|
||||
'hub_cadeb' => [
|
||||
$data['hub_cadeb'] => $this->getFieldData(
|
||||
$data,
|
||||
'hub_cadeb',
|
||||
true
|
||||
)
|
||||
$data['hub_cadeb'] => ($data['hub_cadeb'] == 'sesuai') ? $data['hub_cadeb_sesuai'] : $data['hub_cadeb_tidak_sesuai']
|
||||
],
|
||||
'hub_cadeb_penghuni' => [
|
||||
$data['hub_cadeb_penghuni'] => $this->getFieldData(
|
||||
$data,
|
||||
'hub_cadeb_penghuni',
|
||||
true
|
||||
)
|
||||
$data['hub_cadeb_penghuni'] => ($data['hub_cadeb_penghuni'] == 'sesuai') ? $data['hub_cadeb_penghuni_sesuai'] : $data['hub_penghuni_tidak_sesuai']
|
||||
],
|
||||
|
||||
'kordinat_lng' => $data['kordinat_lng'] ?? null,
|
||||
@@ -1473,11 +1487,9 @@ class SurveyorController extends Controller
|
||||
'luas_tanah',
|
||||
true
|
||||
),
|
||||
'hadap_mata_angin' => $this->getFieldData(
|
||||
$data,
|
||||
'hadap_mata_angin',
|
||||
true
|
||||
),
|
||||
'hadap_mata_angin' => [
|
||||
$data['hadap_mata_angin'] => ($data['hadap_mata_angin'] == 'sesuai') ? $data['hadap_mata_angin_sesuai'] : $data['hadap_mata_angin_tidak_sesuai']
|
||||
],
|
||||
'bentuk_tanah' => $this->getFieldData(
|
||||
$data,
|
||||
'bentuk_tanah',
|
||||
@@ -1486,7 +1498,7 @@ class SurveyorController extends Controller
|
||||
),
|
||||
'kontur_tanah' => $data['kontur_tanah'] ?? [],
|
||||
'ketinggian_tanah' => [
|
||||
'ketinggian' => $data['kontur_tanah'] ?? null,
|
||||
'ketinggian' => $data['ketinggian_jalan'] ?? null,
|
||||
'lebih_tinggi' => $data['ketinggian_lebih_tinggi'] ?? null,
|
||||
'lebih_rendah' => $data['ketinggian_lebih_rendah'] ?? null
|
||||
],
|
||||
@@ -1518,33 +1530,37 @@ class SurveyorController extends Controller
|
||||
|
||||
|
||||
foreach ($request->input('nama_bangunan') as $index => $buildingName) {
|
||||
if (empty($buildingName)) continue; // Skip if building name is empty
|
||||
|
||||
if (empty($buildingName)) {
|
||||
continue;
|
||||
} // Skip if building name is empty
|
||||
|
||||
$buildingData = [];
|
||||
$buildingData['bagunan'] = $buildingName;
|
||||
|
||||
|
||||
$specCategories = $request->input('spek_kategori_bangunan');
|
||||
$buildingData['spek_kategori_bangunan'] = [];
|
||||
|
||||
|
||||
if (!empty($specCategories)) {
|
||||
foreach ($specCategories as $category) {
|
||||
if (empty($category)) continue; // Skip empty categories
|
||||
|
||||
if (empty($category)) {
|
||||
continue;
|
||||
} // Skip empty categories
|
||||
|
||||
$specs = $request->input("spek_bangunan.{$index}.{$category}", []);
|
||||
|
||||
|
||||
// Only add category if it has specifications
|
||||
if (!empty($specs)) {
|
||||
$buildingData['spek_kategori_bangunan'][$category] = $specs;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Only add building data if it has specifications
|
||||
if (!empty($buildingData['spek_kategori_bangunan'])) {
|
||||
$result[] = $buildingData;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return [
|
||||
'bangunan' => [
|
||||
@@ -1575,17 +1591,27 @@ class SurveyorController extends Controller
|
||||
'jarak_cbd_point' => $data['jarak_cbd_point'] ?? null,
|
||||
'nama_cbd_point' => $data['nama_cbd_point'] ?? null,
|
||||
'lebar_perkerasan_jalan' => $data['lebar_perkerasan_jalan'] ?? null,
|
||||
'perkerasan_jalan' => $data['perkerasan_jalan'] ?? null,
|
||||
'perkerasan_jalan' => $this->getFieldData(
|
||||
$data,
|
||||
'perkerasan_jalan',
|
||||
false,
|
||||
'lainnya'
|
||||
),
|
||||
'lalu_lintas' => $data['lalu_lintas'] ?? null,
|
||||
'gol_mas_sekitar' => $data['gol_mas_sekitar'] ?? null,
|
||||
'tingkat_keramaian' => $data['tingkat_keramaian'] ?? null,
|
||||
'terletak_diarea' => $data['terletak_diarea'] ?? null,
|
||||
'terletak_diarea' => $this->getFieldData(
|
||||
$data,
|
||||
'terletak_diarea',
|
||||
false,
|
||||
'lainnya'
|
||||
),
|
||||
'disekitar_lokasi' => $data['disekitar_lokasi'] === 'yes' ? [
|
||||
'kondisi' => $data['kondisi_bagunan_disekitar_lokasi'] ?? null,
|
||||
'sifat' => $data['sifat_bagunan_disekitar_lokasi'] ?? null,
|
||||
] : $data['disekitar_lokasi'],
|
||||
'kondisi_bangunan_sekitar' => $data['kondisi_bangunan_sekitar'] ?? null,
|
||||
'sifat_bangunan_sekitar' => $data['sifat_bangunan_sekitar'] ?? null,
|
||||
'kondisi_bagunan_disekitar_lokasi' => $data['kondisi_bagunan_disekitar_lokasi'] ?? null,
|
||||
'sifat_bagunan_disekitar_lokasi' => $data['sifat_bagunan_disekitar_lokasi'] ?? null,
|
||||
'dekat_makam' => $data['dekat_makam'] ?? null,
|
||||
'jarak_makam' => $data['jarak_makam'] ?? null,
|
||||
'nama_makam' => $data['nama_makam'] ?? null,
|
||||
@@ -1593,7 +1619,12 @@ class SurveyorController extends Controller
|
||||
'jarak_tps' => $data['jarak_tps'] ?? null,
|
||||
'nama_tps' => $data['nama_tps'] ?? null,
|
||||
'merupakan_daerah' => $data['merupakan_daerah'] ?? null,
|
||||
'fasilitas_dekat_object' => $data['fasilitas_dekat_object'] ?? null,
|
||||
'fasilitas_dekat_object' => $this->getFieldData(
|
||||
$data,
|
||||
'fasilitas_dekat_object',
|
||||
false,
|
||||
'lainnya'
|
||||
),
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
@@ -86,6 +86,8 @@ class FormSurveyorRequest extends FormRequest
|
||||
'tusuk_sate' => 'required',
|
||||
'lockland' => 'required',
|
||||
'kondisi_fisik_tanah' => 'required|array',
|
||||
'ketinggian_lebih_tinggi' => 'nullable',
|
||||
'ketinggian_lebih_rendah' => 'nullable',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -104,11 +106,11 @@ class FormSurveyorRequest extends FormRequest
|
||||
'kondisi_bangunan' => 'nullable',
|
||||
'sifat_bangunan' => 'required|array',
|
||||
'sifat_bangunan_input' => 'nullable|array',
|
||||
|
||||
|
||||
'nama_bangunan.*' => 'required|string|max:255',
|
||||
'spek_kategori_bangunan.*' => 'nullable|string',
|
||||
'spek_bangunan.*.*' => 'array',
|
||||
|
||||
'nama_bangunan.*' => 'required|string|max:255',
|
||||
'spek_kategori_bangunan.*' => 'nullable|string',
|
||||
'spek_bangunan.*.*' => 'array',
|
||||
'spek_bangunan.*.*.*' => 'string',
|
||||
|
||||
'sarana_pelengkap' => 'required',
|
||||
@@ -147,12 +149,14 @@ class FormSurveyorRequest extends FormRequest
|
||||
'jarak_cbd_point' => 'nullable',
|
||||
'nama_cbd_point' => 'nullable',
|
||||
'lebar_perkerasan_jalan' => 'nullable',
|
||||
'perkerasan_jalan.*' => 'nullable',
|
||||
'perkerasan_jalan' => 'nullable|array',
|
||||
'perkerasan_jalan_lainnya' => 'nullable',
|
||||
'lalu_lintas' => 'nullable',
|
||||
'gol_mas_sekitar' => 'nullable',
|
||||
'tingkat_keramaian' => 'nullable',
|
||||
'terletak_diarea' => 'nullable',
|
||||
'disekitar_lokasi' => 'nullable',
|
||||
'terletak_diarea_lainnya' => 'nullable',
|
||||
'disekitar_lokasi' => 'required',
|
||||
'kondisi_bagunan_disekitar_lokasi' => 'nullable',
|
||||
'sifat_bagunan_disekitar_lokasi' => 'nullable',
|
||||
'dekat_makam' => 'nullable',
|
||||
@@ -162,7 +166,8 @@ class FormSurveyorRequest extends FormRequest
|
||||
'jarak_tps' => 'nullable',
|
||||
'nama_tpu' => 'nullable',
|
||||
'merupakan_daerah' => 'nullable',
|
||||
'fasilitas_dekat_object' => 'nullable',
|
||||
'fasilitas_dekat_object' => 'nullable|array',
|
||||
'fasilitas_dekat_object_lainnya' => 'nullable',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -530,7 +535,7 @@ class FormSurveyorRequest extends FormRequest
|
||||
'hub_cadeb_tidak_sesuai' => 'nullable',
|
||||
'hub_cadeb_penghuni' => 'required',
|
||||
'hub_cadeb_penghuni_sesuai' => 'nullable',
|
||||
'hub_cadeb_penghuni_tidak_sesuai' => 'nullable',
|
||||
'hub_penghuni_tidak_sesuai' => 'nullable',
|
||||
|
||||
'address' => 'nullable',
|
||||
'village_code' => 'nullable',
|
||||
@@ -557,7 +562,7 @@ class FormSurveyorRequest extends FormRequest
|
||||
'batas_batas_input' => 'nullable|array',
|
||||
'kondisi_lingkungan' => 'nullable|array',
|
||||
'kondisi_lain_bangunan' => 'nullable|array',
|
||||
'informasi_dokument' => 'nullable',
|
||||
'informasi_dokument' => 'nullable|array',
|
||||
'peruntukan' => 'nullable',
|
||||
'kdb' => 'nullable',
|
||||
'kdh' => 'nullable',
|
||||
|
||||
@@ -38,13 +38,19 @@
|
||||
{{ old('luas_tanah_bagunan', isset($forminspeksi['bangunan']['luas_tanah_bagunan']['tidak sesuai'])) ? 'checked' : '' }}>
|
||||
<span class="ml-2">Tidak Sesuai</span>
|
||||
</label>
|
||||
@php
|
||||
$statusKey = isset($forminspeksi['bangunan']['luas_tanah_bagunan']['sesuai'])
|
||||
? 'sesuai'
|
||||
: 'tidak sesuai';
|
||||
$selectedData = $forminspeksi['bangunan']['luas_tanah_bagunan'][$statusKey] ?? null;
|
||||
@endphp
|
||||
|
||||
<div id="luas_tanah_bagunan_tidak_sesuai" class="flex items-baseline gap-2"
|
||||
style="{{ isset($forminspeksi['bangunan']['luas_tanah_bagunan']['tidak_sesuai']) ? '' : 'display: none;' }}">
|
||||
style="{{ old('luas_tanah_bagunan_tidak_sesuai', $selectedData) ? '' : 'display: none'}}">
|
||||
<input type="text" id="analisa_bangunan_tidak_sesuai"
|
||||
name="luas_tanah_bagunan_tidak_sesuai" class="input w-full"
|
||||
placeholder="Masukan Luas Bangunan Tidak Sesuai..."
|
||||
value="{{ old('luas_tanah_bagunan_tidak_sesuai', $forminspeksi['bangunan']['luas_tanah_bagunan']['tidak_sesuai'] ?? '') }}">
|
||||
value="{{ old('luas_tanah_bagunan_tidak_sesuai', $forminspeksi['bangunan']['luas_tanah_bagunan']['tidak sesuai'] ?? '') }}">
|
||||
<button type="button" class="btn btn-md btn-primary"
|
||||
onclick="updateAnalisa('analisa_bangunan')">
|
||||
Save
|
||||
@@ -197,9 +203,8 @@
|
||||
</div>
|
||||
@endforeach
|
||||
@else
|
||||
<!-- Default empty building form when no data exists -->
|
||||
<div class="spek-bangunan w-full gap-4 mt-5">
|
||||
<input type="text" name="nama_bangunan[]" value="Bangunan 1" required>
|
||||
<input type="hidden" name="nama_bangunan[]" value="Bangunan 1" required>
|
||||
<label class="building-label form-label">Bangunan 1</label>
|
||||
<div class="grid grid-cols-2 md:grid-cols-3 gap-4 mt-2 w-full">
|
||||
@if (@isset($basicData['spekKategoriBangunan']))
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
</h3>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
|
||||
|
||||
<div class="grid gap-5">
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">Faktor Positif</label>
|
||||
@@ -70,7 +70,7 @@
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">Rute Menuju</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<textarea class="textarea mt-2" name="rute_menuju" rows="3">{{ old('rute_menuju.0', $forminspeksi['fakta']['rute_menuju'][0] ?? '') }}</textarea>
|
||||
<textarea class="textarea mt-2" name="rute_menuju" rows="3">{{ old('rute_menuju.0', $forminspeksi['fakta']['rute_menuju'] ?? '') }}</textarea>
|
||||
<em id="error-rute_menuju" class="alert text-danger text-sm"></em>
|
||||
</div>
|
||||
</div>
|
||||
@@ -98,8 +98,7 @@
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56 gap-2.5" style="width: 500px">
|
||||
<input class="checkbox" name="batas_batas[]" type="checkbox"
|
||||
value="{{ $item->name }}"
|
||||
{{ $isChecked ? 'checked' : '' }} />
|
||||
value="{{ $item->name }}" {{ $isChecked ? 'checked' : '' }} />
|
||||
{{ $item->name }}
|
||||
</label>
|
||||
<input type="text" name="batas_batas_input[]" class="input w-full"
|
||||
@@ -186,30 +185,35 @@
|
||||
<label class="form-label max-w-56">Informasi Terkait Dokumen</label>
|
||||
<div id="informasi-dokument-container" class="flex flex-wrap items-baseline w-full">
|
||||
@php
|
||||
// Ensure $forminspeksi['fakta']['informasi_dokument'] is an array
|
||||
$informasi_dokument = isset($forminspeksi['fakta']['informasi_dokument']) ? (array) $forminspeksi['fakta']['informasi_dokument'] : [];
|
||||
$informasi_dokument = isset($forminspeksi['fakta']['informasi_dokument'])
|
||||
? (array) $forminspeksi['fakta']['informasi_dokument']
|
||||
: [];
|
||||
@endphp
|
||||
|
||||
@foreach ($informasi_dokument as $index => $document)
|
||||
@if (empty($informasi_dokument))
|
||||
|
||||
@foreach ($informasi_dokument as $index => $document)
|
||||
<div class="informasi_dokument flex items-center gap-2 mt-2 textarea-group w-full">
|
||||
<textarea class="textarea mt-2" name="informasi_dokument[]" rows="3">{{ old("informasi_dokument.$index", $document) }}</textarea>
|
||||
<button class="btn btn-danger btn-sm remove-btn" type="button"
|
||||
style="display: none;">
|
||||
<i class="ki-outline ki-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
@endforeach
|
||||
@else
|
||||
<div class="informasi_dokument flex items-center gap-2 mt-2 textarea-group w-full">
|
||||
<textarea class="textarea mt-2" name="informasi_dokument[]" rows="3">{{ old("informasi_dokument.$index", $document) }}</textarea>
|
||||
<button class="btn btn-danger btn-sm remove-btn" type="button" style="display: none;">
|
||||
<textarea class="textarea mt-2" name="informasi_dokument[]" rows="3">{{ old('informasi_dokument.0', isset($forminspeksi['fakta']['informasi_dokument'][0]) ? $forminspeksi['fakta']['informasi_dokument'][0] : '') }}
|
||||
</textarea>
|
||||
<button class="btn btn-danger btn-sm remove-btn" type="button"
|
||||
style="display: none;">
|
||||
<i class="ki-outline ki-trash"></i>
|
||||
</button>
|
||||
<em id="error-informasi_dokument" class="alert text-danger text-sm"></em>
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
<div class="informasi_dokument flex items-center gap-2 mt-2 textarea-group w-full">
|
||||
<textarea class="textarea mt-2" name="informasi_dokument" rows="3">
|
||||
{{ old('informasi_dokument.0', isset($forminspeksi['fakta']['informasi_dokument'][0]) ? $forminspeksi['fakta']['informasi_dokument'][0] : '') }}
|
||||
</textarea>
|
||||
<button class="btn btn-danger btn-sm remove-btn" type="button" style="display: none;">
|
||||
<i class="ki-outline ki-trash"></i>
|
||||
</button>
|
||||
<em id="error-informasi_dokument" class="alert text-danger text-sm"></em>
|
||||
</div>
|
||||
|
||||
<button class="btn btn-primary btn-sm mt-5" type="button" onclick="addClonableItem('informasi-dokument-container', 'informasi_dokument')">
|
||||
@endif
|
||||
<button class="btn btn-primary btn-sm mt-5" type="button"
|
||||
onclick="addClonableItem('informasi-dokument-container', 'informasi_dokument')">
|
||||
<i class="ki-outline ki-plus"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
@@ -119,7 +119,7 @@
|
||||
|
||||
<!-- Delete button to remove photo -->
|
||||
<button type="button" class="btn btn-danger btn-sm delete-btn"
|
||||
onclick="deletePhoto('{{ $index }}')">
|
||||
id="btnDelete">
|
||||
<i class="ki-filled ki-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
@@ -603,10 +603,9 @@
|
||||
|
||||
<!-- Modal Kamera -->
|
||||
@include('lpj::surveyor.components.modal-kamera')
|
||||
@endsection
|
||||
|
||||
|
||||
@endsection
|
||||
|
||||
@include('lpj::surveyor.js.fotojs')
|
||||
@push('scripts')
|
||||
<script>
|
||||
function submitFoto() {
|
||||
@@ -616,9 +615,6 @@
|
||||
|
||||
const formElement = $('#formFoto')[0];
|
||||
const formData = new FormData(formElement);
|
||||
// for (const [key, value] of formData.entries()) {
|
||||
// console.log(`Key: ${key}, Value: ${value}`);
|
||||
// }
|
||||
|
||||
$.ajax({
|
||||
url: '{{ route('surveyor.storeFoto') }}',
|
||||
|
||||
@@ -50,15 +50,30 @@
|
||||
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5" style="margin-top: 20px">
|
||||
<label class="form-label max-w-56">Debitur/Perwakilan</label>
|
||||
<div id="perwakilan" class="flex flex-wrap items-baseline w-full gap-5">
|
||||
<div class="perwakilan flex flex-wrap w-full items-baseline gap-2 ">
|
||||
<input type="text" class="input form-control" name="debitur_perwakilan[]"
|
||||
value="{{ old('debitur_perwakilan', isset($forminspeksi['asset']['debitur_perwakilan']) ? implode(', ', $forminspeksi['asset']['debitur_perwakilan']) : '') }}"
|
||||
placeholder="Masukkan Debitur/Perwakilan" />
|
||||
<button type="button" class="btn btn-danger btn-outline btn-xs remove-btn"
|
||||
style="display: none">Hapus</button>
|
||||
|
||||
@if (isset($forminspeksi['asset']['debitur_perwakilan']) && !empty($forminspeksi['asset']['debitur_perwakilan']))
|
||||
|
||||
<div id="perwakilan" class="flex flex-wrap items-baseline w-full gap-5">
|
||||
@foreach ($forminspeksi['asset']['debitur_perwakilan'] as $key => $item)
|
||||
<div class="perwakilan flex flex-wrap w-full items-baseline gap-2 ">
|
||||
<input type="text" class="input form-control" name="debitur_perwakilan[]"
|
||||
value="{{ old('debitur_perwakilan.' . $key, $item) }}"
|
||||
placeholder="Masukkan Debitur/Perwakilan" />
|
||||
<button type="button" class="btn btn-danger btn-outline btn-xs remove-btn">Hapus</button>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
@else
|
||||
<div id="perwakilan" class="flex flex-wrap items-baseline w-full gap-5">
|
||||
<div class="perwakilan flex flex-wrap w-full items-baseline gap-2 ">
|
||||
<input type="text" class="input form-control" name="debitur_perwakilan[]"
|
||||
value="{{ old('debitur_perwakilan') }}" placeholder="Masukkan Debitur/Perwakilan" />
|
||||
<button type="button" class="btn btn-danger btn-outline btn-xs remove-btn"
|
||||
style="display: none">Hapus</button>
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<button onclick="addClonableItem('perwakilan', 'perwakilan')" type="button" class="btn-md btn btn-primary">
|
||||
<i class="ki-filled ki-plus"></i>
|
||||
</button>
|
||||
@@ -69,11 +84,11 @@
|
||||
|
||||
|
||||
<div class="card w-full bg-white rounded-lg shadow-md overflow-hidden">
|
||||
|
||||
<div class="card-header">
|
||||
<h1 class="text-md font-medium text-gray-900 uppercase">Nama Cadeb/Debitur</h1>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="py-4">
|
||||
<h1 class="text-md font-medium text-gray-900">Nama Cadeb/Debitur</h1>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="grid gap-5">
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
@@ -90,11 +105,10 @@
|
||||
|
||||
|
||||
<div class="card w-full bg-white rounded-lg shadow-md ">
|
||||
<div class="card-header">
|
||||
<h1 class="text-md font-medium text-gray-900 uppercase">Deskripsi Aset jaminan</h1>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="py-4 ">
|
||||
<h1 class="text-md font-medium text-gray-900">Deskripsi Aset jaminan</h1>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-5 w-full">
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">Jenis Aset</label>
|
||||
@@ -123,7 +137,9 @@
|
||||
</label>
|
||||
<!-- Select dropdown untuk "Tidak Sesuai" -->
|
||||
@php
|
||||
$statusKey = isset($forminspeksi['asset']['jenis_asset']['sesuai']) ? 'sesuai' : 'tidak sesuai';
|
||||
$statusKey = isset($forminspeksi['asset']['jenis_asset']['sesuai'])
|
||||
? 'sesuai'
|
||||
: 'tidak sesuai';
|
||||
$selectedValue = $forminspeksi['asset']['jenis_asset'][$statusKey] ?? null;
|
||||
@endphp
|
||||
<div id="jenis_asset" class="flex items-baseline gap-2"
|
||||
@@ -153,11 +169,11 @@
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">Alamat</label>
|
||||
<div class="w-full">
|
||||
@foreach ($permohonan->debiture->documents as $dokumen)
|
||||
|
||||
<span class="text-2sm text-gray-700">
|
||||
{{ formatAlamat($dokumen) }}
|
||||
{{ $permohonan->debiture->village->name ?? "" }}, {{ $permohonan->debiture->district->name ?? "" }}, {{ $permohonan->debiture->city->name ?? "" }}, {{ $permohonan->debiture->province->name ?? "" }} - {{ $permohonan->debiture->village->postal_code ?? "" }}
|
||||
</span>
|
||||
@endforeach
|
||||
|
||||
|
||||
<div class="flex-wrap items-stretch">
|
||||
<div class="grid grid-cols-3 md:grid-cols-3 gap-4 mt-2">
|
||||
@@ -205,16 +221,15 @@
|
||||
<select id="province_code" name="province_code" class="input w-full">
|
||||
<option value="">Select Province</option>
|
||||
@foreach ($provinces as $province)
|
||||
@if (isset($debitur))
|
||||
<option value="{{ $province->code }}"
|
||||
{{ isset($debitur->province_code) && $debitur->province_code == $province->code ? 'selected' : '' }}>
|
||||
{{ $province->name }}
|
||||
</option>
|
||||
@else
|
||||
<option value="{{ $province->code }}">
|
||||
{{ $province->name }}
|
||||
</option>
|
||||
@endif
|
||||
<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>
|
||||
@@ -227,16 +242,16 @@
|
||||
<option value="">Pilih Kota/Kabupaten</option>
|
||||
@if (isset($cities))
|
||||
@foreach ($cities as $city)
|
||||
@if (isset($debitur))
|
||||
<option value="{{ $city->code }}"
|
||||
{{ isset($debitur->city_code) && $debitur->city_code == $city->code ? 'selected' : '' }}>
|
||||
{{ $city->name }}
|
||||
</option>
|
||||
@else
|
||||
<option value="{{ $city->code }}">
|
||||
{{ $city->name }}
|
||||
</option>
|
||||
@endif
|
||||
<option value="{{ $city->code }}"
|
||||
@if (
|
||||
(isset($cekAlamat['city_code']) && $cekAlamat['city_code'] == $city->code) ||
|
||||
(!isset($cekAlamat['city_code']) && isset($debitur->city_code) && $debitur->city_code == $city->code)
|
||||
)
|
||||
selected
|
||||
@endif>
|
||||
{{ $city->name }}
|
||||
</option>
|
||||
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
@@ -245,21 +260,23 @@
|
||||
|
||||
<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>
|
||||
@if (isset($data['districts']))
|
||||
@if (isset($districts))
|
||||
@foreach ($districts as $district)
|
||||
@if (isset($debitur))
|
||||
<option value="{{ $district->code }}"
|
||||
{{ isset($debitur->district_code) && $debitur->district_code == $district->code ? 'selected' : '' }}>
|
||||
{{ $district->name }}
|
||||
</option>
|
||||
@else
|
||||
<option value="{{ $district->code }}">
|
||||
{{ $district->name }}
|
||||
</option>
|
||||
@endif
|
||||
<option value="{{ $district->code }}"
|
||||
@if (
|
||||
(isset($cekAlamat['district_code']) && $cekAlamat['district_code'] == $district->code) ||
|
||||
(!isset($cekAlamat['district_code']) && isset($debitur->district_code) && $debitur->district_code == $district->code)
|
||||
)
|
||||
selected
|
||||
@endif>
|
||||
{{ $district->name }}
|
||||
</option>
|
||||
|
||||
@endforeach
|
||||
|
||||
@endif
|
||||
@@ -274,16 +291,16 @@
|
||||
<option value="">Pilih Kelurahan</option>
|
||||
@if (isset($villages))
|
||||
@foreach ($villages as $village)
|
||||
@if (isset($debitur))
|
||||
<option value="{{ $village->code }}"
|
||||
{{ isset($debitur->village_code) && $debitur->village_code == $village->code ? 'selected' : '' }}>
|
||||
{{ $village->name }}
|
||||
</option>
|
||||
@else
|
||||
<option value="{{ $village->code }}">
|
||||
{{ $village->name }}
|
||||
</option>
|
||||
@endif
|
||||
<option value="{{ $village->code }}"
|
||||
@if (
|
||||
(isset($cekAlamat['village_code']) && $cekAlamat['village_code'] == $village->code) ||
|
||||
(!isset($cekAlamat['village_code']) && isset($debitur->village_code) && $debitur->village_code == $village->code)
|
||||
)
|
||||
selected
|
||||
@endif>
|
||||
{{ $village->name }}
|
||||
</option>
|
||||
|
||||
@endforeach
|
||||
|
||||
@endif
|
||||
@@ -301,10 +318,10 @@
|
||||
|
||||
|
||||
<div class="card w-full bg-white rounded-lg shadow-md overflow-hidden">
|
||||
<div class="card-header">
|
||||
<h1 class="text-md font-medium text-gray-900 uppercase">Titik Koordinat Google Maps</h1>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="py-4 ">
|
||||
<h1 class="text-md font-medium text-gray-900">Titik Koordinat Google Maps</h1>
|
||||
</div>
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">Kordinat</label>
|
||||
<div id="perwakilan" class="flex items-baseline w-full gap-5">
|
||||
@@ -326,6 +343,9 @@
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
<h1 class="text-md font-medium text-gray-900 uppercase">Status</h1>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div data-accordion="true">
|
||||
@foreach ($permohonan->debiture->documents as $dokumen)
|
||||
@@ -334,7 +354,7 @@
|
||||
<button class="accordion-toggle py-4 group "
|
||||
data-accordion-toggle="#accordion_detail_jaminan_{{ $loop->index }}">
|
||||
<span class="text-base text-gray-900 font-medium">
|
||||
Status Kepemilikan
|
||||
Dokument Kepemilikan
|
||||
</span>
|
||||
<i class="ki-outline ki-plus text-gray-600 text-2sm accordion-active:hidden block">
|
||||
</i>
|
||||
@@ -455,20 +475,20 @@
|
||||
: 'tidak sesuai';
|
||||
$selectedData = $forminspeksi['asset']['hub_cadeb'][$statusKey] ?? null;
|
||||
@endphp
|
||||
<select id="hub_cadeb_tidak_sesuai"
|
||||
class="input w-full
|
||||
name="hub_cadeb_tidak_sesuai"
|
||||
style="{{ old('hub_cadeb', $selectedData ?? '') == 'tidak sesuai' ? '' : 'display: none;' }}">
|
||||
|
||||
<select id="hub_cadeb_tidak_sesuai" class="input w-full" name="hub_cadeb_tidak_sesuai"
|
||||
style="{{ old('hub_cadeb_tidak_sesuai', $selectedData) ? '' : 'display: none;' }}">
|
||||
<option value="">Select Hubungan Cadeb</option>
|
||||
@if (isset($basicData['hubCadeb']))
|
||||
@foreach ($basicData['hubCadeb'] as $item)
|
||||
<option value="{{ $item->name }}"
|
||||
{{ old('hub_cadeb_tidak_sesuai', $forminspeksi['asset']['hub_cadeb_tidak_sesuai'] ?? '') == $item->name ? 'selected' : '' }}>
|
||||
{{ old('hub_cadeb_tidak_sesuai', $selectedData) == $item->name ? 'selected' : '' }}>
|
||||
{{ $item->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
|
||||
</div>
|
||||
<em id="error-hub_cadeb" class="alert text-danger text-sm"></em>
|
||||
</div>
|
||||
@@ -487,7 +507,7 @@
|
||||
<div class="flex flex-wrap items-baseline w-full text-sm">
|
||||
@foreach ($permohonan->debiture->documents as $dokumen)
|
||||
{{ $dokumen->penghuni->hubungan_penghuni->name ?? 'N/A' }}
|
||||
<input type="hidden" name="hub_cadeb_penguhuni_sesuai"
|
||||
<input type="hidden" name="hub_cadeb_penghuni_sesuai"
|
||||
value="{{ isset($dokumen->penghuni->hubungan_penghuni->name) ?? '' }}"
|
||||
id="">
|
||||
@endforeach
|
||||
@@ -496,17 +516,20 @@
|
||||
<div class="flex-wrap items-stretch">
|
||||
<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">
|
||||
|
||||
<input
|
||||
onclick="toggleFieldVisibility('hub_cadeb_penghuni','hub_cadeb_Penghuni_tidak_sesuai', ['tidak sesuai'])"
|
||||
onclick="toggleFieldVisibility('hub_cadeb_penghuni','hub_penghuni_tidak_sesuai', ['tidak sesuai'])"
|
||||
type="radio" class="radio" name="hub_cadeb_penghuni" value="sesuai"
|
||||
{{ old('hub_cadeb_penghuni', isset($forminspeksi['asset']['hub_cadeb_penghuni']['sesuai'])) ? 'checked' : '' }}>
|
||||
|
||||
{{ old('hub_cadeb_penghuni', isset($forminspeksi['asset']['hub_cadeb_penghuni'])) ? 'checked' : '' }}>
|
||||
|
||||
<span class="ml-2">Ya</span>
|
||||
</label>
|
||||
<label class="form-label flex items-center gap-2.5 text-nowrap">
|
||||
<input
|
||||
onclick="toggleFieldVisibility('hub_cadeb_penghuni', 'hub_cadeb_Penghuni_tidak_sesuai', ['tidak sesuai'])"
|
||||
onclick="toggleFieldVisibility('hub_cadeb_penghuni','hub_penghuni_tidak_sesuai', ['tidak sesuai'])"
|
||||
type="radio" class="radio" name="hub_cadeb_penghuni" value="tidak sesuai"
|
||||
{{ old('hub_cadeb_penghuni', isset($forminspeksi['asset']['hub_cadeb_penghuni']['tidak sesuai'])) ? 'checked' : '' }}>
|
||||
{{ old('hub_cadeb_penghuni', $forminspeksi['asset']['hub_cadeb_penghuni']['tidak sesuai'] ?? false) ? 'checked' : '' }}>
|
||||
<span class="ml-2">Tidak</span>
|
||||
</label>
|
||||
<!-- Select dropdown untuk "Tidak Sesuai" -->
|
||||
@@ -516,15 +539,15 @@
|
||||
: 'tidak sesuai';
|
||||
$selectedData = $forminspeksi['asset']['hub_cadeb_penghuni'][$statusKey] ?? null;
|
||||
@endphp
|
||||
<select id="hub_cadeb_Penghuni_tidak_sesuai"
|
||||
<select id="hub_penghuni_tidak_sesuai"
|
||||
class="input w-full
|
||||
name="hub_cadeb_Penghuni_tidak_sesuai"
|
||||
style="{{ old('hub_cadeb', $selectedData) ? '' : 'display: none;' }}">
|
||||
name="hub_penghuni_tidak_sesuai"
|
||||
style="{{ old('hub_penghuni_tidak_sesuai', $selectedData) ? '' : 'display: none;' }}">
|
||||
<option value="">Select Hubungan Cadeb</option>
|
||||
@if (isset($basicData['hubPenghuni']))
|
||||
@foreach ($basicData['hubPenghuni'] as $item)
|
||||
<option value="{{ $item->name }}"
|
||||
{{ old('hub_cadeb_Penghuni_tidak_sesuai', $forminspeksi['asset']['hub_cadeb_Penghuni_tidak_sesuai'] ?? '') == $item->name ? 'selected' : '' }}>
|
||||
{{ old('hub_penghuni_tidak_sesuai', $selectedData) == $item->name ? 'selected' : '' }}>
|
||||
{{ $item->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
|
||||
@@ -206,7 +206,7 @@
|
||||
}).then((response) => {
|
||||
if (response.isConfirmed) {
|
||||
// window.location.href =
|
||||
// '{{ route('surveyor.show', ['id' => $permohonan->id]) }}';
|
||||
// '{{ route('surveyor.show', ['id' => $permohonan->id]) }}';
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -266,21 +266,39 @@
|
||||
return;
|
||||
}
|
||||
|
||||
// Clone the template element
|
||||
const newElement = template.cloneNode(true);
|
||||
const textarea = newElement.querySelector('textarea');
|
||||
if (textarea) {
|
||||
textarea.value = '';
|
||||
}
|
||||
|
||||
// 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());
|
||||
deleteButton.addEventListener('click', () => {
|
||||
newElement.remove();
|
||||
});
|
||||
}
|
||||
|
||||
// Append the cloned element to the container
|
||||
container.appendChild(newElement);
|
||||
}
|
||||
|
||||
// Ensure existing remove buttons are functional
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const removeButtons = document.querySelectorAll('.remove-btn');
|
||||
removeButtons.forEach(button => {
|
||||
button.addEventListener('click', function() {
|
||||
this.closest('.perwakilan').remove();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
function updateAnalisa(params) {
|
||||
const inputMap = {
|
||||
@@ -363,6 +381,7 @@
|
||||
pointer-events: none;
|
||||
|
||||
}
|
||||
|
||||
div[disabled]:hover {
|
||||
background-color: #e8e8e8;
|
||||
}
|
||||
|
||||
@@ -33,11 +33,14 @@
|
||||
</div>
|
||||
</div>
|
||||
<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
|
||||
$lebarPerkerasanJalan = old('lebar_perkerasan_jalan', $forminspeksi['lingkungan']['lebar_perkerasan_jalan'] ?? '');
|
||||
@endphp
|
||||
<input type="text" name="lebar_perkerasan_jalan" class="input mt-2" placeholder="Meter"
|
||||
value="{{ old('lebar_perkerasan_jalan', isset($forminspeksi['lingkungan']['lebar_perkerasan_jalan']) ? $forminspeksi['lingkungan']['lebar_perkerasan_jalan'] : '') }}">
|
||||
value="{{ $lebarPerkerasanJalan }}">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
@@ -46,18 +49,29 @@
|
||||
<div class="flex flex-col items-start gap-4">
|
||||
@if (isset($basicData['perkerasanJalan']))
|
||||
@foreach ($basicData['perkerasanJalan'] as $item)
|
||||
@php
|
||||
$isChecked = in_array($item->name, isset($forminspeksi['lingkungan']['perkerasan_jalan']['perkerasan_jalan']) ? $forminspeksi['lingkungan']['perkerasan_jalan']['perkerasan_jalan'] : []);
|
||||
@endphp
|
||||
<label class="form-label flex items-center gap-2.5 text-nowrap">
|
||||
<input class="checkbox" name="perkerasan_jalan[]" type="checkbox"
|
||||
value="{{ $item->name }}"
|
||||
{{ in_array($item->name, isset($forminspeksi['lingkungan']['perkerasan_jalan']) ? $forminspeksi['lingkungan']['perkerasan_jalan'] : []) ? 'checked' : '' }}
|
||||
onclick="toggleCheckboxVisibility('perkerasan_jalan', 'perkerasan_jalan_lainnya', ['lainnya'])"/>
|
||||
value="{{ $item->name }}"
|
||||
{{ $isChecked ? 'checked' : '' }}
|
||||
onclick="toggleCheckboxVisibility('perkerasan_jalan', 'perkerasan_jalan_lainnya', ['lainnya'])"/>
|
||||
{{ $item->name }}
|
||||
</label>
|
||||
|
||||
@if (strcasecmp($item->name, 'Lainnya') == 0)
|
||||
<input id="perkerasan_jalan_lainnya" type="text" style="display: none;"
|
||||
name="perkerasan_jalan_lainnya" class="input w-full mt-2"
|
||||
placeholder="Masukkan lainnya..." />
|
||||
@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
|
||||
|
||||
@endforeach
|
||||
@endif
|
||||
</div>
|
||||
@@ -65,6 +79,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- Lalulintas -->
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">Lalu Lintas Depan Lokasi</label>
|
||||
@@ -138,16 +153,22 @@
|
||||
<label class="form-label flex items-center gap-2.5 text-nowrap">
|
||||
<input class="checkbox" name="terletak_diarea[]" type="checkbox"
|
||||
value="{{ $item->name }}"
|
||||
{{ isset($forminspeksi['lingkungan']['terletak_diarea']) && in_array($item->name, explode(',', is_array(old('terletak_diarea', $forminspeksi['lingkungan']['terletak_diarea'] ?? '')) ? implode(',', old('terletak_diarea', $forminspeksi['lingkungan']['terletak_diarea'] ?? '')) : old('terletak_diarea', $forminspeksi['lingkungan']['terletak_diarea'] ?? ''))) ? 'checked' : '' }}
|
||||
{{ isset($forminspeksi['lingkungan']['terletak_diarea']['terletak_diarea']) && in_array($item->name, explode(',', is_array(old('terletak_diarea', $forminspeksi['lingkungan']['terletak_diarea']['terletak_diarea'] ?? '')) ? implode(',', old('terletak_diarea', $forminspeksi['lingkungan']['terletak_diarea']['terletak_diarea'] ?? '')) : old('terletak_diarea', $forminspeksi['lingkungan']['terletak_diarea'] ?? ''))) ? 'checked' : '' }}
|
||||
onclick="toggleCheckboxVisibility('terletak_diarea', 'terletak_diarea_lainnya', ['Lainnya'])" />
|
||||
|
||||
{{ $item->name }}
|
||||
</label>
|
||||
@if (strcasecmp($item->name, 'Lainnya') == 0)
|
||||
<input id="terletak_diarea_lainnya" type="text" style="display: none;"
|
||||
name="terletak_diarea_lainnya" class="input w-full mt-2"
|
||||
placeholder="Masukkan lainnya..." />
|
||||
@endif
|
||||
@php
|
||||
$lainnyaValue = old('terletak_diarea_lainnya', isset($forminspeksi['lingkungan']['terletak_diarea']['lainnya']) ? $forminspeksi['lingkungan']['terletak_diarea']['lainnya'] : '');
|
||||
@endphp
|
||||
<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
|
||||
@endif
|
||||
</div>
|
||||
@@ -181,7 +202,7 @@
|
||||
<option value="">pilih kondisi</option>
|
||||
@foreach ($kondisi as $item)
|
||||
<option value="{{ $item }}"
|
||||
{{ old('kondisi_bagunan_disekitar_lokasi', $forminspeksi['lingkungan']['disekitar_lokasi'] ?? '') == $item ? 'selected' : '' }}>
|
||||
{{ old('kondisi_bagunan_disekitar_lokasi', $forminspeksi['lingkungan']['kondisi_bagunan_disekitar_lokasi'] ?? '') == $item ? 'selected' : '' }}>
|
||||
{{ $item }}
|
||||
</option>
|
||||
@endforeach
|
||||
@@ -196,7 +217,7 @@
|
||||
<option value="">pilih sifat bagunan</option>
|
||||
@foreach ($sifat as $item)
|
||||
<option value="{{ $item }}"
|
||||
{{ old('sifat_bagunan_disekitar_lokasi', $forminspeksi['lingkungan']['disekitar_lokasi'] ?? '') == $item ? 'selected' : '' }}>
|
||||
{{ old('sifat_bagunan_disekitar_lokasi', $forminspeksi['lingkungan']['sifat_bagunan_disekitar_lokasi'] ?? '') == $item ? 'selected' : '' }}>
|
||||
{{ $item }}
|
||||
</option>
|
||||
@endforeach
|
||||
@@ -232,7 +253,7 @@
|
||||
<span class="ml-2">Ya</span>
|
||||
</label>
|
||||
<div id="dekat-makam" class="flex items-baseline gap-4 w-full"
|
||||
style="{{ old('dekat_makam', $forminspeksi['lingkungan']['dekat_makam'] ?? '') == 'ya' ? 'display:block;' : 'display:none;' }}">
|
||||
style="{{ old('dekat_makam', $forminspeksi['lingkungan']['dekat_makam'] ?? '') == 'ya' ? 'display:flex;' : 'display:none;' }}">
|
||||
|
||||
<div class="flex items-center gap-2">
|
||||
<label for="jarak_makam" class="form-label max-w-56">Jarak</label>
|
||||
@@ -266,7 +287,7 @@
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">Dekat TPS</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<div class="flex flex-col gap-2 mt-2">
|
||||
<div class="flex flex-col gap-2 mt-2 w-full">
|
||||
<!-- Opsi Ya -->
|
||||
<div class="flex w-full items-center gap-4">
|
||||
<label class="text-sm flex items-center gap-2.5 text-nowrap">
|
||||
@@ -339,18 +360,18 @@
|
||||
$selectedFasilitas = is_array(
|
||||
old(
|
||||
'fasilitas_dekat_object',
|
||||
$forminspeksi['lingkungan']['fasilitas_dekat_object'] ?? [],
|
||||
$forminspeksi['lingkungan']['fasilitas_dekat_object']['fasilitas_dekat_object'] ?? [],
|
||||
),
|
||||
)
|
||||
? old(
|
||||
'fasilitas_dekat_object',
|
||||
$forminspeksi['lingkungan']['fasilitas_dekat_object'] ?? [],
|
||||
$forminspeksi['lingkungan']['fasilitas_dekat_object']['fasilitas_dekat_object'] ?? [],
|
||||
)
|
||||
: explode(
|
||||
',',
|
||||
old(
|
||||
'fasilitas_dekat_object',
|
||||
$forminspeksi['lingkungan']['fasilitas_dekat_object'] ?? '',
|
||||
$forminspeksi['lingkungan']['fasilitas_dekat_object']['fasilitas_dekat_object'] ?? '',
|
||||
),
|
||||
);
|
||||
@endphp
|
||||
@@ -359,9 +380,9 @@
|
||||
value="{{ $item->name }}"
|
||||
{{ in_array(
|
||||
$item->name,
|
||||
is_array(old('fasilitas_dekat_object', $forminspeksi['lingkungan']['fasilitas_dekat_object'] ?? ''))
|
||||
? old('fasilitas_dekat_object', $forminspeksi['lingkungan']['fasilitas_dekat_object'] ?? [])
|
||||
: explode(',', old('fasilitas_dekat_object', $forminspeksi['lingkungan']['fasilitas_dekat_object'] ?? '')),
|
||||
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'
|
||||
: '' }}
|
||||
@@ -372,8 +393,9 @@
|
||||
</label>
|
||||
|
||||
@if (strcasecmp($item->name, 'Lainnya') == 0)
|
||||
<input id="fasilitas_dekat_object_lainnya" type="text" style="display: none;"
|
||||
<input id="fasilitas_dekat_object_lainnya" type="text" style="{{ in_array('Lainnya', $selectedFasilitas) ? '' : 'display: none' }}"
|
||||
name="fasilitas_dekat_object_lainnya" class="input w-full mt-2"
|
||||
value="{{ old('fasilitas_dekat_object_lainnya', $forminspeksi['lingkungan']['fasilitas_dekat_object']['lainnya'] ?? '') }}"
|
||||
placeholder="Masukkan lainnya..." />
|
||||
@endif
|
||||
@endforeach
|
||||
|
||||
@@ -91,15 +91,13 @@
|
||||
style="{{ old('hadap_mata_angin', isset($forminspeksi['tanah']['hadap_mata_angin']['tidak sesuai'])) ? '' : 'display: none;' }}">
|
||||
<select
|
||||
class="input w-full
|
||||
id="hadap_matangin_tidak_sesuai"
|
||||
name="analisa_tanah_hadap_mata_angin_tidak_sesuai">
|
||||
id="hadap_mata_angin_tidak_sesuai"
|
||||
name="hadap_mata_angin_tidak_sesuai">
|
||||
@php
|
||||
$statusKey = isset($forminspeksi['tanah']['hadap_mata_angin']['sesuai'])
|
||||
? 'sesuai'
|
||||
: 'tidak sesuai';
|
||||
$selectedData =
|
||||
$forminspeksi['tanah']['hadap_mata_angin'][$statusKey] ??
|
||||
null;
|
||||
$selectedData = $forminspeksi['tanah']['hadap_mata_angin'][$statusKey] ?? null;
|
||||
@endphp
|
||||
<option value="">Select Hadap Mata Angin</option>
|
||||
@if (isset($basicData['arahMataAngin']))
|
||||
@@ -139,7 +137,8 @@
|
||||
{{ $item->name }}
|
||||
</label>
|
||||
@if (strcasecmp($item->name, 'lainnya') == 0)
|
||||
<input id="bentuk_tanah_lainnya" type="text" style="display: none;"
|
||||
<input id="bentuk_tanah_lainnya" type="text"
|
||||
style="{{ isset($forminspeksi['tanah']['bentuk_tanah']['lainnya']) && $forminspeksi['tanah']['bentuk_tanah']['lainnya'] ? '' : 'display: none;' }}"
|
||||
name="bentuk_tanah_lainnya" class="input w-full mt-2"
|
||||
placeholder="Masukkan bentuk tanah..."
|
||||
value="{{ old('bentuk_tanah_lainnya', $forminspeksi['tanah']['bentuk_tanah']['lainnya'] ?? '') }}" />
|
||||
@@ -189,14 +188,17 @@
|
||||
{{ $item->name }}
|
||||
</label>
|
||||
@if (strcasecmp($item->name, 'Lebih Tinggi') == 0)
|
||||
<input id="input-lebih-tinggi" type="text" style="display: none;"
|
||||
name="ketinggian_lebih_tinggi" class="input w-full mt-2"
|
||||
placeholder="m2" />
|
||||
<input id="input-lebih-tinggi" type="text"
|
||||
style="{{ isset($forminspeksi['tanah']['ketinggian_tanah']['lebih_tinggi']) && $forminspeksi['tanah']['ketinggian_tanah']['lebih_tinggi'] ? '' : 'display: none;' }}"
|
||||
name="ketinggian_lebih_tinggi" class="input w-full mt-2" placeholder="m2"
|
||||
value="{{ old('ketinggian_lebih_tinggi', $forminspeksi['tanah']['ketinggian_tanah']['lebih_tinggi'] ?? '') }}" />
|
||||
@elseif (strcasecmp($item->name, 'Lebih Rendah') == 0)
|
||||
<input id="input-lebih-rendah" type="text" style="display: none;"
|
||||
name="ketinggian_lebih_rendah" class="input w-full mt-2"
|
||||
placeholder="m2" />
|
||||
<input id="input-lebih-rendah" type="text"
|
||||
style="{{ isset($forminspeksi['tanah']['ketinggian_tanah']['lebih_rendah']) && $forminspeksi['tanah']['ketinggian_tanah']['lebih_rendah'] ? '' : 'display: none;' }}"
|
||||
name="ketinggian_lebih_rendah" class="input w-full mt-2" placeholder="m2"
|
||||
value="{{ old('ketinggian_lebih_rendah', $forminspeksi['tanah']['ketinggian_tanah']['lebih_rendah'] ?? '') }}" />
|
||||
@endif
|
||||
|
||||
</div>
|
||||
@endforeach
|
||||
@endif
|
||||
@@ -211,17 +213,18 @@
|
||||
<div class="grid grid-cols-2 md:grid-cols-3 gap-4">
|
||||
<label class="form-label flex items-center gap-2.5 text-nowrap">
|
||||
<input type="radio" class="radio" name="kontur_jalan" value="menurun"
|
||||
{{ old('kontur_jalan', $forminspeksi['tanah']['kontur_jalan'] ?? '') == 'menurun' ? 'checked' : '' }}>
|
||||
{{ old('kontur_jalan', isset($forminspeksi['tanah']['kontur_jalan']) ? $forminspeksi['tanah']['kontur_jalan'] : '') == 'menurun' ? 'checked' : '' }}>
|
||||
<span class="ml-2">Menurun</span>
|
||||
</label>
|
||||
<label class="form-label flex items-center gap-2.5 text-nowrap">
|
||||
<input type="radio" class="radio" name="kontur_jalan" value="rata"
|
||||
{{ old('kontur_jalan', $forminspeksi['tanah']['kontur_jalan'] ?? '') == 'rata' ? 'checked' : '' }}>
|
||||
{{ old('kontur_jalan', isset($forminspeksi['tanah']['kontur_jalan']) ? $forminspeksi['tanah']['kontur_jalan'] : '') == 'rata' ? 'checked' : '' }}>
|
||||
<span class="ml-2">Rata</span>
|
||||
</label>
|
||||
</div>
|
||||
<em id="error-kontur_jalan" class="alert text-danger text-sm"></em>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="flex items-stretch flex-wrap lg:flex-nowrap gap-2.5">
|
||||
@@ -229,20 +232,31 @@
|
||||
<div class="flex-wrap items-stretch">
|
||||
<div class="flex flex-col items-start gap-4">
|
||||
@if (isset($basicData['posisiKavling']))
|
||||
@php
|
||||
$selectedPosisiKavling = old(
|
||||
'posisi_kavling',
|
||||
$forminspeksi['tanah']['posisi_kavling']['posisi_kavling'] ?? [],
|
||||
);
|
||||
$lainnyaValue = old(
|
||||
'posisi_kavling_lainnya',
|
||||
$forminspeksi['tanah']['posisi_kavling']['lainnya'] ?? '',
|
||||
);
|
||||
@endphp
|
||||
@foreach ($basicData['posisiKavling'] as $item)
|
||||
<div class="flex items-center">
|
||||
<label class="form-label flex items-center gap-2.5 text-nowrap">
|
||||
<input class="checkbox" name="posisi_kavling[]" type="checkbox"
|
||||
value="{{ $item->name }}"
|
||||
{{ in_array($item->name, old('posisi_kavling', $forminspeksi['tanah']['posisi_kavling']['posisi_kavling'] ?? [])) ? 'checked' : '' }}
|
||||
{{ in_array($item->name, $selectedPosisiKavling) ? 'checked' : '' }}
|
||||
onclick="toggleCheckboxVisibility('posisi_kavling', 'posisi_kavling_lainnya', ['Lainnya'])" />
|
||||
{{ $item->name }}
|
||||
</label>
|
||||
@if (strcasecmp($item->name, 'Lainnya') == 0)
|
||||
<input id="posisi_kavling_lainnya" type="text" style="display: none;"
|
||||
<input id="posisi_kavling_lainnya" type="text"
|
||||
style="{{ $lainnyaValue ? '' : 'display: none' }}"
|
||||
name="posisi_kavling_lainnya" class="input w-full mt-2"
|
||||
placeholder="Masukkan Posisi Kavling lainnya..."
|
||||
value="{{ old('posisi_kavling_lainnya', $forminspeksi['tanah']['posisi_kavling']['lainnya'] ?? '') }}" />
|
||||
value="{{ $lainnyaValue }}" />
|
||||
@endif
|
||||
</div>
|
||||
@endforeach
|
||||
@@ -251,6 +265,7 @@
|
||||
<em id="error-posisi_kavling" class="alert text-danger text-sm"></em>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Tusuk Sate -->
|
||||
<div class="flex items-stretch flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">Tusuk Sate</label>
|
||||
|
||||
@@ -1,73 +1,5 @@
|
||||
@push('scripts')
|
||||
<script>
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
const ruteLainnyaDiv = document.getElementById("ruteLainnya");
|
||||
const lantaiLainnyaDiv = document.getElementById("lantaiLainnya");
|
||||
|
||||
// Function to add delete event listeners to existing buttons
|
||||
function addDeleteListeners(container) {
|
||||
container.querySelectorAll(".delete-button").forEach(button => {
|
||||
button.addEventListener("click", function() {
|
||||
this.closest(
|
||||
".flex.items-baseline.flex-wrap.lg\\:flex-nowrap.gap-2\\.5.mb-5"
|
||||
).remove();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Add delete listeners to existing buttons
|
||||
addDeleteListeners(ruteLainnyaDiv);
|
||||
addDeleteListeners(lantaiLainnyaDiv);
|
||||
|
||||
function createNewDiv(container, inputName) {
|
||||
const newDiv = document.createElement("div");
|
||||
newDiv.className = "flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 mb-5";
|
||||
newDiv.innerHTML = `
|
||||
<label class="flex flex-col form-label max-w-56">
|
||||
Masukkan nama ${inputName}
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<div class="flex flex-col lg:flex-row gap-2 w-full">
|
||||
<div class="flex flex-wrap items-baseline px-2">
|
||||
<input class="input" type="text" name="name_${inputName}[]">
|
||||
</div>
|
||||
<div class=" w-full flex flex-col gap-2">
|
||||
<img id="foto_${inputName}-preview"
|
||||
src="{{ isset($formFoto['gerbang']) ? asset('storage/' . $formFoto['gerbang']) : '' }}"
|
||||
alt="Foto Gerbong" class="mt-2 max-w-full h-auto"
|
||||
style="{{ isset($formFoto['gerbang']) ? '' : 'display: none;' }} width: 30rem;">
|
||||
|
||||
|
||||
<div class="input-group w-full flex gap-2">
|
||||
<input id="inputLainnya" type="file" name="foto_${inputName}[]"
|
||||
class="file-input file-input-bordered w-full" accept="image/*" capture="camera"
|
||||
onchange="previewImage(this, 'foto_${inputName}-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>
|
||||
|
||||
</div>
|
||||
<button type="button" class="btn btn-danger btn-sm delete-button">
|
||||
<i class="ki-filled ki-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
container.appendChild(newDiv);
|
||||
addDeleteListeners(container);
|
||||
}
|
||||
|
||||
document.getElementById("btnAddMore").addEventListener("click", function() {
|
||||
createNewDiv(ruteLainnyaDiv, "rute_lainnya");
|
||||
});
|
||||
|
||||
document.getElementById("btnAddMoreObject").addEventListener("click", function() {
|
||||
createNewDiv(lantaiLainnyaDiv, "lantai_lainnya");
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -201,139 +133,7 @@
|
||||
|
||||
|
||||
|
||||
function setupInputHandlers(containerId, buttonId, labelText, inputDataClass, buttonDeleteClass) {
|
||||
const addButton = document.getElementById(buttonId);
|
||||
const inputContainer = document.getElementById(containerId);
|
||||
|
||||
if (!addButton || !inputContainer) {
|
||||
console.error(`Element with ID ${containerId} or ${buttonId} not found.`);
|
||||
return;
|
||||
}
|
||||
|
||||
function updateLabels() {
|
||||
const labels = inputContainer.querySelectorAll('.form-label span');
|
||||
labels.forEach((label, index) => {
|
||||
label.textContent = `${labelText} ${index + 1}`;
|
||||
});
|
||||
}
|
||||
|
||||
function handleDeleteButtons() {
|
||||
const deleteBtns = inputContainer.querySelectorAll(`.${buttonDeleteClass}`);
|
||||
deleteBtns.forEach(btn => {
|
||||
btn.style.display = inputContainer.children.length > 1 ? 'block' : 'none';
|
||||
});
|
||||
}
|
||||
|
||||
function createNewInput() {
|
||||
const newDiv = inputContainer.children[0].cloneNode(true);
|
||||
|
||||
// Reset semua input dalam elemen baru
|
||||
const inputFile = newDiv.querySelector(`.${inputDataClass}`);
|
||||
if (inputFile) {
|
||||
inputFile.id = `inputLingkungan-${inputContainer.children.length}`;
|
||||
inputFile.value = ''; // Reset input file
|
||||
|
||||
// Tambahkan event listener untuk preview
|
||||
inputFile.addEventListener('change', function () {
|
||||
const file = this.files[0];
|
||||
if (file) {
|
||||
const reader = new FileReader();
|
||||
reader.onload = function (e) {
|
||||
const img = document.getElementById(
|
||||
`foto_lingkungan_preview_${inputFile.id}`
|
||||
);
|
||||
img.src = e.target.result;
|
||||
img.style.display = 'block';
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Tambahkan logika reset untuk elemen preview
|
||||
const imgPreview = newDiv.querySelector('img');
|
||||
if (imgPreview) {
|
||||
imgPreview.src = '';
|
||||
imgPreview.style.display = 'none';
|
||||
}
|
||||
|
||||
const deleteBtn = newDiv.querySelector(`.${buttonDeleteClass}`);
|
||||
if (deleteBtn) {
|
||||
deleteBtn.addEventListener('click', function () {
|
||||
inputContainer.removeChild(newDiv);
|
||||
handleDeleteButtons();
|
||||
updateLabels();
|
||||
});
|
||||
}
|
||||
|
||||
// Tambahkan container preview jika tidak ada
|
||||
let previewContainer = newDiv.querySelector('.preview-container');
|
||||
if (!previewContainer) {
|
||||
previewContainer = document.createElement('div');
|
||||
previewContainer.className = 'preview-container';
|
||||
|
||||
const img = document.createElement('img');
|
||||
img.id = `foto_lingkungan_preview_${inputFile.id}`;
|
||||
img.src = '';
|
||||
img.className = 'mt-2 h-auto';
|
||||
img.style.display = 'none';
|
||||
img.style.width = '30rem';
|
||||
previewContainer.appendChild(img);
|
||||
|
||||
const inputGroup = newDiv.querySelector('.input-group');
|
||||
inputGroup.appendChild(previewContainer);
|
||||
}
|
||||
|
||||
newDiv.style.marginTop = '10px';
|
||||
inputContainer.appendChild(newDiv);
|
||||
updateLabels();
|
||||
handleDeleteButtons();
|
||||
}
|
||||
|
||||
addButton.addEventListener('click', createNewInput);
|
||||
|
||||
// Terapkan event listener pada elemen yang sudah ada
|
||||
const existingInputs = inputContainer.querySelectorAll(`.${inputDataClass}`);
|
||||
existingInputs.forEach((input, index) => {
|
||||
const deleteBtn = input.closest('.flex').querySelector(`.${buttonDeleteClass}`);
|
||||
if (deleteBtn) {
|
||||
deleteBtn.addEventListener('click', function () {
|
||||
if (inputContainer.children.length > 1) {
|
||||
inputContainer.removeChild(this.closest('.flex'));
|
||||
handleDeleteButtons();
|
||||
updateLabels();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
input.addEventListener('change', function () {
|
||||
const file = this.files[0];
|
||||
if (file) {
|
||||
const reader = new FileReader();
|
||||
reader.onload = function (e) {
|
||||
const img = document.getElementById(
|
||||
`foto_lingkungan_preview_${index}`
|
||||
);
|
||||
img.src = e.target.result;
|
||||
img.style.display = 'block';
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
updateLabels();
|
||||
handleDeleteButtons();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
setupInputHandlers('inputContainerRute', 'btnRute', 'Foto Rute Menuju Lokasi', 'file-input',
|
||||
'delete-btn');
|
||||
setupInputHandlers('inputContainerLantai', 'btnLantai', 'Foto Lantai', 'file-input', 'delete-btn');
|
||||
setupInputHandlers('inputContainerLingkungan', 'btnLingkungan', 'Lingkungan', 'file-input',
|
||||
'delete-btn');
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
204
resources/views/surveyor/js/fotojs.blade.php
Normal file
204
resources/views/surveyor/js/fotojs.blade.php
Normal file
@@ -0,0 +1,204 @@
|
||||
<script type="text/javascript">
|
||||
document.addEventListener("DOMContentLoaded", function() {
|
||||
const ruteLainnyaDiv = document.getElementById("ruteLainnya");
|
||||
const lantaiLainnyaDiv = document.getElementById("lantaiLainnya");
|
||||
|
||||
// Function to add delete event listeners to existing buttons
|
||||
function addDeleteListeners(container) {
|
||||
container.querySelectorAll(".delete-button").forEach(button => {
|
||||
button.addEventListener("click", function() {
|
||||
this.closest(
|
||||
".flex.items-baseline.flex-wrap.lg\\:flex-nowrap.gap-2\\.5.mb-5"
|
||||
).remove();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// Add delete listeners to existing buttons
|
||||
addDeleteListeners(ruteLainnyaDiv);
|
||||
addDeleteListeners(lantaiLainnyaDiv);
|
||||
|
||||
function createNewDiv(container, inputName) {
|
||||
const newDiv = document.createElement("div");
|
||||
newDiv.className = "flex items-baseline flex-wrap lg:flex-nowrap gap-2.5 mb-5";
|
||||
newDiv.innerHTML = `
|
||||
<label class="flex flex-col form-label max-w-56">
|
||||
Masukkan nama ${inputName}
|
||||
</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<div class="flex flex-col lg:flex-row gap-2 w-full">
|
||||
<div class="flex flex-wrap items-baseline px-2">
|
||||
<input class="input" type="text" name="name_${inputName}[]">
|
||||
</div>
|
||||
<div class=" w-full flex flex-col gap-2">
|
||||
<img id="foto_${inputName}-preview"
|
||||
src="{{ isset($formFoto['gerbang']) ? asset('storage/' . $formFoto['gerbang']) : '' }}"
|
||||
alt="Foto Gerbong" class="mt-2 max-w-full h-auto"
|
||||
style="{{ isset($formFoto['gerbang']) ? '' : 'display: none;' }} width: 30rem;">
|
||||
|
||||
|
||||
<div class="input-group w-full flex gap-2">
|
||||
<input id="inputLainnya" type="file" name="foto_${inputName}[]"
|
||||
class="file-input file-input-bordered w-full" accept="image/*" capture="camera"
|
||||
onchange="previewImage(this, 'foto_${inputName}-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>
|
||||
|
||||
</div>
|
||||
<button type="button" class="btn btn-danger btn-sm delete-button">
|
||||
<i class="ki-filled ki-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
container.appendChild(newDiv);
|
||||
addDeleteListeners(container);
|
||||
}
|
||||
|
||||
document.getElementById("btnAddMore").addEventListener("click", function() {
|
||||
createNewDiv(ruteLainnyaDiv, "rute_lainnya");
|
||||
});
|
||||
|
||||
document.getElementById("btnAddMoreObject").addEventListener("click", function() {
|
||||
createNewDiv(lantaiLainnyaDiv, "lantai_lainnya");
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
function setupInputHandlers(containerId, buttonId, labelText, inputDataClass, buttonDeleteClass) {
|
||||
const addButton = document.getElementById(buttonId);
|
||||
const inputContainer = document.getElementById(containerId);
|
||||
|
||||
if (!addButton || !inputContainer) {
|
||||
console.error(`Element with ID ${containerId} or ${buttonId} not found.`);
|
||||
return;
|
||||
}
|
||||
|
||||
function updateLabels() {
|
||||
const labels = inputContainer.querySelectorAll('.form-label span');
|
||||
labels.forEach((label, index) => {
|
||||
label.textContent = `${labelText} ${index + 1}`;
|
||||
});
|
||||
}
|
||||
|
||||
function handleDeleteButtons() {
|
||||
const deleteBtns = inputContainer.querySelectorAll(`.${buttonDeleteClass}`);
|
||||
deleteBtns.forEach(btn => {
|
||||
btn.style.display = inputContainer.children.length > 1 ? 'block' : 'none';
|
||||
});
|
||||
}
|
||||
|
||||
function createNewInput() {
|
||||
const newDiv = inputContainer.children[0].cloneNode(true);
|
||||
|
||||
// Reset semua input dalam elemen baru
|
||||
const inputFile = newDiv.querySelector(`.${inputDataClass}`);
|
||||
if (inputFile) {
|
||||
inputFile.id = `inputLingkungan-${inputContainer.children.length}`;
|
||||
inputFile.value = ''; // Reset input file
|
||||
|
||||
// Tambahkan event listener untuk preview
|
||||
inputFile.addEventListener('change', function() {
|
||||
const file = this.files[0];
|
||||
if (file) {
|
||||
const reader = new FileReader();
|
||||
reader.onload = function(e) {
|
||||
const img = document.getElementById(
|
||||
`foto_lingkungan_preview_${inputFile.id}`
|
||||
);
|
||||
img.src = e.target.result;
|
||||
img.style.display = 'block';
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Tambahkan logika reset untuk elemen preview
|
||||
const imgPreview = newDiv.querySelector('img');
|
||||
if (imgPreview) {
|
||||
imgPreview.src = '';
|
||||
imgPreview.style.display = 'none';
|
||||
}
|
||||
|
||||
const deleteBtn = newDiv.querySelector(`.${buttonDeleteClass}`);
|
||||
if (deleteBtn) {
|
||||
deleteBtn.addEventListener('click', function() {
|
||||
inputContainer.removeChild(newDiv);
|
||||
handleDeleteButtons();
|
||||
updateLabels();
|
||||
});
|
||||
}
|
||||
|
||||
// Tambahkan container preview jika tidak ada
|
||||
let previewContainer = newDiv.querySelector('.preview-container');
|
||||
if (!previewContainer) {
|
||||
previewContainer = document.createElement('div');
|
||||
previewContainer.className = 'preview-container';
|
||||
|
||||
const img = document.createElement('img');
|
||||
img.id = `foto_lingkungan_preview_${inputFile.id}`;
|
||||
img.src = '';
|
||||
img.className = 'mt-2 h-auto';
|
||||
img.style.display = 'none';
|
||||
img.style.width = '30rem';
|
||||
previewContainer.appendChild(img);
|
||||
|
||||
const inputGroup = newDiv.querySelector('.input-group');
|
||||
inputGroup.appendChild(previewContainer);
|
||||
}
|
||||
|
||||
newDiv.style.marginTop = '10px';
|
||||
inputContainer.appendChild(newDiv);
|
||||
updateLabels();
|
||||
handleDeleteButtons();
|
||||
}
|
||||
|
||||
addButton.addEventListener('click', createNewInput);
|
||||
|
||||
// Terapkan event listener pada elemen yang sudah ada
|
||||
const existingInputs = inputContainer.querySelectorAll(`.${inputDataClass}`);
|
||||
existingInputs.forEach((input, index) => {
|
||||
const deleteBtn = input.closest('.flex').querySelector(`.${buttonDeleteClass}`);
|
||||
if (deleteBtn) {
|
||||
deleteBtn.addEventListener('click', function() {
|
||||
if (inputContainer.children.length > 1) {
|
||||
inputContainer.removeChild(this.closest('.flex'));
|
||||
handleDeleteButtons();
|
||||
updateLabels();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
input.addEventListener('change', function() {
|
||||
const file = this.files[0];
|
||||
if (file) {
|
||||
const reader = new FileReader();
|
||||
reader.onload = function(e) {
|
||||
const img = document.getElementById(
|
||||
`foto_lingkungan_preview_${index}`
|
||||
);
|
||||
img.src = e.target.result;
|
||||
img.style.display = 'block';
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
updateLabels();
|
||||
handleDeleteButtons();
|
||||
}
|
||||
|
||||
setupInputHandlers('inputContainerRute', 'btnRute', 'Foto Rute Menuju Lokasi', 'file-input',
|
||||
'delete-btn');
|
||||
setupInputHandlers('inputContainerLantai', 'btnLantai', 'Foto Lantai', 'file-input', 'delete-btn');
|
||||
setupInputHandlers('inputContainerLingkungan', 'btnLingkungan', 'Lingkungan', 'file-input',
|
||||
'delete-btn');
|
||||
});
|
||||
</script>
|
||||
Reference in New Issue
Block a user