public function search($params) { $query = User::find(); $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['createdAt' => SORT_DESC]]]); $this->load($params); if (!$this->validate()) { $query->where('0=1'); return $dataProvider; } $query->andFilterWhere(['user.id' => $this->id, 'type' => $this->type, 'user.status' => $this->status]); $query->andFilterWhere(['like', 'email', $this->email]); return $dataProvider; }
echo $form->field($model, 'email')->textInput(['class' => 'form-control input-medium', 'style' => 'direction:ltr']); ?> <?php if ($model->isNewRecord) { ?> <?php echo $form->field($model, 'password')->widget(ShowPassword::className(), ['options' => ['class' => 'form-control']]); ?> <?php } ?> <?php echo $form->field($model, 'type')->dropDownList([User::TYPE_OPERATOR => 'اپراتور', User::TYPE_EDITOR => 'سردبیر', User::TYPE_SUPERUSER => 'مدیر سیستم'], ['class' => 'form-control input-small']); ?> <?php echo $form->field($model, 'status')->dropDownList(User::statusLabels(), ['class' => 'form-control input-small']); ?> <div class="form-group"> <?php echo Html::submitButton('<i class="fa fa-save"></i> ذخیره', ['class' => 'btn btn-lg btn-success']); ?> <?php echo Button::widget(['label' => 'انصراف', 'options' => ['class' => 'btn-lg'], 'type' => 'warning', 'icon' => 'undo', 'url' => $backLink]); ?> </div> <?php Panel::end(); ?> </div> <div class="col-md-4">
use yii\grid\GridView; use themes\admin360\widgets\Panel; use themes\admin360\widgets\ActionButtons; use modules\user\backend\models\User; $this->title = 'مدیریت کاربران'; $this->params['breadcrumbs'][] = $this->title; echo ActionButtons::widget(['buttons' => ['create' => ['label' => 'کاربر جدید']]]); Panel::begin(['title' => 'لیست کاربران']); ?> <?php Pjax::begin(['id' => 'user-grid', 'enablePushState' => false]); ?> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'kalpok\\grid\\IDColumn'], 'email', ['attribute' => 'type', 'filter' => User::typeLabels(), 'value' => function ($model) { return $model->getTypeLabel(); }], 'lastLoggedInAt:datetime', ['attribute' => 'status', 'filter' => User::statusLabels(), 'value' => function ($model) { return $model->getStatusLabel(); }], ['class' => 'kalpok\\grid\\ActionColumn', 'template' => '{view} {update} {delete} {assign} {change-password}', 'buttons' => ['assign' => function ($url, $model, $key) { if ($model->type != User::TYPE_SUPERUSER) { return Html::a('<span class="fa fa-lock"></span>', $url, ['title' => 'اعطای دسترسی', 'data-pjax' => 0]); } }, 'change-password' => function ($url, $model, $key) { return Html::a('<span class="fa fa-key"></span>', $url, ['title' => 'تغییر رمز عبور', 'data-pjax' => 0]); }]]]]); ?> <?php Pjax::end(); Panel::end(); ?> </div>
public function init() { $this->modelClass = User::className(); $this->searchClass = UserSearch::className(); parent::init(); }