/** * Lists all Record models. * @return mixed */ public function actionIndex() { $teClass = new teClass(); $admin = new Users(); $searchModel = new RecordSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); $id = $searchModel->searchID(); // var_dump($id); // die; $academy = $searchModel->searchacademy(); $te_id = $searchModel->searchte_id(); $array = $admin->getRole($te_id); //根据不同角色返回不同的查看权限 $classArray = $teClass->getRoleClass($id, $te_id, $academy); $major = $teClass->getClass($id, $te_id, $academy); // var_dump($major);die; return $this->render('index', ['te_id' => $te_id, 'array' => $array, 'academy' => $academy, 'searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'classArray' => $classArray, 'major' => $major]); }
/* @var $this yii\web\View */ /* @var $searchModel app\models\UsersSearch */ /* @var $dataProvider yii\data\ActiveDataProvider */ $this->title = Yii::t('app', 'Users'); ?> <div class="user-index"> <br> <?php echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'email', 'format' => 'raw', 'value' => function ($data) { return Html::a($data->email, Url::to(['update', 'id' => $data->id])); }], ['class' => \dosamigos\grid\EditableColumn::className(), 'filter' => Users::$statuses, 'format' => 'raw', 'attribute' => 'status', 'url' => ['ajax-update'], 'type' => 'select', 'display' => 'colors', 'value' => function ($data) { return Users::getStatus($data->status); }, 'editableOptions' => function ($model) { return ['source' => Users::$statuses, 'value' => $model->status]; }], ['class' => \dosamigos\grid\EditableColumn::className(), 'filter' => Users::roles(), 'format' => 'raw', 'attribute' => 'role', 'url' => ['ajax-update'], 'value' => function ($data) { return Users::getRole($data->role); }, 'type' => 'select', 'editableOptions' => function ($model) { return ['source' => Yii::$app->user->identity->getEditableRoles($model->id), 'sourceCache' => false]; }], ['class' => 'yii\\grid\\ActionColumn']]]); ?> </div> <script> function colors(value, sourceData) { var selected = $.grep(sourceData, function (o) { return value == o.value; }), colors = <?php echo json_encode(Users::$status_colors); ?> ;