public function search($params)
 {
     $query = AuthItemGroup::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => Yii::$app->request->cookies->getValue('_grid_page_size', 20)], 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     if ($this->created_at) {
         $tmp = explode(' - ', $this->created_at);
         if (isset($tmp[0], $tmp[1])) {
             $query->andFilterWhere(['between', Yii::$app->getModule('user')->auth_item_group_table . '.created_at', strtotime($tmp[0]), strtotime($tmp[1])]);
         }
     }
     $query->andFilterWhere(['like', Yii::$app->getModule('user')->auth_item_group_table . '.code', $this->code])->andFilterWhere(['like', Yii::$app->getModule('user')->auth_item_group_table . '.name', $this->name]);
     return $dataProvider;
 }
Esempio n. 2
0
				</p>
			</div>

			<div class="col-sm-6 text-right">
				<?php 
echo GridPageSize::widget(['pjaxId' => 'permission-grid-pjax']);
?>
			</div>
		</div>

		<?php 
Pjax::begin(['id' => 'permission-grid-pjax']);
?>

		<?php 
echo GridView::widget(['id' => 'permission-grid', 'dataProvider' => $dataProvider, 'pager' => ['options' => ['class' => 'pagination pagination-sm'], 'hideOnSinglePage' => true, 'lastPageLabel' => '>>', 'firstPageLabel' => '<<'], 'filterModel' => $searchModel, 'layout' => '{items}<div class="row"><div class="col-sm-8">{pager}</div><div class="col-sm-4 text-right">{summary}</div></div>', 'columns' => [['class' => 'yii\\grid\\SerialColumn', 'options' => ['style' => 'width:30px']], ['attribute' => 'description', 'value' => function ($model) {
    if ($model->name == Yii::$app->getModule('user')->commonPermissionName) {
        return Html::a($model->description, ['view', 'id' => $model->name], ['data-pjax' => 0, 'class' => 'label label-primary']);
    } else {
        return Html::a($model->description, ['view', 'id' => $model->name], ['data-pjax' => 0]);
    }
}, 'format' => 'raw'], 'name', ['attribute' => 'group_code', 'filter' => ArrayHelper::map(AuthItemGroup::find()->asArray()->all(), 'code', 'name'), 'value' => function (Permission $model) {
    return $model->group_code ? $model->group->name : '';
}], ['class' => 'yii\\grid\\ActionColumn', 'contentOptions' => ['style' => 'width:70px; text-align:center;']]]]);
?>

		<?php 
Pjax::end();
?>
	</div>
</div>
Esempio n. 3
0
?>

<?php 
$form = ActiveForm::begin(['id' => 'role-form', 'layout' => 'horizontal', 'validateOnBlur' => false]);
?>

	<?php 
echo $form->field($model, 'description')->textInput(['maxlength' => 255, 'autofocus' => $model->isNewRecord ? true : false]);
?>

	<?php 
echo $form->field($model, 'name')->textInput(['maxlength' => 64]);
?>

	<?php 
echo $form->field($model, 'group_code')->dropDownList(ArrayHelper::map(AuthItemGroup::find()->asArray()->all(), 'code', 'name'), ['prompt' => '']);
?>

	<div class="form-group">
		<div class="col-sm-offset-3 col-sm-9">
			<?php 
if ($model->isNewRecord) {
    ?>
				<?php 
    echo Html::submitButton('<span class="glyphicon glyphicon-plus-sign"></span> Create', ['class' => 'btn btn-success']);
    ?>
			<?php 
} else {
    ?>
				<?php 
    echo Html::submitButton('<span class="glyphicon glyphicon-ok"></span> Save', ['class' => 'btn btn-primary']);
Esempio n. 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getGroup()
 {
     return $this->hasOne(AuthItemGroup::className(), ['code' => 'group_code']);
 }