/**
  * Retrieves the default approvers of a certain request type.
  * @param none, accepts json request
  * @return \Illuminate\Http\Response
  */
 public function getRequestApprover(Request $request)
 {
     //Initialization
     $RequestTypeApprover = new RequestTypeApprover();
     $filing_type = $request->filing_type;
     $project_code = $request->project_code;
     $request_type_code = $request->request_type_code;
     $user_id = trim(Auth::user()->app_code);
     //Get request type code (DB:req_code)
     if ($filing_type == 'RFC') {
         $request_type_code = $request->req_ref;
     }
     //Retrieve default approvers
     $request_approvers = $RequestTypeApprover->getRequestApprover($project_code, $request_type_code);
     return Response::json($request_approvers);
 }
Exemplo n.º 2
0
 /**
  * Show the form for editing the specified resource.
  *
  * @param  int  $request_id (required)
  * @param $filing_type (required) values 'RFC', 'RFR' and 'QAC'
  * @param $action_type values 'edit' -> for viewing an empty or filled form, 
  *                            'update' -> for viewing newly saved request form
  * @return Response
  */
 public function edit($request_id, $filing_type, $action_type = 'edit')
 {
     if ($request_id) {
         $EASRequest = new EASRequest();
         $projects = new Project();
         $user_id = trim(Auth::user()->app_code);
         $data = [];
         $data['filing_type'] = $filing_type;
         $data['details'] = $EASRequest->getRequestDetails($request_id, $user_id);
         $data['signed'] = 0;
         $precedingLevel = $data['details']['user_approver']['rfcline_level'] - 1;
         $data['uneditable_fields'] = [];
         //Retrieve user granted projects
         $data['projects'] = $projects->getProjects($user_id, $data['filing_type'], '3');
         //Additional variables per request type, if any.
         if ($data['filing_type'] == 'RFR') {
             $RequestTypeApprover = new RequestTypeApprover();
             $data['granted_request_types'] = $RequestTypeApprover->getUserGrantedRequestTypes($user_id);
             if ($data['details']['re_nature'] == 'Forfeiture') {
                 $data['rfr_type'] = 'forfeiture';
                 $data['uneditable_fields']['rfc_ref_no'] = '1';
             } else {
                 $data['rfr_type'] = 'rfc';
                 $request_description = explode('-', $data['details']['re_nature']);
                 $data['default_req_reference'] = $data['details']['rfc_refno'] . ' : ' . $request_description[1];
                 $data['uneditable_fields']['project_type'] = '1';
                 $data['uneditable_fields']['lot_code'] = '1';
             }
         } else {
             if ($data['filing_type'] == 'RFC') {
                 $RequestType = new RequestType();
                 $data['req_refs'] = $RequestType->getRequestType('RFC');
             }
         }
         if ($action_type == 'update') {
             return view('request.edit', $data)->withErrors(['Request saved.']);
         }
         return view('request.edit', $data);
     }
     return Redirect::back()->withErrors(['Page not found.']);
 }