From 68748645aadee03e5f1e0c89cc501e89709a6a9f Mon Sep 17 00:00:00 2001 From: Alexander Smirnov Date: Sat, 10 Aug 2024 11:23:27 +0300 Subject: [PATCH] =?utf8?q?[ERP-137]=20=D0=94=D0=B5=D0=B1=D0=B0=D0=B3=205?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/actions/motivation/IndexAction.php | 1 + erp24/services/MotivationService.php | 24 +++++++++++------------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/erp24/actions/motivation/IndexAction.php b/erp24/actions/motivation/IndexAction.php index 30c8a223..09bd0915 100644 --- a/erp24/actions/motivation/IndexAction.php +++ b/erp24/actions/motivation/IndexAction.php @@ -154,6 +154,7 @@ class IndexAction extends Action } else { $row['week5'] = null; } + $row['forecast'] = $row['plan']; } } diff --git a/erp24/services/MotivationService.php b/erp24/services/MotivationService.php index fbc5d6be..6c906001 100644 --- a/erp24/services/MotivationService.php +++ b/erp24/services/MotivationService.php @@ -546,26 +546,24 @@ 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; } -// }; -// } - $sum += $mv->value_type == MotivationCostsItem::DATA_TYPE_INT ? 1 : 2; + 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 (!$motivationValue) { $motivationValue = new MotivationValue; $motivationValue->motivation_id = $motivation->id; $motivationValue->motivation_group_id = $motivationValueGroupForecast->id; $motivationValue->value_id = $code; - $motivationValue->value_type = 'float'; // $sum_type; + $motivationValue->value_type = $sum_type; + } + switch ($sum_type) { + case MotivationCostsItem::DATA_TYPE_INT: { $motivationValue->value_int = $sum; break; } + default: { $motivationValue->value_float = $sum; break; } } -// 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