refactor(routes): hapus route destroy untuk jenis lampiran
- Menghapus route untuk menghapus jenis lampiran dari file routes/web.php. - Memperbarui query pada PenilaianController untuk memuat relasi lampiran dokumen dan jenis lampiran.
This commit is contained in:
@@ -437,10 +437,10 @@ class PenilaianController extends Controller
|
|||||||
$header = $headers[$type] ?? 'Pelaporan';
|
$header = $headers[$type] ?? 'Pelaporan';
|
||||||
$authorization = null;
|
$authorization = null;
|
||||||
if ($header === 'SLA') {
|
if ($header === 'SLA') {
|
||||||
$authorization = Authorization::with(['user'])->find($id);
|
$authorization = Authorization::with(['user','permohonan.lampiranDokumen.jenisLampiran'])->find($id);
|
||||||
$permohonan = Permohonan::find($authorization->permohonan_id);
|
$permohonan = Permohonan::with(['lampiranDokumen.jenisLampiran'])->find($authorization->permohonan_id);
|
||||||
} else {
|
} else {
|
||||||
$permohonan = Permohonan::find($id);
|
$permohonan = Permohonan::with(['lampiranDokumen.jenisLampiran'])->find($id);
|
||||||
}
|
}
|
||||||
if ($header === 'SLA') {
|
if ($header === 'SLA') {
|
||||||
return view('lpj::penilaian.otorisator.sla', compact('permohonan', 'header', 'authorization'));
|
return view('lpj::penilaian.otorisator.sla', compact('permohonan', 'header', 'authorization'));
|
||||||
|
|||||||
@@ -82,18 +82,18 @@
|
|||||||
{{ $authorization->keterangan ?? '' }}
|
{{ $authorization->keterangan ?? '' }}
|
||||||
<table class="table table-border">
|
<table class="table table-border">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Pemohon</td>
|
<td>Pemohon</td>
|
||||||
<td>{{ $authorization->user->name }}</td>
|
<td>{{ $authorization->user->name }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Alasan</td>
|
<td>Alasan</td>
|
||||||
<td>{{ $authorization->keterangan }}</td>
|
<td>{{ $authorization->keterangan }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Tanggal Permohonan</td>
|
<td>Tanggal Permohonan</td>
|
||||||
<td>{{ formatTanggalIndonesia($authorization->created_at, 1) }}</td>
|
<td>{{ formatTanggalIndonesia($authorization->created_at, 1) }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@@ -116,28 +116,28 @@
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<table class="table table-border">
|
<table class="table table-border">
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>Diperiksa Oleh</td>
|
||||||
|
<td>{{ getUser($authorization->approve_so)->name ?? 'N/A' }}</td>
|
||||||
|
<td>{{ $authorization->approve_so_at ? formatTanggalIndonesia($authorization->approve_so_at, 1) : 'N/A' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
@if ($authorization->approve_eo != null)
|
||||||
<tr>
|
<tr>
|
||||||
<td>Diperiksa Oleh</td>
|
<td>Disetujui Oleh (EO)</td>
|
||||||
<td>{{ getUser($authorization->approve_so)->name ?? 'N/A' }}</td>
|
<td>{{ getUser($authorization->approve_eo)->name ?? 'N/A' }}</td>
|
||||||
<td>{{ $authorization->approve_so_at ? formatTanggalIndonesia($authorization->approve_so_at, 1) : 'N/A' }}
|
<td>{{ $authorization->approve_eo_at ? formatTanggalIndonesia($authorization->approve_eo_at, 1) : 'N/A' }}
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
@if ($authorization->approve_eo != null)
|
@endif
|
||||||
<tr>
|
@if (in_array($authorization->nilai_eafond_id, [1, 4]) && $authorization->approve_dd != null)
|
||||||
<td>Disetujui Oleh (EO)</td>
|
<tr>
|
||||||
<td>{{ getUser($authorization->approve_eo)->name ?? 'N/A' }}</td>
|
<td>Disetujui Oleh (DD)</td>
|
||||||
<td>{{ $authorization->approve_eo_at ? formatTanggalIndonesia($authorization->approve_eo_at, 1) : 'N/A' }}
|
<td>{{ getUser($authorization->approve_dd)->name ?? 'N/A' }}</td>
|
||||||
</td>
|
<td>{{ $authorization->approve_dd_at ? formatTanggalIndonesia($authorization->approve_dd_at, 1) : 'N/A' }}
|
||||||
</tr>
|
</td>
|
||||||
@endif
|
</tr>
|
||||||
@if (in_array($authorization->nilai_eafond_id, [1, 4]) && $authorization->approve_dd != null)
|
@endif
|
||||||
<tr>
|
|
||||||
<td>Disetujui Oleh (DD)</td>
|
|
||||||
<td>{{ getUser($authorization->approve_dd)->name ?? 'N/A' }}</td>
|
|
||||||
<td>{{ $authorization->approve_dd_at ? formatTanggalIndonesia($authorization->approve_dd_at, 1) : 'N/A' }}
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
@endif
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@@ -161,14 +161,14 @@
|
|||||||
|
|
||||||
@if ($dataHeader == 'pelaporan')
|
@if ($dataHeader == 'pelaporan')
|
||||||
<a class="btn btn-success"
|
<a class="btn btn-success"
|
||||||
href="{{ route('otorisator.view-laporan') }}?permohonanId={{ $permohonan->id }}&documentId={{ $documentId }}&inspeksiId={{ $inspeksiId }}&jaminanId={{ $jenisJaminanId }}&statusLpj={{ true }}">
|
href="{{ route('otorisator.view-laporan') }}?permohonanId={{ $permohonan->id }}&documentId={{ $documentId }}&inspeksiId={{ $inspeksiId }}&jaminanId={{ $jenisJaminanId }}&statusLpj={{ true }}">
|
||||||
Lihat Laporan
|
Lihat Laporan
|
||||||
</a>
|
</a>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if (Auth::user()->hasAnyRole(['administrator', 'senior-officer']) && $authorization->approve_so == null)
|
@if (Auth::user()->hasAnyRole(['administrator', 'senior-officer']) && $authorization->approve_so == null)
|
||||||
<button onclick="otorisatorData({{ $authorization->id }}, 'SO')" type="button"
|
<button onclick="otorisatorData({{ $authorization->id }}, 'SO')" type="button"
|
||||||
class="btn btn-primary">
|
class="btn btn-primary">
|
||||||
<i class="ki-filled ki-double-check"></i>
|
<i class="ki-filled ki-double-check"></i>
|
||||||
Otorisasi {{ $header ?? '' }}
|
Otorisasi {{ $header ?? '' }}
|
||||||
</button>
|
</button>
|
||||||
@@ -178,7 +178,7 @@
|
|||||||
$authorization->approve_so &&
|
$authorization->approve_so &&
|
||||||
$authorization->approve_eo == null)
|
$authorization->approve_eo == null)
|
||||||
<button onclick="otorisatorData({{ $authorization->id }}, 'EO')" type="button"
|
<button onclick="otorisatorData({{ $authorization->id }}, 'EO')" type="button"
|
||||||
class="btn btn-primary">
|
class="btn btn-primary">
|
||||||
<i class="ki-filled ki-double-check"></i>
|
<i class="ki-filled ki-double-check"></i>
|
||||||
Otorisasi {{ $header ?? '' }}
|
Otorisasi {{ $header ?? '' }}
|
||||||
</button>
|
</button>
|
||||||
@@ -189,117 +189,135 @@
|
|||||||
$authorization->approve_dd == null &&
|
$authorization->approve_dd == null &&
|
||||||
in_array($permohonan->nilai_plafond_id, [1, 4]))
|
in_array($permohonan->nilai_plafond_id, [1, 4]))
|
||||||
<button onclick="otorisatorData({{ $authorization->id }}, 'DD')" type="button"
|
<button onclick="otorisatorData({{ $authorization->id }}, 'DD')" type="button"
|
||||||
class="btn btn-primary">
|
class="btn btn-primary">
|
||||||
<i class="ki-filled ki-double-check"></i>
|
<i class="ki-filled ki-double-check"></i>
|
||||||
Otorisasi {{ $header ?? '' }}
|
Otorisasi {{ $header ?? '' }}
|
||||||
</button>
|
</button>
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if (
|
@if (
|
||||||
(Auth::user()->hasAnyRole(['administrator', 'senior-officer']) &&
|
(Auth::user()->hasAnyRole(['administrator', 'senior-officer']) &&
|
||||||
$authorization->approve_so != null &&
|
$authorization->approve_so != null &&
|
||||||
$authorization->approve_eo != null) ||
|
$authorization->approve_eo != null) ||
|
||||||
$authorization->approve_dd != null)
|
$authorization->approve_dd != null
|
||||||
<button onclick="otorisatorData({{ $authorization->id }}, 'UNFREZE')" type="button"
|
)
|
||||||
class="btn btn-primary">
|
@php
|
||||||
<i class="ki-filled ki-double-check"></i>
|
$memoDeviasiExists = false;
|
||||||
Otorisasi Un{{ $header ?? '' }}
|
if ($authorization->permohonan && $authorization->permohonan->lampiranDokumen) {
|
||||||
</button>
|
$memoDeviasiExists = $authorization->permohonan->lampiranDokumen()
|
||||||
|
->whereHas('jenisLampiran', function($query) {
|
||||||
|
$query->where('nama', 'memo-deviasi');
|
||||||
|
})
|
||||||
|
->exists();
|
||||||
|
}
|
||||||
|
@endphp
|
||||||
|
|
||||||
|
@if ($memoDeviasiExists)
|
||||||
|
<button onclick="otorisatorData({{ $authorization->id }}, 'UNFREZE')" type="button"
|
||||||
|
class="btn btn-primary">
|
||||||
|
<i class="ki-filled ki-double-check"></i>
|
||||||
|
Otorisasi Un{{ $header ?? '' }}
|
||||||
|
</button>
|
||||||
|
@else
|
||||||
|
<span class="badge badge-warning">
|
||||||
|
Memo Deviasi Belum Ada
|
||||||
|
</span>
|
||||||
|
@endif
|
||||||
@endif
|
@endif
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@push('scripts')
|
@push('scripts')
|
||||||
<script>
|
<script>
|
||||||
const handleRejection = (dataId, dataHeader = '') => {
|
const handleRejection = (dataId, dataHeader = '') => {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
title: 'Masukkan alasan penolakan:',
|
title: 'Masukkan alasan penolakan:',
|
||||||
input: 'textarea',
|
input: 'textarea',
|
||||||
inputPlaceholder: 'Tuliskan alasan...',
|
inputPlaceholder: 'Tuliskan alasan...',
|
||||||
showCancelButton: true,
|
showCancelButton: true,
|
||||||
confirmButtonColor: '#f39c12',
|
confirmButtonColor: '#f39c12',
|
||||||
cancelButtonColor: '#d33',
|
cancelButtonColor: '#d33',
|
||||||
confirmButtonText: 'Kirim',
|
confirmButtonText: 'Kirim',
|
||||||
cancelButtonText: 'Batal',
|
cancelButtonText: 'Batal',
|
||||||
preConfirm: (alasan) => {
|
preConfirm: (alasan) => {
|
||||||
if (!alasan) {
|
if (!alasan) {
|
||||||
Swal.showValidationMessage('Alasan harus diisi!');
|
Swal.showValidationMessage('Alasan harus diisi!');
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
return alasan;
|
||||||
}
|
}
|
||||||
return alasan;
|
}).then((rejectResult) => {
|
||||||
|
if (rejectResult.isConfirmed) {
|
||||||
|
handleAjaxRequest(
|
||||||
|
`/otorisator/revisi-laporan/${dataId}`, {
|
||||||
|
keterangan: rejectResult.value,
|
||||||
|
dataHeader: dataHeader
|
||||||
|
},
|
||||||
|
'Data berhasil ditolak.',
|
||||||
|
'Terjadi kesalahan saat melakukan penolakan.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const showSwalConfirmation = (
|
||||||
|
title, text, html, confirmText, denyText, cancelText, preConfirm, icon = 'question'
|
||||||
|
) => {
|
||||||
|
return Swal.fire({
|
||||||
|
title: title,
|
||||||
|
text: text,
|
||||||
|
html: html,
|
||||||
|
icon: icon,
|
||||||
|
focusConfirm: false,
|
||||||
|
preConfirm: preConfirm,
|
||||||
|
showCancelButton: true,
|
||||||
|
showDenyButton: !!denyText,
|
||||||
|
confirmButtonColor: '#3085d6',
|
||||||
|
cancelButtonColor: '#d33',
|
||||||
|
denyButtonColor: '#f39c12',
|
||||||
|
confirmButtonText: confirmText,
|
||||||
|
denyButtonText: denyText,
|
||||||
|
cancelButtonText: cancelText,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
const handleAjaxRequest = (url, data, successMessage, errorMessage) => {
|
||||||
|
$.ajaxSetup({
|
||||||
|
headers: {
|
||||||
|
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
||||||
|
},
|
||||||
|
});
|
||||||
|
$.ajax({
|
||||||
|
url: url,
|
||||||
|
type: 'POST',
|
||||||
|
data: data,
|
||||||
|
success: () => {
|
||||||
|
Swal.fire('Berhasil!', successMessage, 'success').then(() => {
|
||||||
|
const redirectUrl = `/otorisator/sla`;
|
||||||
|
window.location.href = redirectUrl;
|
||||||
|
});
|
||||||
|
},
|
||||||
|
error: (error) => {
|
||||||
|
console.error('Error:', error);
|
||||||
|
Swal.fire('Gagal!', errorMessage, 'error');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
function otorisatorData(dataId, role = '') {
|
||||||
|
let dataHeader = @json($header);
|
||||||
|
|
||||||
|
// Update dataHeader if condition matches
|
||||||
|
if (dataHeader === 'Freze SLA' && (role === 'UNFREZE' || role === 'FREZE')) {
|
||||||
|
dataHeader = 'Unfreeze SLA';
|
||||||
}
|
}
|
||||||
}).then((rejectResult) => {
|
|
||||||
if (rejectResult.isConfirmed) {
|
|
||||||
handleAjaxRequest(
|
|
||||||
`/otorisator/revisi-laporan/${dataId}`, {
|
|
||||||
keterangan: rejectResult.value,
|
|
||||||
dataHeader: dataHeader
|
|
||||||
},
|
|
||||||
'Data berhasil ditolak.',
|
|
||||||
'Terjadi kesalahan saat melakukan penolakan.'
|
|
||||||
);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const showSwalConfirmation = (
|
const isPaparanSO = dataHeader === 'Unfreeze SLA' && role === 'UNFREZE';
|
||||||
title, text, html, confirmText, denyText, cancelText, preConfirm, icon = 'question'
|
const hideDenyButton = (dataHeader === 'Unfreeze SLA' && (role === 'UNFREZE' || role === 'FREZE'));
|
||||||
) => {
|
|
||||||
return Swal.fire({
|
|
||||||
title: title,
|
|
||||||
text: text,
|
|
||||||
html: html,
|
|
||||||
icon: icon,
|
|
||||||
focusConfirm: false,
|
|
||||||
preConfirm: preConfirm,
|
|
||||||
showCancelButton: true,
|
|
||||||
showDenyButton: !!denyText,
|
|
||||||
confirmButtonColor: '#3085d6',
|
|
||||||
cancelButtonColor: '#d33',
|
|
||||||
denyButtonColor: '#f39c12',
|
|
||||||
confirmButtonText: confirmText,
|
|
||||||
denyButtonText: denyText,
|
|
||||||
cancelButtonText: cancelText,
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleAjaxRequest = (url, data, successMessage, errorMessage) => {
|
const swalHtml = isPaparanSO ? `
|
||||||
$.ajaxSetup({
|
|
||||||
headers: {
|
|
||||||
'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
|
||||||
},
|
|
||||||
});
|
|
||||||
$.ajax({
|
|
||||||
url: url,
|
|
||||||
type: 'POST',
|
|
||||||
data: data,
|
|
||||||
success: () => {
|
|
||||||
Swal.fire('Berhasil!', successMessage, 'success').then(() => {
|
|
||||||
const redirectUrl = `/otorisator/sla`;
|
|
||||||
window.location.href = redirectUrl;
|
|
||||||
});
|
|
||||||
},
|
|
||||||
error: (error) => {
|
|
||||||
console.error('Error:', error);
|
|
||||||
Swal.fire('Gagal!', errorMessage, 'error');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
function otorisatorData(dataId, role = '') {
|
|
||||||
let dataHeader = @json($header);
|
|
||||||
|
|
||||||
// Update dataHeader if condition matches
|
|
||||||
if (dataHeader === 'Freze SLA' && (role === 'UNFREZE' || role === 'FREZE')) {
|
|
||||||
dataHeader = 'Unfreeze SLA';
|
|
||||||
}
|
|
||||||
|
|
||||||
const isPaparanSO = dataHeader === 'Unfreeze SLA' && role === 'UNFREZE';
|
|
||||||
const hideDenyButton = (dataHeader === 'Unfreeze SLA' && (role === 'UNFREZE' || role === 'FREZE'));
|
|
||||||
|
|
||||||
const swalHtml = isPaparanSO ? `
|
|
||||||
<div class="text-left space-y-4">
|
<div class="text-left space-y-4">
|
||||||
<p class="text-gray-700 text-center">Untuk melakukan otorisasi ${dataHeader}!</p>
|
<p class="text-gray-700 text-center">Untuk melakukan otorisasi ${dataHeader}!</p>
|
||||||
<div>
|
<div>
|
||||||
@@ -307,50 +325,50 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>` : '';
|
</div>` : '';
|
||||||
|
|
||||||
showSwalConfirmation(
|
showSwalConfirmation(
|
||||||
'Apakah Anda yakin?',
|
'Apakah Anda yakin?',
|
||||||
`Untuk melakukan otorisasi ${dataHeader}!`,
|
`Untuk melakukan otorisasi ${dataHeader}!`,
|
||||||
swalHtml,
|
swalHtml,
|
||||||
'Ya, Lanjutkan!',
|
'Ya, Lanjutkan!',
|
||||||
hideDenyButton ? null : 'Tolak',
|
hideDenyButton ? null : 'Tolak',
|
||||||
'Batal',
|
'Batal',
|
||||||
() => {
|
() => {
|
||||||
if (isPaparanSO) {
|
if (isPaparanSO) {
|
||||||
const message = document.getElementById('swal-keterangan')?.value;
|
const message = document.getElementById('swal-keterangan')?.value;
|
||||||
|
|
||||||
if (!message) {
|
if (!message) {
|
||||||
Swal.showValidationMessage('Keterangan harus diisi!');
|
Swal.showValidationMessage('Keterangan harus diisi!');
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
message,
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return {
|
||||||
|
message: 'Ya, lanjutkan.'
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
'question'
|
||||||
|
).then((result) => {
|
||||||
|
if (result.isConfirmed) {
|
||||||
|
const requestData = isPaparanSO ? {
|
||||||
|
keterangan: result.value.message,
|
||||||
|
} : {
|
||||||
|
keterangan: result.value.message
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
handleAjaxRequest(
|
||||||
message,
|
`/otorisator/otorisator/${dataId}/${dataHeader}`,
|
||||||
};
|
requestData,
|
||||||
} else {
|
'Data berhasil diotorisasi.',
|
||||||
return {
|
'Terjadi kesalahan saat melakukan otorisasi.'
|
||||||
message: 'Ya, lanjutkan.'
|
);
|
||||||
};
|
} else if (!hideDenyButton && result.isDenied) {
|
||||||
|
handleRejection(dataId, dataHeader);
|
||||||
}
|
}
|
||||||
},
|
});
|
||||||
'question'
|
}
|
||||||
).then((result) => {
|
</script>
|
||||||
if (result.isConfirmed) {
|
|
||||||
const requestData = isPaparanSO ? {
|
|
||||||
keterangan: result.value.message,
|
|
||||||
} : {
|
|
||||||
keterangan: result.value.message
|
|
||||||
};
|
|
||||||
|
|
||||||
handleAjaxRequest(
|
|
||||||
`/otorisator/otorisator/${dataId}/${dataHeader}`,
|
|
||||||
requestData,
|
|
||||||
'Data berhasil diotorisasi.',
|
|
||||||
'Terjadi kesalahan saat melakukan otorisasi.'
|
|
||||||
);
|
|
||||||
} else if (!hideDenyButton && result.isDenied) {
|
|
||||||
handleRejection(dataId, dataHeader);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
@endpush
|
@endpush
|
||||||
|
|||||||
@@ -60,7 +60,6 @@ Route::middleware(['auth'])->group(function () {
|
|||||||
Route::get('datatables', [JenisLampiranController::class, 'dataForDatatables'])->name('datatables');
|
Route::get('datatables', [JenisLampiranController::class, 'dataForDatatables'])->name('datatables');
|
||||||
Route::get('export', [JenisLampiranController::class, 'export'])->name('export');
|
Route::get('export', [JenisLampiranController::class, 'export'])->name('export');
|
||||||
});
|
});
|
||||||
Route::delete('jenis-lampiran/{id}', [JenisLampiranController::class, 'destroy'])->name('jenis-lampiran.destroy');
|
|
||||||
Route::resource('jenis-lampiran', JenisLampiranController::class);
|
Route::resource('jenis-lampiran', JenisLampiranController::class);
|
||||||
|
|
||||||
Route::name('custom-field.')->prefix('custom-field')->group(function () {
|
Route::name('custom-field.')->prefix('custom-field')->group(function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user