/** * 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 excel($params) { $query = Mon1str::find()->joinWith('monitoring1.user.profile.region'); $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => array('pageSize' => 10000)]); $dataProvider->sort->attributes['region'] = ['asc' => [Region::tableName() . '.name' => SORT_ASC], 'desc' => [Region::tableName() . '.name' => SORT_DESC]]; $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([Monitoring1::tableName() . '.date' => $this->date, Region::tableName() . '.id' => $this->region]); return $dataProvider; }
public function excel($params) { if (Yii::$app->user->can('admin')) { $query = Monitoring2::find()->joinWith('user.profile.region'); } else { $query = Monitoring2::find()->joinWith('user.profile.region')->where([Monitoring2::tableName() . '.user_id' => Yii::$app->user->id]); } $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => array('pageSize' => 10000)]); $dataProvider->sort->attributes['region'] = ['asc' => [Region::tableName() . '.name' => SORT_ASC], 'desc' => [Region::tableName() . '.name' => SORT_DESC]]; $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(['user_id' => $this->user_id, 'month_id' => $this->month_id, 'year_id' => $this->year_id, 'date' => $this->date, Region::tableName() . '.id' => $this->region, Monitoring1::tableName() . '.status' => $this->status]); // $query->andFilterWhere(['like', 'status', $this->status]); return $dataProvider; }
/** * @return \yii\db\ActiveQuery */ public function getMonitoring1s() { return $this->hasMany(Monitoring1::className(), ['year_id' => 'id']); }
/** * Finds the Monitoring1 model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Monitoring1 the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Monitoring1::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }
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(); }
/** * @return \yii\db\ActiveQuery */ public function getMonitoring1() { return $this->hasOne(Monitoring1::className(), ['id' => 'monitoring1_id']); }