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';
|
||||
$authorization = null;
|
||||
if ($header === 'SLA') {
|
||||
$authorization = Authorization::with(['user'])->find($id);
|
||||
$permohonan = Permohonan::find($authorization->permohonan_id);
|
||||
$authorization = Authorization::with(['user','permohonan.lampiranDokumen.jenisLampiran'])->find($id);
|
||||
$permohonan = Permohonan::with(['lampiranDokumen.jenisLampiran'])->find($authorization->permohonan_id);
|
||||
} else {
|
||||
$permohonan = Permohonan::find($id);
|
||||
$permohonan = Permohonan::with(['lampiranDokumen.jenisLampiran'])->find($id);
|
||||
}
|
||||
if ($header === 'SLA') {
|
||||
return view('lpj::penilaian.otorisator.sla', compact('permohonan', 'header', 'authorization'));
|
||||
|
||||
@@ -82,18 +82,18 @@
|
||||
{{ $authorization->keterangan ?? '' }}
|
||||
<table class="table table-border">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Pemohon</td>
|
||||
<td>{{ $authorization->user->name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Alasan</td>
|
||||
<td>{{ $authorization->keterangan }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Tanggal Permohonan</td>
|
||||
<td>{{ formatTanggalIndonesia($authorization->created_at, 1) }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Pemohon</td>
|
||||
<td>{{ $authorization->user->name }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Alasan</td>
|
||||
<td>{{ $authorization->keterangan }}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Tanggal Permohonan</td>
|
||||
<td>{{ formatTanggalIndonesia($authorization->created_at, 1) }}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -116,28 +116,28 @@
|
||||
<div class="card-body">
|
||||
<table class="table table-border">
|
||||
<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>
|
||||
<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>Disetujui Oleh (EO)</td>
|
||||
<td>{{ getUser($authorization->approve_eo)->name ?? 'N/A' }}</td>
|
||||
<td>{{ $authorization->approve_eo_at ? formatTanggalIndonesia($authorization->approve_eo_at, 1) : 'N/A' }}
|
||||
</td>
|
||||
</tr>
|
||||
@if ($authorization->approve_eo != null)
|
||||
<tr>
|
||||
<td>Disetujui Oleh (EO)</td>
|
||||
<td>{{ getUser($authorization->approve_eo)->name ?? 'N/A' }}</td>
|
||||
<td>{{ $authorization->approve_eo_at ? formatTanggalIndonesia($authorization->approve_eo_at, 1) : 'N/A' }}
|
||||
</td>
|
||||
</tr>
|
||||
@endif
|
||||
@if (in_array($authorization->nilai_eafond_id, [1, 4]) && $authorization->approve_dd != null)
|
||||
<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
|
||||
@endif
|
||||
@if (in_array($authorization->nilai_eafond_id, [1, 4]) && $authorization->approve_dd != null)
|
||||
<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>
|
||||
</table>
|
||||
</div>
|
||||
@@ -161,14 +161,14 @@
|
||||
|
||||
@if ($dataHeader == 'pelaporan')
|
||||
<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
|
||||
</a>
|
||||
@endif
|
||||
|
||||
@if (Auth::user()->hasAnyRole(['administrator', 'senior-officer']) && $authorization->approve_so == null)
|
||||
<button onclick="otorisatorData({{ $authorization->id }}, 'SO')" type="button"
|
||||
class="btn btn-primary">
|
||||
class="btn btn-primary">
|
||||
<i class="ki-filled ki-double-check"></i>
|
||||
Otorisasi {{ $header ?? '' }}
|
||||
</button>
|
||||
@@ -178,7 +178,7 @@
|
||||
$authorization->approve_so &&
|
||||
$authorization->approve_eo == null)
|
||||
<button onclick="otorisatorData({{ $authorization->id }}, 'EO')" type="button"
|
||||
class="btn btn-primary">
|
||||
class="btn btn-primary">
|
||||
<i class="ki-filled ki-double-check"></i>
|
||||
Otorisasi {{ $header ?? '' }}
|
||||
</button>
|
||||
@@ -189,117 +189,135 @@
|
||||
$authorization->approve_dd == null &&
|
||||
in_array($permohonan->nilai_plafond_id, [1, 4]))
|
||||
<button onclick="otorisatorData({{ $authorization->id }}, 'DD')" type="button"
|
||||
class="btn btn-primary">
|
||||
class="btn btn-primary">
|
||||
<i class="ki-filled ki-double-check"></i>
|
||||
Otorisasi {{ $header ?? '' }}
|
||||
</button>
|
||||
@endif
|
||||
|
||||
@if (
|
||||
(Auth::user()->hasAnyRole(['administrator', 'senior-officer']) &&
|
||||
$authorization->approve_so != null &&
|
||||
$authorization->approve_eo != null) ||
|
||||
$authorization->approve_dd != null)
|
||||
<button onclick="otorisatorData({{ $authorization->id }}, 'UNFREZE')" type="button"
|
||||
class="btn btn-primary">
|
||||
<i class="ki-filled ki-double-check"></i>
|
||||
Otorisasi Un{{ $header ?? '' }}
|
||||
</button>
|
||||
(Auth::user()->hasAnyRole(['administrator', 'senior-officer']) &&
|
||||
$authorization->approve_so != null &&
|
||||
$authorization->approve_eo != null) ||
|
||||
$authorization->approve_dd != null
|
||||
)
|
||||
@php
|
||||
$memoDeviasiExists = false;
|
||||
if ($authorization->permohonan && $authorization->permohonan->lampiranDokumen) {
|
||||
$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
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
const handleRejection = (dataId, dataHeader = '') => {
|
||||
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;
|
||||
@push('scripts')
|
||||
<script>
|
||||
const handleRejection = (dataId, dataHeader = '') => {
|
||||
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;
|
||||
}
|
||||
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 = (
|
||||
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 isPaparanSO = dataHeader === 'Unfreeze SLA' && role === 'UNFREZE';
|
||||
const hideDenyButton = (dataHeader === 'Unfreeze SLA' && (role === 'UNFREZE' || role === 'FREZE'));
|
||||
|
||||
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';
|
||||
}
|
||||
|
||||
const isPaparanSO = dataHeader === 'Unfreeze SLA' && role === 'UNFREZE';
|
||||
const hideDenyButton = (dataHeader === 'Unfreeze SLA' && (role === 'UNFREZE' || role === 'FREZE'));
|
||||
|
||||
const swalHtml = isPaparanSO ? `
|
||||
const swalHtml = isPaparanSO ? `
|
||||
<div class="text-left space-y-4">
|
||||
<p class="text-gray-700 text-center">Untuk melakukan otorisasi ${dataHeader}!</p>
|
||||
<div>
|
||||
@@ -307,50 +325,50 @@
|
||||
</div>
|
||||
</div>` : '';
|
||||
|
||||
showSwalConfirmation(
|
||||
'Apakah Anda yakin?',
|
||||
`Untuk melakukan otorisasi ${dataHeader}!`,
|
||||
swalHtml,
|
||||
'Ya, Lanjutkan!',
|
||||
hideDenyButton ? null : 'Tolak',
|
||||
'Batal',
|
||||
() => {
|
||||
if (isPaparanSO) {
|
||||
const message = document.getElementById('swal-keterangan')?.value;
|
||||
showSwalConfirmation(
|
||||
'Apakah Anda yakin?',
|
||||
`Untuk melakukan otorisasi ${dataHeader}!`,
|
||||
swalHtml,
|
||||
'Ya, Lanjutkan!',
|
||||
hideDenyButton ? null : 'Tolak',
|
||||
'Batal',
|
||||
() => {
|
||||
if (isPaparanSO) {
|
||||
const message = document.getElementById('swal-keterangan')?.value;
|
||||
|
||||
if (!message) {
|
||||
Swal.showValidationMessage('Keterangan harus diisi!');
|
||||
return false;
|
||||
if (!message) {
|
||||
Swal.showValidationMessage('Keterangan harus diisi!');
|
||||
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 {
|
||||
message,
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
message: 'Ya, lanjutkan.'
|
||||
};
|
||||
handleAjaxRequest(
|
||||
`/otorisator/otorisator/${dataId}/${dataHeader}`,
|
||||
requestData,
|
||||
'Data berhasil diotorisasi.',
|
||||
'Terjadi kesalahan saat melakukan otorisasi.'
|
||||
);
|
||||
} else if (!hideDenyButton && result.isDenied) {
|
||||
handleRejection(dataId, dataHeader);
|
||||
}
|
||||
},
|
||||
'question'
|
||||
).then((result) => {
|
||||
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>
|
||||
});
|
||||
}
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
@@ -60,7 +60,6 @@ Route::middleware(['auth'])->group(function () {
|
||||
Route::get('datatables', [JenisLampiranController::class, 'dataForDatatables'])->name('datatables');
|
||||
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::name('custom-field.')->prefix('custom-field')->group(function () {
|
||||
|
||||
Reference in New Issue
Block a user