feat(spk): tambahkan fitur pembaruan SLA
- Menambahkan metode updateSla pada SpkController untuk memperbarui SLA. - Memvalidasi input SLA agar wajib diisi dan berupa angka positif. - Mengupdate tampilan untuk meminta input SLA sebelum membuat SPK. - Menambahkan rute baru untuk pembaruan SLA di registrasi.php.
This commit is contained in:
@@ -385,4 +385,17 @@ use Illuminate\Support\Facades\Auth;
|
|||||||
|
|
||||||
return response()->download(storage_path('app/public/' .$document->spk_dokumen_path));
|
return response()->download(storage_path('app/public/' .$document->spk_dokumen_path));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function updateSla(Request $request, $id): JsonResponse
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'sla' => 'required|integer|min:1',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$permohonan = Permohonan::where('nomor_registrasi','=',$id)->first();
|
||||||
|
$permohonan->sla = $request->sla;
|
||||||
|
$permohonan->save();
|
||||||
|
|
||||||
|
return response()->json(['message' => 'SLA updated successfully']);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,12 +98,63 @@
|
|||||||
|
|
||||||
@push('scripts')
|
@push('scripts')
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function spkCreate(regId)
|
function spkCreate(regId, sla)
|
||||||
{
|
{
|
||||||
var url1 = "/spk/"+regId+"/edit";
|
const csrf = '{{ @csrf_token() }}';
|
||||||
var url = "{{ url('/') }}"+url1;
|
if (!sla) {
|
||||||
$(location).attr('href',url);
|
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>
|
||||||
<script type="module">
|
<script type="module">
|
||||||
const element = document.querySelector('#spk-table');
|
const element = document.querySelector('#spk-table');
|
||||||
@@ -203,11 +254,12 @@
|
|||||||
actions: {
|
actions: {
|
||||||
title: 'Status',
|
title: 'Status',
|
||||||
render: (item, data) => {
|
render: (item, data) => {
|
||||||
|
console.log(data.id);
|
||||||
var spkShow ='';
|
var spkShow ='';
|
||||||
var spkCreate='';
|
var spkCreate='';
|
||||||
if(!data.spk_dokumen_path)
|
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>
|
<i class="ki-outline ki-notepad-edit"></i>
|
||||||
</a>`;
|
</a>`;
|
||||||
}
|
}
|
||||||
@@ -218,14 +270,14 @@
|
|||||||
<i class="ki-filled ki-cloud-download"></i>
|
<i class="ki-filled ki-cloud-download"></i>
|
||||||
</a> `;
|
</a> `;
|
||||||
if(data.status==='spk') {
|
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>
|
<i class="ki-outline ki-notepad-edit"></i>
|
||||||
</a>`;
|
</a>`;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return `<div class="flex flex-nowrap justify-center">`
|
return `<div class="flex flex-nowrap justify-center">`
|
||||||
+spkShow+spkCreate+
|
+spkShow+spkCreate+data.permohonan.sla+
|
||||||
`</div>`;
|
`</div>`;
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -110,6 +110,7 @@ Route::middleware(['auth'])->group(function () {
|
|||||||
|
|
||||||
Route::get('/spk', 'index')->name('spk.index');
|
Route::get('/spk', 'index')->name('spk.index');
|
||||||
Route::get('/spk/datatables', 'dataForDatatables')->name('spk.datatables');
|
Route::get('/spk/datatables', 'dataForDatatables')->name('spk.datatables');
|
||||||
|
Route::POST('/spk/update-sla/{id}', 'updateSla')->name('spk.update-sla');
|
||||||
Route::get('/spk/{spk}', 'show')->name('spk.show');
|
Route::get('/spk/{spk}', 'show')->name('spk.show');
|
||||||
Route::get('/spk/{spk}/edit', 'edit')->name('spk.edit');
|
Route::get('/spk/{spk}/edit', 'edit')->name('spk.edit');
|
||||||
Route::put('/spk/{spk}', 'update')->name('spk.update');
|
Route::put('/spk/{spk}', 'update')->name('spk.update');
|
||||||
|
|||||||
Reference in New Issue
Block a user