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'];
|
||||
|
||||
@@ -45,11 +45,11 @@ class FormUpCountryController extends Controller
|
||||
|
||||
// Determine the period
|
||||
if ($now->day >= $startDay) {
|
||||
$currentPeriodStartDate = Carbon::create($now->year, $now->month, $startDay)->startOfDay();
|
||||
$currentPeriodClosingDate = 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 {
|
||||
$currentPeriodStartDate = Carbon::create($now->copy()->subMonth()->year, $now->copy()->subMonth()->month, $startDay)->startOfDay();
|
||||
$currentPeriodClosingDate = 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();
|
||||
}
|
||||
|
||||
// Calculate the actual start date for data retrieval (1 month before currentPeriodStartDate)
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user