Exemplo n.º 1
0
 public function getPrivilege($userId = null)
 {
     $db = new Query();
     $db->select("group_id")->from("privilege")->where("user_id = '{$userId}' ");
     $groupUser = $db->all();
     $GroupUserArr = array();
     foreach ($groupUser as $Guser) {
         $GroupUserArr[] = "'" . $Guser['group_id'] . "'";
     }
     $GroupUser = implode(",", $GroupUserArr);
     if (!empty($GroupUser)) {
         $GroupUserVal = $GroupUser;
     } else {
         $GroupUserVal = "''";
     }
     if (!empty($GroupUserVal)) {
         $Privilege = GroupPcu::find()->where('group_id IN(' . $GroupUserVal . ')')->all();
         $PcuArr = array();
         foreach ($Privilege as $rs) {
             $PcuArr[] = $rs['hospcode'];
         }
     } else {
         $PcuArr = null;
     }
     Yii::$app->session['privilege'] = $PcuArr;
 }
Exemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = GroupPcu::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'group_id' => $this->group_id, 'create_date' => $this->create_date]);
     $query->andFilterWhere(['like', 'hospcode', $this->hospcode]);
     return $dataProvider;
 }