From 102c97b96eedced48132e5dc31e4d98c367e1304 Mon Sep 17 00:00:00 2001 From: Alexander Smirnov Date: Sat, 10 Aug 2024 11:09:57 +0300 Subject: [PATCH] =?utf8?q?[ERP-137]=20=D0=94=D0=B5=D0=B1=D0=B0=D0=B3=204?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/services/MotivationService.php | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/erp24/services/MotivationService.php b/erp24/services/MotivationService.php index 6c906001..fbc5d6be 100644 --- a/erp24/services/MotivationService.php +++ b/erp24/services/MotivationService.php @@ -546,24 +546,26 @@ class MotivationService $mv = MotivationValue::find()->where(['motivation_id' => $motivation->id, 'motivation_group_id' => $motivationValueGroups[$ind-1]->id, 'value_id' => $code])->one(); /** @var $mv MotivationValue */ - if ($mv) { - switch ($mv->value_type) { - case MotivationCostsItem::DATA_TYPE_INT: { $sum += $mv->value_int; break; } - default: { $sum += $mv->value_float; $sum_type = MotivationCostsItem::DATA_TYPE_FLOAT; break; } - }; - } +// if ($mv) { +// switch ($mv->value_type) { +// case MotivationCostsItem::DATA_TYPE_INT: { $sum += $mv->value_int; break; } +// default: { $sum += $mv->value_float; $sum_type = MotivationCostsItem::DATA_TYPE_FLOAT; break; } +// }; +// } + $sum += $mv->value_type == MotivationCostsItem::DATA_TYPE_INT ? 1 : 2; } if (!$motivationValue) { $motivationValue = new MotivationValue; $motivationValue->motivation_id = $motivation->id; $motivationValue->motivation_group_id = $motivationValueGroupForecast->id; $motivationValue->value_id = $code; - $motivationValue->value_type = $sum_type; - } - switch ($sum_type) { - case MotivationCostsItem::DATA_TYPE_INT: { $motivationValue->value_int = $sum; break; } - default: { $motivationValue->value_float = $sum; break; } + $motivationValue->value_type = 'float'; // $sum_type; } +// switch ($sum_type) { +// case MotivationCostsItem::DATA_TYPE_INT: { $motivationValue->value_int = $sum; break; } +// default: { $motivationValue->value_float = $sum; break; } +// } + $motivationValue->value_float = $sum; $motivationValue->save(); if ($motivationValue->getErrors()) { throw new \Exception(Json::encode($motivationValue->getErrors())); -- 2.39.5