update form data surveyor
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
<div class="card min-w-full">
|
||||
<div class="card-header">
|
||||
<h3 class="card-title">
|
||||
Data Jaminan
|
||||
Form Inspeksi
|
||||
</h3>
|
||||
<div class="flex items-center gap-2">
|
||||
<a href="{{ route('surveyor.show', ['id' => request('inspeksi')]) }}?form=inspeksi"
|
||||
@@ -19,107 +19,6 @@
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@php
|
||||
$jenisJaminanData = null;
|
||||
|
||||
@endphp
|
||||
|
||||
<div data-accordion="true">
|
||||
@foreach ($permohonan->debiture->documents as $dokumen)
|
||||
@php
|
||||
$jenisJaminanData = $dokumen->jenisJaminan->name ?? '';
|
||||
@endphp
|
||||
|
||||
<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="#accordion_detail_jaminan_{{ $loop->index }}">
|
||||
<span class="text-base text-gray-900 font-medium">
|
||||
Jaminan {{ $loop->index + 1 }}
|
||||
</span>
|
||||
<i class="ki-outline ki-plus text-gray-600 text-2sm accordion-active:hidden block">
|
||||
</i>
|
||||
<i class="ki-outline ki-minus text-gray-600 text-2sm accordion-active:block hidden">
|
||||
</i>
|
||||
</button>
|
||||
<div class="accordion-content hidden" id="accordion_detail_jaminan_{{ $loop->index }}">
|
||||
<div class="card-body lg:py-7.5 grid grid-cols-2">
|
||||
<div class="mb-5">
|
||||
<h3 class="text-md font-medium text-gray-900">
|
||||
Pemilik Jaminan:
|
||||
</h3>
|
||||
<span class="text-2sm text-gray-700">
|
||||
{{ $dokumen->pemilik->name ?? '' }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mb-5">
|
||||
<h3 class="text-md font-medium text-gray-900">
|
||||
Jenis Jaminan:
|
||||
</h3>
|
||||
<span class="text-2sm text-gray-700">
|
||||
{{ $dokumen->jenisJaminan->name ?? '' }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mb-5">
|
||||
<h3 class="text-md font-medium text-gray-900">
|
||||
Hubungan Pemilik Jaminan:
|
||||
</h3>
|
||||
<span class="text-2sm text-gray-700">
|
||||
{{ $dokumen->pemilik->hubungan_pemilik->name ?? '' }}
|
||||
</span>
|
||||
</div>
|
||||
<div class="mb-5">
|
||||
<h3 class="text-md font-medium text-gray-900">
|
||||
Alamat Pemilik Jaminan:
|
||||
</h3>
|
||||
<span class="text-2sm text-gray-700">
|
||||
{{ $dokumen->pemilik->address ?? '' }},
|
||||
<br> {{ $dokumen->pemilik->village->name ?? '' }},
|
||||
{{ $dokumen->pemilik->district->name ?? '' }},
|
||||
{{ $dokumen->pemilik->city->name ?? '' }},
|
||||
{{ $dokumen->pemilik->province->name ?? '' }} -
|
||||
{{ $dokumen->pemilik->village->postal_code ?? '' }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-table scrollable-x-auto pb-3">
|
||||
<table class="table align-middle text-sm text-gray-500">
|
||||
@foreach ($dokumen->detail as $detail)
|
||||
<tr>
|
||||
<td class="py-2 text-gray-600 font-normal max-w-[100px]">
|
||||
{{ $loop->index + 1 }}. {{ $detail->jenisLegalitasJaminan->name }}
|
||||
</td>
|
||||
<td class="py-2 text-gray-800 font-normaltext-sm">
|
||||
{{ $detail->name ?? '' }}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="py-3 max-w-[100px]">
|
||||
Dokumen Jaminan
|
||||
</td>
|
||||
<td class="py-3 text-gray-700 text-2sm font-normal">
|
||||
@if (isset($detail->dokumen_jaminan))
|
||||
<a href="{{ route('debitur.jaminan.download', ['id' => $permohonan->debiture->id, 'dokumen' => $detail->id]) }}"
|
||||
class="badge badge-sm badge-outline mt-2">{{ basename($detail->dokumen_jaminan) }}
|
||||
<i class="ki-filled ki-cloud-download"></i></a>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="py-3 max-w-[100px]">
|
||||
Keterangan
|
||||
</td>
|
||||
<td class="py-3 text-gray-700 text-2sm font-normal">
|
||||
{{ $detail->keterangan ?? '' }}
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -128,91 +27,44 @@
|
||||
{{-- <div class="card">
|
||||
<div class="card-body"> --}}
|
||||
<form id="formInspeksi" method="POST" enctype="multipart/form-data" class="grid gap-5">
|
||||
@if (isset($analisa->id))
|
||||
<input type="hidden" name="id" value="{{ $analisa->id }}">
|
||||
@method('PUT')
|
||||
@endif
|
||||
@csrf
|
||||
|
||||
<input type="hidden" name="permohonan_id" value="{{ $permohonan->id }}">
|
||||
<input type="hidden" name="jenis_jaminan_id" value="{{ request('jenis_jaminan') }}">
|
||||
|
||||
@php
|
||||
$analisaType = 'unknown';
|
||||
$data = [
|
||||
'tanah' => 'Tanah',
|
||||
'unit_rumah' => 'Rumah Tinggal / Ruko (Unit) / Apartemen (Unit) / Gudang',
|
||||
'tanah_bangunan' => 'Kawasan Industrial / Komersil / Residensial - Perumahan',
|
||||
'unit_gedung' => 'Gedung Apartement / Kantor / Condotel (Strata Title)',
|
||||
'tanah_bangunan' => 'Mall',
|
||||
];
|
||||
|
||||
if (isset($analisa->id)) {
|
||||
$analisaType = $analisa->type;
|
||||
} else {
|
||||
foreach ($data as $key => $value) {
|
||||
if (
|
||||
isset($jenisJaminanData) &&
|
||||
trim(strtolower($jenisJaminanData)) === trim(strtolower($value))
|
||||
) {
|
||||
$analisaType = $key;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($analisaType === 'tanah') {
|
||||
$analisaType = 'tanah_bangunan';
|
||||
}
|
||||
|
||||
if ($analisaType === 'unit_rumah' || $analisaType === 'unit_gedung') {
|
||||
$analisaType = 'unit';
|
||||
}
|
||||
|
||||
@endphp
|
||||
|
||||
<input type="hidden" name="action" value="{{ $analisaType }}">
|
||||
<input type="hidden" name="type" value="{{ $analisaType }}">
|
||||
|
||||
@if ($analisaType == 'tanah_bangunan')
|
||||
@include('lpj::surveyor.components.tanah')
|
||||
@elseif($analisaType == 'unit')
|
||||
@include('lpj::surveyor.components.apartemen-kantor')
|
||||
@elseif($analisaType == 'alat-berat')
|
||||
@include('lpj::surveyor.components.alat-berat')
|
||||
@elseif($analisaType == 'mesin')
|
||||
@include('lpj::surveyor.components.mesin')
|
||||
@elseif($analisaType == 'kapal')
|
||||
@include('lpj::surveyor.components.kapal')
|
||||
@elseif($analisaType == 'kendaraan')
|
||||
@include('lpj::surveyor.components.kendaraan')
|
||||
@elseif($analisaType == 'pesawat')
|
||||
@include('lpj::surveyor.components.pesawat')
|
||||
@endif
|
||||
|
||||
@if ($analisaType == 'tanah_bangunan')
|
||||
@include('lpj::surveyor.components.bangunan')
|
||||
@endif
|
||||
|
||||
@if ($analisaType != 'mesin' && $analisaType != 'kapal' && $analisaType != 'kendaraan' && $analisaType != 'pesawat')
|
||||
@include('lpj::surveyor.components.lingkungan')
|
||||
@endif
|
||||
|
||||
|
||||
@include('lpj::surveyor.components.fakta')
|
||||
@foreach ($permohonan->debiture->documents as $dokumen)
|
||||
@if ($dokumen->jenisJaminan)
|
||||
@php
|
||||
$formKategori = json_decode($dokumen->jenisJaminan->form_kategori, true);
|
||||
@endphp
|
||||
<input type="hidden" name="action"
|
||||
value="{{ is_array($formKategori) ? implode(',', $formKategori) : $formKategori }}">
|
||||
<input type="hidden" name="type"
|
||||
value="{{ is_array($formKategori) ? implode(',', $formKategori) : $formKategori }}">
|
||||
@if (is_array($formKategori))
|
||||
@foreach ($formKategori as $kategori)
|
||||
@include('lpj::surveyor.components.' . str_replace('-', '_', $kategori), [
|
||||
'dokumen' => $dokumen,
|
||||
])
|
||||
@endforeach
|
||||
@endif
|
||||
@endif
|
||||
@endforeach
|
||||
|
||||
<div class="flex justify-end gap-2" style="margin-right: 20px; margin-top: 20px">
|
||||
<button type="button" class="btn btn-success" id="saveButton" onclick="submitData()">
|
||||
<span id="saveButtonText">Save</span>
|
||||
<div class="spinner-border spinner-border-sm text-light" role="status" style="display: none;" id="saveButtonSpinner">
|
||||
<div class="spinner-border spinner-border-sm text-light" role="status" style="display: none;"
|
||||
id="saveButtonSpinner">
|
||||
<span class="visually-hidden">Loading...</span>
|
||||
</div>
|
||||
</button>
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
{{-- </div>
|
||||
</div> --}}
|
||||
</div>
|
||||
|
||||
@endsection
|
||||
@push('scripts')
|
||||
<script>
|
||||
@@ -269,50 +121,50 @@
|
||||
}
|
||||
|
||||
function submitData() {
|
||||
const formElement = $('#formInspeksi')[0];
|
||||
const formData = new FormData(formElement);
|
||||
const formElement = $('#formInspeksi')[0];
|
||||
const formData = new FormData(formElement);
|
||||
|
||||
// Disable the button and show the spinner
|
||||
$('#saveButton').prop('disabled', true);
|
||||
$('#saveButtonText').hide();
|
||||
$('#saveButtonSpinner').show();
|
||||
// Disable the button and show the spinner
|
||||
$('#saveButton').prop('disabled', true);
|
||||
$('#saveButtonText').hide();
|
||||
$('#saveButtonSpinner').show();
|
||||
|
||||
$.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) {
|
||||
window.location.href =
|
||||
'{{ route('surveyor.show', ['id' => $permohonan->id]) }}?form=inspeksi';
|
||||
$.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) {
|
||||
window.location.href =
|
||||
'{{ route('surveyor.show', ['id' => $permohonan->id]) }}?form=inspeksi';
|
||||
}
|
||||
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();
|
||||
}
|
||||
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