]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
добавлено форматирование данных и ширина первой колонки
authorJoySystem_v <fvv2011@gmail.com>
Fri, 23 Aug 2024 12:16:41 +0000 (15:16 +0300)
committerJoySystem_v <fvv2011@gmail.com>
Fri, 23 Aug 2024 12:16:41 +0000 (15:16 +0300)
erp24/helpers/FormatHelper.php [new file with mode: 0644]
erp24/views/motivation/index.php

diff --git a/erp24/helpers/FormatHelper.php b/erp24/helpers/FormatHelper.php
new file mode 100644 (file)
index 0000000..e49aef5
--- /dev/null
@@ -0,0 +1,19 @@
+<?php
+
+namespace yii_app\helpers;
+
+use Yii;
+use NumberFormatter;
+
+class FormatHelper
+{
+    public static function asDecimalMotivation($value, $decimals = 2)
+    {
+        $formatter = new NumberFormatter('ru_RU', NumberFormatter::DECIMAL);
+        $formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, $decimals);
+        $formatter->setSymbol(NumberFormatter::DECIMAL_SEPARATOR_SYMBOL, ',');
+        $formatter->setSymbol(NumberFormatter::GROUPING_SEPARATOR_SYMBOL, ' ');
+
+        return $formatter->format($value);
+    }
+}
\ No newline at end of file
index 38386efcadefcf479a0a223c760884edfa182d43..178604d652ef851a7d8ec714824ef9ce1b1098a0 100644 (file)
@@ -5,6 +5,7 @@ use kartik\select2\Select2;
 use yii\widgets\ActiveForm;
 use yii\base\DynamicModel;
 use kartik\grid\GridView;
+use yii_app\helpers\FormatHelper;
 use yii_app\records\MotivationCostsItem;
 /** @var $model DynamicModel */
 /** @var $stores array */
