enhance outstanding expense card
This commit is contained in:
@@ -5,6 +5,17 @@
|
||||
@endsection
|
||||
|
||||
@section('admin-content')
|
||||
<style>
|
||||
#outstandingCard {
|
||||
cursor: pointer;
|
||||
}
|
||||
#outstandingCard.active {
|
||||
box-shadow: 0 0 0 0.25rem rgba(255, 255, 255, 0.35);
|
||||
}
|
||||
</style>
|
||||
@php
|
||||
$outstandingIdCollection = collect($outstandingIds ?? []);
|
||||
@endphp
|
||||
<section class="content-header">
|
||||
<div class="container-fluid">
|
||||
<div class="row mb-2">
|
||||
@@ -140,7 +151,7 @@
|
||||
$role = auth()->user()->getRoleNames()[0];
|
||||
@endphp
|
||||
@foreach ($forms as $item)
|
||||
<tr>
|
||||
<tr data-outstanding="{{ $outstandingIdCollection->contains($item->id) ? 1 : 0 }}">
|
||||
<td>{{ $loop->iteration }}</td>
|
||||
<td>{{ $item->expense_number }}</td>
|
||||
<td>{{ $item->user->name }}</td>
|
||||
@@ -256,7 +267,17 @@
|
||||
</a>
|
||||
@endif
|
||||
|
||||
@if (($role != 'Medical Representatif' && auth()->user()->can('forms.entertainment.edit')) || ($role == 'Medical Representatif' && $item->status == 'On Progress'))
|
||||
@php
|
||||
$canEdit = false;
|
||||
if (auth()->user()->can('forms.entertainment.edit')) {
|
||||
if (in_array($role, ['Medical Representatif', 'Area Manager Cabang'])) {
|
||||
$canEdit = $item->status == 'On Progress';
|
||||
} else {
|
||||
$canEdit = true;
|
||||
}
|
||||
}
|
||||
@endphp
|
||||
@if ($canEdit)
|
||||
<a href="{{ route('forms.entertainment.edit', $item->id) }}" class="btn btn-warning btn-sm">
|
||||
<i class="fas fa-edit text-white"></i>
|
||||
</a>
|
||||
@@ -458,7 +479,18 @@
|
||||
$('.custom-control-input').prop('checked', false);
|
||||
|
||||
if ($('#dataTable').length) {
|
||||
$('#dataTable').DataTable({
|
||||
let outstandingFilterActive = false;
|
||||
const outstandingFilter = function(settings, data, dataIndex) {
|
||||
if (!outstandingFilterActive) {
|
||||
return true;
|
||||
}
|
||||
const row = settings.aoData[dataIndex].nTr;
|
||||
return $(row).data('outstanding') === 1 || $(row).data('outstanding') === '1';
|
||||
};
|
||||
|
||||
$.fn.dataTable.ext.search.push(outstandingFilter);
|
||||
|
||||
const table = $('#dataTable').DataTable({
|
||||
responsive: false,
|
||||
dom: 'Blfrtip',
|
||||
lengthMenu: [ [10, 50, 100, -1], [10, 50, 100, "All"] ], // Control the entries dropdown
|
||||
@@ -487,6 +519,20 @@
|
||||
'colvis'
|
||||
]
|
||||
});
|
||||
|
||||
const $outstandingCard = $('#outstandingCard');
|
||||
const updateCardHint = (isActive) => {
|
||||
const text = isActive ? 'Klik untuk menampilkan semua data' : 'Klik untuk menampilkan detail';
|
||||
$outstandingCard.find('.filter-hint small').text(text);
|
||||
};
|
||||
updateCardHint(outstandingFilterActive);
|
||||
|
||||
$outstandingCard.on('click', function () {
|
||||
outstandingFilterActive = !outstandingFilterActive;
|
||||
$outstandingCard.toggleClass('active', outstandingFilterActive);
|
||||
table.draw();
|
||||
updateCardHint(outstandingFilterActive);
|
||||
});
|
||||
}
|
||||
|
||||
// Handle Reject Button Click
|
||||
|
||||
Reference in New Issue
Block a user