/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Monitoring1::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, 'col1' => $this->col1, 'col2' => $this->col2, 'col3' => $this->col3, 'col4' => $this->col4, 'col5' => $this->col5, 'col6' => $this->col6, 'col7' => $this->col7, 'col8' => $this->col8, 'col9' => $this->col9, 'col10' => $this->col10, 'col11' => $this->col11, 'col12' => $this->col12, 'col13' => $this->col13, 'col14' => $this->col14, 'col15' => $this->col15, 'user_id' => $this->user_id, 'created_at' => $this->created_at, 'month_id' => $this->month_id, 'year_id' => $this->year_id]); return $dataProvider; }
public function searchAll($params) { if (Yii::$app->user->can('admin')) { $query = Monitoring1::find()->joinWith('user.profile.region'); } else { $query = Monitoring1::find()->joinWith('user.profile.region')->where([Monitoring1::tableName() . '.user_id' => Yii::$app->user->id]); } $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 $query->all(); } $query->andFilterWhere(['user_id' => $this->user_id, Monitoring1::tableName() . '.date' => $this->date, 'year_id' => $this->year_id, Region::tableName() . '.id' => $this->region, Monitoring1::tableName() . '.status' => $this->status]); // $query->andFilterWhere(['like', 'status', $this->status]); return $query->all(); }
public function actionGetMonthByYear() { $id = Yii::$app->request->post('id'); $monthsExist = Monitoring1::find()->select('month_id')->Where(['user_id' => Yii::$app->user->id])->andWhere(['year_id' => $id])->column(); $months = Month::find()->where(['NOT IN', 'id', $monthsExist])->all(); $arrayMonth = ArrayHelper::map($months, 'id', 'month'); $options = '<option value="">Оберіть місяць</option>'; foreach ($arrayMonth as $key => $value) { $options .= '<option value=' . $key . '>' . $value . '</option>'; } return $options; }