/**
  * {@inheritDoc}
  */
 public function actions()
 {
     $actions = [];
     /**@var Setting[] $settings */
     $settings = Setting::find()->where(['type' => Setting::TYPE_ACTION])->all();
     foreach ($settings as $setting) {
         $actions[$setting->code] = ['class' => DefaultAction::className()];
     }
     return $actions;
 }
 public function safeUp()
 {
     $this->alterColumn('{{%setting}}', 'type', \yii\db\mysql\Schema::TYPE_STRING . '(255) NOT NULL');
     /**@var Setting[] $settings */
     $settings = Setting::find()->all();
     $type = array_keys(Setting::TYPE);
     foreach ($settings as $setting) {
         foreach ($type as $key => $item) {
             if ($setting->type == $key - 1) {
                 $setting->updateAttributes(['type' => $item]);
             }
         }
     }
 }
Esempio n. 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Setting::find();
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'parent_id' => $this->parent_id, 'type' => $this->type, 'sort_order' => $this->sort_order]);
     $query->andFilterWhere(['like', 'code', $this->code])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'desc', $this->desc])->andFilterWhere(['like', 'store_range', $this->store_range])->andFilterWhere(['like', 'store_dir', $this->store_dir])->andFilterWhere(['like', 'value', $this->value]);
     return $dataProvider;
 }
Esempio n. 4
0
 /**
  * @param null $code
  *
  * @return array
  */
 public static function getItems($code = null)
 {
     /**@var $parentSettings self[] */
     $items = [];
     if ($code == null) {
         $parentSettings = Setting::find()->where(['parent_id' => 0, 'type' => self::TYPE_GROUP])->orderBy(['sort_order' => SORT_ASC])->all();
     } else {
         $currentSetting = self::findOne(['code' => $code]);
         if ($currentSetting !== null) {
             $parentSettings = Setting::find()->where(['parent_id' => $currentSetting->id, 'type' => self::TYPE_GROUP])->orderBy(['sort_order' => SORT_ASC])->all();
         } else {
             $parentSettings = Setting::find()->where(['parent_id' => 0, 'type' => self::TYPE_GROUP])->orderBy(['sort_order' => SORT_ASC])->all();
         }
     }
     foreach ($parentSettings as $parentSetting) {
         $content = Html::beginForm('', 'POST', ['class' => 'form-horizontal', 'id' => 'nava-setting-form', 'enctype' => 'multipart/form-data']);
         $content .= $parentSetting->getContent();
         $content .= Html::beginTag('div', ['class' => 'form-group']);
         $content .= Html::beginTag('div', ['class' => 'col-sm-9 col-sm-offset-3']);
         $content .= Html::submitButton(Yii::t('setting', 'Save'), ['class' => 'btn btn-success']);
         $content .= Html::endTag('div');
         $content .= Html::endTag('div');
         $content .= Html::endForm();
         $items[] = ['label' => ($parentSetting->icon != '' ? '<span class="glyphicon ' . $parentSetting->icon . '"></span> ' : '') . $parentSetting->getName(), 'content' => $content];
     }
     return $items;
 }
Esempio n. 5
0
use yii\web\View;
$this->title = Yii::t('setting', 'Setting');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="navatech-setting">
	<div class="col-sm-12">
		<div class="setting-index">
			<h1><?php 
echo Html::encode($this->title);
?>
</h1>
			<p>
				<?php 
echo Html::a(Yii::t('setting', 'Create Setting'), ['create'], ['class' => 'btn btn-success']);
?>
			</p>
			<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'export' => false, 'pjax' => true, 'hover' => true, 'bordered' => true, 'striped' => true, 'condensed' => true, 'responsive' => true, 'persistResize' => false, 'panel' => ['type' => 'primary', 'heading' => Yii::t('setting', 'Setting configure')], 'containerOptions' => ['style' => 'overflow: auto'], 'headerRowOptions' => ['class' => 'kartik-sheet-style'], 'filterRowOptions' => ['class' => 'kartik-sheet-style'], 'columns' => [['class' => 'kartik\\grid\\SerialColumn'], ['class' => 'kartik\\grid\\ExpandRowColumn', 'value' => function (Setting $model, $key, $index, $column) {
    return GridView::ROW_COLLAPSED;
}, 'detail' => function (Setting $model, $key, $index, $column) {
    return Yii::$app->controller->renderPartial('_view', ['model' => $model]);
}, 'headerOptions' => ['class' => 'kartik-sheet-style'], 'expandOneOnly' => true], ['attribute' => 'parent_id', 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(Setting::find()->where(['type' => 0, 'parent_id' => 0])->orderBy(['sort_order' => SORT_ASC])->all(), 'id', 'name'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => Yii::t('setting', 'Parent tab')], 'value' => function (Setting $data) {
    $parent = $data->findOne($data->parent_id);
    return $parent !== null ? $parent->getName() : '';
}], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'code'], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'name'], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'type', 'filterType' => GridView::FILTER_SELECT2, 'filter' => Setting::TYPE, 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => Yii::t('setting', 'Type')], 'value' => function (Setting $data) {
    return Setting::TYPE[$data->type];
}, 'refreshGrid' => true, 'editableOptions' => ['inputType' => Editable::INPUT_DROPDOWN_LIST, 'data' => Setting::TYPE]], ['class' => 'kartik\\grid\\EditableColumn', 'attribute' => 'sort_order'], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update}&nbsp;{delete}']]]);
?>
		</div>
	</div>
</div>