Example #1
0
 /**
  * Render column cell
  *
  * @param $instance
  * @param int $totalCount
  * @param string $content
  * @return string
  */
 public function render($instance, $totalCount, $content = null)
 {
     if (is_null($content)) {
         $content = $this->valueFromInstance($instance, $this->name);
     }
     $content = $this->renderAppends($instance, $totalCount, $content);
     return $this->htmlBuilder->tag('td', $this->getAttributesForCell($instance), $content);
 }
Example #2
0
 public function render()
 {
     $value = $this->getValueFromForm();
     if (!empty($value)) {
         $this->attributes['checked'] = 'checked';
     } else {
         $value = 1;
     }
     return $this->addon ? HtmlBuilder::checkboxAddon($this->name, $this->label, $value, $this->attributes, $this->addonValue) : HtmlBuilder::checkbox($this->name, $this->label, $value, $this->getOptions($this->attributes));
 }
Example #3
0
 public function render()
 {
     if (is_array($this->list)) {
         $list = $this->list;
     } else {
         if (!method_exists($this->list, 'getList')) {
             throw new \Exception('You must implement "public static function getList()" in "' . $this->list . '"');
         }
         $list = forward_static_call([$this->list, 'getList']);
     }
     return HtmlBuilder::select($this->name, $this->label, $list, $this->getValueFromForm(), $this->getOptions($this->attributes));
 }
Example #4
0
 /**
  * @return string
  */
 public function renderTableAttributes()
 {
     $attributes = [];
     if (!$this->orderable) {
         $attributes['data-ordering'] = 'false';
     }
     $attributes['data-statesave'] = $this->stateSave();
     if ($this->isAsync()) {
         $url = Admin::instance()->router->routeToTable($this->getAlias(), \Input::all());
         $attributes['data-ajax'] = $url;
     }
     return $this->htmlBuilder->attributes($attributes);
 }
Example #5
0
 /**
  * @return $this
  */
 public function render()
 {
     $model = $this->form->instance;
     $value = $this->column;
     $oldInputValue = Admin::$instance->formBuilder->getSessionStore()->getOldInput($value);
     if (!$oldInputValue) {
         $inputValue = $model->{$value};
     } else {
         $inputValue = $oldInputValue;
     }
     $options = ['data-min-value' => $this->minValue, 'data-max-value' => $this->maxValue];
     HtmlBuilder::number($this->name, $this->label, (int) $inputValue, $this->getOptions($options));
 }
Example #6
0
 /**
  * @return string
  */
 public function render()
 {
     $model = $this->form->instance;
     $formats = [];
     foreach (Models\Format::get() as $format) {
         $formats[$format->id] = $format->width . 'x' . $format->height;
     }
     $photos = [];
     $itemsAddons = [];
     $itemsField = [];
     foreach ($model->items()->get() as $key => $item) {
         $itemsField[$key] = [HtmlBuilder::text('items[' . $key . '][qty]', 'Qty', $item->qty, ['data-parsley-required' => true, 'data-parsley-type' => 'number', 'data-parsley-min' => '1']), HtmlBuilder::text('items[' . $key . '][price_per_item]', 'Price per item', $item->price_per_item, ['data-parsley-required' => true, 'data-parsley-type' => 'number']), HtmlBuilder::select('items[' . $key . '][format_id]', 'Format', $formats, $item->format_id, ['data-parsley-required' => true]), $this->formBuilder->hidden('items[' . $key . '][photo_id]', $item->photo_id, ['data-parsley-required' => true])];
         $photos[$key] = $item->photo()->first();
         foreach ($item->ordersItemsAddons()->get() as $ordersItemsAddon) {
             $itemsAddons[$key][$ordersItemsAddon->addon_id] = $ordersItemsAddon->qty;
         }
     }
     return view('admin/form/order/items')->with('label', $this->label)->with('itemsField', $itemsField)->with('photos', $photos)->with('addons', Models\Addon::get())->with('itemsAddons', $itemsAddons);
 }
Example #7
0
 /**
  * Render column header
  *
  * @return string
  */
 public function renderHeader()
 {
     return $this->htmlBuilder->tag('th', $this->getAttributesForHeader(), $this->label);
 }
Example #8
0
 public function render()
 {
     return HtmlBuilder::emailGroupField($this->name, $this->label, $this->getValueFromForm(), $this->attributes);
 }
