Beispiel #1
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     // set titles
     $this->setCreateTitle(Yii::t('kalibao', 'create_title'));
     $this->setUpdateTitle(Yii::t('kalibao', 'update_title'));
     // models
     $models = $this->getModels();
     // language
     $language = $this->getLanguage();
     // get drop down list methods
     $dropDownList = $this->getDropDownList();
     // upload config
     $uploadConfig['main'] = $this->uploadConfig[(new \ReflectionClass($models['main']))->getName()];
     // set items
     $items = [];
     if (!$models['main']->isNewRecord) {
         $items[] = new SimpleValueField(['model' => $models['main'], 'attribute' => 'id', 'value' => $models['main']->id]);
     }
     $items[] = new InputField(['model' => $models['main'], 'attribute' => 'sheet_type_id', 'type' => 'activeHiddenInput', 'options' => ['class' => 'form-control input-sm input-ajax-select', 'data-action' => Url::to(['advanced-drop-down-list', 'id' => 'sheet_type_i18n.label']), 'data-allow-clear' => 1, 'data-placeholder' => Yii::t('kalibao', 'input_select'), 'data-text' => !empty($models['main']->sheet_type_id) ? SheetTypeI18n::findOne(['sheet_type_id' => $models['main']->sheet_type_id, 'i18n_id' => $language])->label : '']]);
     $items[] = new InputField(['model' => $models['main'], 'attribute' => 'branch_id', 'type' => 'activeHiddenInput', 'options' => ['class' => 'form-control input-sm input-ajax-select', 'data-action' => Url::to(['advanced-drop-down-list', 'id' => 'branch_i18n.label']), 'data-allow-clear' => 1, 'data-placeholder' => Yii::t('kalibao', 'input_select'), 'data-text' => !empty($models['main']->branch_id) ? BranchI18n::findOne(['branch_id' => $models['main']->branch_id, 'i18n_id' => $language])->label : '']]);
     $items[] = new InputField(['model' => $models['main'], 'attribute' => 'primary_key', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'maxlength' => true, 'placeholder' => $models['main']->getAttributeLabel('primary_key')]]);
     if (!$models['main']->isNewRecord) {
         $items[] = new SimpleValueField(['model' => $models['main'], 'attribute' => 'created_at', 'value' => Yii::$app->formatter->asDatetime($models['main']->created_at, I18N::getDateFormat())]);
     }
     if (!$models['main']->isNewRecord) {
         $items[] = new SimpleValueField(['model' => $models['main'], 'attribute' => 'updated_at', 'value' => Yii::$app->formatter->asDatetime($models['main']->updated_at, I18N::getDateFormat())]);
     }
     $this->setItems($items);
 }
