]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-88] добавлена проверка, что все элементы словаря участвуют
authorAlexander Smirnov <fredeom@mail.ru>
Mon, 29 Jul 2024 17:45:37 +0000 (20:45 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Mon, 29 Jul 2024 17:45:37 +0000 (20:45 +0300)
erp24/services/MotivationService.php

index 09ec4cd08fe55122b58b2afa11da13e11c2a2770..d015143596100dbe2da02df49ee470e53cd9a81b 100644 (file)
@@ -87,8 +87,9 @@ class MotivationService
                         $error = "Не корректно название элемента '" . ($row[1] ?? '') . "' Ожидается: '" . $motivationCostsItems[$row[0]]->name . "' [$ind,1]";
                         break;
                     }
-                    if ($row[2]  == '') {
-                        break;
+                    if (trim($row[2])  == '') {
+                        $rows []= $row;
+                        continue;
                     }
                     switch ($motivationCostsItems[$row[0]]->data_type) {
                         case MotivationCostsItem::DATA_TYPE_INT: { if (is_int($row[2])) { $value = (int)$row[2]; } else { $error = "Не инт [$ind,2] '" . $row[2] . "'"; }; break; }
@@ -111,6 +112,18 @@ class MotivationService
                     $error = 'Не указан магазин, год и месяц [0,0]';
                 }
             }
+            $motivationCostsItemsCount = count(array_keys($motivationCostsItems));
+            if (empty($error) && (count($rows) != $motivationCostsItemsCount)) {
+                $keys = array_keys($motivationCostsItems);
+                foreach ($rows as $row) {
+                    if (($key = array_search($row[0], $keys)) !== false) {
+                        unset($keys[$key]);
+                    }
+                }
+                $keys = array_values($keys);
+                $error = "Указаны не все элементы справочника. В листе: " . count($rows) . " В справочнике: " . $motivationCostsItemsCount
+                    . " Ожидается, например: '" . $motivationCostsItems[$keys[0]]->name . "'";
+            }
             if (empty($error)) {
                 $motivationValueGroupPlan = MotivationValueGroup::find()->where(['alias' => 'plan'])->one();
                 /** @var $motivationValueGroupPlan MotivationValueGroup */