add budgets

This commit is contained in:
Jagad R R
2025-01-07 17:23:42 +07:00
parent 8c62fb6a19
commit 1027b0dfb4
24 changed files with 868 additions and 36 deletions
@@ -220,10 +220,11 @@ class FormUpCountryController extends Controller
public function edit($id)
{
$this->checkAuthorization(auth()->user(), ['forms.country.edit']);
$role = auth()->user()->getRoleNames()[0];
$form = FormUpCountry::with('rayon')->findOrfail($id);
if($form->status == 'Closed') {
session()->flash('error', 'Form has been closed, you cannot edit it.');
if($form->status != 'On Progress' && $role == 'Medical Representatif') {
session()->flash('error', 'You cannot edit this form because it has been approved or rejected.');
return redirect()->back();
}
@@ -236,6 +237,7 @@ class FormUpCountryController extends Controller
public function update(Request $request, $id)
{
$this->checkAuthorization(auth()->user(), ['forms.country.edit']);
$role = auth()->user()->getRoleNames()[0];
$request->validate([
'rayon_id' => 'required|exists:rayon,id',
@@ -253,8 +255,8 @@ class FormUpCountryController extends Controller
]);
$form = FormUpCountry::findOrfail($id);
if($form->status == 'Closed') {
session()->flash('error', 'Form has been closed, you cannot edit it.');
if($form->status != 'On Progress' && $role == 'Medical Representatif') {
session()->flash('error', 'You cannot edit this form because it has been approved or rejected.');
return redirect()->back();
}
@@ -537,6 +539,11 @@ class FormUpCountryController extends Controller
$this->checkAuthorization(auth()->user(), ['forms.country.delete']);
$form = FormUpCountry::findOrfail($id);
if($form->status != 'On Progress' && $role == 'Medical Representatif') {
session()->flash('error', 'You cannot edit this form because it has been approved or rejected.');
return redirect()->back();
}
AuditTrailHelper::AddAuditTrail('Delete', 'Delete Record at Form Entertainment Presentation (' . $form->expense_number . ')');
$form->delete();