From 8e1bb385290fa2b998b3f193c87af03575f52d55 Mon Sep 17 00:00:00 2001 From: Alexander Smirnov Date: Thu, 25 Jul 2024 15:51:32 +0300 Subject: [PATCH] =?utf8?q?=D0=A4=D0=B8=D0=BB=D1=8C=D1=82=D1=80=20=D0=BF?= =?utf8?q?=D0=BE=D0=BA=D0=B0=D0=B7=D1=8B=D0=B2=D0=B0=D0=B5=D1=82=20=D1=82?= =?utf8?q?=D0=BE=D0=BB=D1=8C=D0=BA=D0=BE=20=D0=B4=D0=BE=D1=81=D1=82=D1=83?= =?utf8?q?=D0=BF=D0=BD=D1=8B=D0=B5=20=D0=B7=D0=BD=D0=B0=D1=87=D0=B5=D0=BD?= =?utf8?q?=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/actions/motivation/IndexAction.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/erp24/actions/motivation/IndexAction.php b/erp24/actions/motivation/IndexAction.php index c3f3794b..15aad57e 100644 --- a/erp24/actions/motivation/IndexAction.php +++ b/erp24/actions/motivation/IndexAction.php @@ -10,6 +10,7 @@ use yii\base\DynamicModel; 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; @@ -39,8 +40,15 @@ class IndexAction extends Action $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')); -- 2.39.5