update kertas kerja dan column name table inspeksi
This commit is contained in:
@@ -67,7 +67,7 @@
|
||||
alt="Uploaded Image">
|
||||
<input type="file"
|
||||
name="foto_objek"
|
||||
class="input"
|
||||
class="file-input"
|
||||
accept="image/*"
|
||||
onchange="previewImage(this, 'uploadedImage1')">
|
||||
</div>
|
||||
@@ -77,7 +77,7 @@
|
||||
<div class="flex flex-col gap-2">
|
||||
<img id="uploadedImage2" class="max-w-[200px] hidden"
|
||||
alt="Pembanding Image">
|
||||
<input type="file" name="foto_objek_pembanding[]" class="input-file"
|
||||
<input type="file" name="foto_objek_pembanding[]" class="file-input"
|
||||
accept="image/*" onchange="previewImage(this, 'uploadedImage2')">
|
||||
</div>
|
||||
</td>
|
||||
@@ -94,19 +94,18 @@
|
||||
<td class="px-4 py-2">
|
||||
<select name="jenis_aset" class="select">
|
||||
<option value="">Pilih Jenis Aset</option>
|
||||
<option value="Tanah"
|
||||
{{ ($inspectionData['jenis_aset'] ?? '') == 'Tanah' ? 'selected' : '' }}>
|
||||
Tanah</option>
|
||||
<option value="Bangunan"
|
||||
{{ ($inspectionData['jenis_aset'] ?? '') == 'Bangunan' ? 'selected' : '' }}>
|
||||
Bangunan</option>
|
||||
@foreach ($data['jenisJaminan'] as $item)
|
||||
<option value="{{ $item->name }}" {{ ($inspectionData['asset']['jenis_asset']['sesuai'] ?? '') == $item->name ? 'selected' : '' }}>{{ $item->name }}</option>
|
||||
@endforeach
|
||||
|
||||
</select>
|
||||
</td>
|
||||
<td class="px-4 py-2">
|
||||
<select name="jenis_aset_pembanding[]" class="select">
|
||||
<option value="">Pilih Jenis Aset</option>
|
||||
<option value="Tanah">Tanah</option>
|
||||
<option value="Bangunan">Bangunan</option>
|
||||
@foreach ($data['jenisJaminan'] as $item)
|
||||
<option value="{{ $item->name }}" {{ ($inspectionData['jenis_aset'] ?? '') == $item->name ? 'selected' : '' }}>{{ $item->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
@@ -141,8 +141,8 @@
|
||||
@endforeach
|
||||
@endif
|
||||
</select>
|
||||
<button type="button" class="btn btn-md btn-primary"
|
||||
onclick="updateAnalisa('jenis_asset')">Save</button>
|
||||
{{-- <button type="button" class="btn btn-md btn-primary"
|
||||
onclick="updateAnalisa('jenis_asset')">Save</button> --}}
|
||||
</div>
|
||||
</div>
|
||||
<em id="error-jenis_asset" class="alert text-danger text-sm"></em>
|
||||
@@ -162,133 +162,90 @@
|
||||
|
||||
<div class="flex-wrap items-stretch">
|
||||
<div class="grid grid-cols-3 md:grid-cols-3 gap-4 mt-2">
|
||||
<div class="grid grid-cols-3 md:grid-cols-3 gap-4 mt-2">
|
||||
<label class="form-label flex items-center gap-3 text-nowrap">
|
||||
<input
|
||||
onclick="toggleAlamatVisibility('alamat_sesuai', 'alamat_tidak_sesuai', 'sesuai')"
|
||||
type="radio" class="radio" 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="toggleAlamatVisibility('alamat_sesuai', 'alamat_tidak_sesuai', 'tidak sesuai')"
|
||||
type="radio" class="radio" name="alamat_sesuai" value="tidak sesuai"
|
||||
{{ old('jenis_asset', isset($forminspeksi['asset']['alamat']['tidak sesuai'])) ? 'checked' : '' }}>
|
||||
<span class="ml-2">Tidak</span>
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<label class="form-label flex items-center gap-3 text-nowrap">
|
||||
<input
|
||||
onclick="updateAlamatFields('sesuai')"
|
||||
type="radio"
|
||||
class="radio"
|
||||
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"
|
||||
{{ old('jenis_asset', isset($forminspeksi['asset']['alamat']['tidak sesuai'])) ? 'checked' : '' }}>
|
||||
<span class="ml-2">Tidak</span>
|
||||
</label>
|
||||
</div>
|
||||
<em id="error-alamat" class="alert text-danger text-sm"></em>
|
||||
</div>
|
||||
|
||||
{{-- Alamat Sesuai --}}
|
||||
<div id="alamat_sesuai" class="grid gap-2 mt-5" style="{{ isset($forminspeksi['asset']['alamat']['sesuai']) ? '' : 'display: none;' }}">
|
||||
@foreach ($permohonan->debiture->documents as $dokumen)
|
||||
@php
|
||||
$fields = [
|
||||
[
|
||||
'label' => 'Jl.',
|
||||
'value' => $dokumen->address ?? '',
|
||||
'name' => 'nama_jalan',
|
||||
'readonly' => false,
|
||||
],
|
||||
[
|
||||
'label' => 'Provinsi',
|
||||
'value' => $dokumen->province->name ?? '',
|
||||
'name' => 'provinsi',
|
||||
'readonly' => true,
|
||||
],
|
||||
[
|
||||
'label' => 'Kota/Kabupaten',
|
||||
'value' => $dokumen->city->name ?? '',
|
||||
'name' => 'kota_kabupaten',
|
||||
'readonly' => true,
|
||||
],
|
||||
[
|
||||
'label' => 'Kecamatan',
|
||||
'value' => $dokumen->district->name ?? '',
|
||||
'name' => 'kecamatan',
|
||||
'readonly' => true,
|
||||
],
|
||||
[
|
||||
'label' => 'Kelurahan',
|
||||
'value' => $dokumen->village->name ?? '',
|
||||
'name' => 'desa_kelurahan',
|
||||
'readonly' => true,
|
||||
],
|
||||
];
|
||||
@endphp
|
||||
@foreach ($fields as $field)
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">{{ $field['label'] }}</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
<input type="text" class="input" name="{{ $field['name'] }}"
|
||||
value="{{ $field['value'] }}" {{ $field['readonly'] ? 'readonly' : '' }}>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
{{-- Alamat Tidak Sesuai --}}
|
||||
<div id="alamat_tidak_sesuai" class="grid gap-2 mt-5" style="{{ isset($forminspeksi['asset']['alamat']['tidak sesuai']) ? '' : 'display: none;' }}"">
|
||||
<div id="alamat_form" class="grid gap-2 mt-5">
|
||||
@php
|
||||
$inputDataLokasi = [
|
||||
['label' => 'Jl.', 'id' => 'address', 'name' => 'address', 'type' => 'text'],
|
||||
$fields = [
|
||||
[
|
||||
'label' => 'Jl.',
|
||||
'name' => 'nama_jalan',
|
||||
'id' => 'nama_jalan',
|
||||
'readonly' => false,
|
||||
],
|
||||
[
|
||||
'label' => 'Provinsi',
|
||||
'id' => 'province_code',
|
||||
'name' => 'provinsi',
|
||||
'id' => 'provinsi',
|
||||
'type' => 'select',
|
||||
'options' => $provinces,
|
||||
],
|
||||
[
|
||||
'label' => 'Kota/Kabupaten',
|
||||
'id' => 'city_code',
|
||||
'name' => 'kota_kabupaten',
|
||||
'id' => 'kota_kabupaten',
|
||||
'type' => 'select',
|
||||
'options' => $provinces,
|
||||
],
|
||||
[
|
||||
'label' => 'Kecamatan',
|
||||
'id' => 'district_code',
|
||||
'name' => 'kecamatan',
|
||||
'id' => 'kecamatan',
|
||||
'type' => 'select',
|
||||
'options' => $provinces,
|
||||
],
|
||||
[
|
||||
'label' => 'Desa/Kelurahan',
|
||||
'id' => 'village_code',
|
||||
'label' => 'Kelurahan',
|
||||
'name' => 'desa_kelurahan',
|
||||
'id' => 'desa_kelurahan',
|
||||
'type' => 'select',
|
||||
'options' => $provinces,
|
||||
],
|
||||
];
|
||||
@endphp
|
||||
|
||||
@foreach ($inputDataLokasi as $item)
|
||||
@foreach ($fields as $field)
|
||||
<div class="flex items-baseline flex-wrap lg:flex-nowrap gap-2.5">
|
||||
<label class="form-label max-w-56">{{ $item['label'] }}</label>
|
||||
<label class="form-label max-w-56">{{ $field['label'] }}</label>
|
||||
<div class="flex flex-wrap items-baseline w-full">
|
||||
@if ($item['type'] === 'text')
|
||||
<input id="{{ $item['id'] }}" name="{{ $item['name'] }}" class="input">
|
||||
@else
|
||||
<select id="{{ $item['id'] }}" name="{{ $item['name'] }}"
|
||||
class="select w-full">
|
||||
<option value="">{{ $item['label'] }}</option>
|
||||
@if ($item['id'] === 'province_code')
|
||||
@foreach ($item['options'] as $option)
|
||||
<option value="{{ $option->code }}">{{ $option->name }}</option>
|
||||
@endforeach
|
||||
@endif
|
||||
@if (isset($field['type']) && $field['type'] === 'select')
|
||||
<select id="{{ $field['id'] }}" name="{{ $field['name'] }}" class="select w-full">
|
||||
<option value="">{{ $field['label'] }}</option>
|
||||
@foreach ($field['options'] as $option)
|
||||
<option value="{{ $option->code }}">{{ $option->name }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
@else
|
||||
<input type="text" id="{{ $field['id'] }}" name="{{ $field['name'] }}" class="input"
|
||||
{{ $field['readonly'] ? 'readonly' : '' }}>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -44,8 +44,8 @@
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- Loading Overlay -->
|
||||
<div id="loadingOverlay" class="fixed inset-0 bg-black bg-opacity-50 hidden items-center justify-center z-50">
|
||||
<!-- Loading Overlay -->
|
||||
<div id="loadingOverlay" class="fixed inset-0 bg-black bg-opacity-50 hidden items-center justify-center z-50">
|
||||
<div class="bg-white p-4 rounded-lg">
|
||||
<div class="loader"></div>
|
||||
<p class="mt-2 text-center">Sedang memproses...</p>
|
||||
@@ -54,6 +54,25 @@
|
||||
@endsection
|
||||
@push('scripts')
|
||||
<script type="text/javascript">
|
||||
function updateAlamatFields(type) {
|
||||
if (type === 'sesuai') {
|
||||
// Update nilai form dengan data sesuai
|
||||
document.getElementById('nama_jalan').value = "{{ $dokumen->address ?? '' }}";
|
||||
document.getElementById('provinsi').value = "{{ $dokumen->province->code ?? '' }}";
|
||||
document.getElementById('kota_kabupaten').value = "{{ $dokumen->city->code ?? '' }}";
|
||||
document.getElementById('kecamatan').value = "{{ $dokumen->district->code ?? '' }}";
|
||||
document.getElementById('desa_kelurahan').value = "{{ $dokumen->village->code ?? '' }}";
|
||||
} else if (type === 'tidak sesuai') {
|
||||
// Reset nilai form untuk input manual
|
||||
document.getElementById('nama_jalan').value = '';
|
||||
document.getElementById('provinsi').value = '';
|
||||
document.getElementById('kota_kabupaten').value = '';
|
||||
document.getElementById('kecamatan').value = '';
|
||||
document.getElementById('desa_kelurahan').value = '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function toggleFieldVisibility(fieldName, inputId, visibleValues = []) {
|
||||
const selectedValue = $(`[name="${fieldName}"]:checked`).val();
|
||||
const inputField = $(`#${inputId}`);
|
||||
@@ -127,65 +146,69 @@
|
||||
|
||||
function submitData() {
|
||||
|
||||
|
||||
|
||||
const loadingOverlay = document.getElementById('loadingOverlay');
|
||||
loadingOverlay.classList.remove('hidden');
|
||||
loadingOverlay.classList.add('flex');
|
||||
|
||||
const formElement = $('#formInspeksi')[0];
|
||||
const formData = new FormData(formElement);
|
||||
|
||||
$.ajax({
|
||||
url: '{{ route('surveyor.store') }}',
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
Swal.fire({
|
||||
title: 'Berhasil!',
|
||||
text: response.message,
|
||||
icon: 'success',
|
||||
confirmButtonText: 'OK'
|
||||
}).then((response) => {
|
||||
if (response.isConfirmed) {
|
||||
window.location.href =
|
||||
'{{ route('surveyor.show', ['id' => $permohonan->id]) }}';
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
title: 'Error!',
|
||||
text: response.message || 'Terjadi kesalahan',
|
||||
icon: 'error',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
}
|
||||
console.log(response);
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
let errors = xhr.responseJSON?.errors;
|
||||
$('.alert').text('');
|
||||
if (errors) {
|
||||
$.each(errors, function(key, value) {
|
||||
$(`#error-${key}`).text(value[0]);
|
||||
});
|
||||
}
|
||||
console.error('Terjadi error:', error); // Menampilkan pesan error di konsol
|
||||
console.log('Status:', status);
|
||||
console.log('Response:', xhr.responseText);
|
||||
console.log(errors);
|
||||
toastrErrorBuild(error);
|
||||
},
|
||||
complete: function() {
|
||||
// Re-enable the button and hide the spinner
|
||||
loadingOverlay.classList.add('hidden');
|
||||
loadingOverlay.classList.remove('flex');
|
||||
}
|
||||
formData.forEach((value, key) => {
|
||||
console.log(key, value);
|
||||
});
|
||||
// $.ajax({
|
||||
// url: '{{ route('surveyor.store') }}',
|
||||
// type: 'POST',
|
||||
// data: formData,
|
||||
// processData: false,
|
||||
// contentType: false,
|
||||
// headers: {
|
||||
// 'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||
// },
|
||||
// success: function(response) {
|
||||
// if (response.success) {
|
||||
// Swal.fire({
|
||||
// title: 'Berhasil!',
|
||||
// text: response.message,
|
||||
// icon: 'success',
|
||||
// confirmButtonText: 'OK'
|
||||
// }).then((response) => {
|
||||
// if (response.isConfirmed) {
|
||||
// window.location.href =
|
||||
// '{{ route('surveyor.show', ['id' => $permohonan->id]) }}';
|
||||
// }
|
||||
// });
|
||||
// } else {
|
||||
// Swal.fire({
|
||||
// title: 'Error!',
|
||||
// text: response.message || 'Terjadi kesalahan',
|
||||
// icon: 'error',
|
||||
// confirmButtonText: 'OK'
|
||||
// });
|
||||
// }
|
||||
// console.log(response);
|
||||
// },
|
||||
// error: function(xhr, status, error) {
|
||||
// let errors = xhr.responseJSON?.errors;
|
||||
// $('.alert').text('');
|
||||
// if (errors) {
|
||||
// $.each(errors, function(key, value) {
|
||||
// $(`#error-${key}`).text(value[0]);
|
||||
// });
|
||||
// }
|
||||
// console.error('Terjadi error:', error); // Menampilkan pesan error di konsol
|
||||
// console.log('Status:', status);
|
||||
// console.log('Response:', xhr.responseText);
|
||||
// console.log(errors);
|
||||
// toastrErrorBuild(error);
|
||||
// },
|
||||
// complete: function() {
|
||||
// // Re-enable the button and hide the spinner
|
||||
// loadingOverlay.classList.add('hidden');
|
||||
// loadingOverlay.classList.remove('flex');
|
||||
// }
|
||||
// });
|
||||
}
|
||||
|
||||
function previewImage(input, previewId) {
|
||||
@@ -260,9 +283,8 @@
|
||||
success: function(response) {
|
||||
console.log(response);
|
||||
if (response.success) {
|
||||
window.location.href =
|
||||
'{{ route('surveyor.show', ['id' => $permohonan->id]) }}';
|
||||
|
||||
// window.location.href =
|
||||
// '{{ route('surveyor.show', ['id' => $permohonan->id]) }}';
|
||||
toastrSuccessBuild(response.message);
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user