fix some revisi

This commit is contained in:
Jagad R R
2025-01-19 14:57:01 +07:00
parent 430700bc59
commit 1610d83bc6
17 changed files with 562 additions and 477 deletions
@@ -115,9 +115,10 @@ class FormUpCountryController extends Controller
public function create()
{
$this->checkAuthorization(auth()->user(), ['forms.country.create']);
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
return view('backend.pages.forms.upcountry.create', [
'rayons' => Rayon::all()
'rayons' => Rayon::where('cabang_id', $cabang->id)->get()
]);
}
@@ -140,14 +141,12 @@ class FormUpCountryController extends Controller
'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);
if ($request->tanggal < $startDate || $request->tanggal > $closingDateNextMonth) {
session()->flash('error', 'Gagal, Input expense sudah melewati periode input 12-10');
return redirect()->back();
}
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
@@ -220,9 +219,8 @@ class FormUpCountryController extends Controller
];
// Check if the total nominal exceeds the available budget
$cabang_id = UserHasCabang::where('user_id', auth()->user()->id)->first()->cabang_id;
if(array_sum($data_nominal) > BudgetHelper::getAvailableBudget($cabang_id)) {
session()->flash('error', 'The total nominal exceeds the available budget.');
if(array_sum($data_nominal) > BudgetHelper::getAvailableBudget($cabang->id)) {
session()->flash('error', 'Alokasi budget bulanan cabang tidak mencukupi,silahkan ajukan pada periode expense berikutnya');
return redirect()->back();
}
@@ -307,6 +305,8 @@ class FormUpCountryController extends Controller
$this->checkAuthorization(auth()->user(), ['forms.country.edit']);
$role = auth()->user()->getRoleNames()[0];
$cabang = UserHasCabang::with('cabang')->where('user_id', auth()->user()->id)->first()->cabang;
$form = FormUpCountry::with('rayon')->findOrfail($id);
if (($form->status != 'On Progress' && $form->status != 'Rejected') && $role == 'Medical Representatif') {
session()->flash('error', 'You cannot edit this form because it has been approved or closed.');
@@ -314,7 +314,7 @@ class FormUpCountryController extends Controller
}
return view('backend.pages.forms.upcountry.edit', [
'rayons' => Rayon::all(),
'rayons' => Rayon::where('cabang_id', $cabang->id)->get(),
'form' => $form
]);
}