Exemple #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();
 }
Exemple #2
0
 public function storeSubProduct(HeaderSpCreateFormRequest $request, $rp_id, $header_id, $sp_id)
 {
     $beneficiaries = $request->get('beneficiaries');
     $participation = 0;
     foreach ($beneficiaries as $beneficiary) {
         $participation += $beneficiary['participation'];
     }
     if ($participation == 100) {
         $success_header = ['success_header' => 'El Sub-Producto fue asociado correctamente'];
         if ($this->headerDeRepository->getHeaderById(decode($header_id)) && $this->retailerProductRepository->getRetailerProductById(decode($sp_id))) {
             $headerDe = $this->headerDeRepository->getModel();
             $detailDe = $headerDe->details()->where('id', decode($request->get('detail_id')))->first();
             $retailerProduct = $this->retailerProductRepository->getModel();
             $request['detail'] = $detailDe;
             $request['policies'] = $this->policyRepository->getPolicyByProduct(decode($sp_id));
             $request['plans'] = $this->planRepository->getPlansByProduct(decode($sp_id));
             if ($this->repository->storeSubProduct($request, $retailerProduct) && $this->accountRepository->storeAccount($request)) {
                 if ($this->repository->destroyClientCacheSP(decode($header_id), decode($request->get('detail_id')))) {
                     return redirect()->route('de.vi.sp.create', ['rp_id' => $rp_id, 'header_id' => $header_id, 'sp_id' => $sp_id])->with($success_header);
                 } else {
                     return redirect()->route('de.issuance', ['rp_id' => $rp_id, 'header_id' => $header_id])->with($success_header);
                 }
             }
         }
     } else {
         return redirect()->back()->with(['error_participation' => 'La suma de porcentajes de Beneficiarios del Titular debe ser del 100%'])->withInput();
     }
     return redirect()->back()->with(['error_header' => 'El Sub-Producto no puede ser asociado al Titular'])->withInput()->withErrors($this->repository->getErrors());
 }
 /**
  * Update the specified resource in storage.
  *
  * @param Request|FacultativeFormRequest $request
  * @param string                         $rp_id
  * @param string                         $id
  *
  * @return \Illuminate\Http\Response
  */
 public function update(FacultativeFormRequest $request, $rp_id, $id)
 {
     if ($request->ajax()) {
         if ($this->repository->getFacultativeById(decode($id))) {
             if ($this->repository->updateFacultative($request)) {
                 $fa = $this->repository->getModel();
                 $header = $fa->detail->header;
                 $this->repository->approved = (int) $request->get('approved');
                 if ($this->repository->approved === 1 || $this->repository->approved === 0) {
                     $this->headerRepository->setApproved($header);
                 }
                 $mail = new MailController($request->user(), $request->get('emails'));
                 $this->repository->sendProcessMail($mail, $rp_id, $id);
                 return response()->json(['location' => route('home')]);
             }
         }
         return response()->json(['err' => 'Unauthorized action.'], 401);
     }
     return redirect()->back();
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @param string                    $rp_id
  * @param string                    $header_id
  *
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request, $rp_id, $header_id)
 {
     $this->validate($request, ['reason' => 'required|ands_full']);
     if (request()->ajax()) {
         if ($this->headerRepository->getHeaderById(decode($header_id))) {
             $header = $this->headerRepository->getModel();
             if ($this->repository->storeCancellation($request, $header)) {
                 $mail = new MailController($request->user());
                 $mail->subject = 'Anulacion de Poliza No. ' . $header->prefix . '-' . $header->issue_number;
                 $mail->template = 'de.cancellation';
                 array_push($mail->receivers, ['email' => $header->user->email, 'name' => $header->user->full_name]);
                 if ($mail->send(decode($rp_id), ['header' => $header])) {
                 }
                 return response()->json(['location' => route('de.cancel.lists', ['rp_id' => $rp_id])]);
             }
         }
         return response()->json(['err' => 'Unauthorized action.'], 401);
     }
     return redirect()->back();
 }
Exemple #5
0
 /**
  * @param string $product
  * @param string $q
  *
  * @return
  */
 public function policies($product, $q = '')
 {
     if (request()->ajax()) {
         if ($this->repository->getPolicies($product, $q)) {
             $headers = $this->repository->getModel();
             return response()->json(['headers' => $headers]);
         }
         return response()->json(['err' => 'Unauthorized action.'], 401);
     }
     return redirect()->back()->with(['error_header' => 'Unauthorized.']);
 }
Exemple #6
0
 /**
  * @param CoverageEditFormRequest $request
  * @param string                  $rp_id
  * @param string                  $de_id
  * @param string                  $header_id
  *
  * @return mixed
  */
 public function coverageUpdate(CoverageEditFormRequest $request, $rp_id, $de_id, $header_id)
 {
     if (Cache::has(decode($header_id)) && $this->retailerProductRepository->getRetailerProductById(decode($rp_id))) {
         $retailerProduct = $this->retailerProductRepository->getModel();
         if ($this->repository->getHeaderById(decode($header_id)) && $this->headerDeRepository->getHeaderById(decode($de_id))) {
             $header = $this->repository->getModel();
             $de = $this->headerDeRepository->getModel();
             if ($this->repository->setPropertyResult($retailerProduct, $header) && $this->repository->updateCoverage($request, $de)) {
                 $rp_de = Cache::get(decode($header_id));
                 return redirect()->route('de.issuance', ['rp_id' => $rp_de, 'header_id' => $de_id])->with(['success_header' => 'La garantía fue asociada correctamente.']);
             }
         }
     }
     return redirect()->back()->with(['error_header' => 'La cobertura no puede ser emitida . ']);
 }