/**
  * Creates data provider instance with search query applied
  *
  * @param string $searchQuery
  *
  * @return ActiveDataProvider
  */
 public function search($searchQuery)
 {
     $query = Employee::find();
     $query->where('status > 0');
     if ($searchQuery !== null) {
         $query->andFilterWhere(['like', 'username', $searchQuery])->andFilterWhere(['like', 'email', $searchQuery])->andFilterWhere(['like', 'fullname', $searchQuery]);
     }
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10], 'sort' => false]);
     return $dataProvider;
 }
 public function actionIndex($q = null)
 {
     $query = Employee::find();
     $query->where(['status' => Employee::STATUS_ACTIVE]);
     if ($q != null) {
         $query->andFilterWhere(['like', 'username', $q]);
         $query->andFilterWhere(['like', 'fullname', $q]);
         $query->andFilterWhere(['like', 'email', $q]);
     }
     return $this->render('index', ['models' => $query->all()]);
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Employee::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['emp_id' => $this->emp_id, 'basic_salary' => $this->basic_salary, 'tot_salary' => $this->tot_salary, 'bonus' => $this->bonus, 'rating' => $this->rating]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'nic', $this->nic])->andFilterWhere(['like', 'surname', $this->surname])->andFilterWhere(['like', 'address_no', $this->address_no])->andFilterWhere(['like', 'address_street', $this->address_street])->andFilterWhere(['like', 'address_city', $this->address_city])->andFilterWhere(['like', 'mobile_no', $this->mobile_no])->andFilterWhere(['like', 'home_no', $this->home_no])->andFilterWhere(['like', 'email', $this->email]);
     return $dataProvider;
 }
Пример #4
0
 public function OrganisationAuthorized($code = [], $chairman = [0], $array_map = false)
 {
     $object_person = \backend\models\Person::find()->where(['id' => \backend\models\Employee::find()->select('person_id')->where(['organisation_id' => \backend\models\Organisation::find()->select('ID')->where(['KD_UNIT_ORG' => $code])->column(), 'chairman' => $chairman])->currentSatker()->column()])->active();
     if ($array_map) {
         $data = ArrayHelper::map($object_person->asArray()->all(), 'id', 'name');
         return $data;
     } else {
         $object_person->count();
         return $object_person->count() > 0 ? true : false;
     }
 }