Example #9
0
 /**
  * @return string
  */
 public function render()
 {
     $model = $this->form->instance;
     if (empty($model)) {
         return false;
     }
     $fields = array();
     foreach ($this->_getLanguageData() as $languageId => $data) {
         $language = Models\Language::find($languageId);
         foreach ($data as $fieldCode => $fieldData) {
             $name = $this->fields[$fieldCode]['name'];
             $fieldTitle = $this->useTabs ? $name : $name . ' [' . $language->name . ']';
             $validationRules = isset($this->fields[$fieldCode]['validation']) ? explode('|', $this->fields[$fieldCode]['validation']) : [];
             switch ($this->fields[$fieldCode]['type']) {
                 case 'ckeditor':
                     $options = ['id' => lcfirst($fieldCode) . '[' . $languageId . ']', 'data-editor' => Textarea::EDITOR_WYSIHTML];
                     $fields[$languageId][] = HtmlBuilder::textarea(lcfirst($fieldCode) . '[' . $languageId . ']', $fieldTitle, $fieldData, $this->getOptions($options, $validationRules));
                     break;
                 case 'textarea':
                     $options = ['id' => lcfirst($fieldCode) . '[' . $languageId . ']'];
                     $fields[$languageId][] = HtmlBuilder::textarea(lcfirst($fieldCode) . '[' . $languageId . ']', $fieldTitle, $fieldData, $this->getOptions($options, $validationRules));
                     break;
                 case 'checkbox':
                     $hotelLanguage = $model->getRepository()->getHotelLanguage($languageId);
                     $options = array('id' => lcfirst($fieldCode) . '[' . $languageId . ']');
                     $oldCheckbox = Admin::$instance->formBuilder->getSessionStore()->getOldInput(lcfirst($fieldCode));
                     if (is_null($oldCheckbox)) {
                         if ($hotelLanguage && $hotelLanguage->active) {
                             $options = array_merge($options, array('checked' => 'checked'));
                         }
                     } else {
                         if ($oldCheckbox[$languageId] == 1) {
                             $options = array_merge($options, array('checked' => 'checked'));
                         }
                         $allOldInputs = Admin::$instance->formBuilder->getSessionStore()->get('_old_input');
                         $fieldName = lcfirst($fieldCode);
                         if (isset($allOldInputs[$fieldName])) {
                             if (isset($allOldInputs[$fieldName][$languageId])) {
                                 unset($allOldInputs[$fieldName][$languageId]);
                             }
                         }
                         Admin::$instance->formBuilder->getSessionStore()->set('_old_input', $allOldInputs);
                     }
                     $fields[$languageId][] = HtmlBuilder::checkbox(lcfirst($fieldCode) . '[' . $languageId . ']', $fieldTitle, $fieldData, $this->getOptions($options, $validationRules));
                     break;
                 default:
                     $options = ['id' => lcfirst($fieldCode) . '[' . $language->name . ']'];
                     $fields[$languageId][] = HtmlBuilder::text(lcfirst($fieldCode) . '[' . $languageId . ']', $fieldTitle, $fieldData, $this->getOptions($options, $validationRules));
                     break;
             }
         }
     }
     return view('admin/form/languages_fields')->with('code', $this->modelMethod)->with('withTabs', $this->useTabs)->with('languages', $this->_getAvailableLanguages())->with('fields', $fields)->with('blockId', uniqid())->with('title', $this->label);
 }
Example #10
0
 public function render($tableId, $filterUniqueKey)
 {
     return HtmlBuilder::datetime($this->getName(), $this->getLabel(), $this->getValue(), ['id' => $this->getId($tableId, $filterUniqueKey)], $this->getRule());
 }
Example #11
0
 /**
  * @return string
  */
 protected function renderSingleItem()
 {
     $content = $this->htmlBuilder->tag('i', ['class' => ['fa', 'fa-fw', $this->getIcon()]]);
     $content .= ' ' . $this->getLabel();
     return $this->htmlBuilder->tag('a', ['href' => $this->getUrl()], $content);
 }
Example #12
0
 public function render()
 {
     return HtmlBuilder::price($this->name, $this->label, $this->getValueFromForm(), $this->getOptions($this->attributes), $this->currency);
 }
Example #13
0
 public function render()
 {
     return HtmlBuilder::color($this->name, $this->label, $this->getValueFromForm(), $this->getOptions($this->attributes));
 }
Example #14
0
 public function render()
 {
     return $this->addon ? HtmlBuilder::radioAddon($this->name, $this->label, $this->getValueFromForm(), $this->attributes, $this->addonValue) : HtmlBuilder::radio($this->name, $this->label, $this->getValueFromForm(), $this->getOptions($this->attributes));
 }
Example #15
0
        case 'code':
            return function () {
                InlineEditItem::text('code', NULL)->validationRule('required');
            };
            break;
        case 'name':
            return function () {
                InlineEditItem::callback('name', '')->callback(function ($instance) {
                    $content = '';
                    foreach (Models\Language::get() as $language) {
                        $value = '';
                        $descriptions = $instance->descriptions->where('language_id', $language->id)->first();
                        if (!is_null($descriptions)) {
                            $value = $descriptions->name;
                        }
                        $content .= HtmlBuilder::text('name_' . $language->id, 'Name [' . $language->code . ']', $value, ['data-parsley-required' => true]);
                    }
                    return $content;
                });
            };
            break;
        default:
            return function () {
            };
            break;
    }
})->form(function () {
    FormItem::text('code', 'Code')->validationRule('required')->group('status');
    FormItem::checkbox('default', 'Default')->group('status');
    FormItem::descriptions()->useTabs(true)->type('model')->modelMethod('descriptions')->fields(['name' => ['name' => 'Name', 'value' => 'name', 'type' => 'text', 'validation' => 'required']])->group('descriptions');
    FormGroup::create('status', 'Status')->setDisplayType(FormGroup::DISPLAY_TYPE_FULL);
Example #16
0
 public function render()
 {
     return $this->actionButton === true ? HtmlBuilder::textWithActions($this->name, $this->label, $this->getValueFromForm(), $this->getOptions($this->attributes), $this->actions) : HtmlBuilder::text($this->name, $this->label, $this->getValueFromForm(), $this->getOptions($this->attributes));
 }