Example #1
0
 public function updateBalance(BalanceFormRequest $request, $rp_id, $header_id, $detail_id)
 {
     if ($request->ajax()) {
         if ($this->headerRepository->getHeaderById(decode($header_id))) {
             $request['header'] = $this->headerRepository->getModel();
             if ($this->repository->updateBalance($request, decode($detail_id))) {
                 $request['detail'] = $this->repository->getModel();
                 $request['retailer'] = $request->user()->retailerUser->retailer;
                 $approved = true;
                 if ($this->facultativeRepository->storeFacultative($request, decode($rp_id))) {
                     $approved = false;
                 }
                 $header = $this->repository->getModel()->header;
                 $facultative = false;
                 if ($header->type === 'I') {
                     $facultative = $this->headerRepository->setFacultative($header);
                 }
                 $this->repository->setApprovedDetail($approved, $facultative);
                 return response()->json(['location' => route('de.edit', compact('rp_id', 'header_id'))]);
             }
         }
         return response()->json(['err' => 'Unauthorized action.'], 401);
     }
     return redirect()->back();
 }
Example #2
0
 /**
  * @param Model|RetailerProduct $retailerProduct
  * @param array                 $data
  */
 private function setData($retailerProduct, &$data)
 {
     if ($retailerProduct->type === 'MP' && $retailerProduct->facultative) {
         $flag_product = false;
         switch ($this->profile->slug) {
             case 'COP':
                 if ($this->profile->slug === 'COP' && $retailerProduct->companyProduct->ad_company_id === $this->user->retailerUser->company->id) {
                     $flag_product = true;
                 }
                 break;
             case 'SEP':
                 if ($this->user->retailerUser->products()->where('ad_products.id', $retailerProduct->companyProduct->product->id)->count() === 1) {
                     $flag_product = true;
                 }
                 break;
         }
         if ($flag_product) {
             $product = $retailerProduct->companyProduct->product;
             $product->rp = $retailerProduct;
             switch ($product->code) {
                 case 'de':
                     $product->records = $this->facultativeDeRepository->getRecords($this->user, $this->inbox, $this->header_id);
                     break;
                 case 'au':
                     $product->records = $this->facultativeAuRepository->getRecords($this->user, $this->inbox, $this->header_id);
                     break;
                 case 'td':
                     $product->records = $this->facultativeTdRepository->getRecords($this->user, $this->inbox, $this->header_id);
                     break;
             }
             array_push($data['products'], $product);
         }
     }
 }
Example #3
0
 public function readUpdate(Request $request, $rp_id, $id)
 {
     if (request()->ajax()) {
         if ($this->repository->readUpdate($request, decode($id))) {
             return response()->json(['read' => filter_var($request->get('read'), FILTER_VALIDATE_BOOLEAN)]);
         }
         return response()->json(['err' => 'Unauthorized action.'], 401);
     }
     return redirect()->back();
 }
Example #4
0
 /**
  * Update the specified resource in storage.
  *
  * @param HeaderEditFormRequest $request
  * @param string                $rp_id
  * @param string                $header_id
  * @param string                $id_facultative
  *
  * @return Response
  */
 public function updateFa(HeaderEditFormRequest $request, $rp_id, $header_id, $id_facultative)
 {
     if ($this->repository->updateHeaderFacultative($request, decode($header_id))) {
         $mail = new MailController($request->user());
         $this->facultativeRepository->approved = 2;
         $this->facultativeRepository->sendProcessMail($mail, $rp_id, $id_facultative, true);
         return redirect()->route('home')->with(['success_header' => 'La Póliza fue actualizada con éxito.']);
     }
     return redirect()->back()->with(['error_header' => 'La Póliza no pudo ser actualizada.'])->withInput()->withErrors($this->repository->getErrors());
 }
 /**
  * Display the specified resource.
  *
  * @param string $rp_id
  * @param  int   $id
  *
  * @return \Illuminate\Http\Response
  */
 public function show($rp_id, $id)
 {
     if ($this->facultativeRepository->getFacultativeById(decode($id))) {
         $fa = $this->facultativeRepository->getModel();
         if ($fa->observations->last()->state->slug === 'me') {
             $answer = $fa->observations->last()->answers;
             if ($answer instanceof Answer && $this->repository->getMedicalCertificateById($answer->mc_certificate_id)) {
                 $mc = $this->repository->getModel();
                 $answer->response = json_decode($answer->response, true);
                 $payload = view('de.mc.certificate', compact('mc', 'fa', 'answer'))->render();
                 return $this->pdf->create($payload, 'Certificado Médico');
             }
         }
     }
     return redirect()->back();
 }