Exemple #1
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());
 }
Exemple #2
0
 public function updateIssue(ClientComplementFormRequest $request, $rp_id, $header_id, $detail_id, $ref)
 {
     $ref = strtoupper($ref);
     if ($this->repository->getDetailById(decode($detail_id))) {
         $detail = $this->repository->getModel();
         if (in_array($ref, $this->reference)) {
             if ($detail->client instanceof Client && $this->clientRepository->updateIssueClient($request, $detail->client)) {
                 return redirect()->route('de.edit', ['rp_id' => $rp_id, 'header_id' => $header_id, $request->has('_idf') ? 'idf=' . e($request->get('_idf')) : null])->with(['success_client' => 'La información del Cliente se actualizó correctamente']);
             }
         }
     }
     return redirect()->back()->with(['error_client' => 'La información del Cliente no pudo ser actualizada'])->withInput()->withErrors($this->repository->getErrors());
 }
Exemple #3
0
 /**
  * @param CoverageCreateFormRequest $request
  * @param string                    $rp_id
  * @param string                    $de_id
  *
  * @return mixed
  */
 public function coverageStore(CoverageCreateFormRequest $request, $rp_id, $de_id)
 {
     if (request()->ajax()) {
         if ($this->retailerProductRepository->getRetailerProductById(decode($rp_id)) && $this->headerDeRepository->getHeaderById(decode($de_id)) && $this->clientRepository->getClientById(decode($request->get('client')))) {
             $retailerProduct = $this->retailerProductRepository->getModel();
             $de = $this->headerDeRepository->getModel();
             $client = $this->clientRepository->getModel();
             if ($this->repository->storeCoverage($request, $retailerProduct)) {
                 $header = $this->repository->getModel();
                 Cache::put($header->id, $request->get('rp_de'), 180);
                 return response()->json(['location' => route('td.coverage.edit', ['rp_id' => $rp_id, 'de_id' => $de_id, 'header_id' => encode($header->id)])]);
             }
         }
         return response()->json(['err' => 'Unauthorized action.'], 401);
     }
     return redirect()->back();
 }