Esempio n. 1
0
 public function updateCustomRecord($parameters)
 {
     // get object to update data and data_lang field
     $customField = CustomField::find($this->request->input('id'));
     // get values
     $data = json_decode($customField->data_026, true);
     // set values
     $data['labels'][$this->request->input('lang')] = $this->request->input('label');
     CustomField::where('id_026', $parameters['id'])->update(['group_id_026' => $this->request->input('group'), 'name_026' => $this->request->input('name'), 'field_type_id_026' => $this->request->input('fieldType'), 'field_type_name_026' => collect(config('pulsar.fieldTypes'))->keyBy('id')[$this->request->input('fieldType')]->name, 'data_type_id_026' => $this->request->input('dataType'), 'data_type_name_026' => collect(config('pulsar.dataTypes'))->keyBy('id')[$this->request->input('dataType')]->name, 'required_026' => $this->request->has('required'), 'sorting_026' => empty($this->request->input('sorting')) ? null : $this->request->input('sorting'), 'max_length_026' => empty($this->request->input('maxLength')) ? null : $this->request->input('maxLength'), 'pattern_026' => empty($this->request->input('pattern')) ? null : $this->request->input('pattern'), 'label_size_026' => empty($this->request->input('labelSize')) ? null : $this->request->input('labelSize'), 'field_size_026' => empty($this->request->input('fieldSize')) ? null : $this->request->input('fieldSize'), 'data_026' => json_encode($data)]);
 }
 /**
  * Function to get html from custom fields
  *
  * @param $parameters
  * @return \Illuminate\Http\JsonResponse
  * @throws \Exception
  * @throws \Throwable
  */
 public static function getCustomFields($parameters)
 {
     // get custom fields
     $customFields = CustomField::getRecords(['lang_026' => $parameters['lang'], 'group_id_026' => $parameters['customFieldGroup']]);
     if ($parameters['object']) {
         if (!empty($parameters['action']) && $parameters['action'] == 'storeLang') {
             // if is a new object translated
             $langFieldResults = base_lang()->id_001;
         } else {
             $langFieldResults = $parameters['lang'];
         }
         // get results if there is a object
         $customFieldResults = CustomFieldResult::where('lang_id_028', $langFieldResults)->where('object_id_028', $parameters['object'])->where('resource_id_028', $parameters['resource'])->get();
     }
     $html = '';
     foreach ($customFields as $customField) {
         $setValue = isset($customFieldResults) && $customFieldResults->where('field_id_028', $customField->id_026)->count() > 0;
         // add suffix '_custom' to avoid conflict with other field names
         if (collect(config('pulsar.fieldTypes'))->keyBy('id')[$customField->field_type_id_026]->key == 'selectMultiple' || collect(config('pulsar.fieldTypes'))->keyBy('id')[$customField->field_type_id_026]->key == 'selectMultiple2') {
             // TODO: se pueden coger todos los valores antes del foreach para evitar multiples consultas
             $customFieldValues = $customField->getValues()->where('lang_id_027', base_lang()->id_001)->get();
             $multipleSelectValue = null;
             if ($setValue) {
                 if (collect(config('pulsar.dataTypes'))->keyBy('id')[$customField->data_type_id_026]->type == 'array') {
                     $multipleSelectValue = $customFieldResults->where('field_id_028', $customField->id_026)->first()->value_028;
                 } else {
                     $multipleSelectValue = $customFieldResults->where('field_id_028', $customField->id_026)->pluck('value_028')->toArray();
                 }
             }
             // check if is select2 plugin
             $isSelect2 = collect(config('pulsar.fieldTypes'))->keyBy('id')[$customField->field_type_id_026]->key == 'selectMultiple2';
             $html .= view(collect(config('pulsar.fieldTypes'))->keyBy('id')[$customField->field_type_id_026]->view, ['label' => $customField['label_026'], 'name' => $customField['name_026'] . '_custom[]', 'fieldSize' => empty($customField['field_size_026']) ? 10 : $customField['field_size_026'], 'objects' => $customFieldValues, 'idSelect' => 'id_027', 'nameSelect' => 'name_027', 'required' => $customField->required_026, 'class' => $isSelect2 ? 'select2' : null, 'id' => $customField['name_026'] . '_custom', 'multiple' => true, 'data' => $isSelect2 ? ['language' => config('app.locale'), 'width' => '100%', 'error-placement' => 'select2-' . $customField['name_026'] . '_custom' . '-outer-container'] : null, 'value' => $setValue ? $multipleSelectValue : null])->render();
         } elseif (collect(config('pulsar.fieldTypes'))->keyBy('id')[$customField->field_type_id_026]->key == 'select' || collect(config('pulsar.fieldTypes'))->keyBy('id')[$customField->field_type_id_026]->key == 'select2') {
             $customFieldValues = $customField->getValues()->where('lang_id_027', base_lang()->id_001)->get();
             // check if is select2 plugin
             $isSelect2 = collect(config('pulsar.fieldTypes'))->keyBy('id')[$customField->field_type_id_026]->key == 'select2';
             $html .= view(collect(config('pulsar.fieldTypes'))->keyBy('id')[$customField->field_type_id_026]->view, ['label' => $customField['label_026'], 'name' => $customField['name_026'] . '_custom', 'fieldSize' => empty($customField['field_size_026']) ? 10 : $customField['field_size_026'], 'objects' => $customFieldValues, 'idSelect' => 'id_027', 'nameSelect' => 'name_027', 'required' => $customField->required_026, 'class' => $isSelect2 ? 'select2' : null, 'id' => $customField['name_026'] . '_custom', 'data' => $isSelect2 ? ['language' => config('app.locale'), 'width' => '100%', 'error-placement' => 'select2-' . $customField['name_026'] . '_custom' . '-outer-container'] : null, 'value' => $setValue ? $customFieldResults->where('field_id_028', $customField->id_026)->first()->value_028 : null])->render();
         } elseif (collect(config('pulsar.fieldTypes'))->keyBy('id')[$customField->field_type_id_026]->key == 'checkbox') {
             $html .= view(collect(config('pulsar.fieldTypes'))->keyBy('id')[$customField->field_type_id_026]->view, ['label' => $customField['label_026'], 'name' => $customField['name_026'] . '_custom', 'fieldSize' => empty($customField['field_size_026']) ? 10 : $customField['field_size_026'], 'required' => $customField->required_026, 'checked' => $setValue ? $customFieldResults->where('field_id_028', $customField->id_026)->first()->value_028 : null])->render();
         } else {
             $html .= view(collect(config('pulsar.fieldTypes'))->keyBy('id')[$customField->field_type_id_026]->view, ['label' => $customField['label_026'], 'name' => $customField['name_026'] . '_custom', 'fieldSize' => empty($customField['field_size_026']) ? 10 : $customField['field_size_026'], 'required' => $customField->required_026, 'value' => $setValue ? $customFieldResults->where('field_id_028', $customField->id_026)->first()->value_028 : null])->render();
         }
     }
     return $html;
 }
