use yii\helpers\ArrayHelper;
use yii\web\UploadedFile;
use yii_app\records\CityStore;
+use yii_app\records\Motivation;
use yii_app\records\MotivationCostsItem;
use yii_app\services\MotivationService;
$stores = ArrayHelper::map(CityStore::find()->all(), 'id', 'name');
- $years = [2023, 2024, 2025, 2026];
- $months = ['Январь',' Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'];
+ $motivations = Motivation::find()->all();
+ $possibleYears = ArrayHelper::getColumn($motivations, 'year');
+ $years = array_filter(range(2023, 20100), function ($k) use ($possibleYears) {
+ return in_array($k, $possibleYears);
+ });
+ $possibleMonth = ArrayHelper::getColumn($motivations, 'month');
+ $months = array_filter(['Январь',' Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'], function ($k, $v) use ($possibleMonth) {
+ return in_array($v + 1, $possibleMonth);
+ }, ARRAY_FILTER_USE_BOTH);
return $this->controller->render('index',
compact('model', 'stores', 'years', 'months'));