use yii\grid\GridView; use backend\models\Admin; use yii\helpers\ArrayHelper; use dosamigos\datepicker\DatePicker; /* @var $this yii\web\View */ /* @var $searchModel backend\models\UserSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = 'Admins'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="user-index"> <div class="box-body"> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'options' => ['class' => 'table table-bordered table-hover'], 'summary' => '', 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'username', 'name', 'email:email', ['attribute' => 'auth_role', 'value' => function ($model) { return $model->authRoleLabel; }, 'filter' => Html::activeDropDownList($searchModel, 'auth_role', Admin::getArrayAuthRole(), ['class' => 'form-control', 'prompt' => 'Please Filter'])], ['attribute' => 'status', 'format' => 'html', 'value' => function ($model) { if ($model->status === $model::STATUS_ACTIVE) { $class = 'label-success'; } elseif ($model->status === $model::STATUS_INACTIVE) { $class = 'label-warning'; } else { $class = 'label-danger'; } return '<span class="label ' . $class . '">' . $model->statusLabel . '</span>'; }, 'filter' => Html::activeDropDownList($searchModel, 'status', $arrayStatus, ['class' => 'form-control', 'prompt' => 'Please Filter'])], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{view} {update} {delete} {inactive}', 'buttons' => ['inactive' => function ($url, $model) { if ($model->status != $model::STATUS_INACTIVE) { return Html::a('<span class="glyphicon glyphicon-eye-close"></span>', ['inactive', 'id' => $model->id], ['title' => 'Inactive', 'data' => ['confirm' => 'Are you sure you want to inactive this user?', 'method' => 'post']]); } else { if ($model->status == $model::STATUS_INACTIVE) { return Html::a('<span class="glyphicon glyphicon-exclamation-sign"></span>', ['active', 'id' => $model->id], ['title' => 'Inactive', 'data' => ['confirm' => 'Are you sure you want to actived this user?', 'method' => 'post']]); } else {
<?php if (Yii::$app->controller->action->id != 'update') { ?> <?php echo $form->field($model, 'password')->passwordInput(['maxlength' => 255]); ?> <?php echo $form->field($model, 'repassword')->passwordInput(['maxlength' => 255]); ?> <?php } ?> <?php echo $form->field($model, 'auth_role')->dropDownList(Admin::getArrayAuthRole()); ?> <div class="form-group pull-right"> <?php echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']); ?> </div> <?php ActiveForm::end(); ?> </div> </div> </div> </div>