added form parking / toll
This commit is contained in:
@@ -42,25 +42,26 @@ class FormEntertainmentPresentationController extends Controller
|
|||||||
|
|
||||||
$now = Carbon::now();
|
$now = Carbon::now();
|
||||||
|
|
||||||
// Tentukan periode aktif (mulai dan tutup)
|
// Determine the period
|
||||||
if ($now->day >= $startDay) {
|
if ($now->day >= $startDay) {
|
||||||
$startDate = Carbon::create($now->year, $now->month, $startDay)->startOfDay();
|
$currentPeriodStartDate = Carbon::create($now->year, $now->month, $startDay)->startOfDay();
|
||||||
$closingDate = Carbon::create($now->copy()->addMonth()->year, $now->copy()->addMonth()->month, $closingDay)->endOfDay();
|
$currentPeriodClosingDate = Carbon::create($now->copy()->addMonth()->year, $now->copy()->addMonth()->month, $closingDay)->endOfDay();
|
||||||
} else {
|
} else {
|
||||||
$startDate = Carbon::create($now->copy()->subMonth()->year, $now->copy()->subMonth()->month, $startDay)->startOfDay();
|
$currentPeriodStartDate = Carbon::create($now->copy()->subMonth()->year, $now->copy()->subMonth()->month, $startDay)->startOfDay();
|
||||||
$closingDate = Carbon::create($now->year, $now->month, $closingDay)->endOfDay();
|
$currentPeriodClosingDate = Carbon::create($now->year, $now->month, $closingDay)->endOfDay();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ambil nama bulan dan tahun dari $startDate untuk keperluan BudgetHelper
|
// Calculate the actual start date for data retrieval (1 month before currentPeriodStartDate)
|
||||||
$periodeMonth = strtolower($startDate->format('F')); // ex: 'august'
|
$dataRetrievalStartDate = $currentPeriodStartDate->copy()->subMonth()->startOfDay();
|
||||||
$periodeYear = (int) $startDate->format('Y'); // ex: 2025
|
|
||||||
|
|
||||||
$forms = FormEntertaimentPresentation::whereBetween('tanggal', [$startDate, $closingDate])
|
$forms = FormEntertaimentPresentation::whereBetween('tanggal', [$dataRetrievalStartDate, $currentPeriodClosingDate])
|
||||||
->orderBy('tanggal', 'desc')
|
->orderBy('tanggal', 'desc')
|
||||||
->with('user')
|
->with('user')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$availableBudget = null;
|
$availableBudget = null;
|
||||||
|
$periodeMonth = strtolower($currentPeriodStartDate->format('F'));
|
||||||
|
$periodeYear = (int) $currentPeriodStartDate->format('Y');
|
||||||
|
|
||||||
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
||||||
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
||||||
|
|||||||
@@ -43,25 +43,26 @@ class FormMeetingSeminarController extends Controller
|
|||||||
// Referensi waktu sekarang
|
// Referensi waktu sekarang
|
||||||
$now = Carbon::now();
|
$now = Carbon::now();
|
||||||
|
|
||||||
// Tentukan periode
|
// Determine the period
|
||||||
if ($now->day >= $startDay) {
|
if ($now->day >= $startDay) {
|
||||||
$startDate = Carbon::create($now->year, $now->month, $startDay)->startOfDay();
|
$currentPeriodStartDate = Carbon::create($now->year, $now->month, $startDay)->startOfDay();
|
||||||
$closingDate = Carbon::create($now->copy()->addMonth()->year, $now->copy()->addMonth()->month, $closingDay)->endOfDay();
|
$currentPeriodClosingDate = Carbon::create($now->copy()->addMonth()->year, $now->copy()->addMonth()->month, $closingDay)->endOfDay();
|
||||||
} else {
|
} else {
|
||||||
$startDate = Carbon::create($now->copy()->subMonth()->year, $now->copy()->subMonth()->month, $startDay)->startOfDay();
|
$currentPeriodStartDate = Carbon::create($now->copy()->subMonth()->year, $now->copy()->subMonth()->month, $startDay)->startOfDay();
|
||||||
$closingDate = Carbon::create($now->year, $now->month, $closingDay)->endOfDay();
|
$currentPeriodClosingDate = Carbon::create($now->year, $now->month, $closingDay)->endOfDay();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ambil bulan dan tahun dari $startDate untuk keperluan budget
|
// Calculate the actual start date for data retrieval (1 month before currentPeriodStartDate)
|
||||||
$periodeMonth = strtolower($startDate->format('F')); // contoh: 'august'
|
$dataRetrievalStartDate = $currentPeriodStartDate->copy()->subMonth()->startOfDay();
|
||||||
$periodeYear = (int) $startDate->format('Y');
|
|
||||||
|
|
||||||
$forms = FormMeetingSeminar::whereBetween('tanggal', [$startDate, $closingDate])
|
$forms = FormMeetingSeminar::whereBetween('tanggal', [$dataRetrievalStartDate, $currentPeriodClosingDate])
|
||||||
->orderBy('tanggal', 'desc')
|
->orderBy('tanggal', 'desc')
|
||||||
->with('user')
|
->with('user')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$availableBudget = null;
|
$availableBudget = null;
|
||||||
|
$periodeMonth = strtolower($currentPeriodStartDate->format('F'));
|
||||||
|
$periodeYear = (int) $currentPeriodStartDate->format('Y');
|
||||||
|
|
||||||
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
||||||
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
||||||
|
|||||||
@@ -37,27 +37,29 @@ class FormOtherController extends Controller
|
|||||||
$startDay = (int) env('STARTING_DATE', 11);
|
$startDay = (int) env('STARTING_DATE', 11);
|
||||||
$closingDay = (int) env('CLOSING_DATE', 10);
|
$closingDay = (int) env('CLOSING_DATE', 10);
|
||||||
|
|
||||||
|
// Referensi waktu sekarang
|
||||||
$now = Carbon::now();
|
$now = Carbon::now();
|
||||||
|
|
||||||
// Tentukan periode aktif
|
// Determine the period
|
||||||
if ($now->day >= $startDay) {
|
if ($now->day >= $startDay) {
|
||||||
$startDate = Carbon::create($now->year, $now->month, $startDay)->startOfDay();
|
$currentPeriodStartDate = Carbon::create($now->year, $now->month, $startDay)->startOfDay();
|
||||||
$closingDate = Carbon::create($now->copy()->addMonth()->year, $now->copy()->addMonth()->month, $closingDay)->endOfDay();
|
$currentPeriodClosingDate = Carbon::create($now->copy()->addMonth()->year, $now->copy()->addMonth()->month, $closingDay)->endOfDay();
|
||||||
} else {
|
} else {
|
||||||
$startDate = Carbon::create($now->copy()->subMonth()->year, $now->copy()->subMonth()->month, $startDay)->startOfDay();
|
$currentPeriodStartDate = Carbon::create($now->copy()->subMonth()->year, $now->copy()->subMonth()->month, $startDay)->startOfDay();
|
||||||
$closingDate = Carbon::create($now->year, $now->month, $closingDay)->endOfDay();
|
$currentPeriodClosingDate = Carbon::create($now->year, $now->month, $closingDay)->endOfDay();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Periode untuk keperluan budget
|
// Calculate the actual start date for data retrieval (1 month before currentPeriodStartDate)
|
||||||
$periodeMonth = strtolower($startDate->format('F'));
|
$dataRetrievalStartDate = $currentPeriodStartDate->copy()->subMonth()->startOfDay();
|
||||||
$periodeYear = (int) $startDate->format('Y');
|
|
||||||
|
|
||||||
$forms = FormOthers::whereBetween('tanggal', [$startDate, $closingDate])
|
$forms = FormOthers::whereBetween('tanggal', [$dataRetrievalStartDate, $currentPeriodClosingDate])
|
||||||
->orderBy('tanggal', 'desc')
|
->orderBy('tanggal', 'desc')
|
||||||
->with('user')
|
->with('user')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$availableBudget = null;
|
$availableBudget = null;
|
||||||
|
$periodeMonth = strtolower($currentPeriodStartDate->format('F'));
|
||||||
|
$periodeYear = (int) $currentPeriodStartDate->format('Y');
|
||||||
|
|
||||||
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
if ($role == 'Admin Region' || $role == 'Marketing Operational Manager Region') {
|
||||||
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
||||||
|
|||||||
@@ -39,27 +39,30 @@ class FormVehicleController extends Controller
|
|||||||
$role = auth()->user()->getRoleNames()[0];
|
$role = auth()->user()->getRoleNames()[0];
|
||||||
$startDay = (int) env('STARTING_DATE', 11);
|
$startDay = (int) env('STARTING_DATE', 11);
|
||||||
$closingDay = (int) env('CLOSING_DATE', 10);
|
$closingDay = (int) env('CLOSING_DATE', 10);
|
||||||
|
|
||||||
|
// Referensi waktu sekarang
|
||||||
$now = Carbon::now();
|
$now = Carbon::now();
|
||||||
|
|
||||||
// Tentukan periode aktif
|
// Determine the period
|
||||||
if ($now->day >= $startDay) {
|
if ($now->day >= $startDay) {
|
||||||
$startDate = Carbon::create($now->year, $now->month, $startDay)->startOfDay();
|
$currentPeriodStartDate = Carbon::create($now->year, $now->month, $startDay)->startOfDay();
|
||||||
$closingDate = Carbon::create($now->copy()->addMonth()->year, $now->copy()->addMonth()->month, $closingDay)->endOfDay();
|
$currentPeriodClosingDate = Carbon::create($now->copy()->addMonth()->year, $now->copy()->addMonth()->month, $closingDay)->endOfDay();
|
||||||
} else {
|
} else {
|
||||||
$startDate = Carbon::create($now->copy()->subMonth()->year, $now->copy()->subMonth()->month, $startDay)->startOfDay();
|
$currentPeriodStartDate = Carbon::create($now->copy()->subMonth()->year, $now->copy()->subMonth()->month, $startDay)->startOfDay();
|
||||||
$closingDate = Carbon::create($now->year, $now->month, $closingDay)->endOfDay();
|
$currentPeriodClosingDate = Carbon::create($now->year, $now->month, $closingDay)->endOfDay();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Hitung periode untuk keperluan budget
|
// Calculate the actual start date for data retrieval (1 month before currentPeriodStartDate)
|
||||||
$periodeMonth = strtolower($startDate->format('F'));
|
$dataRetrievalStartDate = $currentPeriodStartDate->copy()->subMonth()->startOfDay();
|
||||||
$periodeYear = (int) $startDate->format('Y');
|
|
||||||
|
|
||||||
$forms = FormVehicleRunningCost::whereBetween('tanggal', [$startDate, $closingDate])
|
$forms = FormVehicleRunningCost::whereBetween('tanggal', [$dataRetrievalStartDate, $currentPeriodClosingDate])
|
||||||
->orderBy('tanggal', 'desc')
|
->orderBy('tanggal', 'desc')
|
||||||
->with('user')
|
->with('user')
|
||||||
->get();
|
->get();
|
||||||
|
|
||||||
$availableBudget = null;
|
$availableBudget = null;
|
||||||
|
$periodeMonth = strtolower($currentPeriodStartDate->format('F'));
|
||||||
|
$periodeYear = (int) $currentPeriodStartDate->format('Y');
|
||||||
|
|
||||||
if ($role === 'Admin Region' || $role === 'Marketing Operational Manager Region') {
|
if ($role === 'Admin Region' || $role === 'Marketing Operational Manager Region') {
|
||||||
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
$region_id = auth()->user()->getMyCabangAndRegionId()['region'];
|
||||||
@@ -133,11 +136,12 @@ class FormVehicleController extends Controller
|
|||||||
$this->checkAuthorization(auth()->user(), ['forms.vehicle.create']);
|
$this->checkAuthorization(auth()->user(), ['forms.vehicle.create']);
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'tanggal' => 'required',
|
'tanggal' => 'required',
|
||||||
'liter' => 'required',
|
'type' => 'required',
|
||||||
|
'liter' => 'nullable|numeric|min:0',
|
||||||
'total' => 'required|numeric|min:1',
|
'total' => 'required|numeric|min:1',
|
||||||
'jarak' => 'required',
|
'jarak' => 'nullable|numeric|min:0',
|
||||||
'tipe_bensin' => 'required|in:pertalite,pertamax',
|
'tipe_bensin' => 'nullable|in:pertalite,pertamax',
|
||||||
'nopol' => 'required',
|
'nopol' => 'nullable',
|
||||||
'keterangan' => 'required',
|
'keterangan' => 'required',
|
||||||
'bukti_total' => ['nullable', 'file', 'max:51200'],
|
'bukti_total' => ['nullable', 'file', 'max:51200'],
|
||||||
]);
|
]);
|
||||||
@@ -215,11 +219,12 @@ class FormVehicleController extends Controller
|
|||||||
'expense_number' => $expense_number,
|
'expense_number' => $expense_number,
|
||||||
'user_id' => auth()->user()->id,
|
'user_id' => auth()->user()->id,
|
||||||
'tanggal' => $request->tanggal,
|
'tanggal' => $request->tanggal,
|
||||||
'liter' => $request->liter,
|
'type' => $request->type,
|
||||||
|
'liter' => $request->liter ?? 0,
|
||||||
'total' => $request->total,
|
'total' => $request->total,
|
||||||
'jarak' => $request->jarak,
|
'jarak' => $request->jarak ?? 0,
|
||||||
'tipe_bensin' => $request->tipe_bensin,
|
'tipe_bensin' => $request->tipe_bensin ?? '-',
|
||||||
'nopol' => $request->nopol,
|
'nopol' => $request->nopol ?? '-',
|
||||||
'keterangan' => $request->keterangan,
|
'keterangan' => $request->keterangan,
|
||||||
'bukti_total' => $filePaths['bukti_total'] ?? null,
|
'bukti_total' => $filePaths['bukti_total'] ?? null,
|
||||||
'account_number' => $kategori->account_number,
|
'account_number' => $kategori->account_number,
|
||||||
@@ -354,11 +359,12 @@ class FormVehicleController extends Controller
|
|||||||
// Validasi input
|
// Validasi input
|
||||||
$request->validate([
|
$request->validate([
|
||||||
'tanggal' => 'required',
|
'tanggal' => 'required',
|
||||||
'liter' => 'required',
|
'type' => 'required',
|
||||||
|
'liter' => 'nullable|numeric|min:0',
|
||||||
'total' => 'required|numeric|min:1|max:' . $availableBudget,
|
'total' => 'required|numeric|min:1|max:' . $availableBudget,
|
||||||
'jarak' => 'required',
|
'jarak' => 'nullable|numeric|min:0',
|
||||||
'tipe_bensin' => 'required|in:pertalite,pertamax',
|
'tipe_bensin' => 'nullable|in:pertalite,pertamax',
|
||||||
'nopol' => 'required',
|
'nopol' => 'nullable',
|
||||||
'keterangan' => 'required',
|
'keterangan' => 'required',
|
||||||
'bukti_total' => ['nullable', 'file', 'max:51200'],
|
'bukti_total' => ['nullable', 'file', 'max:51200'],
|
||||||
]);
|
]);
|
||||||
@@ -391,11 +397,12 @@ class FormVehicleController extends Controller
|
|||||||
// Save the form data
|
// Save the form data
|
||||||
$form->update([
|
$form->update([
|
||||||
'tanggal' => $request->tanggal,
|
'tanggal' => $request->tanggal,
|
||||||
'liter' => $request->liter,
|
'type' => $request->type,
|
||||||
|
'liter' => $request->liter ?? 0,
|
||||||
'total' => $request->total,
|
'total' => $request->total,
|
||||||
'jarak' => $request->jarak,
|
'jarak' => $request->jarak ?? 0,
|
||||||
'tipe_bensin' => $request->tipe_bensin,
|
'tipe_bensin' => $request->tipe_bensin ?? '-',
|
||||||
'nopol' => $request->nopol,
|
'nopol' => $request->nopol ?? '-',
|
||||||
'keterangan' => $request->keterangan,
|
'keterangan' => $request->keterangan,
|
||||||
'bukti_total' => $filePaths['bukti_total'] ?? $form->bukti_total,
|
'bukti_total' => $filePaths['bukti_total'] ?? $form->bukti_total,
|
||||||
'account_number' => $kategori->account_number,
|
'account_number' => $kategori->account_number,
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ class FormVehicleRunningCost extends Model
|
|||||||
'keterangan',
|
'keterangan',
|
||||||
'bukti_total',
|
'bukti_total',
|
||||||
'account_number',
|
'account_number',
|
||||||
|
'type',
|
||||||
'status',
|
'status',
|
||||||
'approved_at',
|
'approved_at',
|
||||||
'approved2_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">
|
<div class="col-sm-6">
|
||||||
<ol class="breadcrumb float-sm-right">
|
<ol class="breadcrumb float-sm-right">
|
||||||
<li class="breadcrumb-item"><a href="{{ route('dashboard.index') }}">Dashboard</a></li>
|
<li class="breadcrumb-item"><a href="{{ route('dashboard.index') }}">Dashboard</a></li>
|
||||||
</li>
|
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -55,34 +54,42 @@
|
|||||||
<input type="datetime-local" class="form-control" name="tanggal" required value="{{ old('tanggal') }}">
|
<input type="datetime-local" class="form-control" name="tanggal" required value="{{ old('tanggal') }}">
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<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>
|
<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>
|
||||||
<div class="mb-3">
|
<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') }}">
|
<input type="string" class="form-control" name="total" id="total" required value="{{ old('total') }}">
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<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') }}">
|
<input type="file" class="form-control" name="bukti_total" value="{{ old('bukti_total') }}">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-lg-6">
|
<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>
|
<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>
|
||||||
<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>
|
<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') }}">
|
<select class="form-control" name="tipe_bensin" id="tipe_bensin" value="{{ old('tipe_bensin') }}">
|
||||||
<option value="pertamax">Pertamax</option>
|
<option value="pertamax" {{ old('tipe_bensin') == 'pertamax' ? 'selected' : '' }}>Pertamax</option>
|
||||||
<option value="pertalite">Pertalite</option>
|
<option value="pertalite" {{ old('tipe_bensin') == 'pertalite' ? 'selected' : '' }}>Pertalite</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</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>
|
<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>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label">Keterangan <span class="font-italic font-weight-normal">(required)</span></label>
|
<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)
|
decimalCharacter: ',', // Karakter desimal (tidak digunakan karena tanpa desimal)
|
||||||
currencySymbol: 'Rp.', // Simbol mata uang
|
currencySymbol: 'Rp.', // Simbol mata uang
|
||||||
decimalPlaces: 0, // Tidak ada angka desimal
|
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) {
|
document.getElementById('expense-form').addEventListener('submit', function (e) {
|
||||||
@@ -120,5 +127,46 @@
|
|||||||
spinnerOverlay.classList.remove('d-none'); // Show overlay
|
spinnerOverlay.classList.remove('d-none'); // Show overlay
|
||||||
spinnerOverlay.classList.add('d-flex'); // Use flexbox for centering
|
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>
|
</script>
|
||||||
@endsection
|
@endsection
|
||||||
@@ -15,7 +15,6 @@
|
|||||||
<div class="col-sm-6">
|
<div class="col-sm-6">
|
||||||
<ol class="breadcrumb float-sm-right">
|
<ol class="breadcrumb float-sm-right">
|
||||||
<li class="breadcrumb-item"><a href="{{ route('dashboard.index') }}">Dashboard</a></li>
|
<li class="breadcrumb-item"><a href="{{ route('dashboard.index') }}">Dashboard</a></li>
|
||||||
</li>
|
|
||||||
</ol>
|
</ol>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -52,42 +51,59 @@
|
|||||||
<div class="col-lg-6">
|
<div class="col-lg-6">
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label">Tanggal <span class="font-italic font-weight-normal">(required)</span></label>
|
<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>
|
</div>
|
||||||
|
{{-- Updated: Expense Type dropdown with name="type" and $form->type for selection --}}
|
||||||
<div class="mb-3">
|
<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>
|
<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>
|
||||||
<div class="mb-3">
|
<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="{{ $form->total }}">
|
<input type="string" class="form-control" name="total" id="total" required value="{{ old('total', $form->total) }}">
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label">Bukti Total Harga Bensin <span class="font-italic font-weight-normal">(optional)</span></label>
|
<label class="form-label">Bukti Total Harga <span class="font-italic font-weight-normal">(optional)</span></label>
|
||||||
<input type="file" class="form-control" name="bukti_total" value="{{ old('bukti_total') }}">
|
{{-- 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>
|
</div>
|
||||||
|
|
||||||
<div class="col-lg-6">
|
<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>
|
<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>
|
||||||
<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>
|
<label class="form-label">Tipe Bensin <span class="font-italic font-weight-normal">(required)</span></label>
|
||||||
<select class="form-control" name="tipe_bensin" required>
|
<select class="form-control" name="tipe_bensin" id="tipe_bensin">
|
||||||
<option value="pertamax" {{ $form->tipe_bensin == 'pertamax' ? 'selected' : '' }}>Pertamax</option>
|
<option value="pertamax" {{ old('tipe_bensin', $form->tipe_bensin) == 'pertamax' ? 'selected' : '' }}>Pertamax</option>
|
||||||
<option value="pertalite" {{ $form->tipe_bensin == 'pertalite' ? 'selected' : '' }}>Pertalite</option>
|
<option value="pertalite" {{ old('tipe_bensin', $form->tipe_bensin) == 'pertalite' ? 'selected' : '' }}>Pertalite</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</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>
|
<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>
|
||||||
<div class="mb-3">
|
<div class="mb-3">
|
||||||
<label class="form-label">Keterangan <span class="font-italic font-weight-normal">(required)</span></label>
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -113,7 +129,7 @@
|
|||||||
decimalCharacter: ',', // Karakter desimal (tidak digunakan karena tanpa desimal)
|
decimalCharacter: ',', // Karakter desimal (tidak digunakan karena tanpa desimal)
|
||||||
currencySymbol: 'Rp.', // Simbol mata uang
|
currencySymbol: 'Rp.', // Simbol mata uang
|
||||||
decimalPlaces: 0, // Tidak ada angka desimal
|
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) {
|
document.getElementById('expense-form').addEventListener('submit', function (e) {
|
||||||
@@ -121,5 +137,45 @@
|
|||||||
spinnerOverlay.classList.remove('d-none'); // Show overlay
|
spinnerOverlay.classList.remove('d-none'); // Show overlay
|
||||||
spinnerOverlay.classList.add('d-flex'); // Use flexbox for centering
|
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>
|
</script>
|
||||||
@endsection
|
@endsection
|
||||||
@@ -101,6 +101,7 @@
|
|||||||
<th>Nama</th>
|
<th>Nama</th>
|
||||||
<th>Cabang</th>
|
<th>Cabang</th>
|
||||||
<th>Tanggal</th>
|
<th>Tanggal</th>
|
||||||
|
<th>Type</th>
|
||||||
<th>Liter</th>
|
<th>Liter</th>
|
||||||
<th>Keterangan</th>
|
<th>Keterangan</th>
|
||||||
<th>Total</th>
|
<th>Total</th>
|
||||||
@@ -135,6 +136,16 @@
|
|||||||
<td>{{ $item->user->name }}</td>
|
<td>{{ $item->user->name }}</td>
|
||||||
<td>{{ $item->user->cabang->cabang->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>{{ \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->liter }}</td>
|
||||||
<td>{{ $item->keterangan }}</td>
|
<td>{{ $item->keterangan }}</td>
|
||||||
<td>{{ number_format($item->total, 0, ',', '.') }}</td>
|
<td>{{ number_format($item->total, 0, ',', '.') }}</td>
|
||||||
@@ -309,7 +320,7 @@
|
|||||||
<strong>User:</strong> <span id="user"></span>
|
<strong>User:</strong> <span id="user"></span>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<strong>Tipe:</strong> Vehicle Running Cost
|
<strong>Tipe:</strong> <span id="type"></span>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<strong>Tanggal & Waktu:</strong> <span id="tanggal"></span>
|
<strong>Tanggal & Waktu:</strong> <span id="tanggal"></span>
|
||||||
@@ -377,7 +388,7 @@
|
|||||||
<strong>User:</strong> <span id="final_user"></span>
|
<strong>User:</strong> <span id="final_user"></span>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<strong>Tipe:</strong> Vehicle Running Cost
|
<strong>Tipe:</strong> <span id="final_type"></span>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<strong>Tanggal & Waktu:</strong> <span id="final_tanggal"></span>
|
<strong>Tanggal & Waktu:</strong> <span id="final_tanggal"></span>
|
||||||
@@ -492,6 +503,9 @@
|
|||||||
day: 'numeric'
|
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);
|
$('#jarak').text(data.jarak);
|
||||||
$('#liter').text(data.liter);
|
$('#liter').text(data.liter);
|
||||||
$('#tipe_bensin').text(data.tipe_bensin);
|
$('#tipe_bensin').text(data.tipe_bensin);
|
||||||
@@ -545,6 +559,8 @@
|
|||||||
day: 'numeric'
|
day: 'numeric'
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
$('#final_type').html(data.type.split('_').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' '));
|
||||||
|
|
||||||
$('#final_jarak').text(data.jarak);
|
$('#final_jarak').text(data.jarak);
|
||||||
$('#final_liter').text(data.liter);
|
$('#final_liter').text(data.liter);
|
||||||
$('#final_tipe_bensin').text(data.tipe_bensin);
|
$('#final_tipe_bensin').text(data.tipe_bensin);
|
||||||
|
|||||||
@@ -144,7 +144,7 @@
|
|||||||
<strong>User:</strong> <span id="user"></span>
|
<strong>User:</strong> <span id="user"></span>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<strong>Tipe:</strong> Vehicle Running Cost
|
<strong>Tipe:</strong> <span id="type"></span>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<strong>Tanggal & Waktu:</strong> <span id="tanggal"></span>
|
<strong>Tanggal & Waktu:</strong> <span id="tanggal"></span>
|
||||||
@@ -212,7 +212,7 @@
|
|||||||
<strong>User:</strong> <span id="final_user"></span>
|
<strong>User:</strong> <span id="final_user"></span>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<strong>Tipe:</strong> Vehicle Running Cost
|
<strong>Tipe:</strong> <span id="final_type"></span>
|
||||||
</li>
|
</li>
|
||||||
<li class="list-group-item">
|
<li class="list-group-item">
|
||||||
<strong>Tanggal & Waktu:</strong> <span id="final_tanggal"></span>
|
<strong>Tanggal & Waktu:</strong> <span id="final_tanggal"></span>
|
||||||
@@ -300,6 +300,8 @@
|
|||||||
day: 'numeric'
|
day: 'numeric'
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
$('#type').html(data.type.split('_').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' '));
|
||||||
|
|
||||||
$('#jarak').text(data.jarak);
|
$('#jarak').text(data.jarak);
|
||||||
$('#liter').text(data.liter);
|
$('#liter').text(data.liter);
|
||||||
$('#tipe_bensin').text(data.tipe_bensin);
|
$('#tipe_bensin').text(data.tipe_bensin);
|
||||||
@@ -353,6 +355,8 @@
|
|||||||
day: 'numeric'
|
day: 'numeric'
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
$('#final_type').html(data.type.split('_').map(w => w.charAt(0).toUpperCase() + w.slice(1)).join(' '));
|
||||||
|
|
||||||
$('#final_jarak').text(data.jarak);
|
$('#final_jarak').text(data.jarak);
|
||||||
$('#final_liter').text(data.liter);
|
$('#final_liter').text(data.liter);
|
||||||
$('#final_tipe_bensin').text(data.tipe_bensin);
|
$('#final_tipe_bensin').text(data.tipe_bensin);
|
||||||
|
|||||||
Reference in New Issue
Block a user