From: Alexander Smirnov Date: Mon, 29 Jul 2024 17:45:37 +0000 (+0300) Subject: [ERP-88] добавлена проверка, что все элементы словаря участвуют X-Git-Tag: 1.4~45^2~6 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=22604df0dd6c5aab9246cfd13590b459672cf0a2;p=erp24_rep%2Fyii-erp24%2F.git [ERP-88] добавлена проверка, что все элементы словаря участвуют --- diff --git a/erp24/services/MotivationService.php b/erp24/services/MotivationService.php index 09ec4cd0..d0151435 100644 --- a/erp24/services/MotivationService.php +++ b/erp24/services/MotivationService.php @@ -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 */