/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = TrashCountSummer::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]);
     $query->andFilterWhere(['like', 'name_short', $this->name_short])->andFilterWhere(['like', 'name_eng', $this->name_eng])->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'name_short_eng', $this->name_short_eng]);
     return $dataProvider;
 }
 public function actionTables()
 {
     $params = Yii::$app->request->queryParams;
     $region = 1;
     if (!empty($params['MainSearch']['region'])) {
         $region = $params['MainSearch']['region'];
     }
     if (empty($params['excel'])) {
         $params['excel'] = false;
     }
     $data = Main::getMainData($region);
     if ($region == -1) {
         $regionWhere = [];
     } else {
         $regionWhere = ['region' => $region];
     }
     $cityIds = ArrayHelper::map($data, 'city', 'city');
     $regionWhere['id'] = array_values($cityIds);
     $cities = ArrayHelper::map(City::find()->where($regionWhere)->orderBy('id')->all(), 'id', 'nameBoth');
     $types = ArrayHelper::map(Type::find()->orderBy('id')->all(), 'id', 'nameBoth');
     $trashPlaceArm = ArrayHelper::map(TrashPlace::find()->orderBy('id')->all(), 'id', 'name');
     $trashPlaceEng = ArrayHelper::map(TrashPlace::find()->orderBy('id')->all(), 'id', 'name_eng');
     $trashManArm = ArrayHelper::map(TrashMan::find()->orderBy('id')->all(), 'id', 'name');
     $trashManEng = ArrayHelper::map(TrashMan::find()->orderBy('id')->all(), 'id', 'name_eng');
     $trashRelationArm = ArrayHelper::map(TrashRelation::find()->orderBy('id')->all(), 'id', 'name');
     $trashRelationEng = ArrayHelper::map(TrashRelation::find()->orderBy('id')->all(), 'id', 'name_eng');
     $trashRecycleArm = ArrayHelper::map(TrashRecycle::find()->orderBy('id')->all(), 'id', 'name');
     $trashRecycleEng = ArrayHelper::map(TrashRecycle::find()->orderBy('id')->all(), 'id', 'name_eng');
     $trashCountSummerArm = ArrayHelper::map(TrashCountSummer::find()->orderBy('id')->all(), 'id', 'name');
     $trashCountSummerEng = ArrayHelper::map(TrashCountSummer::find()->orderBy('id')->all(), 'id', 'name_eng');
     $trashCountWinterArm = ArrayHelper::map(TrashCountWinter::find()->orderBy('id')->all(), 'id', 'name');
     $trashCountWinterEng = ArrayHelper::map(TrashCountWinter::find()->orderBy('id')->all(), 'id', 'name_eng');
     return $this->render('tables', ['data' => $data, 'region' => $region, 'cities' => $cities, 'types' => $types, 'trashPlaceArm' => $trashPlaceArm, 'trashPlaceEng' => $trashPlaceEng, 'trashManArm' => $trashManArm, 'trashManEng' => $trashManEng, 'trashRelationArm' => $trashRelationArm, 'trashRelationEng' => $trashRelationEng, 'trashRecycleArm' => $trashRecycleArm, 'trashRecycleEng' => $trashRecycleEng, 'trashCountSummerArm' => $trashCountSummerArm, 'trashCountSummerEng' => $trashCountSummerEng, 'trashCountWinterArm' => $trashCountWinterArm, 'trashCountWinterEng' => $trashCountWinterEng, 'excel' => $params['excel']]);
 }