add validation for masa input

This commit is contained in:
Jagad R R
2025-01-18 15:01:28 +07:00
parent d497fe08a5
commit 4f8384676b
7 changed files with 109 additions and 21 deletions
@@ -34,10 +34,10 @@ class FormEntertainmentPresentationController extends Controller
$this->checkAuthorization(auth()->user(), ['forms.entertainment.view']); $this->checkAuthorization(auth()->user(), ['forms.entertainment.view']);
$role = auth()->user()->getRoleNames()[0]; $role = auth()->user()->getRoleNames()[0];
$forms = FormEntertaimentPresentation::whereMonth('tanggal', date('m')) $startDate = date('Y-m-' . env('STARTING_DATE')); // Starting date from .env for the current month
->whereYear('tanggal', date('Y')) $closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE'); // Closing date for the next month
->where('tanggal', '<=', date('Y-m-' . env('CLOSING_DATE')))
->whereRaw('DAY(CURDATE()) <= ' . env('CLOSING_DATE')) $forms = FormEntertaimentPresentation::whereBetween('tanggal', [$startDate, $closingDateNextMonth])
->orderBy('tanggal', 'desc') ->orderBy('tanggal', 'desc')
->with('user') ->with('user')
->get(); ->get();
@@ -127,6 +127,16 @@ class FormEntertainmentPresentationController extends Controller
'bukti_total' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], 'bukti_total' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
]); ]);
$currentDate = date('Y-m-d');
$startDate = date('Y-m-' . env('STARTING_DATE'));
$closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE');
if ($currentDate < $startDate || $currentDate > $closingDateNextMonth) {
return response()->json([
'error' => 'Current date is not within the valid range.'
], 400);
}
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang; $cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
$region = Region::where('id', $cabang->region_id)->first(); $region = Region::where('id', $cabang->region_id)->first();
$kategori = Kategori::where('name', 'Entertainment')->first(); $kategori = Kategori::where('name', 'Entertainment')->first();
@@ -34,10 +34,10 @@ class FormMeetingSeminarController extends Controller
$this->checkAuthorization(auth()->user(), ['forms.meeting.view']); $this->checkAuthorization(auth()->user(), ['forms.meeting.view']);
$role = auth()->user()->getRoleNames()[0]; $role = auth()->user()->getRoleNames()[0];
$forms = FormMeetingSeminar::whereMonth('created_at', date('m')) $startDate = date('Y-m-' . env('STARTING_DATE')); // Starting date from .env for the current month
->whereYear('created_at', date('Y')) $closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE'); // Closing date for the next month
->where('created_at', '<=', date('Y-m-' . env('CLOSING_DATE')))
->whereRaw('DAY(CURDATE()) <= ' . env('CLOSING_DATE')) $forms = FormMeetingSeminar::whereBetween('created_at', [$startDate, $closingDateNextMonth])
->orderBy('created_at', 'desc') ->orderBy('created_at', 'desc')
->with('user') ->with('user')
->get(); ->get();
@@ -128,6 +128,16 @@ class FormMeetingSeminarController extends Controller
'bukti_hotel' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], 'bukti_hotel' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
]); ]);
$currentDate = date('Y-m-d');
$startDate = date('Y-m-' . env('STARTING_DATE'));
$closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE');
if ($currentDate < $startDate || $currentDate > $closingDateNextMonth) {
return response()->json([
'error' => 'Current date is not within the valid range.'
], 400);
}
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang; $cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
$region = Region::where('id', $cabang->region_id)->first(); $region = Region::where('id', $cabang->region_id)->first();
$kategori = Kategori::where('name', 'Meeting / Seminar')->first(); $kategori = Kategori::where('name', 'Meeting / Seminar')->first();
@@ -30,12 +30,12 @@ class FormOtherController extends Controller
$this->checkAuthorization(auth()->user(), ['forms.other.view']); $this->checkAuthorization(auth()->user(), ['forms.other.view']);
$role = auth()->user()->getRoleNames()[0]; $role = auth()->user()->getRoleNames()[0];
$forms = FormOthers::whereMonth('tanggal', date('m')) $startDate = date('Y-m-' . env('STARTING_DATE')); // Starting date from .env for the current month
->whereYear('tanggal', date('Y')) $closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE'); // Closing date for the next month
->where('tanggal', '<=', date('Y-m-' . env('CLOSING_DATE')))
->whereRaw('DAY(CURDATE()) <= ' . env('CLOSING_DATE')) $forms = FormOthers::whereBetween('tanggal', [$startDate, $closingDateNextMonth])
->orderBy('tanggal', 'desc') ->orderBy('tanggal', 'desc')
->with(['user', 'kategori']) ->with('user')
->get(); ->get();
$availableBudget = null; $availableBudget = null;
@@ -124,6 +124,16 @@ class FormOtherController extends Controller
'bukti_total' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], 'bukti_total' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
]); ]);
$currentDate = date('Y-m-d');
$startDate = date('Y-m-' . env('STARTING_DATE'));
$closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE');
if ($currentDate < $startDate || $currentDate > $closingDateNextMonth) {
return response()->json([
'error' => 'Current date is not within the valid range.'
], 400);
}
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang; $cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
$region = Region::where('id', $cabang->region_id)->first(); $region = Region::where('id', $cabang->region_id)->first();
$kategori = Kategori::where('id', $request->kategori_id)->first(); $kategori = Kategori::where('id', $request->kategori_id)->first();
@@ -34,10 +34,10 @@ class FormUpCountryController extends Controller
$this->checkAuthorization(auth()->user(), ['forms.country.view']); $this->checkAuthorization(auth()->user(), ['forms.country.view']);
$role = auth()->user()->getRoleNames()[0]; $role = auth()->user()->getRoleNames()[0];
$forms = FormUpCountry::whereMonth('tanggal', date('m')) $startDate = date('Y-m-' . env('STARTING_DATE')); // Starting date from .env for the current month
->whereYear('tanggal', date('Y')) $closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE'); // Closing date for the next month
->where('tanggal', '<=', date('Y-m-' . env('CLOSING_DATE')))
->whereRaw('DAY(CURDATE()) <= ' . env('CLOSING_DATE')) $forms = FormUpCountry::whereBetween('tanggal', [$startDate, $closingDateNextMonth])
->orderBy('tanggal', 'desc') ->orderBy('tanggal', 'desc')
->with(['rayon', 'user']) ->with(['rayon', 'user'])
->get(); ->get();
@@ -140,6 +140,16 @@ class FormUpCountryController extends Controller
'bukti_hotel' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], 'bukti_hotel' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
]); ]);
$currentDate = date('Y-m-d');
$startDate = date('Y-m-' . env('STARTING_DATE'));
$closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE');
if ($currentDate < $startDate || $currentDate > $closingDateNextMonth) {
return response()->json([
'error' => 'Current date is not within the valid range.'
], 400);
}
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang; $cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
$region = Region::where('id', $cabang->region_id)->first(); $region = Region::where('id', $cabang->region_id)->first();
$kategori = Kategori::where('name', 'Up Country')->first(); $kategori = Kategori::where('name', 'Up Country')->first();
@@ -34,10 +34,10 @@ class FormVehicleController extends Controller
$this->checkAuthorization(auth()->user(), ['forms.vehicle.view']); $this->checkAuthorization(auth()->user(), ['forms.vehicle.view']);
$role = auth()->user()->getRoleNames()[0]; $role = auth()->user()->getRoleNames()[0];
$forms = FormVehicleRunningCost::whereMonth('tanggal', date('m')) $startDate = date('Y-m-' . env('STARTING_DATE')); // Starting date from .env for the current month
->whereYear('tanggal', date('Y')) $closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE'); // Closing date for the next month
->where('tanggal', '<=', date('Y-m-' . env('CLOSING_DATE')))
->whereRaw('DAY(CURDATE()) <= ' . env('CLOSING_DATE')) $forms = FormVehicleRunningCost::whereBetween('tanggal', [$startDate, $closingDateNextMonth])
->orderBy('tanggal', 'desc') ->orderBy('tanggal', 'desc')
->with('user') ->with('user')
->get(); ->get();
@@ -128,6 +128,16 @@ class FormVehicleController extends Controller
'bukti_total' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])], 'bukti_total' => ['nullable', 'file', 'max:51200', new FileType(['php', 'exe', 'js', 'sh', 'bat', 'exe', 'sh', 'php', 'vbs'])],
]); ]);
$currentDate = date('Y-m-d');
$startDate = date('Y-m-' . env('STARTING_DATE'));
$closingDateNextMonth = date('Y-m-', strtotime('+1 month')) . env('CLOSING_DATE');
if ($currentDate < $startDate || $currentDate > $closingDateNextMonth) {
return response()->json([
'error' => 'Current date is not within the valid range.'
], 400);
}
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang; $cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
$region = Region::where('id', $cabang->region_id)->first(); $region = Region::where('id', $cabang->region_id)->first();
$kategori = Kategori::where('name', 'Vehicle Running Cost')->first(); $kategori = Kategori::where('name', 'Vehicle Running Cost')->first();
@@ -22,6 +22,25 @@
</div> </div>
</div> </div>
</section> </section>
<style>
#loading-spinner-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent black background */
z-index: 9999; /* High z-index to cover everything */
display: flex;
justify-content: center;
align-items: center;
}
.spinner-wrapper {
text-align: center;
color: white;
}
</style>
<section class="content"> <section class="content">
<div class="container-fluid"> <div class="container-fluid">
<div class="card card-primary card-outline"> <div class="card card-primary card-outline">
@@ -22,6 +22,25 @@
</div> </div>
</div> </div>
</section> </section>
<style>
#loading-spinner-overlay {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5); /* Semi-transparent black background */
z-index: 9999; /* High z-index to cover everything */
display: flex;
justify-content: center;
align-items: center;
}
.spinner-wrapper {
text-align: center;
color: white;
}
</style>
<section class="content"> <section class="content">
<div class="container-fluid"> <div class="container-fluid">
<div class="card card-primary card-outline"> <div class="card card-primary card-outline">