示例#1
0
 public function getUserName($uid)
 {
     $ret = DcmdUser::findOne($uid);
     if ($ret) {
         return $ret['username'];
     }
     return "";
 }
示例#2
0
 public function getUserName($uid)
 {
     $query = DcmdUser::findOne($uid);
     if ($query) {
         return $query['username'];
     }
     return "";
 }
示例#3
0
 public function getOprName($uid)
 {
     $query = DcmdUser::findOne($uid);
     if ($query) {
         return $query->username;
     }
     return "";
 }
示例#4
0
 public function getDepartment($uid)
 {
     $query = DcmdUser::findOne($uid);
     if (!$query) {
         return "";
     }
     $ret = DcmdDepartment::findOne($query['depart_id']);
     if (!$ret) {
         return "";
     }
     return $ret['depart_name'];
 }
示例#5
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params, $qstr = NULL)
 {
     if ($qstr) {
         $query = DcmdUser::find()->andWhere($qstr)->orderBy("username");
     } else {
         $query = DcmdUser::find()->orderBy("username");
     }
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pagesize' => 20]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['uid' => $this->uid, 'sa' => $this->sa, 'admin' => $this->admin, 'depart_id' => $this->depart_id, 'state' => $this->state, 'utime' => $this->utime, 'ctime' => $this->ctime, 'opr_uid' => $this->opr_uid]);
     $query->andFilterWhere(['like', 'username', $this->username])->andFilterWhere(['like', 'passwd', $this->passwd])->andFilterWhere(['like', 'tel', $this->tel])->andFilterWhere(['like', 'email', $this->email])->andFilterWhere(['like', 'comment', $this->comment]);
     return $dataProvider;
 }
 /**
  * Finds the DcmdUser model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return DcmdUser the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = DcmdUser::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
 /**
  * Deletes an existing DcmdDepartment model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     if (Yii::$app->user->getIdentity()->admin != 1 || Yii::$app->user->getIdentity()->sa != 1) {
         Yii::$app->getSession()->setFlash('success', NULL);
         Yii::$app->getSession()->setFlash('error', "对不起, 你没有权限!");
         return $this->redirect(array('index'));
     }
     $query = DcmdUser::find()->andWhere(['depart_id' => $id])->asArray()->all();
     if (count($query) != 0) {
         Yii::$app->getSession()->setFlash('error', "该部门下用户不为空!");
         return $this->redirect(['index']);
     }
     $model = $this->findModel($id);
     $this->oprlog(3, "delete department:" . $model->depart_name);
     $model->delete();
     Yii::$app->getSession()->setFlash('success', '删除成功');
     return $this->redirect(['index']);
 }