/** * Update the specified resource in storage. * PUT /approval/{id} * * @param int $id * @return Response */ public function update($id) { try { $this->approvalForm->validate(Input::all()); } catch (FormValidationException $error) { return Redirect::back()->withInput()->withErrors($error->getErrors()); } $decisionOptions = Input::get('decisionOptions'); $formRejectReasons = Input::get('formRejectReasons'); $approver = Input::get('approver'); $approval = $this->execute(new ApproveRequestCommand($id, $decisionOptions, $formRejectReasons, $approver)); if ($approval) { $formNum = $this->onlineFormRepo->getFormNum($id); $viewRequest = '<a href="' . URL::route('rfps.show', $formNum) . '">View Request here.' . '</a>'; $msg = ''; if ($decisionOptions == 0) { $msg = 'Request approved! ' . $viewRequest; Flash::success($msg); } else { $msg = 'Request rejected! ' . $viewRequest; Flash::success($msg); } } else { Flash::error('Failed to make a decision'); } return Redirect::route('approval.edit', $id); }
/** * Handles the command. * * @param CloseRequestCommand $command */ public function handle($command) { $onlineForm = $this->onlineFormRepository->getFormByFormableID($command->id); $onlineForm->stage = 0; $onlineForm->status = 1; $updateOnlineForm = $this->onlineFormRepository->save($onlineForm); if ($onlineForm->form_type == 'RequestForPayment' && $updateOnlineForm) { $closeForm = $this->rfpRepository->closeForm($onlineForm->formable_id); } return $this->onlineFormRepository->closeRequest($command->id); }
/** * Handles the command. * * @param EditRFPCommand $command * @return RequestForPayment */ public function handle($command) { $rfp = $this->rfpRepository->getFormByFormNum($command->form_num); if ($rfp) { $rfp->payee_firstname = $command->payee_firstname; $rfp->payee_middlename = $command->payee_middlename; $rfp->payee_lastname = $command->payee_lastname; $rfp->date_requested = $command->date_requested; $rfp->particulars = $command->particulars; $rfp->total_amount = $command->total_amount; $rfp->client_id = $command->client_id; $rfp->check_num = $command->check_num; $rfp->date_needed = $command->date_needed; $this->rfpRepository->save($rfp); $onlineForm = $this->onlineFormRepository->getFormByFormableID($rfp->id); $onlineForm->department_id = $command->department_id; $this->onlineFormRepository->save($onlineForm); } return $rfp; }
/** * Update the specified resource in storage. * * @param int $id * @return Response */ public function update($id) { $this->approvalForm->validate(Input::all()); $decisionOptions = Input::get('decisionOptions'); $formRejectReasons = Input::get('formRejectReasons'); $receiver = Input::get('receiver'); $receiving = $this->execute(new ApproveReceiveRequestCommand($id, $decisionOptions, $formRejectReasons, $receiver)); if ($receiving) { $formNum = $this->onlineFormRepo->getFormNum($id); $viewRequest = '<a href="' . URL::route('rfps.show', $formNum) . '">View Request here.' . '</a>'; $msg = ''; if ($decisionOptions == 0) { $msg = 'Request approved! ' . $viewRequest; Flash::success($msg); } else { $msg = 'Request rejected! ' . $viewRequest; Flash::success($msg); } } else { Flash::error('Failed to make a decision'); } return Redirect::route('receiving.edit', $id); }