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="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"
|
<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">
|
<div class="card-header bg-agi-50 py-5 flex-wrap">
|
||||||
<h3 class="card-title">
|
<h3 class="card-title">
|
||||||
Daftar Permohonan
|
Daftar Permohonan
|
||||||
@@ -22,53 +22,55 @@
|
|||||||
<div class="flex flex-wrap gap-2.5">
|
<div class="flex flex-wrap gap-2.5">
|
||||||
<div class="h-[24px] border border-r-gray-200"></div>
|
<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-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>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="scrollable-x-auto">
|
<div class="scrollable-x-auto">
|
||||||
<table class="table table-auto table-border align-middle text-gray-700 font-medium text-sm"
|
<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>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="w-14">
|
<th class="w-14">
|
||||||
<input class="checkbox checkbox-sm" data-datatable-check="true" type="checkbox" />
|
<input class="checkbox checkbox-sm" data-datatable-check="true" type="checkbox"/>
|
||||||
</th>
|
</th>
|
||||||
<th class="min-w-[150px]" data-datatable-column="nomor_registrasi">
|
<th class="min-w-[150px]" data-datatable-column="nomor_registrasi">
|
||||||
<span class="sort"> <span class="sort-label"> Nomor Registrasi </span>
|
<span class="sort"> <span class="sort-label"> Nomor Registrasi </span>
|
||||||
<span class="sort-icon"> </span> </span>
|
<span class="sort-icon"> </span> </span>
|
||||||
</th>
|
</th>
|
||||||
<th class="min-w-[150px]" data-datatable-column="tanggal_permohonan">
|
<th class="min-w-[150px]" data-datatable-column="tanggal_permohonan">
|
||||||
<span class="sort"> <span class="sort-label"> Tanggal Permohonan </span>
|
<span class="sort"> <span class="sort-label"> Tanggal Permohonan </span>
|
||||||
<span class="sort-icon"> </span> </span>
|
<span class="sort-icon"> </span> </span>
|
||||||
</th>
|
</th>
|
||||||
<th class="min-w-[150px]" data-datatable-column="user_id">
|
<th class="min-w-[150px]" data-datatable-column="user_id">
|
||||||
<span class="sort"> <span class="sort-label"> User Pemohon </span>
|
<span class="sort"> <span class="sort-label"> User Pemohon </span>
|
||||||
<span class="sort-icon"> </span> </span>
|
<span class="sort-icon"> </span> </span>
|
||||||
</th>
|
</th>
|
||||||
<th class="min-w-[150px]" data-datatable-column="branch_id">
|
<th class="min-w-[150px]" data-datatable-column="branch_id">
|
||||||
<span class="sort"> <span class="sort-label"> Cabang Pemohon </span>
|
<span class="sort"> <span class="sort-label"> Cabang Pemohon </span>
|
||||||
<span class="sort-icon"> </span> </span>
|
<span class="sort-icon"> </span> </span>
|
||||||
</th>
|
</th>
|
||||||
<th class="min-w-[150px]" data-datatable-column="debitur_id">
|
<th class="min-w-[150px]" data-datatable-column="debitur_id">
|
||||||
<span class="sort"> <span class="sort-label"> Debitur </span>
|
<span class="sort"> <span class="sort-label"> Debitur </span>
|
||||||
<span class="sort-icon"> </span> </span>
|
<span class="sort-icon"> </span> </span>
|
||||||
</th>
|
</th>
|
||||||
<th class="min-w-[150px]" data-datatable-column="tujuan_penilaian_id">
|
<th class="min-w-[150px]" data-datatable-column="tujuan_penilaian_id">
|
||||||
<span class="sort"> <span class="sort-label"> Tujuan Penilaian </span>
|
<span class="sort"> <span class="sort-label"> Tujuan Penilaian </span>
|
||||||
<span class="sort-icon"> </span> </span>
|
<span class="sort-icon"> </span> </span>
|
||||||
</th>
|
</th>
|
||||||
<th class="min-w-[150px] text-center" data-datatable-column="status">
|
<th class="min-w-[150px] text-center" data-datatable-column="status">
|
||||||
<span class="sort"> <span class="sort-label"> Status </span>
|
<span class="sort"> <span class="sort-label"> Status </span>
|
||||||
<span class="sort-icon"> </span> </span>
|
<span class="sort-icon"> </span> </span>
|
||||||
</th>
|
</th>
|
||||||
<th class="min-w-[150px]" data-datatable-column="keterangan">
|
<th class="min-w-[150px]" data-datatable-column="keterangan">
|
||||||
<span class="sort"> <span class="sort-label"> Keterangan </span>
|
<span class="sort"> <span class="sort-label"> Keterangan </span>
|
||||||
<span class="sort-icon"> </span> </span>
|
<span class="sort-icon"> </span> </span>
|
||||||
</th>
|
</th>
|
||||||
<th class="min-w-[50px] text-right" data-datatable-column="actions">Action</th>
|
<th class="min-w-[50px] text-right" data-datatable-column="actions">Action</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@@ -90,6 +92,10 @@
|
|||||||
@endsection
|
@endsection
|
||||||
|
|
||||||
@push('scripts')
|
@push('scripts')
|
||||||
|
<script>
|
||||||
|
const userRoles = @json(auth()->user()->roles->pluck('name'));
|
||||||
|
</script>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
function deleteData(data, noReg, debitur) {
|
function deleteData(data, noReg, debitur) {
|
||||||
Swal.fire({
|
Swal.fire({
|
||||||
@@ -198,11 +204,11 @@
|
|||||||
},
|
},
|
||||||
keterangan: {
|
keterangan: {
|
||||||
title: 'Keterangan',
|
title: 'Keterangan',
|
||||||
render : (item, data) => {
|
render: (item, data) => {
|
||||||
|
|
||||||
let keterangan = data.keterangan ?? ""
|
let keterangan = data.keterangan ?? ""
|
||||||
if(data.registrasi_catatan){
|
if (data.registrasi_catatan) {
|
||||||
if(keterangan) keterangan += "\n";
|
if (keterangan) keterangan += "\n";
|
||||||
keterangan += data.registrasi_catatan;
|
keterangan += data.registrasi_catatan;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,6 +219,7 @@
|
|||||||
title: 'Actions',
|
title: 'Actions',
|
||||||
render: (item, data) => {
|
render: (item, data) => {
|
||||||
let actionHtml = `<div class="flex flex-nowrap justify-end gap-1.5">`;
|
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') {
|
if (data.status === 'proses-survey' || data.status == 'rejected-reschedule') {
|
||||||
actionHtml += `
|
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 += `
|
actionHtml += `
|
||||||
<a class="btn btn-sm btn-outline btn-info" href="permohonan/${data.id}/edit" title="Edit Permohonan">
|
<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>
|
<i class="ki-outline ki-notepad-edit"></i>
|
||||||
</a>`;
|
</a>`;
|
||||||
}
|
}
|
||||||
if (data.status === 'order') {
|
if (data.status === 'order' && hasRole(['administrator', 'pemohon-ao'])) {
|
||||||
actionHtml += `
|
actionHtml += `
|
||||||
<a onclick="deleteData(${data.id}, '${data.nomor_registrasi}','${data.debiture?.name}')" class="delete btn btn-sm btn-outline btn-danger" title="Batalkan Permohonan">
|
<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>
|
<i class="ki-outline ki-cross-square"></i>
|
||||||
</a>`;
|
</a>`;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -280,7 +286,7 @@ title="Approve Jadwal Kunjungan No Reg ${data.nomor_registrasi}"
|
|||||||
|
|
||||||
let dataTable = new KTDataTable(element, dataTableOptions);
|
let dataTable = new KTDataTable(element, dataTableOptions);
|
||||||
// Custom search functionality
|
// Custom search functionality
|
||||||
searchInput.addEventListener('input', function() {
|
searchInput.addEventListener('input', function () {
|
||||||
const searchValue = this.value.trim();
|
const searchValue = this.value.trim();
|
||||||
dataTable.search(searchValue, true);
|
dataTable.search(searchValue, true);
|
||||||
|
|
||||||
@@ -325,7 +331,7 @@ title="Approve Jadwal Kunjungan No Reg ${data.nomor_registrasi}"
|
|||||||
cache: false,
|
cache: false,
|
||||||
data: input_data,
|
data: input_data,
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(response) {
|
success: function (response) {
|
||||||
console.log(response);
|
console.log(response);
|
||||||
if ('success' == response.status) {
|
if ('success' == response.status) {
|
||||||
swal.fire('Sukses Menyetujui!', response.message, 'success').then(
|
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;
|
// var errors = response.responseJSON.errors;
|
||||||
// console.log(errors);
|
// console.log(errors);
|
||||||
console.log(response);
|
console.log(response);
|
||||||
@@ -415,7 +421,7 @@ title="Approve Jadwal Kunjungan No Reg ${data.nomor_registrasi}"
|
|||||||
cache: false,
|
cache: false,
|
||||||
data: data,
|
data: data,
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(response) {
|
success: function (response) {
|
||||||
if (response.status === 'success') {
|
if (response.status === 'success') {
|
||||||
Swal.fire('Sukses Reschedule!', response.message,
|
Swal.fire('Sukses Reschedule!', response.message,
|
||||||
'success').then(() => {
|
'success').then(() => {
|
||||||
@@ -425,7 +431,7 @@ title="Approve Jadwal Kunjungan No Reg ${data.nomor_registrasi}"
|
|||||||
Swal.fire('Error!', response.message, 'error');
|
Swal.fire('Error!', response.message, 'error');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function(response) {
|
error: function (response) {
|
||||||
console.log(response);
|
console.log(response);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -529,17 +535,17 @@ title="Approve Jadwal Kunjungan No Reg ${data.nomor_registrasi}"
|
|||||||
cache: false,
|
cache: false,
|
||||||
data: data,
|
data: data,
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
success: function(response) {
|
success: function (response) {
|
||||||
if (response.status === 'success') {
|
if (response.status === 'success') {
|
||||||
Swal.fire('Sukses Reschedule!', response.message, 'success').then(
|
Swal.fire('Sukses Reschedule!', response.message, 'success').then(
|
||||||
() => {
|
() => {
|
||||||
location.reload();
|
location.reload();
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
Swal.fire('Error!', response.message, 'error');
|
Swal.fire('Error!', response.message, 'error');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function(response) {
|
error: function (response) {
|
||||||
const errorMessage = response.responseJSON?.message ||
|
const errorMessage = response.responseJSON?.message ||
|
||||||
'Terjadi kesalahan saat memproses data.';
|
'Terjadi kesalahan saat memproses data.';
|
||||||
Swal.fire('Error!', errorMessage, 'error');
|
Swal.fire('Error!', errorMessage, 'error');
|
||||||
|
|||||||
Reference in New Issue
Block a user