update kertas kerja dan column name table inspeksi
This commit is contained in:
@@ -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