/**
  * Show the form for editing the specified resource.
  *
  * @param $rp_id
  * @param $header_id
  * @param $detail_id
  *
  * @return \Illuminate\Http\Response
  */
 public function edit($rp_id, $header_id, $detail_id)
 {
     if (request()->ajax()) {
         if ($this->detailRepository->getDetailById(decode($detail_id))) {
             $detail = $this->detailRepository->getModel();
             $beneficiary = $detail->beneficiary;
             $data = ['cities' => $this->cityRepository->getCitiesByType()];
             $payload = view('beneficiary.edit', compact('rp_id', 'header_id', 'detail', 'beneficiary', 'data'));
             return response()->json(['payload' => $payload->render(), 'beneficiary' => [$beneficiary]]);
         }
         return response()->json(['err' => 'Unauthorized action.'], 401);
     }
     return redirect()->back();
 }
Beispiel #2
0
 protected function getDataForReport()
 {
     $this->cities = $this->cityRepository->getCitiesByRetailer($this->retailer->id);
     $this->agencies = $this->agencyRepository->getAgenciesByRetailer($this->retailer->id);
     $this->users = $this->userRepository->getUsersByRetailer($this->retailer->id);
     $permission = $this->getPermissionForReport($this->user);
     /*
      * Cities
      */
     $this->cities = $this->cities->filter(function ($item) use($permission) {
         $item->id = $item->slug;
         if ($permission === 'RU' || $permission === 'RA' || $permission === 'RR') {
             if ($item->slug === $this->user->city->slug) {
                 return true;
             }
         } elseif ($permission === 'RN') {
             return true;
         }
     })->toArray();
     /*
      * Agencies
      */
     $this->agencies = $this->agencies->filter(function ($item) use($permission) {
         $item->id = $item->slug;
         if (!$this->user->agency instanceof Agency && $this->profile->slug === 'COP') {
             return true;
         } else {
             if ($permission === 'RU' || $permission === 'RA') {
                 if ($item->slug === $this->user->agency->slug) {
                     return true;
                 }
             } elseif ($permission === 'RR') {
                 foreach ($item->retailerCityAgencies as $retailerCityAgency) {
                     if ($retailerCityAgency->retailerCity->ad_city_id === $this->user->city->id) {
                         return true;
                     }
                 }
             } elseif ($permission === 'RN') {
                 return true;
             }
         }
     })->toArray();
     /*
      * Users
      */
     $this->users = $this->users->filter(function ($item) use($permission) {
         $item->id = $item->username;
         $item->name = $item->full_name;
         if ($permission === 'RU') {
             if ($item->username === $this->user->username) {
                 return true;
             }
         } elseif ($permission === 'RA') {
             if ($item->agency instanceof Agency && $item->agency->id === $this->user->agency->id) {
                 return true;
             }
         } elseif ($permission === 'RR') {
             if ($item->city instanceof City && $item->city->id === $this->user->city->id) {
                 return true;
             }
         } elseif ($permission === 'RN') {
             if ($item->agency instanceof Agency && $item->city instanceof City) {
                 return true;
             }
         }
     })->toArray();
     if ($permission !== 'RU') {
         $users = $this->getSelectOption();
         $this->users = $users->merge($this->users)->toArray();
         if ($permission === 'RN' || $permission === 'RR') {
             $agencies = $this->getSelectOption();
             $this->agencies = $agencies->merge($this->agencies)->toArray();
             if ($permission === 'RN') {
                 $cities = $this->getSelectOption();
                 $this->cities = $cities->merge($this->cities)->toArray();
             }
         }
     }
 }
Beispiel #3
0
 private function getData()
 {
     return ['property_types' => $this->dataRepository->getPropertyTypes(), 'property_uses' => $this->dataRepository->getPropertyUses(), 'cities' => $this->cityRepository->getCitiesByType()];
 }
Beispiel #4
0
 public function cityByType()
 {
     return $this->repository->getCitiesByType();
 }
Beispiel #5
0
 public function getData()
 {
     return ['payment_methods' => $this->dataRepository->getPaymentMethod(), 'periods' => $this->dataRepository->getPeriod(), 'civil_status' => $this->dataRepository->getCivilStatus(), 'document_type' => $this->dataRepository->getDocumentType(), 'gender' => $this->dataRepository->getGender(), 'cities' => $this->cityRepository->getCitiesByType(), 'activities' => $this->activityRepository->getActivities(), 'hands' => $this->dataRepository->getHand(), 'avenue_street' => $this->dataRepository->getAvenueStreet()];
 }
Beispiel #6
0
 /**
  * Returns Data for Client register
  *
  * @param string $rp_id
  *
  * @return array
  */
 public function getData($rp_id)
 {
     $this->getInstance();
     return ['civil_status' => $this->dataRepository->getCivilStatus(), 'document_type' => $this->dataRepository->getDocumentType(), 'gender' => $this->dataRepository->getGender(), 'cities' => $this->cityRepository->getCitiesByType(), 'activities' => $this->activityRepository->getActivitiesByProduct(decode($rp_id)), 'hands' => $this->dataRepository->getHand(), 'avenue_street' => $this->dataRepository->getAvenueStreet(), 'term_types' => $this->dataRepository->getTermType(), 'currencies' => $this->dataRepository->getCurrency()];
 }