public function actionTable()
 {
     $model = UnemploymentAR::find();
     $model2 = UnemploymentQuery::create();
     $regionFilter = $this->getFilter('filter_region');
     $regionFilter->setPossibleValues(UnemploymentQuery::create()->distinct()->select('region_name')->find());
     if ($regionFilter->isSelected()) {
         $model->where(['region_name' => $regionFilter->selectedValue]);
         $model2->filterByRegionName($regionFilter->selectedValue);
     }
     $model2 = $model2->orderByRegionName()->orderByYear()->find();
     $dataProvider = new ActiveDataProvider(['query' => $model, 'pagination' => ['pageSize' => 10], 'sort' => ['defaultOrder' => ['unemployment_adult' => SORT_DESC]]]);
     $w = $this->getWidget('widget_hist');
     $w->setCategories($model2->getColumnValues('RegionName'));
     $w->setSeries(Helpers::toKeyValueArray($model2, 'Year', 'UnemploymentYouth'));
     $w = $this->getWidget('widget_hist2');
     $w->setCategories($model2->getColumnValues('RegionName'));
     $w->setSeries(Helpers::toKeyValueArray($model2, 'Year', 'UnemploymentYouth'));
     $peopleModel = PeopleAR::find();
     $peopleModel2 = \PeopleQuery::create();
     $peopleFilter = $this->getFilter('filter_people');
     $peopleFilter->setPossibleValues(PeopleQuery::create()->distinct()->select('name')->find());
     if ($peopleFilter->isSelected()) {
         $peopleModel->where(['name' => $peopleFilter->selectedValues]);
         $peopleModel2->filterByName($peopleFilter->selectedValues);
     }
     $peopleModel2 = $peopleModel2->find();
     $dataProvider2 = new ActiveDataProvider(['query' => $peopleModel, 'pagination' => ['pageSize' => 10], 'sort' => ['defaultOrder' => ['id' => SORT_ASC]]]);
     return $this->render('table.tpl', ['dataProvider' => $dataProvider, 'model2' => $model2, 'peopleModel2' => $peopleModel2, 'dataProvider2' => $dataProvider2]);
 }
 public function actionIndex()
 {
     $model = UnemploymentQuery::create()->orderByYear();
     $filter = $this->getFilter('filter_region');
     $filter->setPossibleValues(UnemploymentQuery::create()->distinct()->select('region_name')->find());
     if (!$filter->isSelected()) {
         $filter->setSelectedValues($filter->getPossibleValues()[0]);
     }
     $model = $model->filterByRegionName($filter->selectedValue)->find();
     $widget = $this->getWidget('widget_hist');
     $widget->setCategories($model->getColumnValues('Year'));
     $widget->setSeries(['Безработица' => $model->getColumnValues('UnemploymentYouth')]);
     $widget = $this->getWidget('widget_hist2');
     $widget->setCategories($model->getColumnValues('RegionName'));
     $widget->setSeries(Helpers::toKeyValueArray($model, 'Year', 'UnemploymentYouth'));
     return $this->render('index.tpl');
 }