Merge branch 'staging' of https://git.putrakuningan.com/daengdeni/lpj into andydev
This commit is contained in:
@@ -217,7 +217,7 @@ class SurveyorController extends Controller
|
||||
try {
|
||||
$maxSize = getMaxFileSize('Foto');
|
||||
$validatedData = $request->validate([
|
||||
'foto_denah' => 'required|image|mimes:jpeg,png,jpg,gif,svg|max:'. $maxSize,
|
||||
'foto_denah' => 'required|file|mimes:jpeg,jpg,png,pdf,svg|max:'. $maxSize,
|
||||
'luas' => 'required|numeric',
|
||||
'permohonan_id' => 'required',
|
||||
'jenis_jaminan_id' => 'required'
|
||||
@@ -577,24 +577,24 @@ class SurveyorController extends Controller
|
||||
}
|
||||
|
||||
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);
|
||||
{
|
||||
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());
|
||||
}
|
||||
|
||||
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)
|
||||
@@ -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'
|
||||
));
|
||||
}
|
||||
|
||||
@@ -822,7 +843,7 @@ class SurveyorController extends Controller
|
||||
|
||||
$inspectionData = json_decode($inspeksi->data_form, true);
|
||||
if (json_last_error() !== JSON_ERROR_NONE) {
|
||||
throw new \Exception('Error decoding inspection data: ' . json_last_error_msg());
|
||||
throw new \Exception('Harap mengisi form inspeksi terlebih dahulu.');
|
||||
}
|
||||
|
||||
if ($inspeksi->data_pembanding) {
|
||||
@@ -842,7 +863,7 @@ class SurveyorController extends Controller
|
||||
|
||||
$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();
|
||||
|
||||
|
||||
|
||||
@@ -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,7 +1530,9 @@ 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;
|
||||
@@ -1528,7 +1542,9 @@ class SurveyorController extends Controller
|
||||
|
||||
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}", []);
|
||||
|
||||
@@ -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',
|
||||
];
|
||||
}
|
||||
|
||||
@@ -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',
|
||||
|
||||
@@ -130,8 +130,8 @@
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<div class="flex-wrap items-stretch">
|
||||
<div class="flex flex-col items-start gap-2">
|
||||
@if (isset($basicDdata['viewUnit']))
|
||||
@foreach ($basicDdata['viewUnit'] as $item)
|
||||
@if (isset($basicData['viewUnit']))
|
||||
@foreach ($basicData['viewUnit'] as $item)
|
||||
<label class="form-label flex items-center gap-2.5 text-nowrap">
|
||||
<input class="checkbox" name="view[]" type="checkbox"
|
||||
value="{{ $item->name }}"
|
||||
|
||||
@@ -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']))
|
||||
|
||||
@@ -241,12 +241,10 @@
|
||||
</td>
|
||||
<td class="px-4 py-2">
|
||||
<select id="province_code_pembanding" name="province_code_pembanding[]"
|
||||
class="input w-full">
|
||||
<option value="">Select Province</option>
|
||||
onchange="handleProvinceChange(this)" class="input w-full">
|
||||
<option value="">Pilih Provinsi</option>
|
||||
@foreach ($provinces as $province)
|
||||
<option value="{{ $province->code }}"
|
||||
{{ $selectedProvince == $province->code ? 'selected' : '' }}>
|
||||
{{ $province->name }}
|
||||
<option value="{{ $province->code }}">{{ $province->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@@ -280,10 +278,8 @@
|
||||
</td>
|
||||
<td class="px-4 py-2">
|
||||
<select id="city_code_pembanding" name="city_code_pembanding[]"
|
||||
class="input w-full">
|
||||
|
||||
onchange="handleCityChange(this)" class="input w-full">
|
||||
<option value="">Pilih Kota/Kabupaten</option>
|
||||
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -316,10 +312,8 @@
|
||||
<td class="px-4 py-2">
|
||||
|
||||
<select id="district_code_pembanding" name="district_code_pembanding[]"
|
||||
class="input w-full">
|
||||
|
||||
onchange="handleDistrictChange(this)" class="input w-full">
|
||||
<option value="">Pilih Kecamatan</option>
|
||||
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -351,9 +345,7 @@
|
||||
<td class="px-4 py-2">
|
||||
<select id="village_code_pembanding" name="village_code_pembanding[]"
|
||||
class="input w-full">
|
||||
|
||||
<option value="">Pilih Kecamatan</option>
|
||||
|
||||
<option value="">Pilih Desa/Kelurahan</option>
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -539,7 +531,6 @@
|
||||
const newCell = document.createElement('td');
|
||||
newCell.className = 'px-4 py-2';
|
||||
|
||||
// Clone the last input cell
|
||||
const lastInputCell = row.querySelector('td:last-child');
|
||||
if (lastInputCell) {
|
||||
const clonedContent = lastInputCell.innerHTML;
|
||||
@@ -547,7 +538,7 @@
|
||||
|
||||
// Update IDs and names for the new cell
|
||||
const inputs = newCell.querySelectorAll('input, select, textarea');
|
||||
inputs.forEach((input, index) => {
|
||||
inputs.forEach((input) => {
|
||||
if (input.type === 'file') {
|
||||
const newImageId = `uploadedImage${columnCount + 1}`;
|
||||
const preview = newCell.querySelector('img');
|
||||
@@ -561,19 +552,29 @@
|
||||
}
|
||||
}
|
||||
|
||||
if (input.id) {
|
||||
input.id = updateDynamicId(input.id, columnCount);
|
||||
// Menangani select alamat
|
||||
if (input.tagName === 'SELECT') {
|
||||
const oldId = input.id;
|
||||
const newId = `${oldId}_${columnCount}`;
|
||||
input.id = newId;
|
||||
|
||||
// Menambahkan event listener untuk select alamat
|
||||
if (oldId.includes('city')) {
|
||||
input.onchange = function() {
|
||||
handleCityChange(this);
|
||||
};
|
||||
} else if (oldId.includes('district')) {
|
||||
input.onchange = function() {
|
||||
handleDistrictChange(this);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Clear values
|
||||
if (input.type !== 'file') {
|
||||
input.value = '';
|
||||
}
|
||||
|
||||
loadIdSelectAddres(input.id);
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
row.appendChild(newCell);
|
||||
});
|
||||
@@ -582,6 +583,7 @@
|
||||
reinitializeEventListeners();
|
||||
}
|
||||
|
||||
|
||||
function updateDynamicId(currentId, columnCount) {
|
||||
return `${currentId.split('_')[0]}_${'code_pembanding'}_${columnCount}`;
|
||||
}
|
||||
@@ -739,112 +741,176 @@
|
||||
'district_code_pembanding',
|
||||
'village_code_pembanding'
|
||||
]
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
// Memuat data provinsi saat halaman dimuat
|
||||
loadProvinces();
|
||||
// Inisialisasi event listener untuk data pembanding pertama
|
||||
initializeFirstPembandingListeners();
|
||||
|
||||
// Event listener untuk perubahan pada dropdown Province
|
||||
document.getElementById('province_code_pembanding').addEventListener('change', function() {
|
||||
const provinceId = this.value;
|
||||
if (provinceId) {
|
||||
getCity(provinceId); // Kirimkan provinceId ke fungsi getCity
|
||||
} else {
|
||||
resetDropdown('city_code_pembanding', 'Select City');
|
||||
resetDropdown('district_code_pembanding', 'Select District');
|
||||
resetDropdown('village_code_pembanding', 'Select Village');
|
||||
}
|
||||
});
|
||||
try {
|
||||
const inspectionData = {!! isset($inspectionData) ? json_encode($inspectionData) : 'null' !!};
|
||||
const comparisons = {!! isset($comparisons) ? json_encode($comparisons) : 'null' !!};
|
||||
|
||||
// Event listener untuk perubahan pada dropdown City
|
||||
document.getElementById('city_code_pembanding').addEventListener('change', function() {
|
||||
const cityId = this.value;
|
||||
if (cityId) {
|
||||
getDistrict(cityId);
|
||||
} else {
|
||||
resetDropdown('district_code_pembanding', 'Select District');
|
||||
resetDropdown('village_code_pembanding', 'Select Village');
|
||||
if (comparisons) {
|
||||
comparisons.data_pembanding.forEach((comparison, index) => {
|
||||
if (index > 0) {
|
||||
addColumn();
|
||||
}
|
||||
fillPembandingData(comparison, index);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// Event listener untuk perubahan pada dropdown District
|
||||
document.getElementById('district_code_pembanding').addEventListener('change', function() {
|
||||
const districtId = this.value;
|
||||
if (districtId) {
|
||||
getVillage(districtId);
|
||||
} else {
|
||||
resetDropdown('village_code_pembanding', 'Select Village');
|
||||
}
|
||||
});
|
||||
updateRemoveButtonVisibility();
|
||||
initializeEventListeners();
|
||||
} catch (error) {
|
||||
console.error('Error initializing form:', error);
|
||||
}
|
||||
});
|
||||
|
||||
function loadProvinces() {
|
||||
const provinces =
|
||||
@json($provinces); // Using Laravel's Blade templating to pass the provinces array to JS
|
||||
function initializeFirstPembandingListeners() {
|
||||
// Event listener untuk province pembanding pertama
|
||||
const firstProvinceSelect = document.getElementById('province_code_pembanding');
|
||||
if (firstProvinceSelect) {
|
||||
firstProvinceSelect.addEventListener('change', function() {
|
||||
const provinceId = this.value;
|
||||
if (provinceId) {
|
||||
getCity(provinceId, 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const provinceDropdown = document.getElementById('province_code_pembanding');
|
||||
provinceDropdown.innerHTML = '<option value="">Select Province</option>';
|
||||
// Event listener untuk city pembanding pertama
|
||||
const firstCitySelect = document.getElementById('city_code_pembanding');
|
||||
if (firstCitySelect) {
|
||||
firstCitySelect.addEventListener('change', function() {
|
||||
const cityId = this.value;
|
||||
if (cityId) {
|
||||
getDistrict(cityId, 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
provinces.forEach(province => {
|
||||
provinceDropdown.innerHTML += `<option value="${province.code}">${province.name}</option>`;
|
||||
});
|
||||
// Event listener untuk district pembanding pertama
|
||||
const firstDistrictSelect = document.getElementById('district_code_pembanding');
|
||||
if (firstDistrictSelect) {
|
||||
firstDistrictSelect.addEventListener('change', function() {
|
||||
const districtId = this.value;
|
||||
if (districtId) {
|
||||
getVillage(districtId, 1);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function getCity(provinceId) {
|
||||
function handleProvinceChange(provinceSelect) {
|
||||
const provinceId = provinceSelect.value;
|
||||
let columnIndex;
|
||||
|
||||
// Cek apakah ini pembanding pertama atau tambahan
|
||||
if (provinceSelect.id === 'province_code_pembanding') {
|
||||
columnIndex = 1;
|
||||
} else {
|
||||
columnIndex = provinceSelect.id.split('_').pop();
|
||||
}
|
||||
|
||||
if (provinceId) {
|
||||
getCity(provinceId, columnIndex);
|
||||
}
|
||||
}
|
||||
|
||||
function handleCityChange(citySelect) {
|
||||
const cityId = citySelect.value;
|
||||
let columnIndex;
|
||||
|
||||
if (citySelect.id === 'city_code_pembanding') {
|
||||
columnIndex = 1;
|
||||
} else {
|
||||
columnIndex = citySelect.id.split('_').pop();
|
||||
}
|
||||
|
||||
if (cityId) {
|
||||
getDistrict(cityId, columnIndex);
|
||||
}
|
||||
}
|
||||
|
||||
function handleDistrictChange(districtSelect) {
|
||||
const districtId = districtSelect.value;
|
||||
let columnIndex;
|
||||
|
||||
if (districtSelect.id === 'district_code_pembanding') {
|
||||
columnIndex = 1;
|
||||
} else {
|
||||
columnIndex = districtSelect.id.split('_').pop();
|
||||
}
|
||||
|
||||
if (districtId) {
|
||||
getVillage(districtId, columnIndex);
|
||||
}
|
||||
}
|
||||
|
||||
async function getCity(provinceId, columnIndex) {
|
||||
try {
|
||||
const response = await fetch(
|
||||
`/locations/cities/province/${provinceId}`); // Assuming this is still your API
|
||||
const response = await fetch(`/locations/cities/province/${provinceId}`);
|
||||
const data = await response.json();
|
||||
|
||||
const cityDropdown = document.getElementById('city_code_pembanding');
|
||||
cityDropdown.innerHTML = '<option value="">Select City</option>';
|
||||
// Pilih dropdown berdasarkan index
|
||||
const cityDropdown = columnIndex === 1 ?
|
||||
document.getElementById('city_code_pembanding') :
|
||||
document.getElementById(`city_code_pembanding_${columnIndex}`);
|
||||
|
||||
data.forEach(city => {
|
||||
cityDropdown.innerHTML += `<option value="${city.code}">${city.name}</option>`;
|
||||
});
|
||||
if (cityDropdown) {
|
||||
cityDropdown.innerHTML = '<option value="">Pilih Kota/Kabupaten</option>';
|
||||
data.forEach(city => {
|
||||
cityDropdown.innerHTML += `<option value="${city.code}">${city.name}</option>`;
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching cities:', error);
|
||||
}
|
||||
}
|
||||
|
||||
async function getDistrict(cityId) {
|
||||
async function getDistrict(cityId, columnIndex) {
|
||||
try {
|
||||
const response = await fetch(`/locations/districts/city/${cityId}`);
|
||||
const data = await response.json();
|
||||
|
||||
const districtDropdown = document.getElementById('district_code_pembanding');
|
||||
districtDropdown.innerHTML = '<option value="">Select District</option>';
|
||||
const districtDropdown = columnIndex === 1 ?
|
||||
document.getElementById('district_code_pembanding') :
|
||||
document.getElementById(`district_code_pembanding_${columnIndex}`);
|
||||
|
||||
data.forEach(district => {
|
||||
districtDropdown.innerHTML += `<option value="${district.code}">${district.name}</option>`;
|
||||
});
|
||||
if (districtDropdown) {
|
||||
districtDropdown.innerHTML = '<option value="">Pilih Kecamatan</option>';
|
||||
data.forEach(district => {
|
||||
districtDropdown.innerHTML +=
|
||||
`<option value="${district.code}">${district.name}</option>`;
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching districts:', error);
|
||||
}
|
||||
}
|
||||
|
||||
async function getVillage(districtId) {
|
||||
async function getVillage(districtId, columnIndex) {
|
||||
try {
|
||||
const response = await fetch(`/locations/villages/district/${districtId}`);
|
||||
const data = await response.json();
|
||||
|
||||
const villageDropdown = document.getElementById('village_code_pembanding');
|
||||
villageDropdown.innerHTML = '<option value="">Select Village</option>';
|
||||
const villageDropdown = columnIndex === 1 ?
|
||||
document.getElementById('village_code_pembanding') :
|
||||
document.getElementById(`village_code_pembanding_${columnIndex}`);
|
||||
|
||||
data.forEach(village => {
|
||||
villageDropdown.innerHTML += `<option value="${village.code}">${village.name}</option>`;
|
||||
});
|
||||
if (villageDropdown) {
|
||||
villageDropdown.innerHTML = '<option value="">Pilih Desa/Kelurahan</option>';
|
||||
data.forEach(village => {
|
||||
villageDropdown.innerHTML += `<option value="${village.code}">${village.name}</option>`;
|
||||
});
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error fetching villages:', error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function resetDropdown(elementId, placeholder) {
|
||||
const dropdown = document.getElementById(elementId);
|
||||
dropdown.innerHTML = `<option value="">${placeholder}</option>`;
|
||||
|
||||
@@ -5,6 +5,15 @@
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
<style>
|
||||
.pdf-preview {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
border: 1px solid #ddd;
|
||||
margin-top: 10px;
|
||||
}
|
||||
</style>
|
||||
|
||||
@include('lpj::assetsku.includenya')
|
||||
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
|
||||
<div class="card min-w-full">
|
||||
@@ -130,34 +139,40 @@
|
||||
<input type="hidden" value="{{ $permohonan->id }}" name="permohonan_id">
|
||||
<input type="hidden" name="jenis_jaminan_id" value="{{ request('jenis_jaminan') }}">
|
||||
<div class="mt-2">
|
||||
<div class=""max-w-4xl mx-auto bg-white rounded-lg shadow-md overflow-hidden">
|
||||
|
||||
<div>
|
||||
</div>
|
||||
<div class=" mx-auto overflow-hidden">
|
||||
<div class="flex flex-wrap gap-4" style="margin-top: 20px">
|
||||
<div class="flex w-full items-center justify-center gap-4">
|
||||
<div class="flex w-full items-center justify-center gap-4">
|
||||
<label class="form-label max-w-56">
|
||||
<span class="form-label">Upload Denah</span>
|
||||
<span class="form-label">Upload Denah (Foto/PDF)</span>
|
||||
</label>
|
||||
<div class="w-full grid gap-5">
|
||||
<img id="foto_denah-preview"
|
||||
src="{{ isset($formDenah['foto_denah']) ? asset('storage/' . old('foto_denah', $formDenah['foto_denah'])) : '' }}"
|
||||
alt="Gambar foto_denah"
|
||||
style="{{ isset($formDenah['foto_denah']) ? 'width: 30rem;' : 'display: none;' }}">
|
||||
|
||||
<!-- Preview Container -->
|
||||
<div id="preview-container">
|
||||
<!-- Image preview -->
|
||||
<img id="foto_denah-preview"
|
||||
src="{{ isset($formDenah['foto_denah']) ? asset('storage/' . old('foto_denah', $formDenah['foto_denah'])) : '' }}"
|
||||
alt="Gambar foto_denah"
|
||||
style="{{ isset($formDenah['foto_denah']) && strpos($formDenah['foto_denah'], '.pdf') === false ? 'width: 30rem;' : 'display: none;' }}">
|
||||
|
||||
<!-- PDF preview -->
|
||||
@if (isset($formDenah['foto_denah']) && strpos($formDenah['foto_denah'], '.pdf') !== false)
|
||||
<div id="pdf-preview" class="pdf-preview">
|
||||
<embed src="{{ asset('storage/' . $formDenah['foto_denah']) }}"
|
||||
type="application/pdf" width="100%" height="500px">
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div class="input-group w-full flex gap-2">
|
||||
<input type="file"
|
||||
value="{{ old('foto_denah', isset($formDenah['foto_denah']) ? $formDenah['foto_denah'] : '') }}"
|
||||
name="foto_denah" class="file-input file-input-bordered w-full "
|
||||
accept="image/*" onchange="previewImage(this, 'foto_denah-preview')">
|
||||
name="foto_denah" class="file-input file-input-bordered w-full"
|
||||
accept=".jpg,.jpeg,.png,.pdf" onchange="previewFile(this)">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<em id="error-foto_denah" class="alert text-danger text-sm"></em>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -202,18 +217,56 @@
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
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();
|
||||
function previewFile(input) {
|
||||
const previewContainer = document.getElementById('preview-container');
|
||||
const imagePreview = document.getElementById('foto_denah-preview');
|
||||
const file = input.files[0];
|
||||
|
||||
// Hapus preview PDF yang ada (jika ada)
|
||||
const existingPdfPreview = document.getElementById('pdf-preview');
|
||||
if (existingPdfPreview) {
|
||||
existingPdfPreview.remove();
|
||||
}
|
||||
|
||||
if (file) {
|
||||
// Cek tipe file
|
||||
if (file.type.startsWith('image/')) {
|
||||
// Jika file adalah gambar
|
||||
imagePreview.style.display = 'block';
|
||||
const reader = new FileReader();
|
||||
|
||||
reader.onload = function(e) {
|
||||
imagePreview.src = e.target.result;
|
||||
imagePreview.style.width = '30rem';
|
||||
}
|
||||
|
||||
reader.readAsDataURL(file);
|
||||
} else if (file.type === 'application/pdf') {
|
||||
// Jika file adalah PDF
|
||||
imagePreview.style.display = 'none';
|
||||
|
||||
// Buat preview PDF
|
||||
const pdfPreview = document.createElement('div');
|
||||
pdfPreview.id = 'pdf-preview';
|
||||
pdfPreview.className = 'pdf-preview';
|
||||
|
||||
const pdfEmbed = document.createElement('embed');
|
||||
pdfEmbed.src = URL.createObjectURL(file);
|
||||
pdfEmbed.type = 'application/pdf';
|
||||
pdfEmbed.width = '100%';
|
||||
pdfEmbed.height = '500px';
|
||||
|
||||
pdfPreview.appendChild(pdfEmbed);
|
||||
previewContainer.appendChild(pdfPreview);
|
||||
}
|
||||
reader.readAsDataURL(input.files[0]);
|
||||
} else {
|
||||
$('#' + previewId).hide();
|
||||
// Jika tidak ada file yang dipilih
|
||||
imagePreview.style.display = 'none';
|
||||
imagePreview.src = '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function submitDenah() {
|
||||
const loadingOverlay = document.getElementById('loadingOverlay');
|
||||
loadingOverlay.classList.remove('hidden');
|
||||
|
||||
@@ -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>
|
||||
@@ -256,9 +256,11 @@
|
||||
$objekViews = [];
|
||||
if ($kategori === 'tanah') {
|
||||
$objekViews = [
|
||||
['label' => 'Tampak Samping Kiri', 'index' => 0],
|
||||
['label' => 'Tampak Samping Kanan', 'index' => 1],
|
||||
['label' => 'Nomor Rumah/Unit', 'index' => 2],
|
||||
['label' => 'Tampak Depan Objek', 'index' => 0],
|
||||
['label' => 'Tampak Samping Kiri', 'index' => 1],
|
||||
['label' => 'Tampak Samping Kanan', 'index' => 2],
|
||||
['label' => 'Nomor Rumah/Unit', 'index' => 3],
|
||||
|
||||
];
|
||||
} elseif ($kategori === 'apartemen-kantor') {
|
||||
$objekViews = [
|
||||
@@ -603,10 +605,9 @@
|
||||
|
||||
<!-- Modal Kamera -->
|
||||
@include('lpj::surveyor.components.modal-kamera')
|
||||
@endsection
|
||||
|
||||
|
||||
@endsection
|
||||
|
||||
@include('lpj::surveyor.js.fotojs')
|
||||
@push('scripts')
|
||||
<script>
|
||||
function submitFoto() {
|
||||
@@ -616,9 +617,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') }}',
|
||||
@@ -639,8 +637,8 @@
|
||||
confirmButtonText: 'OK'
|
||||
}).then((response) => {
|
||||
if (response.isConfirmed) {
|
||||
// window.location.href =
|
||||
// '{{ route('surveyor.show', ['id' => $permohonan->id]) }}';
|
||||
window.location.href =
|
||||
'{{ route('surveyor.show', ['id' => $permohonan->id]) }}';
|
||||
}
|
||||
console.log(response);
|
||||
|
||||
|
||||
@@ -50,15 +50,31 @@
|
||||
|
||||
<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>
|
||||
@@ -67,13 +83,12 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<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>
|
||||
@@ -111,25 +125,27 @@
|
||||
<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('jenis_asset', 'jenis_asset', ['tidak sesuai'])"
|
||||
type="radio" class="radio" name="jenis_asset" value="sesuai"
|
||||
type="radio" class="radio" name="jenis_asset" value="sesuai"
|
||||
{{ isset($forminspeksi['asset']['jenis_asset']['sesuai']) ? 'checked' : '' }}>
|
||||
<span class="ml-2">Ya</span>
|
||||
</label>
|
||||
<label class="form-label flex items-center gap-2.5 text-nowrap">
|
||||
<input onclick="toggleFieldVisibility('jenis_asset', 'jenis_asset', ['tidak sesuai'])"
|
||||
type="radio" class="radio" name="jenis_asset" value="tidak sesuai"
|
||||
type="radio" class="radio" name="jenis_asset" value="tidak sesuai"
|
||||
{{ isset($forminspeksi['asset']['jenis_asset']['tidak sesuai']) ? 'checked' : '' }}>
|
||||
<span class="ml-2">Tidak</span>
|
||||
</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"
|
||||
style="{{ isset($selectedValue) === 'tidak sesuai' ? '' : 'display: none;' }}">
|
||||
style="{{ isset($selectedValue) === 'tidak sesuai' ? '' : 'display: none;' }}">
|
||||
<select id="jenis_asset_tidak_sesuai" class="input w-full"
|
||||
name="jenis_asset_tidak_sesuai">
|
||||
name="jenis_asset_tidak_sesuai">
|
||||
<option value="">Select Jenis asset</option>
|
||||
@if (isset($basicData['jenisJaminan']))
|
||||
@foreach ($basicData['jenisJaminan'] as $item)
|
||||
@@ -153,23 +169,23 @@
|
||||
<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) }}
|
||||
</span>
|
||||
@endforeach
|
||||
|
||||
<span class="text-2sm text-gray-700">
|
||||
{{ formatAlamat($permohonan->debiture) }}
|
||||
</span>
|
||||
|
||||
|
||||
<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="updateAlamatFields('sesuai')" type="radio" class="radio"
|
||||
name="alamat_sesuai" value="sesuai"
|
||||
name="alamat_sesuai" value="sesuai"
|
||||
{{ old('jenis_asset', isset($forminspeksi['asset']['alamat']['sesuai'])) ? 'checked' : '' }}>
|
||||
<span class="ml-2">Ya</span>
|
||||
</label>
|
||||
<label class="form-label flex items-center gap-3 text-nowrap">
|
||||
<input onclick="updateAlamatFields('tidak sesuai')" type="radio" class="radio"
|
||||
name="alamat_sesuai" value="tidak sesuai"
|
||||
name="alamat_sesuai" value="tidak sesuai"
|
||||
{{ old('jenis_asset', isset($forminspeksi['asset']['alamat']['tidak sesuai'])) ? 'checked' : '' }}>
|
||||
<span class="ml-2">Tidak</span>
|
||||
</label>
|
||||
@@ -184,13 +200,13 @@
|
||||
@endphp
|
||||
|
||||
<div id="alamat_form" class="grid gap-2 mt-5"
|
||||
style="{{ isset($address) ? '' : 'display: none;' }}">
|
||||
style="{{ isset($address) ? '' : 'display: none;' }}">
|
||||
<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>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input type="text" id="address" name="address" class="input w-full"
|
||||
placeholder="Masukkan Jl."
|
||||
value="{{ isset($forminspeksi['asset']['alamat']['tidak sesuai']['address'])
|
||||
placeholder="Masukkan Jl."
|
||||
value="{{ isset($forminspeksi['asset']['alamat']['tidak sesuai']['address'])
|
||||
? $forminspeksi['asset']['alamat']['tidak sesuai']['address']
|
||||
: (isset($forminspeksi['asset']['alamat']['sesuai']['address'])
|
||||
? $forminspeksi['asset']['alamat']['sesuai']['address']
|
||||
@@ -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,23 +318,23 @@
|
||||
|
||||
|
||||
<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">
|
||||
<div class="grid grid-cols-2 gap-4 items-center w-full">
|
||||
<input class="input" type="text" placeholder="Masukan Koordinat Latitude" type="text"
|
||||
name="kordinat_lat" id="lat"
|
||||
value="{{ old('kordinat_lat', isset($forminspeksi['asset']['kordinat_lat']) ? $forminspeksi['asset']['kordinat_lat'] : '') }}">
|
||||
name="kordinat_lat" id="lat"
|
||||
value="{{ old('kordinat_lat', isset($forminspeksi['asset']['kordinat_lat']) ? $forminspeksi['asset']['kordinat_lat'] : '') }}">
|
||||
<input class="input" type="text" placeholder="Masukan Koordinat Longitude"
|
||||
name="kordinat_lng" id="lng"
|
||||
value="{{ old('kordinat_lng', isset($forminspeksi['asset']['kordinat_lng']) ? $forminspeksi['asset']['kordinat_lng'] : '') }}">
|
||||
name="kordinat_lng" id="lng"
|
||||
value="{{ old('kordinat_lng', isset($forminspeksi['asset']['kordinat_lng']) ? $forminspeksi['asset']['kordinat_lng'] : '') }}">
|
||||
</div>
|
||||
<a target="_blank" href="https://www.google.com/maps"type="button"
|
||||
class="btn btn-md btn-outline btn-primary">
|
||||
<a target="_blank" href="https://www.google.com/maps" type="button"
|
||||
class="btn btn-md btn-outline btn-primary">
|
||||
<i class="ki-filled ki-map"></i>Ambil
|
||||
Kordinat</a>
|
||||
</div>
|
||||
@@ -326,15 +343,18 @@
|
||||
</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)
|
||||
<div class="accordion-item [&:not(:last-child)]:border-b border-b-gray-200" data-accordion-item="true"
|
||||
id="accordion_detail_jaminan">
|
||||
id="accordion_detail_jaminan">
|
||||
<button class="accordion-toggle py-4 group "
|
||||
data-accordion-toggle="#accordion_detail_jaminan_{{ $loop->index }}">
|
||||
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>
|
||||
@@ -345,7 +365,7 @@
|
||||
<div class="accordion-content hidden" id="accordion_detail_jaminan_{{ $loop->index }}">
|
||||
<div class="card-table scrollable-x-auto pb-3">
|
||||
<a href="{{ route('debitur.jaminan.bulk.download', ['id' => $permohonan->debiture->id, 'jaminan' => $dokumen->id]) }}"
|
||||
class="ml-6 btn btn-dark dark:btn-light">
|
||||
class="ml-6 btn btn-dark dark:btn-light">
|
||||
<i class="ki-outline ki-cloud-download"></i> Download Semua Dokumen
|
||||
</a>
|
||||
<table class="table align-middle text-sm text-gray-500">
|
||||
@@ -383,7 +403,7 @@
|
||||
{{ $dokumen_nomor[$index] }}</span>
|
||||
@endif
|
||||
<a href="{{ route('debitur.jaminan.download', ['id' => $permohonan->debiture->id, 'dokumen' => $detail->id, 'index' => $index]) }}"
|
||||
class="flex-none badge badge-sm badge-outline mt-2 mr-2">
|
||||
class="flex-none badge badge-sm badge-outline mt-2 mr-2">
|
||||
{{ basename($dokumen) }}
|
||||
<i class="ki-filled ki-cloud-download"></i>
|
||||
</a>
|
||||
@@ -428,7 +448,7 @@
|
||||
@foreach ($permohonan->debiture->documents as $dokumen)
|
||||
{{ $dokumen->pemilik->hubungan_pemilik->name ?? '' }}
|
||||
<input type="hidden" name="hub_cadeb_sesuai"
|
||||
value="{{ $dokumen->pemilik->hubungan_pemilik->name }}" id="">
|
||||
value="{{ $dokumen->pemilik->hubungan_pemilik->name }}" id="">
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
@@ -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,26 +507,29 @@
|
||||
<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"
|
||||
value="{{ isset($dokumen->penghuni->hubungan_penghuni->name) ?? '' }}"
|
||||
id="">
|
||||
<input type="hidden" name="hub_cadeb_penghuni_sesuai"
|
||||
value="{{ isset($dokumen->penghuni->hubungan_penghuni->name) ?? '' }}"
|
||||
id="">
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
<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,20 +539,20 @@
|
||||
: 'tidak sesuai';
|
||||
$selectedData = $forminspeksi['asset']['hub_cadeb_penghuni'][$statusKey] ?? null;
|
||||
@endphp
|
||||
<select id="hub_cadeb_Penghuni_tidak_sesuai"
|
||||
class="input w-full
|
||||
name="hub_cadeb_Penghuni_tidak_sesuai"
|
||||
style="{{ old('hub_cadeb', $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' : '' }}>
|
||||
{{ $item->name }}
|
||||
</option>
|
||||
<select id="hub_penghuni_tidak_sesuai"
|
||||
class="input w-full
|
||||
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_penghuni_tidak_sesuai', $selectedData) == $item->name ? 'selected' : '' }}>
|
||||
{{ $item->name }}
|
||||
</option>
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
@endif
|
||||
</select>
|
||||
</div>
|
||||
<em id="error-hub_cadeb" class="alert text-danger text-sm"></em>
|
||||
</div>
|
||||
|
||||
@@ -205,8 +205,8 @@
|
||||
confirmButtonText: 'OK'
|
||||
}).then((response) => {
|
||||
if (response.isConfirmed) {
|
||||
// window.location.href =
|
||||
// '{{ route('surveyor.show', ['id' => $permohonan->id]) }}';
|
||||
window.location.href =
|
||||
'{{ 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>
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user