Exemplo n.º 1
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);
         }
     }
 }
Exemplo n.º 2
0
 /**
  * @param Request $request
  * @param string  $rp_id
  * @param string  $id
  *
  * @return mixed
  */
 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();
 }
Exemplo n.º 3
0
 /**
  * Update the specified resource in storage.
  *
  * @param PropertyEditFormRequest $request
  * @param string                  $rp_id
  * @param string                  $header_id
  * @param string                  $detail_id
  *
  * @return
  */
 public function updateIssuance(PropertyEditFormRequest $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->updatePropertyIssuance($request)) {
                     $detail = $this->repository->getModel();
                     if (Cache::has(decode($header_id)) && $request->has('coverage')) {
                         goto StoreVehicle;
                     }
                     /*if ($this->facultativeRepository->storeTdFacultative($detail, $retailerProduct,
                                                 $request->user())
                                             ) {
                                                 $this->headerRepository->setHeaderFacultative(decode($header_id));
                     
                                                 return response()->json([
                                                     'location' => route('td.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->storeProperty($request, $header, true)) {
                     $detail = $this->repository->getModel();
                     StoreVehicle:
                     $sf = $this->facultativeRepository->storeTdFacultative($detail, $retailerProduct, $request->user(), true);
                     if ($sf === 428) {
                         $errors = $this->facultativeRepository->getErrors();
                         return response()->json(['reason' => $errors['reason']], 428);
                     }
                     return response()->json(['location' => route('td.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();
 }
Exemplo n.º 4
0
 /**
  * Update the specified resource in storage.
  *
  * @param HeaderEditFormRequest $request
  * @param string                $rp_id
  * @param string                $header_id
  */
 public function update(HeaderEditFormRequest $request, $rp_id, $header_id)
 {
     if ($this->repository->getHeaderById(decode($header_id))) {
         $header = $this->repository->getModel();
         $keyFac = false;
         $obs = false;
         # validacion facultativo
         $facultative = $this->facultativeRepository->roleFacultative(decode($rp_id), decode($header_id), $header);
         if ($facultative['facultative'] > 0) {
             $this->facultativeRepository->storeFacultative($facultative, $request->user());
             $obs = $this->facultativeRepository->returnObservation();
             $keyFac = true;
         } else {
             if ($header->facultative === 1) {
                 $this->repository->deleteFacultativeHeader();
             }
         }
         if ($this->repository->updateHeader($request, $keyFac, $obs)) {
             return redirect()->route('td.edit', ['rp_id' => $rp_id, 'header_id' => $header_id])->with(['success_header' => 'La Póliza fue actualizada con éxito.']);
         }
     }
     return redirect()->back()->withInput();
 }