fix(so/dd/eo/penilai) : perbaikan otorisator pelaporan dan print out sedehana dan standar

This commit is contained in:
majid
2025-02-27 12:15:55 +07:00
parent fbabb2efaa
commit b8a492e842
5 changed files with 156 additions and 246 deletions

View File

@@ -134,9 +134,6 @@
<i class="ki-filled ki-double-check"></i>
Otorisator {{ $header ?? '' }}
</button>
<button class="btn btn-warning" onclick="revisiLaporan({{ $permohonan->id }})">
<i class="ki-filled ki-arrow-circle-right"></i> Revisi
</button>
@endif
@if (Auth::user()->hasAnyRole(['administrator', 'EO Appraisal']) &&
@@ -185,8 +182,7 @@
</button>
@endif
@if (Auth::user()->hasAnyRole(['administrator', 'EO Appraisal']) &&
$authorization->approve_eo == null)
@if (Auth::user()->hasAnyRole(['administrator', 'EO Appraisal']) && $authorization->approve_eo == null)
<button onclick="otorisatorData({{ $authorization->id }},'EO')" type="button"
class="btn btn-primary">
<i class="ki-filled ki-double-check"></i>
@@ -209,10 +205,38 @@
@push('scripts')
<script>
function otorisatorData(dataId, role = '') {
const dataHeader = @json($header);
if (dataHeader == 'Paparan') {
const showSwalConfirmation = (title, text, html, confirmText, denyText, cancelText, preConfirm) => {
const handleRejection = (dataId) => {
Swal.fire({
title: 'Masukkan alasan penolakan:',
input: 'textarea',
inputPlaceholder: 'Tuliskan alasan...',
showCancelButton: true,
confirmButtonColor: '#f39c12',
cancelButtonColor: '#d33',
confirmButtonText: 'Kirim',
cancelButtonText: 'Batal',
preConfirm: (alasan) => {
if (!alasan) {
Swal.showValidationMessage('Alasan harus diisi!');
return false;
}
return alasan;
}
}).then((rejectResult) => {
if (rejectResult.isConfirmed) {
handleAjaxRequest(
`/otorisator/revisi/${dataId}`, {
message: rejectResult.value
},
'Data berhasil ditolak.',
'Terjadi kesalahan saat melakukan penolakan.'
);
}
});
};
const showSwalConfirmation = (title, text, html, confirmText, denyText, cancelText, preConfirm) => {
return Swal.fire({
title: title,
text: text,
@@ -253,35 +277,12 @@
});
};
const handleRejection = (dataId) => {
Swal.fire({
title: 'Masukkan alasan penolakan:',
input: 'textarea',
inputPlaceholder: 'Tuliskan alasan...',
showCancelButton: true,
confirmButtonColor: '#f39c12',
cancelButtonColor: '#d33',
confirmButtonText: 'Kirim',
cancelButtonText: 'Batal',
preConfirm: (alasan) => {
if (!alasan) {
Swal.showValidationMessage('Alasan harus diisi!');
return false;
}
return alasan;
}
}).then((rejectResult) => {
if (rejectResult.isConfirmed) {
handleAjaxRequest(
`/otorisator/revisi/${dataId}`, {
message: rejectResult.value
},
'Data berhasil ditolak.',
'Terjadi kesalahan saat melakukan penolakan.'
);
}
});
};
function otorisatorData(dataId, role = '') {
const dataHeader = @json($header);
if (dataHeader == 'Paparan') {
// Main logic based on role
if (role === 'SO') {
@@ -395,49 +396,38 @@
}
} else {
Swal.fire({
title: 'Apakah Anda yakin?',
text: `Untuk melakukan otorisator ${dataHeader}!`,
icon: 'warning',
input: 'textarea',
inputLabel: 'Keterangan',
inputPlaceholder: 'Masukkan keterangan...',
inputAttributes: {
'aria-label': 'Masukkan keterangan'
},
showCancelButton: true,
confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33',
confirmButtonText: 'Ya, Lanjutkan!',
cancelButtonText: 'Batal',
}).then((result) => {
showSwalConfirmation(
'Apakah Yakin?',
'Pastikan sudah dilakukan!',
`
<p class="text-gray-700 text-center">Untuk melakukan otorisator ${dataHeader}!</p>
<textarea id="swal-keterangan" class="block w-full px-4 py-2 border border-gray-300 rounded-lg shadow-sm focus:ring-blue-500 focus:border-blue-500 sm:text-sm" placeholder="Masukkan keterangan..."></textarea>
`,
'Ya, Lanjutkan!', 'Rejected', 'Batal',
() => {
const keterangan = document.getElementById('swal-keterangan').value;
if (!keterangan) {
Swal.showValidationMessage('Keterangan harus diisi!');
return false;
}
return {
keterangan
};
}
).then((result) => {
if (result.isConfirmed) {
const userMessage = result.value || ''; // Ambil pesan dari textarea
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
handleAjaxRequest(
`/otorisator/otorisator/${dataId}/${dataHeader}`, {
message: result.value.keterangan
},
});
$.ajax({
url: `/otorisator/otorisator/${dataId}/${dataHeader}`,
type: 'POST',
data: {
message: userMessage
},
success: (response) => {
Swal.fire('Berhasil!',
'Data berhasil diotorisasi. Menunggu Approval EO dan atau DD',
'success').then(() => {
window.location.reload();
});
console.log(response);
},
error: (error) => {
console.error('Error:', error);
Swal.fire('Gagal!', 'Terjadi kesalahan saat melakukan otorisator.',
'error');
}
});
'Data berhasil diotorisasi.',
'Terjadi kesalahan saat melakukan otorisator.'
);
} else if (result.isDenied) {
handleRejection(dataId);
}
});
}