update form data surveyor
This commit is contained in:
@@ -23,7 +23,8 @@
|
||||
@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_1_item_1">
|
||||
<button class="accordion-toggle py-4 group mx-8" data-accordion-toggle="#accoordion_detail_jaminan_{{ $loop->index }}">
|
||||
<button class="accordion-toggle py-4 group mx-8"
|
||||
data-accordion-toggle="#accoordion_detail_jaminan_{{ $loop->index }}">
|
||||
<span class="text-base text-gray-900 font-medium">
|
||||
Jaminan {{ $loop->index + 1 }}
|
||||
</span>
|
||||
@@ -117,9 +118,8 @@
|
||||
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
<form
|
||||
action="{{ isset($debitur->id) ? route('debitur.update', $debitur->id) : route('surveyor.storeDenah') }}"
|
||||
method="POST" class="grid gap-5" enctype="multipart/form-data">
|
||||
|
||||
<form id="formDenah" method="POST" class="grid gap-5" enctype="multipart/form-data">
|
||||
@if (isset($debitur->id))
|
||||
<input type="hidden" name="id" value="{{ $debitur->id }}">
|
||||
@method('PUT')
|
||||
@@ -134,18 +134,27 @@
|
||||
<div>
|
||||
</div>
|
||||
<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>
|
||||
</label>
|
||||
<input type="file"
|
||||
value="{{ old('foto_denah', isset($denah->foto_denah) ? $denah->foto_denah : '') }}"
|
||||
name="foto_denah" class="file-input file-input-bordered w-full " accept="image/*">
|
||||
<div class="w-full grid gap-5">
|
||||
<img id="foto_denah"
|
||||
src="{{ isset($formFoto['foto_denah']) ? asset('storage/' . old('foto_denah', $formFoto['foto_denah'])) : '#' }}"
|
||||
alt="Gambar foto_denah" style="width: 30rem;">
|
||||
|
||||
|
||||
<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/*">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@error('foto_denah')
|
||||
<em class="alert text-danger text-sm">{{ $message }}</em>
|
||||
@enderror
|
||||
<em id="error-foto_denah" class="alert text-danger text-sm"></em>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -160,7 +169,7 @@
|
||||
<span class="form-label">Masukkan total luas tanah</span>
|
||||
</label>
|
||||
<input type="text" name="luas" class="input w-full "
|
||||
value="{{ old('luas', isset($denah->luas) ? $denah->luas : '') }}">
|
||||
value="{{ old('luas', isset($formDenah['luas']) ? $formDenah['luas'] : '') }}">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -170,15 +179,70 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end gap-2" style="margin-right: 20px; margin-top: 20px">
|
||||
<button type="submit" class="btn btn-success">
|
||||
Save
|
||||
<button type="button" class="btn btn-success" id="saveButton" onclick="submitDenah()">
|
||||
<span id="saveButtonText">Save</span>
|
||||
<div class="spinner-border spinner-border-sm text-light" role="status" style="display: none;"
|
||||
id="saveButtonSpinner">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
function submitDenah() {
|
||||
|
||||
const formElement = $('#formDenah')[0];
|
||||
const formData = new FormData(formElement);
|
||||
|
||||
// Disable the button and show the spinner
|
||||
$('#saveButton').prop('disabled', true);
|
||||
$('#saveButtonText').hide();
|
||||
$('#saveButtonSpinner').show();
|
||||
|
||||
$.ajax({
|
||||
url: '{{ route('surveyor.storeDenah') }}',
|
||||
type: 'POST',
|
||||
data: formData,
|
||||
processData: false,
|
||||
contentType: false,
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
window.location.href =
|
||||
'{{ route('surveyor.show', ['id' => $permohonan->id]) }}?form=denah';
|
||||
}
|
||||
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);
|
||||
},
|
||||
complete: function() {
|
||||
// Re-enable the button and hide the spinner
|
||||
$('#saveButton').prop('disabled', false);
|
||||
$('#saveButtonText').show();
|
||||
$('#saveButtonSpinner').hide();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
Reference in New Issue
Block a user