]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Фильтр показывает только доступные значения и для магазинов
authorAlexander Smirnov <fredeom@mail.ru>
Thu, 25 Jul 2024 12:58:22 +0000 (15:58 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Thu, 25 Jul 2024 12:58:22 +0000 (15:58 +0300)
erp24/actions/motivation/IndexAction.php

index 15aad57e6b0d7261ef9baafb7d4acc4b68cb432f..6c3c7ae4d0b4bf13f9d31098eb61ede470b879e1 100644 (file)
@@ -38,9 +38,14 @@ class IndexAction extends Action
             ]);
         $model->load(Yii::$app->request->get());
 
+        $motivations = Motivation::find()->all();
+        $possibleStoreIds = ArrayHelper::getColumn($motivations, 'store_id');
+
         $stores = ArrayHelper::map(CityStore::find()->all(), 'id', 'name');
+        $stores = array_filter($stores, function ($k, $v) use($possibleStoreIds) {
+            return in_array($v, $possibleStoreIds);
+        }, ARRAY_FILTER_USE_BOTH);
 
-        $motivations = Motivation::find()->all();
         $possibleYears = ArrayHelper::getColumn($motivations, 'year');
         $years = array_filter(range(2023, 20100), function ($k) use ($possibleYears) {
             return in_array($k, $possibleYears);