Beispiel #2
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     // get model
     $model = $this->getModel();
     // language
     $language = $this->getLanguage();
     // get drop down list methods
     $dropDownList = $this->getDropDownList();
     // set titles
     $this->setTitle(Yii::t('kalibao', 'list_title'));
     // set head attributes
     $this->setGridHeadAttributes(['id' => true, 'sheet_type_i18n_label' => true, 'branch_i18n_label' => true, 'primary_key' => true, 'created_at' => true, 'updated_at' => true]);
     // set head filters
     $this->setGridHeadFilters([new InputField(['model' => $model, 'attribute' => 'id', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'placeholder' => Yii::t('kalibao', 'input_search')]]), new InputField(['model' => $model, 'attribute' => 'sheet_type_id', 'type' => 'activeHiddenInput', 'options' => ['class' => 'form-control input-sm input-ajax-select', 'data-action' => Url::to(['advanced-drop-down-list', 'id' => 'sheet_type_i18n.label']), 'data-allow-clear' => 1, 'data-placeholder' => Yii::t('kalibao', 'input_select'), 'data-text' => !empty($model->sheet_type_id) ? SheetTypeI18n::findOne(['sheet_type_id' => $model->sheet_type_id, 'i18n_id' => $language])->label : '']]), new InputField(['model' => $model, 'attribute' => 'branch_id', 'type' => 'activeHiddenInput', 'options' => ['class' => 'form-control input-sm input-ajax-select', 'data-action' => Url::to(['advanced-drop-down-list', 'id' => 'branch_i18n.label']), 'data-allow-clear' => 1, 'data-placeholder' => Yii::t('kalibao', 'input_select'), 'data-text' => !empty($model->branch_id) ? BranchI18n::findOne(['branch_id' => $model->branch_id, 'i18n_id' => $language])->label : '']]), new InputField(['model' => $model, 'attribute' => 'primary_key', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'placeholder' => Yii::t('kalibao', 'input_search')]]), new DateRangeField(['model' => $model, 'attribute' => 'created_at', 'start' => new InputField(['model' => $model, 'attribute' => 'created_at_start', 'type' => 'activeTextInput', 'options' => ['placeholder' => Yii::t('kalibao', 'input_search'), 'maxlength' => true, 'class' => 'form-control input-sm date-picker date-range']]), 'end' => new InputField(['model' => $model, 'attribute' => 'created_at_end', 'type' => 'activeTextInput', 'options' => ['placeholder' => Yii::t('kalibao', 'input_search'), 'maxlength' => true, 'class' => 'form-control input-sm date-picker date-range']])]), new DateRangeField(['model' => $model, 'attribute' => 'updated_at', 'start' => new InputField(['model' => $model, 'attribute' => 'updated_at_start', 'type' => 'activeTextInput', 'options' => ['placeholder' => Yii::t('kalibao', 'input_search'), 'maxlength' => true, 'class' => 'form-control input-sm date-picker date-range']]), 'end' => new InputField(['model' => $model, 'attribute' => 'updated_at_end', 'type' => 'activeTextInput', 'options' => ['placeholder' => Yii::t('kalibao', 'input_search'), 'maxlength' => true, 'class' => 'form-control input-sm date-picker date-range']])])]);
     // set advanced filters
     $this->setAdvancedFilters([new InputField(['model' => $model, 'attribute' => 'id', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'placeholder' => Yii::t('kalibao', 'input_search')]]), new InputField(['model' => $model, 'attribute' => 'sheet_type_id', 'type' => 'activeHiddenInput', 'options' => ['class' => 'form-control input-sm input-ajax-select', 'data-action' => Url::to(['advanced-drop-down-list', 'id' => 'sheet_type_i18n.label']), 'data-allow-clear' => 1, 'data-placeholder' => Yii::t('kalibao', 'input_select'), 'data-text' => !empty($model->sheet_type_id) ? SheetTypeI18n::findOne(['sheet_type_id' => $model->sheet_type_id, 'i18n_id' => $language])->label : '']]), new InputField(['model' => $model, 'attribute' => 'branch_id', 'type' => 'activeHiddenInput', 'options' => ['class' => 'form-control input-sm input-ajax-select', 'data-action' => Url::to(['advanced-drop-down-list', 'id' => 'branch_i18n.label']), 'data-allow-clear' => 1, 'data-placeholder' => Yii::t('kalibao', 'input_select'), 'data-text' => !empty($model->branch_id) ? BranchI18n::findOne(['branch_id' => $model->branch_id, 'i18n_id' => $language])->label : '']]), new InputField(['model' => $model, 'attribute' => 'primary_key', 'type' => 'activeTextInput', 'options' => ['class' => 'form-control input-sm', 'placeholder' => Yii::t('kalibao', 'input_search')]]), new DateRangeField(['model' => $model, 'attribute' => 'created_at', 'start' => new InputField(['model' => $model, 'attribute' => 'created_at_start', 'type' => 'activeTextInput', 'options' => ['placeholder' => Yii::t('kalibao', 'input_search'), 'maxlength' => true, 'class' => 'form-control input-sm date-picker date-range']]), 'end' => new InputField(['model' => $model, 'attribute' => 'created_at_end', 'type' => 'activeTextInput', 'options' => ['placeholder' => Yii::t('kalibao', 'input_search'), 'maxlength' => true, 'class' => 'form-control input-sm date-picker date-range']])]), new DateRangeField(['model' => $model, 'attribute' => 'updated_at', 'start' => new InputField(['model' => $model, 'attribute' => 'updated_at_start', 'type' => 'activeTextInput', 'options' => ['placeholder' => Yii::t('kalibao', 'input_search'), 'maxlength' => true, 'class' => 'form-control input-sm date-picker date-range']]), 'end' => new InputField(['model' => $model, 'attribute' => 'updated_at_end', 'type' => 'activeTextInput', 'options' => ['placeholder' => Yii::t('kalibao', 'input_search'), 'maxlength' => true, 'class' => 'form-control input-sm date-picker date-range']])])]);
 }