]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-137] Дебаг 5
authorAlexander Smirnov <fredeom@mail.ru>
Sat, 10 Aug 2024 08:23:27 +0000 (11:23 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Sat, 10 Aug 2024 08:23:27 +0000 (11:23 +0300)
erp24/actions/motivation/IndexAction.php
erp24/services/MotivationService.php

index 30c8a2230488104458de97e492dc24f0bc9aac10..09bd09152a9a5c03c659a495c9cd2545ce703d24 100644 (file)
@@ -154,6 +154,7 @@ class IndexAction extends Action
                     } else {
                         $row['week5'] = null;
                     }
+                    $row['forecast'] = $row['plan'];
                 }
             }
 
index fbc5d6be6a0b1c95c23927b5ccc4b18b213532e8..6c90600104bbf4952cdfe26528d00513100a0d9b 100644 (file)
@@ -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()));