示例#1
0
 /**
  * Update the specified resource in storage.
  *
  * @param 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->retailerProductRepository->getRetailerProductById(decode($rp_id)) && $this->repository->getFacultativeById(decode($id))) {
             $retailerProduct = $this->retailerProductRepository->getModel();
             if ($this->repository->updateFacultative($request)) {
                 $fa = $this->repository->getModel();
                 $header = $fa->detail->header;
                 $this->repository->approved = (int) $request->get('approved');
                 $surcharge = (bool) $request->get('surcharge');
                 if ($this->repository->approved === 1 || $this->repository->approved === 0) {
                     $this->headerRepository->setApproved($header);
                     if ($surcharge) {
                         $this->headerRepository->setVehicleResult($retailerProduct, $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();
 }
示例#2
0
 /**
  * Return Client by search
  *
  * @param string      $rp_id
  * @param string|null $header_id
  *
  * @return $this|\Illuminate\Http\RedirectResponse
  */
 public function search($rp_id, $header_id = null)
 {
     $ws = false;
     $client = null;
     $retailerProduct = null;
     if ($this->retailerProductRepository->getRetailerProductById(decode($rp_id))) {
         $retailerProduct = $this->retailerProductRepository->getModel();
         $ws = $retailerProduct->ws;
         if ($ws && $this->ws->getCustomer(request()->get('dni'))) {
             $result = $this->ws->result;
             $data = $this->getData($rp_id);
             $client = new Client();
             $client->code = $result[1];
             $client->last_name = $result[2];
             $client->mother_last_name = $result[3];
             $client->married_name = $result[4];
             $client->first_name = $result[5];
             $client->gender = $result[7];
             $client->civil_status = substr($result[8], 0, 1);
             $client->country = explode('-', $result[9])[3];
             $client->document_type = $result[10];
             $client->dni = $result[11];
             $client->extension = $result[12];
             $client->birthdate = date('Y-m-d', strtotime(str_replace('/', '-', $result[13])));
             $client->phone_number_home = $result[15];
             $client->phone_number_office = $result[16];
             $client->phone_number_mobile = $result[17];
             $client->email = $result[18];
             $client->place_residence = strtolower(str_replace(' ', '-', $result[19]));
             $client->locality = $result[20];
             $client->home_address = $result[21];
             foreach ($data['activities'] as $activity) {
                 if (array_key_exists('code', $activity) && $activity['code'] == $result[22]) {
                     $client->ad_activity_id = $activity['id'];
                 }
             }
             $client->occupation_description = $result[24];
             $client->debit_balance = empty($result[25]) ? '' : str_replace(',', '.', $result[25]);
         } elseif ($this->repository->getClientByDni(request()->get('dni'))) {
             $client = $this->repository->getModel();
             $client_id = encode($client->id);
             // return redirect()->route('de.detail.create', compact('rp_id', 'header_id', 'client_id'));
         }
         if ($client instanceof Client) {
             if ($retailerProduct->companyProduct->product->code === 'de') {
                 return redirect()->route('de.detail.create', compact('rp_id', 'header_id'))->with(['client' => $client]);
             }
             $url = URL::previous();
             return redirect($url)->with(['client' => $client])->withInput();
         }
     }
     return redirect()->back()->with(['error_client' => 'El Cliente no existe'])->withInput()->withErrors($this->repository->getErrors());
 }
示例#3
0
 /**
  * Update the specified resource in storage.
  *
  * @param VehicleEditFormRequest $request
  * @param string                 $rp_id
  * @param string                 $header_id
  * @param string                 $detail_id
  *
  * @return
  */
 public function updateIssuance(VehicleEditFormRequest $request, $rp_id, $header_id, $detail_id = null)
 {
     if (request()->ajax()) {
         if ($this->retailerProductRepository->getRetailerProductById(decode($rp_id))) {
             $retailerProduct = $this->retailerProductRepository->getModel();
             if ($this->repository->getDetailById(decode($detail_id))) {
                 if ($this->repository->updateVehicleIssuance($request)) {
                     $detail = $this->repository->getModel();
                     if (Cache::has(decode($header_id)) && $request->has('coverage')) {
                         goto StoreVehicle;
                     }
                     if ($this->facultativeRepository->storeFacultative($detail, $retailerProduct, $request->user())) {
                         $this->headerRepository->setHeaderFacultative(decode($header_id));
                         return response()->json(['location' => route('au.edit', ['rp_id' => $rp_id, 'header_id' => $header_id, $request->get('idf') ? 'idf=' . $request->get('idf') : null])]);
                     }
                 }
             } elseif (Cache::has(decode($header_id)) && $request->has('coverage') && $this->headerRepository->getHeaderById(decode($header_id))) {
                 $header = $this->headerRepository->getModel();
                 if ($this->repository->storeVehicle($request, $header, true)) {
                     $detail = $this->repository->getModel();
                     StoreVehicle:
                     $sf = $this->facultativeRepository->storeFacultative($detail, $retailerProduct, $request->user(), true);
                     if ($sf === 428) {
                         $errors = $this->facultativeRepository->getErrors();
                         return response()->json(['reason' => $errors['reason']], 428);
                     }
                     return response()->json(['location' => route('au.coverage.edit', ['rp_id' => $rp_id, 'de_id' => $request->get('coverage'), 'header_id' => $header_id])]);
                 }
             }
         }
         return response()->json(['err' => 'Unauthorized action.'], 401);
     }
     return redirect()->back();
 }
示例#4
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());
 }
示例#5
0
 /**
  * @param Guard   $auth
  * @param Request $request
  * @param string  $rp_id
  *
  * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
  */
 public function lists(Guard $auth, Request $request, $rp_id)
 {
     $data = $this->data($auth->user());
     $headers = [];
     $parameter = null;
     if ($request->has('_token')) {
         $request->flash();
     }
     if ($this->retailerProductRepository->getRetailerProductById(decode($rp_id))) {
         $retailerProduct = $this->retailerProductRepository->getModel();
         $parameter = $retailerProduct->parameters()->where('slug', 'GE')->first();
     }
     if ($parameter instanceof ProductParameter) {
         $headers = $this->repository->getHeaderList($request);
     }
     return view('de.quote.list', compact('rp_id', 'headers', 'data', 'parameter'));
 }
示例#6
0
 /**
  * @param string $rp_id
  * @param string $header_id
  *
  * @return mixed
  */
 public function issuance($rp_id, $header_id)
 {
     if ($this->retailerProductRepository->getRetailerProductById(decode($rp_id)) && $this->repository->getHeaderById(decode($header_id))) {
         $header = $this->repository->getModel();
         $retailerProduct = $this->retailerProductRepository->getModel();
         $retailer = $retailerProduct->retailer;
         return view('de.issuance', compact('rp_id', 'header_id', 'header', 'retailerProduct', 'retailer'));
     }
     return redirect()->back();
 }
示例#7
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 . ']);
 }