added form parking / toll
This commit is contained in:
@@ -42,25 +42,26 @@ class FormEntertainmentPresentationController extends Controller
|
||||
|
||||
$now = Carbon::now();
|
||||
|
||||
// Tentukan periode aktif (mulai dan tutup)
|
||||
// Determine the period
|
||||
if ($now->day >= $startDay) {
|
||||
$startDate = Carbon::create($now->year, $now->month, $startDay)->startOfDay();
|
||||
$closingDate = Carbon::create($now->copy()->addMonth()->year, $now->copy()->addMonth()->month, $closingDay)->endOfDay();
|
||||
$currentPeriodStartDate = Carbon::create($now->year, $now->month, $startDay)->startOfDay();
|
||||
$currentPeriodClosingDate = Carbon::create($now->copy()->addMonth()->year, $now->copy()->addMonth()->month, $closingDay)->endOfDay();
|
||||
} else {
|
||||
$startDate = Carbon::create($now->copy()->subMonth()->year, $now->copy()->subMonth()->month, $startDay)->startOfDay();
|
||||
$closingDate = Carbon::create($now->year, $now->month, $closingDay)->endOfDay();
|
||||
$currentPeriodStartDate = Carbon::create($now->copy()->subMonth()->year, $now->copy()->subMonth()->month, $startDay)->startOfDay();
|
||||
$currentPeriodClosingDate = Carbon::create($now->year, $now->month, $closingDay)->endOfDay();
|
||||
}
|
||||
|
||||
// Ambil nama bulan dan tahun dari $startDate untuk keperluan BudgetHelper
|
||||
$periodeMonth = strtolower($startDate->format('F')); // ex: 'august'
|
||||
$periodeYear = (int) $startDate->format('Y'); // ex: 2025
|
||||
// Calculate the actual start date for data retrieval (1 month before currentPeriodStartDate)
|
||||
$dataRetrievalStartDate = $currentPeriodStartDate->copy()->subMonth()->startOfDay();
|
||||
|
||||
$forms = FormEntertaimentPresentation::whereBetween('tanggal', [$startDate, $closingDate])
|
||||
$forms = FormEntertaimentPresentation::whereBetween('tanggal', [$dataRetrievalStartDate, $currentPeriodClosingDate])
|
||||
->orderBy('tanggal', 'desc')
|
||||
->with('user')
|
||||
->get();
|
||||
|
||||
$availableBudget = null;
|
||||
$periodeMonth = strtolower($currentPeriodStartDate->format('F'));
|
||||
$periodeYear = (int) $currentPeriodStartDate->format('Y');
|
||||
|
||||
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
||||
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
||||
|
||||
@@ -43,25 +43,26 @@ class FormMeetingSeminarController extends Controller
|
||||
// Referensi waktu sekarang
|
||||
$now = Carbon::now();
|
||||
|
||||
// Tentukan periode
|
||||
// Determine the period
|
||||
if ($now->day >= $startDay) {
|
||||
$startDate = Carbon::create($now->year, $now->month, $startDay)->startOfDay();
|
||||
$closingDate = Carbon::create($now->copy()->addMonth()->year, $now->copy()->addMonth()->month, $closingDay)->endOfDay();
|
||||
$currentPeriodStartDate = Carbon::create($now->year, $now->month, $startDay)->startOfDay();
|
||||
$currentPeriodClosingDate = Carbon::create($now->copy()->addMonth()->year, $now->copy()->addMonth()->month, $closingDay)->endOfDay();
|
||||
} else {
|
||||
$startDate = Carbon::create($now->copy()->subMonth()->year, $now->copy()->subMonth()->month, $startDay)->startOfDay();
|
||||
$closingDate = Carbon::create($now->year, $now->month, $closingDay)->endOfDay();
|
||||
$currentPeriodStartDate = Carbon::create($now->copy()->subMonth()->year, $now->copy()->subMonth()->month, $startDay)->startOfDay();
|
||||
$currentPeriodClosingDate = Carbon::create($now->year, $now->month, $closingDay)->endOfDay();
|
||||
}
|
||||
|
||||
// Ambil bulan dan tahun dari $startDate untuk keperluan budget
|
||||
$periodeMonth = strtolower($startDate->format('F')); // contoh: 'august'
|
||||
$periodeYear = (int) $startDate->format('Y');
|
||||
// Calculate the actual start date for data retrieval (1 month before currentPeriodStartDate)
|
||||
$dataRetrievalStartDate = $currentPeriodStartDate->copy()->subMonth()->startOfDay();
|
||||
|
||||
$forms = FormMeetingSeminar::whereBetween('tanggal', [$startDate, $closingDate])
|
||||
$forms = FormMeetingSeminar::whereBetween('tanggal', [$dataRetrievalStartDate, $currentPeriodClosingDate])
|
||||
->orderBy('tanggal', 'desc')
|
||||
->with('user')
|
||||
->get();
|
||||
|
||||
$availableBudget = null;
|
||||
$periodeMonth = strtolower($currentPeriodStartDate->format('F'));
|
||||
$periodeYear = (int) $currentPeriodStartDate->format('Y');
|
||||
|
||||
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
||||
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
||||
|
||||
@@ -37,27 +37,29 @@ class FormOtherController extends Controller
|
||||
$startDay = (int) env('STARTING_DATE', 11);
|
||||
$closingDay = (int) env('CLOSING_DATE', 10);
|
||||
|
||||
// Referensi waktu sekarang
|
||||
$now = Carbon::now();
|
||||
|
||||
// Tentukan periode aktif
|
||||
// Determine the period
|
||||
if ($now->day >= $startDay) {
|
||||
$startDate = Carbon::create($now->year, $now->month, $startDay)->startOfDay();
|
||||
$closingDate = Carbon::create($now->copy()->addMonth()->year, $now->copy()->addMonth()->month, $closingDay)->endOfDay();
|
||||
$currentPeriodStartDate = Carbon::create($now->year, $now->month, $startDay)->startOfDay();
|
||||
$currentPeriodClosingDate = Carbon::create($now->copy()->addMonth()->year, $now->copy()->addMonth()->month, $closingDay)->endOfDay();
|
||||
} else {
|
||||
$startDate = Carbon::create($now->copy()->subMonth()->year, $now->copy()->subMonth()->month, $startDay)->startOfDay();
|
||||
$closingDate = Carbon::create($now->year, $now->month, $closingDay)->endOfDay();
|
||||
$currentPeriodStartDate = Carbon::create($now->copy()->subMonth()->year, $now->copy()->subMonth()->month, $startDay)->startOfDay();
|
||||
$currentPeriodClosingDate = Carbon::create($now->year, $now->month, $closingDay)->endOfDay();
|
||||
}
|
||||
|
||||
// Periode untuk keperluan budget
|
||||
$periodeMonth = strtolower($startDate->format('F'));
|
||||
$periodeYear = (int) $startDate->format('Y');
|
||||
// Calculate the actual start date for data retrieval (1 month before currentPeriodStartDate)
|
||||
$dataRetrievalStartDate = $currentPeriodStartDate->copy()->subMonth()->startOfDay();
|
||||
|
||||
$forms = FormOthers::whereBetween('tanggal', [$startDate, $closingDate])
|
||||
$forms = FormOthers::whereBetween('tanggal', [$dataRetrievalStartDate, $currentPeriodClosingDate])
|
||||
->orderBy('tanggal', 'desc')
|
||||
->with('user')
|
||||
->get();
|
||||
|
||||
$availableBudget = null;
|
||||
$periodeMonth = strtolower($currentPeriodStartDate->format('F'));
|
||||
$periodeYear = (int) $currentPeriodStartDate->format('Y');
|
||||
|
||||
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
||||
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
||||
|
||||
@@ -39,27 +39,30 @@ class FormVehicleController extends Controller
|
||||
$role = auth()->user()->getRoleNames()[0];
|
||||
$startDay = (int) env('STARTING_DATE', 11);
|
||||
$closingDay = (int) env('CLOSING_DATE', 10);
|
||||
|
||||
// Referensi waktu sekarang
|
||||
$now = Carbon::now();
|
||||
|
||||
// Tentukan periode aktif
|
||||
// Determine the period
|
||||
if ($now->day >= $startDay) {
|
||||
$startDate = Carbon::create($now->year, $now->month, $startDay)->startOfDay();
|
||||
$closingDate = Carbon::create($now->copy()->addMonth()->year, $now->copy()->addMonth()->month, $closingDay)->endOfDay();
|
||||
$currentPeriodStartDate = Carbon::create($now->year, $now->month, $startDay)->startOfDay();
|
||||
$currentPeriodClosingDate = Carbon::create($now->copy()->addMonth()->year, $now->copy()->addMonth()->month, $closingDay)->endOfDay();
|
||||
} else {
|
||||
$startDate = Carbon::create($now->copy()->subMonth()->year, $now->copy()->subMonth()->month, $startDay)->startOfDay();
|
||||
$closingDate = Carbon::create($now->year, $now->month, $closingDay)->endOfDay();
|
||||
$currentPeriodStartDate = Carbon::create($now->copy()->subMonth()->year, $now->copy()->subMonth()->month, $startDay)->startOfDay();
|
||||
$currentPeriodClosingDate = Carbon::create($now->year, $now->month, $closingDay)->endOfDay();
|
||||
}
|
||||
|
||||
// Hitung periode untuk keperluan budget
|
||||
$periodeMonth = strtolower($startDate->format('F'));
|
||||
$periodeYear = (int) $startDate->format('Y');
|
||||
// Calculate the actual start date for data retrieval (1 month before currentPeriodStartDate)
|
||||
$dataRetrievalStartDate = $currentPeriodStartDate->copy()->subMonth()->startOfDay();
|
||||
|
||||
$forms = FormVehicleRunningCost::whereBetween('tanggal', [$startDate, $closingDate])
|
||||
$forms = FormVehicleRunningCost::whereBetween('tanggal', [$dataRetrievalStartDate, $currentPeriodClosingDate])
|
||||
->orderBy('tanggal', 'desc')
|
||||
->with('user')
|
||||
->get();
|
||||
|
||||
$availableBudget = null;
|
||||
$periodeMonth = strtolower($currentPeriodStartDate->format('F'));
|
||||
$periodeYear = (int) $currentPeriodStartDate->format('Y');
|
||||
|
||||
if ($role === 'Admin Region' || $role === 'Marketing Operational Manager Region') {
|
||||
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
||||
@@ -133,11 +136,12 @@ class FormVehicleController extends Controller
|
||||
$this->checkAuthorization(auth()->user(), ['forms.vehicle.create']);
|
||||
$request->validate([
|
||||
'tanggal' => 'required',
|
||||
'liter' => 'required',
|
||||
'type' => 'required',
|
||||
'liter' => 'nullable|numeric|min:0',
|
||||
'total' => 'required|numeric|min:1',
|
||||
'jarak' => 'required',
|
||||
'tipe_bensin' => 'required|in:pertalite,pertamax',
|
||||
'nopol' => 'required',
|
||||
'jarak' => 'nullable|numeric|min:0',
|
||||
'tipe_bensin' => 'nullable|in:pertalite,pertamax',
|
||||
'nopol' => 'nullable',
|
||||
'keterangan' => 'required',
|
||||
'bukti_total' => ['nullable', 'file', 'max:51200'],
|
||||
]);
|
||||
@@ -215,11 +219,12 @@ class FormVehicleController extends Controller
|
||||
'expense_number' => $expense_number,
|
||||
'user_id' => auth()->user()->id,
|
||||
'tanggal' => $request->tanggal,
|
||||
'liter' => $request->liter,
|
||||
'type' => $request->type,
|
||||
'liter' => $request->liter ?? 0,
|
||||
'total' => $request->total,
|
||||
'jarak' => $request->jarak,
|
||||
'tipe_bensin' => $request->tipe_bensin,
|
||||
'nopol' => $request->nopol,
|
||||
'jarak' => $request->jarak ?? 0,
|
||||
'tipe_bensin' => $request->tipe_bensin ?? '-',
|
||||
'nopol' => $request->nopol ?? '-',
|
||||
'keterangan' => $request->keterangan,
|
||||
'bukti_total' => $filePaths['bukti_total'] ?? null,
|
||||
'account_number' => $kategori->account_number,
|
||||
@@ -354,11 +359,12 @@ class FormVehicleController extends Controller
|
||||
// Validasi input
|
||||
$request->validate([
|
||||
'tanggal' => 'required',
|
||||
'liter' => 'required',
|
||||
'type' => 'required',
|
||||
'liter' => 'nullable|numeric|min:0',
|
||||
'total' => 'required|numeric|min:1|max:' . $availableBudget,
|
||||
'jarak' => 'required',
|
||||
'tipe_bensin' => 'required|in:pertalite,pertamax',
|
||||
'nopol' => 'required',
|
||||
'jarak' => 'nullable|numeric|min:0',
|
||||
'tipe_bensin' => 'nullable|in:pertalite,pertamax',
|
||||
'nopol' => 'nullable',
|
||||
'keterangan' => 'required',
|
||||
'bukti_total' => ['nullable', 'file', 'max:51200'],
|
||||
]);
|
||||
@@ -391,11 +397,12 @@ class FormVehicleController extends Controller
|
||||
// Save the form data
|
||||
$form->update([
|
||||
'tanggal' => $request->tanggal,
|
||||
'liter' => $request->liter,
|
||||
'type' => $request->type,
|
||||
'liter' => $request->liter ?? 0,
|
||||
'total' => $request->total,
|
||||
'jarak' => $request->jarak,
|
||||
'tipe_bensin' => $request->tipe_bensin,
|
||||
'nopol' => $request->nopol,
|
||||
'jarak' => $request->jarak ?? 0,
|
||||
'tipe_bensin' => $request->tipe_bensin ?? '-',
|
||||
'nopol' => $request->nopol ?? '-',
|
||||
'keterangan' => $request->keterangan,
|
||||
'bukti_total' => $filePaths['bukti_total'] ?? $form->bukti_total,
|
||||
'account_number' => $kategori->account_number,
|
||||
|
||||
@@ -23,6 +23,7 @@ class FormVehicleRunningCost extends Model
|
||||
'keterangan',
|
||||
'bukti_total',
|
||||
'account_number',
|
||||
'type',
|
||||
'status',
|
||||
'approved_at',
|
||||
'approved2_at',
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('form_vehicle_running_cost', function (Blueprint $table) {
|
||||
$table->string('type')->nullable()->default('gasoline')->after('id');
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('form_vehicle_running_cost', function (Blueprint $table) {
|
||||
$table->dropColumn('type');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -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>
|
||||
@@ -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>
|
||||
<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>
|
||||
@@ -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
|
||||
@@ -15,7 +15,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>
|
||||
@@ -52,42 +51,59 @@
|
||||
<div class="col-lg-6">
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Tanggal <span class="font-italic font-weight-normal">(required)</span></label>
|
||||
<input type="datetime-local" class="form-control" name="tanggal" required value="{{ $form->tanggal }}">
|
||||
<input type="datetime-local" class="form-control" name="tanggal" required value="{{ old('tanggal', $form->tanggal ? \Carbon\Carbon::parse($form->tanggal)->format('Y-m-d\TH:i') : '') }}">
|
||||
</div>
|
||||
{{-- Updated: Expense Type dropdown with name="type" and $form->type for selection --}}
|
||||
<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', $form->type) == 'gasoline' ? 'selected' : '' }}>Gasoline</option>
|
||||
<option value="parking_toll" {{ old('type', $form->type) == 'parking_toll' ? 'selected' : '' }}>Parking / Toll</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{{-- Wrap gasoline-specific fields with .gasoline-fields --}}
|
||||
<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="{{ $form->liter }}">
|
||||
<input type="text" class="form-control" name="liter" value="{{ old('liter', $form->liter) }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Total Harga Bensin <span class="font-italic font-weight-normal">(required)</span></label>
|
||||
<input type="string" class="form-control" name="total" id="total" required value="{{ $form->total }}">
|
||||
<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', $form->total) }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Bukti Total Harga Bensin <span class="font-italic font-weight-normal">(optional)</span></label>
|
||||
<input type="file" class="form-control" name="bukti_total" value="{{ old('bukti_total') }}">
|
||||
<label class="form-label">Bukti Total Harga <span class="font-italic font-weight-normal">(optional)</span></label>
|
||||
{{-- Display current proof if exists --}}
|
||||
@if($form->bukti_total)
|
||||
<div class="mb-2">
|
||||
<a href="{{ \App\Helpers\NextCloudHelper::getFileUrl($form->bukti_total) }}" target="_blank" class="btn btn-sm btn-info">Lihat Bukti Saat Ini</a>
|
||||
</div>
|
||||
@endif
|
||||
<input type="file" class="form-control" name="bukti_total">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-lg-6">
|
||||
<div class="mb-3">
|
||||
{{-- Wrap gasoline-specific fields with .gasoline-fields --}}
|
||||
<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="{{ $form->jarak }}">
|
||||
<input type="number" class="form-control" name="jarak" id="jarak" value="{{ old('jarak', $form->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>
|
||||
<option value="pertamax" {{ $form->tipe_bensin == 'pertamax' ? 'selected' : '' }}>Pertamax</option>
|
||||
<option value="pertalite" {{ $form->tipe_bensin == 'pertalite' ? 'selected' : '' }}>Pertalite</option>
|
||||
<select class="form-control" name="tipe_bensin" id="tipe_bensin">
|
||||
<option value="pertamax" {{ old('tipe_bensin', $form->tipe_bensin) == 'pertamax' ? 'selected' : '' }}>Pertamax</option>
|
||||
<option value="pertalite" {{ old('tipe_bensin', $form->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="{{ $form->nopol }}">
|
||||
<input type="text" class="form-control" name="nopol" id="nopol" value="{{ old('nopol', $form->nopol) }}">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Keterangan <span class="font-italic font-weight-normal">(required)</span></label>
|
||||
<textarea class="form-control" name="keterangan" id="keterangan" required>{{ $form->keterangan }}</textarea>
|
||||
<textarea class="form-control" name="keterangan" id="keterangan" required>{{ old('keterangan', $form->keterangan) }}</textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -113,7 +129,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) {
|
||||
@@ -121,5 +137,45 @@
|
||||
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'); // Still uses the ID for selection
|
||||
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';
|
||||
});
|
||||
// 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 the retrieved form data
|
||||
toggleGasolineFields();
|
||||
|
||||
// Add event listener for when the select box changes
|
||||
expenseTypeSelect.addEventListener('change', toggleGasolineFields);
|
||||
</script>
|
||||
@endsection
|
||||
@@ -101,6 +101,7 @@
|
||||
<th>Nama</th>
|
||||
<th>Cabang</th>
|
||||
<th>Tanggal</th>
|
||||
<th>Type</th>
|
||||
<th>Liter</th>
|
||||
<th>Keterangan</th>
|
||||
<th>Total</th>
|
||||
@@ -135,6 +136,16 @@
|
||||
<td>{{ $item->user->name }}</td>
|
||||
<td>{{ $item->user->cabang->cabang->name }}</td>
|
||||
<td>{{ \Carbon\Carbon::parse($item->tanggal)->locale('id')->isoFormat('dddd, D MMMM Y HH:mm:ss') }}</td>
|
||||
<td>
|
||||
{{-- gunakan badge --}}
|
||||
@if ($item->type == 'gasoline')
|
||||
<span class="badge badge-info">Gasoline</span>
|
||||
@elseif ($item->type == 'parking_toll')
|
||||
<span class="badge badge-warning text-white">Parking / Toll</span>
|
||||
@else
|
||||
<span class="badge badge-secondary">Unknown</span>
|
||||
@endif
|
||||
</td>
|
||||
<td>{{ $item->liter }}</td>
|
||||
<td>{{ $item->keterangan }}</td>
|
||||
<td>{{ number_format($item->total, 0, ',', '.') }}</td>
|
||||
@@ -309,7 +320,7 @@
|
||||
<strong>User:</strong> <span id="user"></span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>Tipe:</strong> Vehicle Running Cost
|
||||
<strong>Tipe:</strong> <span id="type"></span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>Tanggal & Waktu:</strong> <span id="tanggal"></span>
|
||||
@@ -377,7 +388,7 @@
|
||||
<strong>User:</strong> <span id="final_user"></span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>Tipe:</strong> Vehicle Running Cost
|
||||
<strong>Tipe:</strong> <span id="final_type"></span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>Tanggal & Waktu:</strong> <span id="final_tanggal"></span>
|
||||
@@ -492,6 +503,9 @@
|
||||
day: 'numeric'
|
||||
}));
|
||||
|
||||
// untuk type gunakan badge
|
||||
$('#type').html(data.type.split('_').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' '));
|
||||
|
||||
$('#jarak').text(data.jarak);
|
||||
$('#liter').text(data.liter);
|
||||
$('#tipe_bensin').text(data.tipe_bensin);
|
||||
@@ -545,6 +559,8 @@
|
||||
day: 'numeric'
|
||||
}));
|
||||
|
||||
$('#final_type').html(data.type.split('_').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' '));
|
||||
|
||||
$('#final_jarak').text(data.jarak);
|
||||
$('#final_liter').text(data.liter);
|
||||
$('#final_tipe_bensin').text(data.tipe_bensin);
|
||||
|
||||
@@ -144,7 +144,7 @@
|
||||
<strong>User:</strong> <span id="user"></span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>Tipe:</strong> Vehicle Running Cost
|
||||
<strong>Tipe:</strong> <span id="type"></span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>Tanggal & Waktu:</strong> <span id="tanggal"></span>
|
||||
@@ -212,7 +212,7 @@
|
||||
<strong>User:</strong> <span id="final_user"></span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>Tipe:</strong> Vehicle Running Cost
|
||||
<strong>Tipe:</strong> <span id="final_type"></span>
|
||||
</li>
|
||||
<li class="list-group-item">
|
||||
<strong>Tanggal & Waktu:</strong> <span id="final_tanggal"></span>
|
||||
@@ -300,6 +300,8 @@
|
||||
day: 'numeric'
|
||||
}));
|
||||
|
||||
$('#type').html(data.type.split('_').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' '));
|
||||
|
||||
$('#jarak').text(data.jarak);
|
||||
$('#liter').text(data.liter);
|
||||
$('#tipe_bensin').text(data.tipe_bensin);
|
||||
@@ -353,6 +355,8 @@
|
||||
day: 'numeric'
|
||||
}));
|
||||
|
||||
$('#final_type').html(data.type.split('_').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' '));
|
||||
|
||||
$('#final_jarak').text(data.jarak);
|
||||
$('#final_liter').text(data.liter);
|
||||
$('#final_tipe_bensin').text(data.tipe_bensin);
|
||||
|
||||
Reference in New Issue
Block a user