revised approval system (all forms)
This commit is contained in:
@@ -75,7 +75,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section class="content">
|
||||
<section class="content">
|
||||
<div class="container-fluid">
|
||||
<div class="card card-primary card-outline">
|
||||
<div class="card-body">
|
||||
@@ -109,7 +109,10 @@
|
||||
<th>Account Number</th>
|
||||
<th>Status</th>
|
||||
@if (auth()->user()->can('approval.approve'))
|
||||
<th>Approval</th>
|
||||
<th>Approval 1</th>
|
||||
@endif
|
||||
@if (auth()->user()->can('approval2.approve'))
|
||||
<th>Approval 2</th>
|
||||
@endif
|
||||
@if (auth()->user()->can('final_approval.approve'))
|
||||
<th>Final Approval</th>
|
||||
@@ -138,7 +141,7 @@
|
||||
<td>
|
||||
@if ($item->status == 'On Progress')
|
||||
<span class="badge badge-warning text-white">{{ $item->status }}</span>
|
||||
@elseif ($item->status == 'Approved' || $item->status == 'Final Approved')
|
||||
@elseif ($item->status == 'Approved 1' || $item->status == 'Approved 2' || $item->status == 'Final Approved')
|
||||
<span class="badge badge-success text-white">{{ $item->status }}</span>
|
||||
@else
|
||||
<span class="badge badge-danger text-white">{{ $item->status }}</span>
|
||||
@@ -147,16 +150,16 @@
|
||||
@if (auth()->user()->can('approval.approve'))
|
||||
<td>
|
||||
{{-- approve / reject button --}}
|
||||
@if ($item->status == 'On Progress')
|
||||
@if ($item->status == 'On Progress' || $item->status == 'Rejected')
|
||||
<form action="javascript:void(0);" class="d-inline">
|
||||
<button type="button"
|
||||
class="btn btn-success btn-sm open-approve-modal"
|
||||
data-id="{{ route('forms.meeting.approve', $item->id) }}">
|
||||
Approve
|
||||
Approve 1
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<form action="{{ route('forms.meeting.reject', $item->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to reject this item?');">
|
||||
<form action="{{ route('forms.meeting.reject', $item->id) }}" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to reject this item?');">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
<button type="submit" class="btn btn-danger btn-sm">
|
||||
@@ -174,14 +177,44 @@
|
||||
@endif
|
||||
</td>
|
||||
@endif
|
||||
@if (auth()->user()->can('approval2.approve'))
|
||||
<td>
|
||||
{{-- approve / reject button --}}
|
||||
@if ($item->status == 'Approved 1' && $item->approved_at)
|
||||
<form action="javascript:void(0);" class="d-inline">
|
||||
<button type="button"
|
||||
class="btn btn-success btn-sm open-approve-modal"
|
||||
data-id="{{ route('forms.meeting.approve2', $item->id) }}">
|
||||
Approve 2
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<form action="{{ route('forms.meeting.reject', $item->id) }}" method="POST" class="d-inline" onsubmit="return confirm('Are you sure you want to reject this item?');">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
<button type="submit" class="btn btn-danger btn-sm">
|
||||
Reject
|
||||
</button>
|
||||
</form>
|
||||
@else
|
||||
@if ($item->approved2_at)
|
||||
{{ \Carbon\Carbon::parse($item->approved_at)->locale('id')->isoFormat('D MMMM Y') }}
|
||||
@elseif($item->rejected_at)
|
||||
{{ \Carbon\Carbon::parse($item->rejected_at)->locale('id')->isoFormat('D MMMM Y') }}
|
||||
@else
|
||||
-
|
||||
@endif
|
||||
@endif
|
||||
</td>
|
||||
@endif
|
||||
@if(auth()->user()->can('final_approval.approve'))
|
||||
<td>
|
||||
{{-- approve / reject button --}}
|
||||
@if ($item->status == 'Approved' && $item->approved_at && !$item->final_approved_at)
|
||||
<form action="{{ route('forms.meeting.final-approve', $item->id) }}" method="POST" class="d-inline"onsubmit="return confirm('Are you sure you want to approve this item?');">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
<button type="submit" class="btn btn-success btn-sm">
|
||||
@if ($item->status == 'Approved 2' && $item->approved2_at && !$item->final_approved_at)
|
||||
<form action="javascript:void(0);" class="d-inline">
|
||||
<button type="button"
|
||||
class="btn btn-success btn-sm final-approve-modal"
|
||||
data-id="{{ route('forms.meeting.final-approve', $item->id) }}">
|
||||
Final Approve
|
||||
</button>
|
||||
</form>
|
||||
@@ -235,7 +268,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<section>
|
||||
<div class="modal fade" id="approveModal" tabindex="-1" role="dialog" aria-labelledby="approveModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
@@ -267,44 +300,112 @@
|
||||
<strong>User:</strong> <span id="user"></span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>Tipe:</strong> Meeting & Seminar
|
||||
<strong>Tipe:</strong> Meeting / Seminar
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>Tanggal:</strong> <span id="tanggal"></span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>Nominal Allowance:</strong> <span id="allowance_value"></span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>Bukti Allowance:</strong> <span id="bukti_allowance"></span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>Nominal Transport Antar Kota:</strong> <span id="transport_ankot_value"></span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>Bukti Transport Antar Kota:</strong> <span id="bukti_transport_ankot"></span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>Nominal Hotel:</strong> <span id="hotel_value"></span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>Bukti Hotel:</strong> <span id="bukti_hotel"></span>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" class="btn btn-primary">Approve</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
<section>
|
||||
<div class="modal fade" id="finalApproveModal" tabindex="-1" role="dialog" aria-labelledby="finalApproveModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg" role="document">
|
||||
<div class="modal-content">
|
||||
<form id="finalApproveForm" method="POST" action="">
|
||||
@csrf
|
||||
@method('PUT')
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="approveModalLabel">Approve Item</h5>
|
||||
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<!-- Loading spinner -->
|
||||
<div id="finalLoadingSpinner" class="d-flex justify-content-center align-items-center" style="height: 200px;">
|
||||
<div class="spinner-border text-primary" role="status">
|
||||
<span class="sr-only">Loading...</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal content (hidden initially) -->
|
||||
<div id="finalModalContent" class="d-none">
|
||||
<p>Please review the details below:</p>
|
||||
<ul class="list-group">
|
||||
<li class="list-group-item">
|
||||
<strong>Expense Number:</strong> <span id="final_expense_number"></span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>User:</strong> <span id="final_user"></span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>Tipe:</strong> Meeting / Seminar
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>Tanggal:</strong> <span id="final_tanggal"></span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>Bukti Allowance:</strong> <span id="final_bukti_allowance"></span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>Bukti Transport Antar Kota:</strong> <span id="final_bukti_transport_ankot"></span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>Bukti Hotel:</strong> <span id="final_bukti_hotel"></span>
|
||||
</li>
|
||||
</ul>
|
||||
<p class="mt-2">Please select the items you want to approve:</p>
|
||||
<ul class="list-group list-unstyled">
|
||||
<li>
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input" id="allowance" name="allowance">
|
||||
<label class="custom-control-label" for="allowance">Allowance (<span id="allowance_value"></span>)</label>
|
||||
<input type="checkbox" class="custom-control-input" id="final_allowance" name="allowance">
|
||||
<label class="custom-control-label" for="final_allowance">Allowance (<span id="final_allowance_value"></span>)</label>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input" id="transport_ankot" name="transport_ankot">
|
||||
<label class="custom-control-label" for="transport_ankot">Transport Ankot (<span id="transport_ankot_value"></span>)</label>
|
||||
<input type="checkbox" class="custom-control-input" id="final_transport_ankot" name="transport_ankot">
|
||||
<label class="custom-control-label" for="final_transport_ankot">Transport Ankot (<span id="final_transport_ankot_value"></span>)</label>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
<li>
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input" id="hotel" name="hotel">
|
||||
<label class="custom-control-label" for="hotel">Hotel (<span id="hotel_value"></span>)</label>
|
||||
<input type="checkbox" class="custom-control-input" id="final_hotel" name="hotel">
|
||||
<label class="custom-control-label" for="final_hotel">Hotel (<span id="final_hotel_value"></span>)</label>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
@@ -379,8 +480,8 @@
|
||||
$('#loadingSpinner').addClass('d-flex');
|
||||
$('#approveModal').modal('show'); // Show the modal
|
||||
|
||||
// Get detail from /forms/up-country/detail/{id}
|
||||
$.get(approveUrl.replace('approve', 'detail'), function (data) {
|
||||
// Get detail from /forms/meeting/detail/{id}
|
||||
$.get(approveUrl.replace(/approve(2)?/, 'detail'), function (data) {
|
||||
const formatter = new Intl.NumberFormat('id-ID', {
|
||||
style: 'currency',
|
||||
currency: 'IDR',
|
||||
@@ -391,11 +492,6 @@
|
||||
$('#transport_ankot_value').text(formatter.format(data.transport_ankot));
|
||||
$('#hotel_value').text(formatter.format(data.hotel));
|
||||
|
||||
// Assign data values to checkboxes
|
||||
$('#allowance').data('value', data.allowance);
|
||||
$('#transport_ankot').data('value', data.transport_ankot);
|
||||
$('#hotel').data('value', data.hotel);
|
||||
|
||||
// Detail data
|
||||
$('#user').text(data.user.name);
|
||||
$('#expense_number').text(data.expense_number);
|
||||
@@ -420,27 +516,79 @@
|
||||
});
|
||||
});
|
||||
|
||||
// Handle Approve Button Click
|
||||
$('.final-approve-modal').on('click', function () {
|
||||
const approveUrl = $(this).data('id');
|
||||
|
||||
// Show spinner and hide content initially
|
||||
$('#finalLoadingSpinner').show();
|
||||
$('#finalModalContent').addClass('d-none');
|
||||
|
||||
$('#finalApproveForm').attr('action', approveUrl); // Set the form action
|
||||
$('#finalLoadingSpinner').addClass('d-flex');
|
||||
$('#finalApproveModal').modal('show'); // Show the modal
|
||||
|
||||
// Get detail from /forms/meeting/detail/{id}
|
||||
$.get(approveUrl.replace('final-approve', 'detail'), function (data) {
|
||||
console.log(data);
|
||||
const formatter = new Intl.NumberFormat('id-ID', {
|
||||
style: 'currency',
|
||||
currency: 'IDR',
|
||||
minimumFractionDigits: 0
|
||||
});
|
||||
|
||||
$('#final_allowance_value').text(formatter.format(data.allowance));
|
||||
$('#final_transport_ankot_value').text(formatter.format(data.transport_ankot));
|
||||
$('#final_hotel_value').text(formatter.format(data.hotel));
|
||||
|
||||
// Assign data values to checkboxes
|
||||
$('#final_allowance').data('value', data.allowance);
|
||||
$('#final_transport_ankot').data('value', data.transport_ankot);
|
||||
$('#final_hotel').data('value', data.hotel);
|
||||
|
||||
// Detail data
|
||||
$('#final_user').text(data.user.name);
|
||||
$('#final_expense_number').text(data.expense_number);
|
||||
$('#final_tanggal').text(new Date(data.created_at).toLocaleDateString('id-ID', {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric'
|
||||
}));
|
||||
|
||||
$('#final_bukti_allowance').html(data.bukti_allowance ? '<a href="' + data.bukti_allowance + '" target="_blank">Download</a>' : '-');
|
||||
$('#final_bukti_transport_ankot').html(data.bukti_transport_ankot ? '<a href="' + data.bukti_transport_ankot + '" target="_blank">Download</a>' : '-');
|
||||
$('#final_bukti_hotel').html(data.bukti_hotel ? '<a href="' + data.bukti_hotel + '" target="_blank">Download</a>' : '-');
|
||||
|
||||
// Hide spinner and show content
|
||||
$('#finalLoadingSpinner').hide();
|
||||
$('#finalLoadingSpinner').removeClass('d-flex');
|
||||
$('#finalLoadingSpinner').addClass('d-none');
|
||||
$('#finalModalContent').removeClass('d-none');
|
||||
|
||||
// Reset the total to zero
|
||||
$('#total').val(0);
|
||||
});
|
||||
});
|
||||
|
||||
// Update total dynamically
|
||||
$('.custom-control-input').on('change', function () {
|
||||
let total = 0;
|
||||
|
||||
// Calculate the total based on checked checkboxes
|
||||
$('.custom-control-input:checked').each(function () {
|
||||
total += parseFloat($(this).data('value') || 0);
|
||||
});
|
||||
|
||||
// Update the total field with formatted value
|
||||
const formatter = new Intl.NumberFormat('id-ID', {
|
||||
style: 'currency',
|
||||
currency: 'IDR',
|
||||
minimumFractionDigits: 0
|
||||
minimumFractionDigits: 0,
|
||||
});
|
||||
|
||||
$('#total').val(formatter.format(total));
|
||||
});
|
||||
|
||||
|
||||
// Uncheck all checkboxes when the modal is closed
|
||||
$('#approveModal').on('hidden.bs.modal', function () {
|
||||
$('#finalApproveModal').on('hidden.bs.modal', function () {
|
||||
$('.custom-control-input').prop('checked', false); // Uncheck all checkboxes
|
||||
$('#total').val('0'); // Reset total to 0
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user