From: JoySystem_v Date: Fri, 23 Aug 2024 12:16:41 +0000 (+0300) Subject: добавлено форматирование данных и ширина первой колонки X-Git-Tag: 1.4~17^2~2 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=986f5f7131077e310e899249a051f8d191e7e2f2;p=erp24_rep%2Fyii-erp24%2F.git добавлено форматирование данных и ширина первой колонки --- diff --git a/erp24/helpers/FormatHelper.php b/erp24/helpers/FormatHelper.php new file mode 100644 index 00000000..e49aef5a --- /dev/null +++ b/erp24/helpers/FormatHelper.php @@ -0,0 +1,19 @@ +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 diff --git a/erp24/views/motivation/index.php b/erp24/views/motivation/index.php index 38386efc..178604d6 100644 --- a/erp24/views/motivation/index.php +++ b/erp24/views/motivation/index.php @@ -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 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
(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
(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
(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
(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 = [ 'Стоимость товара', 'Услуги агентов (Расходы на закупку, хранение, доставку товара)', 'Брак, пересорт', 'Расходные материалы (обеспечение продаж)', 'Оплата труда', 'Содержание помещения', - 'Расходы по доставке', 'Услуги маркетплейсов', 'Содержание и обслуживание ОС и НМА', + 'Расходы по доставке', 'Содержание и обслуживание ОС и НМА', 'Услуги связи', 'Прочие операционные расходы', 'Бухгалтерия и финансы', 'Юридическое сопровождение', '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,