Beispiel #1
0
 public function getDepartment($depart_id)
 {
     $ret = DcmdDepartment::findOne($depart_id);
     if ($ret) {
         return $ret['depart_name'];
     } else {
         return "";
     }
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = DcmdDepartment::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pagesize' => 20]]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['depart_id' => $this->depart_id, 'utime' => $this->utime, 'ctime' => $this->ctime, 'opr_uid' => $this->opr_uid]);
     $query->andFilterWhere(['like', 'depart_name', $this->depart_name])->andFilterWhere(['like', 'comment', $this->comment]);
     return $dataProvider;
 }
Beispiel #3
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'];
 }
 /**
  * Updates an existing DcmdUser model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($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'));
     }
     $model = $this->findModel($id);
     $ret = DcmdDepartment::find()->asArray()->all();
     $depart = array();
     foreach ($ret as $item) {
         $depart[$item['depart_id']] = $item['depart_name'];
     }
     if (Yii::$app->request->post()) {
         $model->utime = date('Y-m-d H:i:s');
         $model->opr_uid = Yii::$app->user->getId();
         if ($model->load(Yii::$app->request->post())) {
             if ($model->admin != 1) {
                 $model->sa = 0;
             }
             if ($model->save()) {
                 $this->oprlog(2, "update user:"******"修改成功");
                 return $this->redirect(['view', 'id' => $model->uid]);
             }
         }
         $err_str = "";
         foreach ($model->getErrors() as $k => $v) {
             $err_str .= $k . ":" . $v[0] . "<br>";
         }
         Yii::$app->getSession()->setFlash('error', "修改失败失败:" . $err_str);
     }
     return $this->render('update', ['model' => $model, 'depart' => $depart]);
 }
 /**
  * Finds the DcmdDepartment model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return DcmdDepartment the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = DcmdDepartment::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }