Esempio n. 1
0
 public function actionActivate()
 {
     $searchModel = new UserSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     if (Yii::$app->request->isPost) {
         $selected = Yii::$app->request->post('selected');
         $action = Yii::$app->request->post('action');
         if ($action === 'assignedAsMentor') {
             $users_id = explode(',', $selected);
             foreach ($users_id as $key => $value) {
                 $temp[] = [$value, $value];
             }
             Yii::$app->db->createCommand()->batchInsert('mentor', ['id', 'user_id'], $temp)->execute();
             Yii::$app->session->setFlash('success', 'Your request has been successfully processed');
             return $this->redirect(['index']);
         }
         if (isset($selected)) {
             $condition = "id in ({$selected})";
             Yii::$app->db->createCommand()->update('user', ['status' => intval($action)], $condition)->execute();
             Yii::$app->session->setFlash('success', 'Your request has been successfully processed');
             return $this->redirect(['index']);
         }
     }
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Esempio n. 2
0
 /**
  * Lists all User models.
  * @return mixed
  */
 public function actionIndex()
 {
     $params = Yii::$app->request->queryParams;
     $params = Utils::rememberSearchModel($params, 'UserSearch');
     $searchModel = new UserSearch();
     $dataProvider = $searchModel->search($params);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'cities' => $this->getCitiesView(), 'educations' => $this->getEducationsView()]);
 }
 /**
  * Lists all User models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new UserSearch();
     $dataProvider = $searchModel->search($_GET);
     Tabs::clearLocalStorage();
     Url::remember();
     \Yii::$app->session['__crudReturnUrl'] = null;
     return $this->render('index', ['dataProvider' => $dataProvider, 'searchModel' => $searchModel]);
 }
 public function actionIndex()
 {
     if (Yii::$app->user->can('admin')) {
         $searchModel = new UserSearch();
         $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
         return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
     } else {
         return $this->goHome();
     }
 }
Esempio n. 5
0
 /**
  * Updates an existing User model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param string $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $searchModel = new UserSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     if ($model->role === 10) {
         $model->role = 20;
         if ($model->save()) {
             return $this->redirect('/user/index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
         }
     } elseif ($model->role === 20) {
         $model->role = 10;
         if ($model->save()) {
             return $this->redirect('/user/index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
         }
     }
 }
Esempio n. 6
0
 /**
  * Lists all User models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new UserSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $gridColumns[] = ['class' => 'kartik\\grid\\SerialColumn', 'contentOptions' => ['class' => 'kartik-sheet-style'], 'width' => '36px', 'header' => '序号', 'headerOptions' => ['class' => 'kartik-sheet-style']];
     $gridColumns[] = ['mergeHeader' => true, 'attribute' => 'avatar24Show', 'header' => '头像', 'format' => 'html'];
     $gridColumns[] = ['attribute' => 'id', 'vAlign' => 'middle'];
     $gridColumns[] = ['attribute' => 'username', 'vAlign' => 'middle'];
     $gridColumns[] = ['attribute' => 'role', 'vAlign' => 'middle', 'width' => '180px', 'value' => function ($searchModel, $key, $index, $widget) {
         return $searchModel->roleName;
     }, 'filterType' => GridView::FILTER_SELECT2, 'filter' => $searchModel->arrayRole, 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => '角色'], 'format' => 'raw'];
     $gridColumns[] = ['class' => 'kartik\\grid\\BooleanColumn', 'attribute' => 'status', 'width' => '100px', 'vAlign' => 'middle', 'trueLabel' => '启用', 'falseLabel' => '禁用'];
     $gridColumns[] = 'email';
     $gridColumns[] = ['mergeHeader' => true, 'attribute' => 'created_at', 'format' => 'datetime'];
     $gridColumns[] = ['class' => '\\kartik\\grid\\ActionColumn', 'template' => '{view} {update}'];
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'gridColumns' => $gridColumns]);
 }
Esempio n. 7
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = User::find()->select('user.*')->joinWith('education');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => self::PAGE_SIZE], 'sort' => ['attributes' => ['username', 'email']]]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $className = UserSearch::className();
     if (isset($params[Utils::getClassName($className)]['cities']) && $params[Utils::getClassName($className)]['cities']) {
         $cityIds = $params[Utils::getClassName($className)]['cities'];
         $query->joinWith('cities')->where(['cities.id' => $cityIds])->distinct('user.username');
     }
     if (isset($this->education_id) && $this->education_id) {
         $query->andFilterWhere(['education_id' => $this->education_id]);
     }
     $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'email', $this->email]);
     return $dataProvider;
 }
Esempio n. 8
0
 /**
  * Lists all User models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new UserSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Esempio n. 9
0
 /**
  * Lists all User models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new UserSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     return $dataProvider;
     //mprd($dataProvider->getModels()); die;
 }
 /**
  * Deletes an existing User model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionSell()
 {
     $searchModel = new UserSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     if (Yii::$app->request->isAjax) {
         echo json_encode($dataProvider);
         return true;
     }
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]);
 }
Esempio n. 11
0
 public function actionIndex()
 {
     $search = new UserSearch();
     $provider = $search->search(\Yii::$app->request->get());
     return $this->render('index', ['search' => $search, 'dataProvider' => $provider]);
 }
 public function actionAssign()
 {
     $searchModel = new UserSearch();
     $dp = $searchModel->search(Yii::$app->request->queryParams);
     return $this->render('assign', ['dp' => $dp, 'searchModel' => $searchModel]);
 }