@@ -83,7 +84,14 @@ $this->registerJsFile('/js/motivation/index.js', ['position' => \yii\web\View::P
             <?php else : ?>
 
                 <?php
-
+                // CSS для фиксации ширины и переноса слов в первом столбце
+                $this->registerCss("
+                        .grid-view td:first-child, .grid-view th:first-child {
+                         width: 150px; /* Фиксированная ширина */
+                         word-wrap: break-word; /* Перенос слов */
+                         white-space: normal; /* Разрешаем перенос слов */
+                         }
+                    ");
 
                 // Функция для расчета значения недели
                 function calculateWeekValue($plan, $daysInMonth, $daysInWeek)
@@ -124,22 +132,18 @@ $this->registerJsFile('/js/motivation/index.js', ['position' => \yii\web\View::P
                         [
                             'attribute' => 'plan',
                             'value' => function ($model) {
-                                if ($model["plan"] !== null) {
-                                    return Yii::$app->formatter->asDecimal($model["plan"], 2);
-                                } else {
-                                    return " ";
-                                }
+
+                                return $model["plan"] !== null ? FormatHelper::asDecimalMotivation($model["plan"]) : " ";
+
                             },
                             'header' => 'План',
                         ],
                         [
                             'attribute' => 'correction',
                             'value' => function ($model) {
-                                if ($model["correction"] !== null && $model["correction"] !== '') {
-                                    return Yii::$app->formatter->asDecimal($model["correction"], 2);
-                                } else {
-                                    return " ";
-                                }
+
+                                return $model["correction"] !== null ? FormatHelper::asDecimalMotivation($model["correction"]) : " ";
+
                             },
 
                             'header' => 'Корректировка',
@@ -150,11 +154,8 @@ $this->registerJsFile('/js/motivation/index.js', ['position' => \yii\web\View::P
 
                             'header' => 'Неделя 1<br>(1-7)',
                             'value' => function ($model) {
-                                if ($model["week1"] !== null) {
-                                    return Yii::$app->formatter->asDecimal($model["week1"], 2);
-                                } else {
-                                    return " ";
-                                }
+                                return $model["week1"] !== null ? FormatHelper::asDecimalMotivation($model["week1"]) : " ";
+
                             },
 
                         ],
@@ -164,11 +165,8 @@ $this->registerJsFile('/js/motivation/index.js', ['position' => \yii\web\View::P
 
                             'header' => 'Неделя 2<br>(8-14)',
                             'value' => function ($model) {
-                                if ($model["week2"] !== null) {
-                                    return Yii::$app->formatter->asDecimal($model["week2"], 2);
-                                } else {
-                                    return " ";
-                                }
+                                return $model["week2"] !== null ? FormatHelper::asDecimalMotivation($model["week2"]) : " ";
+
                             },
 
                         ],
@@ -178,11 +176,8 @@ $this->registerJsFile('/js/motivation/index.js', ['position' => \yii\web\View::P
 
                             'header' => 'Неделя 3<br>(15-21)',
                             'value' => function ($model) {
-                                if ($model["week3"] !== null) {
-                                    return Yii::$app->formatter->asDecimal($model["week3"], 2);
-                                } else {
-                                    return " ";
-                                }
+                                return $model["week3"] !== null ? FormatHelper::asDecimalMotivation($model["week3"]) : " ";
+
                             },
 
                         ],
@@ -192,11 +187,8 @@ $this->registerJsFile('/js/motivation/index.js', ['position' => \yii\web\View::P
 
                             'header' => 'Неделя 4<br>(22-28)',
                             'value' => function ($model) {
-                                if ($model["week4"] !== null) {
-                                    return Yii::$app->formatter->asDecimal($model["week4"], 2);
-                                } else {
-                                    return " ";
-                                }
+                                return $model["week4"] !== null ? FormatHelper::asDecimalMotivation($model["week4"]) : " ";
+
                             },
 
                         ],
@@ -206,11 +198,8 @@ $this->registerJsFile('/js/motivation/index.js', ['position' => \yii\web\View::P
 
                             'header' => $week5Header,
                             'value' => function ($model) {
-                                if ($model["week5"] !== null) {
-                                    return Yii::$app->formatter->asDecimal($model["week5"], 2);
-                                } else {
-                                    return " ";
-                                }
+                                return $model["week5"] !== null ? FormatHelper::asDecimalMotivation($model["week5"]) : " ";
+
                             },
 
                         ],
@@ -220,11 +209,8 @@ $this->registerJsFile('/js/motivation/index.js', ['position' => \yii\web\View::P
 
                             'header' => 'Прогноз за месяц',
                             'value' => function ($model) {
-                                if ($model["forecast"] !== null) {
-                                    return Yii::$app->formatter->asDecimal($model["forecast"], 2);
-                                } else {
-                                    return " ";
-                                }
+                                return $model["forecast"] !== null ? FormatHelper::asDecimalMotivation($model["forecast"]) : " ";
+
                             },
 
                         ],
@@ -234,11 +220,8 @@ $this->registerJsFile('/js/motivation/index.js', ['position' => \yii\web\View::P
 
                             'header' => 'Факт за месяц',
                             'value' => function ($model) {
-                                if ($model["fact"] !== null) {
-                                    return Yii::$app->formatter->asDecimal($model["fact"], 2);
-                                } else {
-                                    return " ";
-                                }
+                                return $model["fact"] !== null ? FormatHelper::asDecimalMotivation($model["fact"]) : " ";
+
                             },
                         ],
                         [
@@ -246,11 +229,8 @@ $this->registerJsFile('/js/motivation/index.js', ['position' => \yii\web\View::P
 
                             'header' => 'Отклонение, %',
                             'value' => function ($model) {
-                                if ($model["deviation"] !== null) {
-                                    return Yii::$app->formatter->asDecimal($model["deviation"], 2);
-                                } else {
-                                    return " ";
-                                }
+                                return $model["deviation"] !== null ? FormatHelper::asDecimalMotivation($model["deviation"]) : " ";
+
                             },
 
                         ]
@@ -286,7 +266,7 @@ $this->registerJsFile('/js/motivation/index.js', ['position' => \yii\web\View::P
                                 $boldRows = [
                                     'Стоимость товара', 'Услуги агентов (Расходы на закупку, хранение, доставку товара)',
                                     'Брак, пересорт', 'Расходные материалы (обеспечение продаж)', 'Оплата труда', 'Содержание помещения',
-                                    'РаÑ\81Ñ\85одÑ\8b Ð¿Ð¾ Ð´Ð¾Ñ\81Ñ\82авке', 'УÑ\81лÑ\83ги Ð¼Ð°Ñ\80кеÑ\82плейÑ\81ов', 'СодеÑ\80жание Ð¸ Ð¾Ð±Ñ\81лÑ\83живание Ð\9eС Ð¸ Ð\9dÐ\9cÐ\90',
+                                    'Расходы по доставке', 'Содержание и обслуживание ОС и НМА',
                                     'Услуги связи', 'Прочие операционные расходы', 'Бухгалтерия и финансы',
                                     'Юридическое сопровождение', 'HR- услуги', 'IT услуги',
                                     'Продвижение и продажа товара через сайт', 'Минимальный порог Чистой прибыли, руб.',
@@ -337,7 +317,10 @@ $this->registerJsFile('/js/motivation/index.js', ['position' => \yii\web\View::P
                         [
                             'attribute' => 'plan',
                             'header' => 'Значение',
-                            'format' => ['decimal', 2],
+                            'value' => function ($model) {
+                                return $model["plan"] !== null ? FormatHelper::asDecimalMotivation($model["plan"]) : " ";
+
+                            },
                         ],
                     ],
                     'responsive' => true,