added form parking / toll
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
@extends('layouts.app')
|
||||
|
||||
@section('title')
|
||||
Dashboard
|
||||
Dashboard
|
||||
@endsection
|
||||
|
||||
@section('admin-content')
|
||||
@@ -16,7 +16,6 @@
|
||||
<div class="col-sm-6">
|
||||
<ol class="breadcrumb float-sm-right">
|
||||
<li class="breadcrumb-item"><a href="{{ route('dashboard.index') }}">Dashboard</a></li>
|
||||
</li>
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
@@ -45,7 +44,7 @@
|
||||
<div class="container-fluid">
|
||||
<div class="card card-primary card-outline">
|
||||
<div class="card-body">
|
||||
<form id="expense-form" method="POST" action="{{ route('forms.vehicle.store') }}" enctype="multipart/form-data">
|
||||
<form id="expense-form" method="POST" action="{{ route('forms.vehicle.store') }}" enctype="multipart/form-data">
|
||||
@csrf
|
||||
@include('backend.layouts.partials.messages')
|
||||
<div class="row">
|
||||
@@ -55,34 +54,42 @@
|
||||
<input type="datetime-local" class="form-control" name="tanggal" required value="{{ old('tanggal') }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Tipe Pengeluaran <span class="font-italic font-weight-normal">(required)</span></label>
|
||||
<select class="form-control" name="type" id="expense_type" required>
|
||||
<option value="gasoline" {{ old('type') == 'gasoline' ? 'selected' : '' }}>Gasoline</option>
|
||||
<option value="parking_toll" {{ old('type') == 'parking_toll' ? 'selected' : '' }}>Parking / Toll</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="mb-3 gasoline-fields">
|
||||
<label class="form-label">Liter Bensin <span class="font-italic font-weight-normal">(required)</span></label>
|
||||
<input type="text" class="form-control" name="liter" required value="{{ old('liter') }}">
|
||||
<input type="text" class="form-control" name="liter" value="{{ old('liter') }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Total Harga Bensin <span class="font-italic font-weight-normal">(required)</span></label>
|
||||
<label class="form-label">Total Harga <span class="font-italic font-weight-normal">(required)</span></label>
|
||||
<input type="string" class="form-control" name="total" id="total" required value="{{ old('total') }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Bukti Total Harga Bensin <span class="font-italic font-weight-normal">(required)</span></label>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Bukti Total Harga <span class="font-italic font-weight-normal">(required)</span></label>
|
||||
<input type="file" class="form-control" name="bukti_total" value="{{ old('bukti_total') }}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-lg-6">
|
||||
<div class="mb-3">
|
||||
<div class="mb-3 gasoline-fields">
|
||||
<label class="form-label">Km (Odometer) <span class="font-italic font-weight-normal">(required)</span></label>
|
||||
<input type="number" class="form-control" name="jarak" id="jarak" required value="{{ old('jarak') }}">
|
||||
<input type="number" class="form-control" name="jarak" id="jarak" value="{{ old('jarak') }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<div class="mb-3 gasoline-fields">
|
||||
<label class="form-label">Tipe Bensin <span class="font-italic font-weight-normal">(required)</span></label>
|
||||
<select class="form-control" name="tipe_bensin" required value="{{ old('tipe_bensin') }}">
|
||||
<option value="pertamax">Pertamax</option>
|
||||
<option value="pertalite">Pertalite</option>
|
||||
<select class="form-control" name="tipe_bensin" id="tipe_bensin" value="{{ old('tipe_bensin') }}">
|
||||
<option value="pertamax" {{ old('tipe_bensin') == 'pertamax' ? 'selected' : '' }}>Pertamax</option>
|
||||
<option value="pertalite" {{ old('tipe_bensin') == 'pertalite' ? 'selected' : '' }}>Pertalite</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<div class="mb-3 gasoline-fields">
|
||||
<label class="form-label">Nomor Polisi <span class="font-italic font-weight-normal">(required)</span></label>
|
||||
<input type="text" class="form-control" name="nopol" id="nopol" required value="{{ old('nopol') }}">
|
||||
<input type="text" class="form-control" name="nopol" id="nopol" value="{{ old('nopol') }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Keterangan <span class="font-italic font-weight-normal">(required)</span></label>
|
||||
@@ -92,7 +99,7 @@
|
||||
|
||||
<button type="submit" class="btn btn-primary ml-2">Submit</button>
|
||||
</div>
|
||||
</form>
|
||||
</form>
|
||||
|
||||
<div id="loading-spinner-overlay" class="d-none">
|
||||
<div class="spinner-wrapper">
|
||||
@@ -112,7 +119,7 @@
|
||||
decimalCharacter: ',', // Karakter desimal (tidak digunakan karena tanpa desimal)
|
||||
currencySymbol: 'Rp.', // Simbol mata uang
|
||||
decimalPlaces: 0, // Tidak ada angka desimal
|
||||
unformatOnSubmit: true // Nilai asli tanpa format saat dikirimkan
|
||||
unformatOnSubmit: true // Nilai asli tanpa format saat dikirimkan
|
||||
});
|
||||
|
||||
document.getElementById('expense-form').addEventListener('submit', function (e) {
|
||||
@@ -120,5 +127,46 @@
|
||||
spinnerOverlay.classList.remove('d-none'); // Show overlay
|
||||
spinnerOverlay.classList.add('d-flex'); // Use flexbox for centering
|
||||
});
|
||||
|
||||
// JavaScript for dynamic field visibility and clearing values
|
||||
const expenseTypeSelect = document.getElementById('expense_type');
|
||||
const gasolineFields = document.querySelectorAll('.gasoline-fields');
|
||||
const literInput = document.querySelector('input[name="liter"]');
|
||||
const jarakInput = document.querySelector('input[name="jarak"]');
|
||||
const tipeBensinSelect = document.getElementById('tipe_bensin');
|
||||
const nopolInput = document.getElementById('nopol');
|
||||
|
||||
function toggleGasolineFields() {
|
||||
if (expenseTypeSelect.value === 'gasoline') {
|
||||
gasolineFields.forEach(field => {
|
||||
field.style.display = 'block';
|
||||
});
|
||||
literInput.setAttribute('required', 'required');
|
||||
jarakInput.setAttribute('required', 'required');
|
||||
tipeBensinSelect.setAttribute('required', 'required');
|
||||
nopolInput.setAttribute('required', 'required');
|
||||
} else {
|
||||
gasolineFields.forEach(field => {
|
||||
field.style.display = 'none';
|
||||
});
|
||||
// --- NEW ADDITION: Clear values when fields are hidden ---
|
||||
literInput.value = '';
|
||||
jarakInput.value = '';
|
||||
tipeBensinSelect.value = ''; // Clears selected option
|
||||
nopolInput.value = '';
|
||||
// --------------------------------------------------------
|
||||
|
||||
literInput.removeAttribute('required');
|
||||
jarakInput.removeAttribute('required');
|
||||
tipeBensinSelect.removeAttribute('required');
|
||||
nopolInput.removeAttribute('required');
|
||||
}
|
||||
}
|
||||
|
||||
// Initial call to set visibility based on initial select value (e.g., from old('expense_type'))
|
||||
toggleGasolineFields();
|
||||
|
||||
// Add event listener for when the select box changes
|
||||
expenseTypeSelect.addEventListener('change', toggleGasolineFields);
|
||||
</script>
|
||||
@endsection
|
||||
@endsection
|
||||
Reference in New Issue
Block a user