update memo, lpj, resume, dan perbaikan form inspeksi
This commit is contained in:
@@ -5,6 +5,7 @@
|
||||
@endsection
|
||||
|
||||
@section('content')
|
||||
@include('lpj::assetsku.includenya')
|
||||
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
|
||||
<div class="card pb-2.5">
|
||||
<div class="card-header" id="basic_settings">
|
||||
@@ -174,8 +175,6 @@
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -188,7 +187,7 @@
|
||||
<a class="btn btn-primary" data-modal-toggle="#modal_2">
|
||||
KERTAS KERJA
|
||||
</a>
|
||||
<a class="btn btn-primary" href="#">
|
||||
<a class="btn btn-primary" href="{{ route('penilai.paparan') }}">
|
||||
PAPARAN
|
||||
</a>
|
||||
|
||||
@@ -196,10 +195,17 @@
|
||||
<button class="dropdown-toggle btn btn-primary">
|
||||
WORKSHEET
|
||||
</button>
|
||||
@php
|
||||
$inspeksiId = null;
|
||||
foreach ($dokumen->inspeksi as $item) {
|
||||
$inspeksiId = $item->id;
|
||||
}
|
||||
@endphp
|
||||
<div class="dropdown-content w-full max-w-56 py-2">
|
||||
<div class="menu menu-default flex flex-col w-full">
|
||||
<div class="menu-item">
|
||||
<a class="menu-link" href="{{ route('penilai.memo', $permohonan->id) }}">
|
||||
<a class="menu-link"
|
||||
onclick="memo('{{ $permohonan->id }}', '{{ $dokumen->id }}', '{{ $inspeksiId }}', {{ $dokumen->jenis_jaminan_id }})">
|
||||
<span class="menu-icon">
|
||||
<i class="ki-outline ki-badge">
|
||||
</i>
|
||||
@@ -210,7 +216,8 @@
|
||||
</a>
|
||||
</div>
|
||||
<div class="menu-item">
|
||||
<a class="menu-link" href="{{ route('penilai.resume', $permohonan->id) }}">
|
||||
<a class="menu-link"
|
||||
onclick="resume('{{ $permohonan->id }}', '{{ $dokumen->id }}', '{{ $inspeksiId }}', {{ $dokumen->jenis_jaminan_id }})">
|
||||
<span class="menu-icon">
|
||||
<i class="ki-outline ki-profile-circle">
|
||||
</i>
|
||||
@@ -220,20 +227,21 @@
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
<div class="menu-item">
|
||||
<a class="menu-link" onclick="seletSederhanaStandart()">
|
||||
<span class="menu-icon">
|
||||
<i class="ki-outline ki-setting-2">
|
||||
</i>
|
||||
</span>
|
||||
<span class="menu-title">
|
||||
LPJ
|
||||
</span>
|
||||
|
||||
|
||||
<div class="menu-item">
|
||||
<a class="menu-link"
|
||||
onclick="seletSederhanaStandart('{{ $permohonan->id }}', '{{ $dokumen->id }}', '{{ $inspeksiId }}', {{ $dokumen->jenis_jaminan_id }})">
|
||||
<span class="menu-icon">
|
||||
<i class="ki-outline ki-setting-2"></i>
|
||||
</span>
|
||||
<span class="menu-title">LPJ</span>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="menu-item">
|
||||
<a class="menu-link" href="#">
|
||||
<a class="menu-link"
|
||||
onclick="rap('{{ $permohonan->id }}', '{{ $dokumen->id }}', '{{ $inspeksiId }}', {{ $dokumen->jenis_jaminan_id }})">
|
||||
<span class="menu-icon">
|
||||
<i class="ki-outline ki-message-programming">
|
||||
</i>
|
||||
@@ -249,15 +257,10 @@
|
||||
</div>
|
||||
|
||||
<div class="flex justify-end gap-5">
|
||||
<a class="btn btn-success" href="#">
|
||||
SAVE
|
||||
</a>
|
||||
|
||||
<a class="btn btn-success" href="#">
|
||||
REPORT
|
||||
</a>
|
||||
|
||||
|
||||
<a class="btn btn-success" href="#">
|
||||
PRINT OUT
|
||||
</a>
|
||||
@@ -265,9 +268,14 @@
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
@endforeach
|
||||
|
||||
<div class="flex justify-start gap-5">
|
||||
<a class="btn btn-success" onclick="savePenilai()">
|
||||
SAVE
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -285,26 +293,35 @@
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body grid gap-5">
|
||||
@php
|
||||
$jenisJaminanId = null;
|
||||
$inspeksiId = null;
|
||||
$documentId = null;
|
||||
foreach ($permohonan->debiture->documents as $item) {
|
||||
$documentId = $item->id;
|
||||
}
|
||||
foreach ($dokumen->inspeksi as $item) {
|
||||
$inspeksiId = $item->id;
|
||||
}
|
||||
@endphp
|
||||
@foreach ($permohonan->debiture->documents as $document)
|
||||
@if ($document->jenisjaminan)
|
||||
@php
|
||||
$jenisJaminanId = $document->jenisjaminan->id;
|
||||
@endphp
|
||||
@endif
|
||||
@endforeach
|
||||
<div class="flex items-baseline w-full">
|
||||
<label for="" class="form-label max-w-56">Import Kertas Kerja</label>
|
||||
|
||||
<div class="flex justify-center items-center gap-2">
|
||||
<input type="file" name="" id="" class="file-input">
|
||||
<input type="file" id="kertas_kerja" class="file-input">
|
||||
<button type="button" class="btn btn-outline btn-success"
|
||||
onclick="uploadKertasKerja()">Upload</button>
|
||||
onclick="uploadKertasKerja({{ $permohonan->id }}, '{{ $documentId }}', '{{ $inspeksiId }}', '{{ $jenisJaminanId }}')">Upload</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group flex items-baseline flex-wrap">
|
||||
@php
|
||||
$jenisJaminanId = null;
|
||||
@endphp
|
||||
@foreach ($permohonan->debiture->documents as $document)
|
||||
@if ($document->jenisjaminan)
|
||||
@php
|
||||
$jenisJaminanId = $document->jenisjaminan->id;
|
||||
@endphp
|
||||
@endif
|
||||
@endforeach
|
||||
|
||||
@if ($jenisJaminanId)
|
||||
<a class="btn btn-outline btn-primary w-full"
|
||||
href="{{ route('penilai.export.kertas-kerja', ['id' => $permohonan->id, 'jaminanId' => $jenisJaminanId]) }}">
|
||||
@@ -325,42 +342,184 @@
|
||||
|
||||
|
||||
<script>
|
||||
function seletSederhanaStandart() {
|
||||
Swal.fire({
|
||||
title: 'Apakah kamu akan memilih lpj standar?',
|
||||
icon: 'warning',
|
||||
showDenyButton: true,
|
||||
showCancelButton: false,
|
||||
confirmButtonText: 'Yes',
|
||||
denyButtonText: 'No',
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
window.location.href = "{{ route('penilai.standard', $permohonan->id) }}";
|
||||
} else if (result.isDenied) {
|
||||
window.location.href = "{{ route('penilai.sederhana', $permohonan->id) }}";
|
||||
}
|
||||
})
|
||||
function seletSederhanaStandart(permohonanId, documentId, inspeksiId, jaminanId) {
|
||||
fetch(
|
||||
`{{ url('/penilai/check-status-lpj') }}?permohonanId=${permohonanId}&documentId=${documentId}&inspeksiId=${inspeksiId}`
|
||||
)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.status) {
|
||||
// Jika status LPJ sudah ada, arahkan langsung ke halaman
|
||||
if (data.status === 'standar') {
|
||||
showLoadingSwal('Tunggu ...');
|
||||
window.location.href =
|
||||
`{{ route('penilai.standard', $permohonan->id) }}?documentId=${documentId}&inspeksiId=${inspeksiId}&jaminanId=${jaminanId}`;
|
||||
} else if (data.status === 'sederhana') {
|
||||
showLoadingSwal('Tunggu ...');
|
||||
window.location.href =
|
||||
`{{ route('penilai.sederhana', $permohonan->id) }}?documentId=${documentId}&inspeksiId=${inspeksiId}&jaminanId=${jaminanId}`;
|
||||
}
|
||||
} else {
|
||||
Swal.fire({
|
||||
title: 'Pilih Jenis LPJ',
|
||||
text: 'Apakah kamu akan memilih LPJ Standar?',
|
||||
icon: 'question',
|
||||
showCloseButton: true,
|
||||
showDenyButton: true,
|
||||
confirmButtonText: 'LPJ Standar',
|
||||
denyButtonText: 'LPJ Sederhana',
|
||||
confirmButtonColor: '#3085d6',
|
||||
denyButtonColor: '#d33',
|
||||
}).then((result) => {
|
||||
if (result.isConfirmed) {
|
||||
saveStatusLpj(permohonanId, documentId, inspeksiId, 'standar', jaminanId);
|
||||
} else if (result.isDenied) {
|
||||
saveStatusLpj(permohonanId, documentId, inspeksiId, 'sederhana', jaminanId);
|
||||
}
|
||||
});
|
||||
}
|
||||
console.log(data);
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function saveStatusLpj(permohonanId, documentId, inspeksiId, type, jaminanId) {
|
||||
fetch(`{{ url('/penilai/save-status-lpj') }}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}',
|
||||
},
|
||||
body: JSON.stringify({
|
||||
permohonan_id: permohonanId,
|
||||
document_id: documentId,
|
||||
inspeksi_id: inspeksiId,
|
||||
type: type
|
||||
}),
|
||||
}).then(response => response.json())
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
if (type === 'standar') {
|
||||
window.location.href =
|
||||
`{{ route('penilai.standard', $permohonan->id) }}?documentId=${documentId}&inspeksiId=${inspeksiId}&jaminanId=${jaminanId}`;
|
||||
} else if (type === 'sederhana') {
|
||||
window.location.href =
|
||||
`{{ route('penilai.sederhana', $permohonan->id) }}?documentId=${documentId}&inspeksiId=${inspeksiId}&jaminanId=${jaminanId}`;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function uploadKertasKerja() {
|
||||
showLoadingSwal('Mengirim data ke server...');
|
||||
|
||||
Swal.fire({
|
||||
title: 'Berhasil!',
|
||||
text: response.message,
|
||||
icon: 'success',
|
||||
timer: 2000,
|
||||
timerProgressBar: true,
|
||||
didOpen: () => {
|
||||
Swal.showLoading()
|
||||
},
|
||||
willClose: () => {
|
||||
hideLoadingSwal();
|
||||
function uploadKertasKerja(permohonanId, documentId, inspeksiId, jaminanId) {
|
||||
const kertasKerjaInput = document.getElementById('kertas_kerja');
|
||||
if (!kertasKerjaInput.files.length) {
|
||||
Swal.fire({
|
||||
title: 'Error!',
|
||||
text: 'Silakan pilih file sebelum mengupload.',
|
||||
icon: 'error',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const kertasKerja = kertasKerjaInput.files[0];
|
||||
const formData = new FormData();
|
||||
formData.append('permohonan_id', permohonanId);
|
||||
formData.append('document_id', documentId);
|
||||
formData.append('inspeksi_id', inspeksiId);
|
||||
formData.append('jenis_jaminan_id', jaminanId);
|
||||
formData.append('kertas_kerja', kertasKerja);
|
||||
|
||||
fetch(`{{ url('/penilai/import/kertas-kerja') }}`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}',
|
||||
},
|
||||
body: formData,
|
||||
})
|
||||
.then(response => response.json()) // Pastikan respons diurai menjadi JSON
|
||||
.then(data => {
|
||||
if (data.success) {
|
||||
Swal.fire({
|
||||
title: 'Berhasil!',
|
||||
text: data.message || 'Kertas kerja berhasil diunggah.',
|
||||
icon: 'success',
|
||||
confirmButtonText: 'OK'
|
||||
}).then(result => {
|
||||
if (result.isConfirmed) {
|
||||
window.location.reload();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
Swal.fire({
|
||||
title: 'Error!',
|
||||
text: data.message || 'Terjadi kesalahan.',
|
||||
icon: 'error',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
Swal.fire({
|
||||
title: 'Error!',
|
||||
text: 'Terjadi kesalahan saat mengunggah file.',
|
||||
icon: 'error',
|
||||
confirmButtonText: 'OK'
|
||||
});
|
||||
console.error('Error:', error); // Debug error di konsol
|
||||
});
|
||||
}
|
||||
|
||||
function resume(permohonanId, documentId, inspeksiId, jaminanId) {
|
||||
showLoadingSwal('Tunggu ...');
|
||||
window.location.href =
|
||||
`{{ route('penilai.resume') }}?permohonanId=${permohonanId}&documentId=${documentId}&inspeksiId=${inspeksiId}&jaminanId=${jaminanId}`;
|
||||
}
|
||||
|
||||
function memo(permohonanId, documentId, inspeksiId, jaminanId) {
|
||||
showLoadingSwal('Tunggu ...');
|
||||
window.location.href =
|
||||
`{{ route('penilai.memo') }}?permohonanId=${permohonanId}&documentId=${documentId}&inspeksiId=${inspeksiId}&jaminanId=${jaminanId}`;
|
||||
}
|
||||
|
||||
function rap(permohonanId, documentId, inspeksiId, jaminanId) {
|
||||
showLoadingSwal('Tunggu ...');
|
||||
window.location.href =
|
||||
`{{ route('penilai.rap') }}?permohonanId=${permohonanId}&documentId=${documentId}&inspeksiId=${inspeksiId}&jaminanId=${jaminanId}`;
|
||||
}
|
||||
|
||||
|
||||
function savePenilai() {
|
||||
showLoadingSwal('Mengirim data keserver ...');
|
||||
$.ajax({
|
||||
url: "{{ route('penilai.proses.laporan', ['id' => $permohonan->id]) }}",
|
||||
type: "POST",
|
||||
headers: {
|
||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||
},
|
||||
success: function(response) {
|
||||
if (response.success) {
|
||||
// window.location.reload();
|
||||
hideLoadingSwal();
|
||||
toastrSuccessBuild(response.message);
|
||||
}
|
||||
},
|
||||
error: function(xhr, status, error) {
|
||||
console.log('Error checking button status:', error, status, xhr);
|
||||
if (xhr.responseJSON.message) {
|
||||
// window.location.reload();
|
||||
toastrErrorBuild(xhr.responseJSON.message);
|
||||
} else {
|
||||
// window.location.reload();
|
||||
toastrErrorBuild('Terjadi kesalahan');
|
||||
}
|
||||
hideLoadingSwal();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
</script>
|
||||
|
||||
@include('lpj::surveyor.js.utils')
|
||||
|
||||
Reference in New Issue
Block a user