fix(permohonan): perbaikan tampilan dan logika akses pada halaman permohonan
- Menambahkan kondisi untuk menampilkan tombol "Tambah Permohonan" hanya untuk pengguna dengan peran 'administrator' dan 'pemohon-ao'. - Memperbaiki indentasi dan format HTML untuk tabel permohonan. - Mengoptimalkan logika untuk menampilkan aksi berdasarkan status permohonan dan peran pengguna. - Memperbaiki penanganan event input untuk pencarian data.
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
<div class="w-full grid gap-5 lg:gap-7.5 mx-auto">
|
||||
|
||||
<div class="card border border-agi-100 card-grid min-w-full" data-datatable="false" data-datatable-page-size="10"
|
||||
data-datatable-state-save="false" id="permohonan-table" data-api-url="{{ route('permohonan.datatables') }}">
|
||||
data-datatable-state-save="false" id="permohonan-table" data-api-url="{{ route('permohonan.datatables') }}">
|
||||
<div class="card-header bg-agi-50 py-5 flex-wrap">
|
||||
<h3 class="card-title">
|
||||
Daftar Permohonan
|
||||
@@ -22,53 +22,55 @@
|
||||
<div class="flex flex-wrap gap-2.5">
|
||||
<div class="h-[24px] border border-r-gray-200"></div>
|
||||
<a class="btn btn-sm btn-light" href="{{ route('permohonan.export') }}"> Export to Excel </a>
|
||||
<a class="btn btn-sm btn-primary" href="{{ route('permohonan.create') }}"> Tambah Permohonan </a>
|
||||
@if(auth()->user()->hasAnyRole(['administrator', 'pemohon-ao']))
|
||||
<a class="btn btn-sm btn-primary" href="{{ route('permohonan.create') }}"> Tambah Permohonan </a>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<div class="scrollable-x-auto">
|
||||
<table class="table table-auto table-border align-middle text-gray-700 font-medium text-sm"
|
||||
data-datatable-table="true">
|
||||
data-datatable-table="true">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="w-14">
|
||||
<input class="checkbox checkbox-sm" data-datatable-check="true" type="checkbox" />
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="nomor_registrasi">
|
||||
<tr>
|
||||
<th class="w-14">
|
||||
<input class="checkbox checkbox-sm" data-datatable-check="true" type="checkbox"/>
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="nomor_registrasi">
|
||||
<span class="sort"> <span class="sort-label"> Nomor Registrasi </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="tanggal_permohonan">
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="tanggal_permohonan">
|
||||
<span class="sort"> <span class="sort-label"> Tanggal Permohonan </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="user_id">
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="user_id">
|
||||
<span class="sort"> <span class="sort-label"> User Pemohon </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="branch_id">
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="branch_id">
|
||||
<span class="sort"> <span class="sort-label"> Cabang Pemohon </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="debitur_id">
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="debitur_id">
|
||||
<span class="sort"> <span class="sort-label"> Debitur </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="tujuan_penilaian_id">
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="tujuan_penilaian_id">
|
||||
<span class="sort"> <span class="sort-label"> Tujuan Penilaian </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[150px] text-center" data-datatable-column="status">
|
||||
</th>
|
||||
<th class="min-w-[150px] text-center" data-datatable-column="status">
|
||||
<span class="sort"> <span class="sort-label"> Status </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="keterangan">
|
||||
</th>
|
||||
<th class="min-w-[150px]" data-datatable-column="keterangan">
|
||||
<span class="sort"> <span class="sort-label"> Keterangan </span>
|
||||
<span class="sort-icon"> </span> </span>
|
||||
</th>
|
||||
<th class="min-w-[50px] text-right" data-datatable-column="actions">Action</th>
|
||||
</tr>
|
||||
</th>
|
||||
<th class="min-w-[50px] text-right" data-datatable-column="actions">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
@@ -90,6 +92,10 @@
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
const userRoles = @json(auth()->user()->roles->pluck('name'));
|
||||
</script>
|
||||
|
||||
<script type="text/javascript">
|
||||
function deleteData(data, noReg, debitur) {
|
||||
Swal.fire({
|
||||
@@ -198,11 +204,11 @@
|
||||
},
|
||||
keterangan: {
|
||||
title: 'Keterangan',
|
||||
render : (item, data) => {
|
||||
render: (item, data) => {
|
||||
|
||||
let keterangan = data.keterangan ?? ""
|
||||
if(data.registrasi_catatan){
|
||||
if(keterangan) keterangan += "\n";
|
||||
if (data.registrasi_catatan) {
|
||||
if (keterangan) keterangan += "\n";
|
||||
keterangan += data.registrasi_catatan;
|
||||
}
|
||||
|
||||
@@ -213,6 +219,7 @@
|
||||
title: 'Actions',
|
||||
render: (item, data) => {
|
||||
let actionHtml = `<div class="flex flex-nowrap justify-end gap-1.5">`;
|
||||
const hasRole = (roles) => roles.some(role => userRoles.includes(role));
|
||||
|
||||
if (data.status === 'proses-survey' || data.status == 'rejected-reschedule') {
|
||||
actionHtml += `
|
||||
@@ -255,18 +262,17 @@ title="Approve Jadwal Kunjungan No Reg ${data.nomor_registrasi}"
|
||||
`;
|
||||
}
|
||||
|
||||
if (data.status !== 'done' && data.status !== 'batal') {
|
||||
if (data.status !== 'done' && data.status !== 'batal' && hasRole(['administrator', 'pemohon-ao'])) {
|
||||
actionHtml += `
|
||||
<a class="btn btn-sm btn-outline btn-info" href="permohonan/${data.id}/edit" title="Edit Permohonan">
|
||||
<i class="ki-outline ki-notepad-edit"></i>
|
||||
</a>`;
|
||||
}
|
||||
if (data.status === 'order') {
|
||||
if (data.status === 'order' && hasRole(['administrator', 'pemohon-ao'])) {
|
||||
actionHtml += `
|
||||
<a onclick="deleteData(${data.id}, '${data.nomor_registrasi}','${data.debiture?.name}')" class="delete btn btn-sm btn-outline btn-danger" title="Batalkan Permohonan">
|
||||
<i class="ki-outline ki-cross-square"></i>
|
||||
</a>`;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -280,7 +286,7 @@ title="Approve Jadwal Kunjungan No Reg ${data.nomor_registrasi}"
|
||||
|
||||
let dataTable = new KTDataTable(element, dataTableOptions);
|
||||
// Custom search functionality
|
||||
searchInput.addEventListener('input', function() {
|
||||
searchInput.addEventListener('input', function () {
|
||||
const searchValue = this.value.trim();
|
||||
dataTable.search(searchValue, true);
|
||||
|
||||
@@ -325,7 +331,7 @@ title="Approve Jadwal Kunjungan No Reg ${data.nomor_registrasi}"
|
||||
cache: false,
|
||||
data: input_data,
|
||||
dataType: "json",
|
||||
success: function(response) {
|
||||
success: function (response) {
|
||||
console.log(response);
|
||||
if ('success' == response.status) {
|
||||
swal.fire('Sukses Menyetujui!', response.message, 'success').then(
|
||||
@@ -337,7 +343,7 @@ title="Approve Jadwal Kunjungan No Reg ${data.nomor_registrasi}"
|
||||
}
|
||||
|
||||
},
|
||||
error: function(response, textStatus, errorThrown) {
|
||||
error: function (response, textStatus, errorThrown) {
|
||||
// var errors = response.responseJSON.errors;
|
||||
// console.log(errors);
|
||||
console.log(response);
|
||||
@@ -415,7 +421,7 @@ title="Approve Jadwal Kunjungan No Reg ${data.nomor_registrasi}"
|
||||
cache: false,
|
||||
data: data,
|
||||
dataType: "json",
|
||||
success: function(response) {
|
||||
success: function (response) {
|
||||
if (response.status === 'success') {
|
||||
Swal.fire('Sukses Reschedule!', response.message,
|
||||
'success').then(() => {
|
||||
@@ -425,7 +431,7 @@ title="Approve Jadwal Kunjungan No Reg ${data.nomor_registrasi}"
|
||||
Swal.fire('Error!', response.message, 'error');
|
||||
}
|
||||
},
|
||||
error: function(response) {
|
||||
error: function (response) {
|
||||
console.log(response);
|
||||
}
|
||||
});
|
||||
@@ -529,17 +535,17 @@ title="Approve Jadwal Kunjungan No Reg ${data.nomor_registrasi}"
|
||||
cache: false,
|
||||
data: data,
|
||||
dataType: "json",
|
||||
success: function(response) {
|
||||
success: function (response) {
|
||||
if (response.status === 'success') {
|
||||
Swal.fire('Sukses Reschedule!', response.message, 'success').then(
|
||||
() => {
|
||||
location.reload();
|
||||
});
|
||||
() => {
|
||||
location.reload();
|
||||
});
|
||||
} else {
|
||||
Swal.fire('Error!', response.message, 'error');
|
||||
}
|
||||
},
|
||||
error: function(response) {
|
||||
error: function (response) {
|
||||
const errorMessage = response.responseJSON?.message ||
|
||||
'Terjadi kesalahan saat memproses data.';
|
||||
Swal.fire('Error!', errorMessage, 'error');
|
||||
|
||||
Reference in New Issue
Block a user