]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-107] умножил на 100 и добавил проценты origin/feature_smirnov_erp-107_bonus_calculation
authorAlexander Smirnov <fredeom@mail.ru>
Thu, 5 Sep 2024 08:37:03 +0000 (11:37 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Thu, 5 Sep 2024 08:37:03 +0000 (11:37 +0300)
erp24/views/motivation/index.php

index 99c185830de44dde2903d977b6e4648bab5f0492..22f404da1eb1b1d983f82285abac855cd805009f 100644 (file)
@@ -141,80 +141,81 @@ $this->registerJsFile('/js/motivation/index.js', ['position' => \yii\web\View::P
                         [
                             'attribute' => 'plan',
                             'value' => function ($model) {
-                                return $model["plan"] !== null ? FormatHelper::asDecimalMotivation($model["plan"]) : " ";
+                                $koef = ($model['code'] == MotivationService::CODE_NET_PROFIT_MARGIN_PERCENT) ? 100 : 1;
+                                return $model["plan"] !== null ? FormatHelper::asDecimalMotivation($model["plan"] * $koef) . ($koef == 100 ? "%" : "") : " ";
                             },
                             'header' => 'План',
                         ],
                         [
                             'attribute' => 'adjustment',
                             'value' => function ($model) {
-                                return $model["adjustment"] !== null ? FormatHelper::asDecimalMotivation($model["adjustment"]) : " ";
+                                $koef = ($model['code'] == MotivationService::CODE_NET_PROFIT_MARGIN_PERCENT) ? 100 : 1;
+                                return $model["adjustment"] !== null ? FormatHelper::asDecimalMotivation($model["adjustment"] * $koef) . ($koef == 100 ? "%" : "") : " ";
                             },
                             'header' => 'Корректировка',
                         ],
                         [
                             'attribute' => 'week1',
                             'class' => 'kartik\grid\FormulaColumn',
-
                             'header' => 'Неделя 1<br>(1-7)',
                             'value' => function ($model) {
-                                return $model["week1"] !== null ? FormatHelper::asDecimalMotivation($model["week1"]) : "0";
+                                $koef = ($model['code'] == MotivationService::CODE_NET_PROFIT_MARGIN_PERCENT) ? 100 : 1;
+                                return $model["week1"] !== null ? FormatHelper::asDecimalMotivation($model["week1"] * $koef) . ($koef == 100 ? "%" : "") : "0";
                             },
                         ],
                         [
                             'attribute' => 'week2',
                             'class' => 'kartik\grid\FormulaColumn',
-
                             'header' => 'Неделя 2<br>(8-14)',
                             'value' => function ($model) {
-                                return $model["week2"] !== null ? FormatHelper::asDecimalMotivation($model["week2"]) : "0";
+                                $koef = ($model['code'] == MotivationService::CODE_NET_PROFIT_MARGIN_PERCENT) ? 100 : 1;
+                                return $model["week2"] !== null ? FormatHelper::asDecimalMotivation($model["week2"] * $koef) . ($koef == 100 ? "%" : "") : "0";
                             },
 
                         ],
                         [
                             'attribute' => 'week3',
                             'class' => 'kartik\grid\FormulaColumn',
-
                             'header' => 'Неделя 3<br>(15-21)',
                             'value' => function ($model) {
-                                return $model["week3"] !== null ? FormatHelper::asDecimalMotivation($model["week3"]) : "0";
+                                $koef = ($model['code'] == MotivationService::CODE_NET_PROFIT_MARGIN_PERCENT) ? 100 : 1;
+                                return $model["week3"] !== null ? FormatHelper::asDecimalMotivation($model["week3"] * $koef) . ($koef == 100 ? "%" : "") : "0";
                             },
 
                         ],
                         [
                             'attribute' => 'week4',
                             'class' => 'kartik\grid\FormulaColumn',
-
                             'header' => 'Неделя 4<br>(22-28)',
                             'value' => function ($model) {
-                                return $model["week4"] !== null ? FormatHelper::asDecimalMotivation($model["week4"]) : "0";
+                                $koef = ($model['code'] == MotivationService::CODE_NET_PROFIT_MARGIN_PERCENT) ? 100 : 1;
+                                return $model["week4"] !== null ? FormatHelper::asDecimalMotivation($model["week4"] * $koef) . ($koef == 100 ? "%" : "") : "0";
                             },
 
                         ],
                         [
                             'attribute' => 'week5',
                             'class' => 'kartik\grid\FormulaColumn',
-
                             'header' => $week5Header,
                             'value' => function ($model) {
-                                return $model["week5"] !== null ? FormatHelper::asDecimalMotivation($model["week5"]) : "0";
+                                $koef = ($model['code'] == MotivationService::CODE_NET_PROFIT_MARGIN_PERCENT) ? 100 : 1;
+                                return $model["week5"] !== null ? FormatHelper::asDecimalMotivation($model["week5"] * $koef) . ($koef == 100 ? "%" : "") : "0";
                             },
                         ],
                         [
                             'attribute' => 'forecast',
                             'header' => 'Прогноз за месяц',
                             'value' => function ($model) {
-                                return $model["forecast"] !== null ? FormatHelper::asDecimalMotivation($model["forecast"]) : " ";
-
+                                $koef = ($model['code'] == MotivationService::CODE_NET_PROFIT_MARGIN_PERCENT) ? 100 : 1;
+                                return $model["forecast"] !== null ? FormatHelper::asDecimalMotivation($model["forecast"] * $koef) . ($koef == 100 ? "%" : "") : " ";
                             },
-
                         ],
                         [
                             'attribute' => 'fact',
                             'header' => 'Факт за месяц',
                             'value' => function ($model) {
-                                return $model["fact"] !== null ? FormatHelper::asDecimalMotivation($model["fact"]) : " ";
-
+                                $koef = ($model['code'] == MotivationService::CODE_NET_PROFIT_MARGIN_PERCENT) ? 100 : 1;
+                                return $model["fact"] !== null ? FormatHelper::asDecimalMotivation($model["fact"] * $koef) . ($koef == 100 ? "%" : "") : " ";
                             },
                         ],
                         [