/** * @inheritdoc */ protected function renderDataCellContent($model, $key, $index) { /* @todo use yii params instead of 1 */ if ($model->primaryKey == 1 || $model->primaryKey == Yii::$app->user->id) { return ''; } return parent::renderDataCellContent($model, $key, $index); }
<div class="header-title"> <h1><?php echo yii\helpers\Html::encode($this->title); ?> </h1> </div> <p> <?php echo yii\helpers\Html::a(\Yii::t('app', 'Create User'), ['create'], ['class' => 'btn btn-success', 'data-pjax' => '0']); ?> </p> <?php echo yii\grid\GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $model, 'columns' => [['label' => '#', 'attribute' => 'id', 'headerOptions' => ['style' => 'width: 100px;']], ['attribute' => 'fullName', 'value' => 'fullName', 'filter' => kartik\typeahead\Typeahead::widget(['model' => $model, 'attribute' => 'fullName', 'value' => $model->getFullName(), 'dataset' => [['display' => 'value', 'remote' => ['url' => \yii\helpers\Url::to(['suggestion', 'code' => $modelCode, 'field' => 'fullName', 'value' => '%value']), 'wildcard' => '%25value'], 'limit' => $autoCompleteLimit]], 'pluginOptions' => ['highlight' => true, 'minLength' => 3]])], ['attribute' => 'phone', 'headerOptions' => ['style' => 'width: 120px;']], ['attribute' => 'email', 'format' => 'email', 'headerOptions' => ['style' => 'width: 250px;']], ['attribute' => 'logins_count', 'headerOptions' => ['style' => 'width: 40px;']], ['attribute' => 'created_at', 'format' => 'datetime', 'headerOptions' => ['style' => 'width: 150px;'], 'filter' => kartik\daterange\DateRangePicker::widget(['name' => 'User[created_at]', 'value' => $model->created_at, 'pluginOptions' => ['opens' => 'left']])], ['attribute' => 'last_login_at', 'format' => 'datetime', 'headerOptions' => ['style' => 'width: 150px;'], 'filter' => kartik\daterange\DateRangePicker::widget(['name' => 'User[last_login_at]', 'value' => $model->last_login_at, 'pluginOptions' => ['opens' => 'left']])], ['class' => \dosamigos\grid\ToggleColumn::className(), 'attribute' => 'is_active', 'onValue' => User::STATUS_ACTIVE, 'onLabel' => \Yii::t('app', 'Active'), 'offLabel' => \Yii::t('app', 'Not active'), 'contentOptions' => ['class' => 'text-center'], 'afterToggle' => 'function(r, data){}', 'onIcon' => 'glyphicon glyphicon-ok text-success', 'offIcon' => 'glyphicon glyphicon-remove text-danger', 'filter' => \app\enums\YesNo::listData(), 'headerOptions' => ['style' => 'width: 85px;']], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {delete}', 'buttons' => ['delete' => function ($url, $model, $key) { // if(!\Yii::$app->get('service|user')->haveDeletePermission($model->primaryKey)){ // return ''; // } $options = ['title' => \Yii::t('yii', 'Delete'), 'aria-label' => \Yii::t('yii', 'Delete'), 'data-confirm' => \Yii::t('yii', 'Are you sure you want to delete this item?'), 'data-method' => 'post', 'data-pjax' => '0']; return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, $options); }, 'update' => function ($url, $model, $key) { // if(\Yii::$app->user->id == $model->primaryKey){ // return ''; // } $options = array_merge(['title' => \Yii::t('yii', 'Update'), 'aria-label' => \Yii::t('yii', 'Update'), 'data-pjax' => '0']); return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, $options); }], 'headerOptions' => ['style' => 'width: 70px;']]]]); yii\widgets\Pjax::end(); $this->registerJs('$("document").ready(function(){ $("#admin-user-id").on("pjax:start", function() {
/** * @var yii\web\View $this * @var yii\data\ActiveDataProvider $dataProvider * @var app\models\SchoolSearch $searchModel */ $this->title = 'Schools'; $this->params['breadcrumbs'][] = $this->title; ?> <div class="school-index"> <h1><?php echo Html::encode($this->title); ?> </h1> <?php // echo $this->render('_search', ['model' => $searchModel]); ?> <p> <?php echo Html::a('Create School', ['create'], ['class' => 'btn btn-success']); ?> </p> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['class' => ToggleColumn::className(), 'attribute' => 'active'], 'name', 'abbr', 'kai_template', ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div>