revised form vehicle, entertainment and other

This commit is contained in:
Jagad R R
2025-01-06 16:00:51 +07:00
parent e56708ef93
commit 6f2946cd62
22 changed files with 1135 additions and 530 deletions
@@ -39,7 +39,7 @@
<div class="col-lg-4 col-6">
<div class="small-box bg-success">
<div class="inner">
<h3>Rp {{ number_format($forms->whereIn('status', ['Approved', 'Closed'])->sum('total'), 0, ',', '.') }}</h3>
<h3>Rp {{ number_format($forms->whereIn('status', ['Approved', 'Closed'])->sum('approved_total'), 0, ',', '.') }}</h3>
<p>Approved Expenses</p>
</div>
<div class="icon">
@@ -88,12 +88,11 @@
<th>Tanggal</th>
<th>Liter</th>
<th>Total</th>
<th>Total Approved</th>
<th>Jarak</th>
<th>Tipe Bensin</th>
<th>Nomor Polisi</th>
<th>Bukti 1</th>
<th>Bukti 2</th>
<th>Bukti 3</th>
<th>Bukti</th>
<th>Account Number</th>
<th>Status</th>
@if (auth()->user()->can('approval.approve'))
@@ -116,30 +115,13 @@
<td>{{ \Carbon\Carbon::parse($item->tanggal)->locale('id')->isoFormat('dddd, D MMMM Y HH:mm:ss') }}</td>
<td>{{ $item->liter }}</td>
<td>{{ number_format($item->total, 0, ',', '.') }}</td>
<td>{{ number_format($item->approved_total, 0, ',', '.') }}</td>
<td>{{ $item->jarak }} km</td>
<td>{{ $item->tipe_bensin }}</td>
<td>{{ $item->nopol }}</td>
<td>
@if ($item->bukti1)
<a href="{{ NextCloudHelper::getFileUrl($item->bukti1) }}" target="_blank">
Download
</a>
@else
-
@endif
</td>
<td>
@if ($item->bukti2)
<a href="{{ NextCloudHelper::getFileUrl($item->bukti2) }}" target="_blank">
Download
</a>
@else
-
@endif
</td>
<td>
@if ($item->bukti3)
<a href="{{ NextCloudHelper::getFileUrl($item->bukti3) }}" target="_blank">
@if ($item->bukti_total)
<a href="{{ NextCloudHelper::getFileUrl($item->bukti_total) }}" target="_blank">
Download
</a>
@else
@@ -160,10 +142,10 @@
<td>
{{-- approve / reject button --}}
@if ($item->status == 'On Progress')
<form action="{{ route('forms.vehicle.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">
<form action="javascript:void(0);" class="d-inline">
<button type="button"
class="btn btn-success btn-sm open-approve-modal"
data-id="{{ route('forms.vehicle.approve', $item->id) }}">
Approve
</button>
</form>
@@ -215,6 +197,12 @@
</td>
@endif
<td>
@if (auth()->user()->can('forms.vehicle.view'))
<a href="{{ route('forms.vehicle.view', $item->id) }}" class="btn btn-primary btn-sm">
<i class="fas fa-eye text-white"></i>
</a>
@endif
@if (auth()->user()->can('forms.vehicle.edit'))
<a href="{{ route('forms.vehicle.edit', $item->id) }}" class="btn btn-warning btn-sm">
<i class="fas fa-edit text-white"></i>
@@ -241,20 +229,183 @@
</div>
</div>
</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">
<form id="approveForm" 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">&times;</span>
</button>
</div>
<div class="modal-body">
<!-- Loading spinner -->
<div id="loadingSpinner" 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="modalContent" 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="expense_number"></span>
</li>
<li class="list-group-item">
<strong>User:</strong> <span id="user"></span>
</li>
<li class="list-group-item">
<strong>Tipe:</strong> Vehicle Running Cost
</li>
<li class="list-group-item">
<strong>Tanggal & Waktu:</strong> <span id="tanggal"></span>
</li>
<li class="list-group-item">
<strong>Jarak:</strong> <span id="jarak"></span> km
</li>
<li class="list-group-item">
<strong>Total Liter Bensin:</strong> <span id="liter"></span> liter
</li>
<li class="list-group-item">
<strong>No Polisi:</strong> <span id="nopol"></span>
</li>
<li class="list-group-item">
<strong>Tipe Bensin:</strong> <span id="tipe_bensin"></span>
</li>
<li class="list-group-item">
<strong>Keterangan:</strong> <span id="keterangan"></span>
</li>
<li class="list-group-item">
<strong>Bukti Total Harga Bensin:</strong> <span id="bukti_total"></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="total_bensin" name="total_bensin">
<label class="custom-control-label" for="total_bensin">Total Harga Bensin (<span id="total_bensin_value"></span>)</label>
</div>
</div>
</li>
<li>
<div class="form-group">
<label for="total">Total</label>
<input type="text" class="form-control" id="total" name="total" value="0" readonly>
</div>
</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>
@endsection
@section('scripts')
<script>
$(document).ready(function () {
if ($('#dataTable').length) {
$('#dataTable').DataTable({
responsive: false,
dom: 'Bfrtip',
buttons: [
'excel', 'pdf', 'print'
]
});
}
});
</script>
$(document).ready(function () {
// Uncheck all checkboxes on page refresh
$('.custom-control-input').prop('checked', false);
if ($('#dataTable').length) {
$('#dataTable').DataTable({
responsive: false,
dom: 'Bfrtip',
buttons: ['excel', 'pdf', 'print']
});
}
// Handle Approve Button Click
$('.open-approve-modal').on('click', function () {
const approveUrl = $(this).data('id');
// Show spinner and hide content initially
$('#loadingSpinner').show();
$('#modalContent').addClass('d-none');
$('#approveForm').attr('action', approveUrl); // Set the form action
$('#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) {
const formatter = new Intl.NumberFormat('id-ID', {
style: 'currency',
currency: 'IDR',
minimumFractionDigits: 0
});
$('#total_bensin_value').text(formatter.format(data.total));
$('#total_bensin').data('value', data.total);
$('#jarak').text(data.jarak);
$('#liter').text(data.liter);
$('#nopol').text(data.nopol);
$('#tipe_bensin').text(data.tipe_bensin);
$('#keterangan').text(data.keterangan);
// Detail data
$('#user').text(data.user.name);
$('#expense_number').text(data.expense_number);
$('#tanggal').text(new Date(data.tanggal).toLocaleDateString('id-ID', {
year: 'numeric',
month: 'long',
day: 'numeric',
hour: '2-digit',
minute: '2-digit',
}));
$('#bukti_total').html(data.bukti_total ? '<a href="' + data.bukti_total + '" target="_blank">Download</a>' : '-');
// Hide spinner and show content
$('#loadingSpinner').hide();
$('#loadingSpinner').removeClass('d-flex');
$('#loadingSpinner').addClass('d-none');
$('#modalContent').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
});
$('#total').val(formatter.format(total));
});
// Uncheck all checkboxes when the modal is closed
$('#approveModal').on('hidden.bs.modal', function () {
$('.custom-control-input').prop('checked', false); // Uncheck all checkboxes
$('#total').val('0'); // Reset total to 0
});
});
</script>
@endsection