Merge branch 'staging' of https://git.putrakuningan.com/daengdeni/lpj into tender

This commit is contained in:
2025-03-05 13:24:17 +07:00
3 changed files with 72 additions and 6 deletions

View File

@@ -98,12 +98,63 @@
@push('scripts')
<script type="text/javascript">
function spkCreate(regId)
function spkCreate(regId, sla)
{
var url1 = "/spk/"+regId+"/edit";
var url = "{{ url('/') }}"+url1;
$(location).attr('href',url);
const csrf = '{{ @csrf_token() }}';
if (!sla) {
Swal.fire({
title: 'Input SLA',
input: 'number',
inputAttributes: {
min: 1,
step: 1
},
showCancelButton: true,
confirmButtonText: 'Submit',
showLoaderOnConfirm: true,
preConfirm: (inputValue) => {
if (inputValue) {
return fetch(`/spk/update-sla/${regId}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': `${csrf}`
},
body: JSON.stringify({ sla: inputValue })
})
.then(response => {
if (!response.ok) {
throw new Error(response.statusText)
}
return response.json()
})
.catch(error => {
Swal.showValidationMessage(
`Request failed: ${error}`
)
})
} else {
Swal.showValidationMessage('SLA is required')
}
},
allowOutsideClick: () => !Swal.isLoading()
}).then((result) => {
if (result.isConfirmed) {
Swal.fire({
title: 'SLA updated successfully',
icon: 'success'
}).then(() => {
// Redirect to edit page after successful SLA update
window.location.href = "{{ url('/') }}/spk/"+regId+"/edit";
});
}
});
} else {
// If SLA is not empty, directly redirect to edit page
window.location.href = "{{ url('/') }}/spk/"+regId+"/edit";
}
}
</script>
<script type="module">
const element = document.querySelector('#spk-table');
@@ -203,11 +254,12 @@
actions: {
title: 'Status',
render: (item, data) => {
console.log(data.id);
var spkShow ='';
var spkCreate='';
if(!data.spk_dokumen_path)
{
spkCreate=`<a class="btn btn-sm btn-icon btn-clear btn-info" title="Buat SPK" onclick="spkCreate(${data.id})" >
spkCreate=`<a class="btn btn-sm btn-icon btn-clear btn-info" title="Buat SPK" onclick="spkCreate(${data.id}, ${data.permohonan.sla})" >
<i class="ki-outline ki-notepad-edit"></i>
</a>`;
}
@@ -218,7 +270,7 @@
<i class="ki-filled ki-cloud-download"></i>
</a> `;
if(data.status==='spk') {
spkCreate = `<a class="btn btn-sm btn-icon btn-clear btn-info" title="Buat SPK" onclick="spkCreate(${data.id})" >
spkCreate = `<a class="btn btn-sm btn-icon btn-clear btn-info" title="Buat SPK" onclick="spkCreate(${data.id}, ${data.permohonan.sla})" >
<i class="ki-outline ki-notepad-edit"></i>
</a>`;
}