revised approve system and some minor fixes
This commit is contained in:
@@ -65,6 +65,17 @@ class FormUpCountryController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
public function detail($id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['forms.country.view']);
|
||||
|
||||
$form = FormUpCountry::with(['rayon', 'user'])->findOrFail($id);
|
||||
$form->bukti1 = NextCloudHelper::getFileUrl($form->bukti1);
|
||||
$form->bukti2 = NextCloudHelper::getFileUrl($form->bukti2);
|
||||
$form->bukti3 = NextCloudHelper::getFileUrl($form->bukti3);
|
||||
return response()->json($form);
|
||||
}
|
||||
|
||||
public function create()
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['forms.country.create']);
|
||||
@@ -273,15 +284,28 @@ class FormUpCountryController extends Controller
|
||||
return redirect()->back();
|
||||
}
|
||||
|
||||
public function approve($id)
|
||||
public function approve(Request $request, $id)
|
||||
{
|
||||
$this->checkAuthorization(auth()->user(), ['approval.approve']);
|
||||
|
||||
$form = FormUpCountry::findOrfail($id);
|
||||
$approved_data = [
|
||||
'allowance' => $request->allowance ? $form->allowance : 0,
|
||||
'transport_dalkot' => $request->transport_dalkot ? $form->transport_dalkot : 0,
|
||||
'transport_ankot' => $request->transport_ankot ? $form->transport_ankot : 0,
|
||||
'hotel' => $request->hotel ? $form->hotel : 0,
|
||||
];
|
||||
|
||||
$form->update([
|
||||
'approved_at' => now(),
|
||||
'approved_by' => auth()->user()->id,
|
||||
'status' => 'Approved'
|
||||
'status' => 'Approved',
|
||||
|
||||
'approved_allowance' => $approved_data['allowance'],
|
||||
'approved_transport_dalkot' => $approved_data['transport_dalkot'],
|
||||
'approved_transport_ankot' => $approved_data['transport_ankot'],
|
||||
'approved_hotel' => $approved_data['hotel'],
|
||||
'approved_total' => array_sum($approved_data),
|
||||
]);
|
||||
|
||||
$heads = $form->user->getCabangAndRegionHead();
|
||||
|
||||
Reference in New Issue
Block a user