Esempio n. 3
0
 public static function deleteTranslationRecord($parameters, $deleteLangDataRecord = true)
 {
     $customField = CustomField::find($parameters['id']);
     // get values
     $data = collect(json_decode($customField->data_026, true)['labels']);
     unset($data[$parameters['lang']]);
     CustomField::where('id_026', $parameters['id'])->update(['data_026' => json_encode(['labels' => $data])]);
     // set values on data_lang_026
     CustomField::deleteLangDataRecord($parameters);
 }
Esempio n. 4
0
 private function sendEmails(Booking $booking)
 {
     // objects from place
     if (isset($booking->place_id_225)) {
         $result = collect(config('booking.models'))->where('id', $booking->place_id_225);
         if (count($result) === 0) {
             return response()->json(['status' => 'error', 'code' => 404, 'message' => 'Records not found']);
         }
         // model constructor
         $model = App::make($result->first()->model);
         // use sofa to get lang from lang table of object query
         $establishment = $model->builder()->where('lang_id', base_lang()->id_001)->where('id', $booking->object_id_225)->first();
         $attachment = Attachment::builder()->where('lang_id_016', base_lang()->id_001)->where('resource_id_016', 'hotels-hotel')->where('object_id_016', $establishment->id)->where('family_id_016', 1)->orderBy('sorting', 'asc')->first();
         //****************************
         // get values to Master Card
         //****************************
         $customFields = CustomField::where('group_id_026', 4)->get();
         if (isset($customFields) && $customFields->where('name_026', 'master_card_feature')->count() > 0) {
             $masterCardFeatures = $customFields->where('name_026', 'master_card_feature')->first()->getResults()->where('object_id_028', $establishment->id_170)->where('lang_id_028', 'es')->get()->first();
         } else {
             $masterCardFeatures = null;
         }
         // get vouchers
         $vouchers = Voucher::builder()->whereIn('id_226', json_decode($booking->data_225))->get();
         // status confirmed
         if ($booking->status_225 == 1) {
             Mail::to('*****@*****.**')->bcc('*****@*****.**')->cc('*****@*****.**')->send(new BookingEmail('booking::emails.customer_booking_notification', trans('booking::pulsar.subject_customer_booking_email', ['bookingId' => $booking->id_225 . '/' . date('Y')]), $booking, $establishment, $vouchers, $attachment, $masterCardFeatures));
             Mail::to('*****@*****.**')->bcc('*****@*****.**')->cc('*****@*****.**')->send(new BookingEmail('booking::emails.hotel_booking_notification', trans('booking::pulsar.subject_hotel_booking_email', ['bookingId' => $booking->id_225 . '/' . date('Y')]), $booking, $establishment, $vouchers, $attachment, $masterCardFeatures));
         } elseif ($booking->status_225 == 3) {
             Mail::to('*****@*****.**')->bcc('*****@*****.**')->cc('*****@*****.**')->send(new BookingEmail('booking::emails.customer_cancel_booking_notification', trans('booking::pulsar.subject_customer_cancel_booking_email', ['bookingId' => $booking->id_225 . '/' . date('Y')]), $booking, $establishment, $vouchers, $attachment, $masterCardFeatures));
             Mail::to('*****@*****.**')->bcc('*****@*****.**')->cc('*****@*****.**')->send(new BookingEmail('booking::emails.hotel_cancel_booking_notification', trans('booking::pulsar.subject_hotel_cancel_booking_email', ['bookingId' => $booking->id_225 . '/' . date('Y')]), $booking, $establishment, $vouchers, $attachment, $masterCardFeatures));
         }
     }
 }
 public function editCustomRecord($parameters)
 {
     $parameters['fieldObject'] = CustomField::getTranslationRecord(['id' => $parameters['field'], 'lang' => $parameters['lang']->id_001]);
     $parameters['customTransHeader'] = trans_choice($this->objectTrans, 2) . ' (' . trans_choice('pulsar::pulsar.field', 1) . ': ' . $parameters['fieldObject']->name_026 . ')';
     return $parameters;
 }