From: Vladimir Fomichev Date: Fri, 30 Aug 2024 07:45:15 +0000 (+0300) Subject: исправление ошибок X-Git-Tag: 1.4~15^2~7 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=c023dffa53e0cf1db6be4ab7824a6e19a1154cd1;p=erp24_rep%2Fyii-erp24%2F.git исправление ошибок --- diff --git a/erp24/actions/motivation/IndexAction.php b/erp24/actions/motivation/IndexAction.php index a65b645d..1aaeb10c 100644 --- a/erp24/actions/motivation/IndexAction.php +++ b/erp24/actions/motivation/IndexAction.php @@ -115,11 +115,11 @@ class IndexAction extends Action if ($model->store_id !== null && $model->year !== null && $model->month !== null) { $showTable = true; - $motivationService = new MotivationService(); + // получаем данные из таблицы - $motivationDataTableSort = $motivationService->getMotivationDataTableSort($model->store_id, $model->year, $model->month); + $motivationDataTableSort = MotivationService::getMotivationDataTableSort($model->store_id, $model->year, $model->month); // Получаем количество дней в месяце $daysInMonth = cal_days_in_month(CAL_GREGORIAN, $model->month, $model->year); @@ -184,7 +184,7 @@ class IndexAction extends Action return $this->controller->render( 'index', - compact('model', 'stores', 'years', 'months', 'motivationDataTableSort', 'showTable', + compact('model', 'stores', 'years', 'months', 'motivationDataTableSort', 'showTable', 'daysInMonth', 'daysInLastWeek', 'week5Header') ); } diff --git a/erp24/services/MotivationService.php b/erp24/services/MotivationService.php index 6186c5d9..a720cf8f 100644 --- a/erp24/services/MotivationService.php +++ b/erp24/services/MotivationService.php @@ -134,7 +134,7 @@ class MotivationService * @return array Ассоциативный массив, где ключами являются ID групп мотивации, * а значениями — их алиасы. */ - private function getMotivationValueGroupAliases() + private static function getMotivationValueGroupAliases() { $groups = MotivationValueGroup::find()->all(); $aliases = []; @@ -158,7 +158,7 @@ class MotivationService * * @return array Отсортированный массив данных мотивации, включая плановые, фактические и другие элементы. */ - public function getMotivationDataTableSort($storeId = null, $year = null, $month = null) + public static function getMotivationDataTableSort($storeId = null, $year = null, $month = null) { // 1. Запрос к таблице Motivation $motivation = Motivation::find() @@ -186,7 +186,7 @@ class MotivationService // 4. Группировка значений $result = []; - $groupAliases = $this->getMotivationValueGroupAliases(); + $groupAliases = self::getMotivationValueGroupAliases(); foreach ($motivationValues as $value) { $valueId = $value->value_id; @@ -239,8 +239,7 @@ class MotivationService foreach (self::$additionalItems as $key => $item) { if (!isset($result[$key])) { $result[$key] = array_merge($item, [ - 'code' => $item['code'], - 'name' => $item['name'], + 'plan' => null, 'adjustment' => null, 'week1' => null, @@ -1118,12 +1117,12 @@ class MotivationService } $indMap[intval($row['code'])] = $ind; } - foreach (range(0,7) as $ind) { - switch ($ind) { + foreach (range(0,7) as $indexItem) { + switch ($indexItem) { case 0: { $column = 'plan'; break; } case 6: { $column = 'fact'; break; } case 7: { $column = 'forecast'; break; } - default: { $column = 'week' . $ind; break; } + default: { $column = 'week' . $indexItem; break; } } // Проверка на наличие необходимого ключа в $indMap @@ -1163,7 +1162,7 @@ class MotivationService Yii::info("Брак " . $motivationDataTableSort[$indMap[self::CODE_DEFECT_RESORTING]][$column]); $motivationDataTableSort[$indMap[self::CODE_AGENT_SERVICES_EXPENSES_FOR_PURCHASING_STORING_DELIVERING_GOODS]][$column] = // "Услуги агентов (Расходы на закупку, хранение, доставку товара)" ( - $motivationDataTableSort[$indMap[self::CODE_COST_PRICE_OF_GOODS]][$column] + // "Себестоимость товара" + $motivationDataTableSort[$indMap[self::CODE_COSTS_OF_GOODS]][$column] + // "Себестоимость товара код 5" $motivationDataTableSort[$indMap[self::CODE_DEFECT_RESORTING]][$column] // "Брак, пересорт" ) * $motivationDataTableSort[$indMap[self::CODE_AGENT_SERVICES_TARIFF]]['plan']; // "Услуги агентов (тариф)" @@ -1250,7 +1249,7 @@ class MotivationService $motivationDataTableSort[$indMap[self::CODE_NET_PROFIT]][$column] / $c5; // "Чистая прибыль" } - if ($ind == 0) { + if ($indexItem == 0) { $b62 = $motivationDataTableSort[$indMap[self::CODE_NET_PROFIT]]["plan"]; // "Чистая прибыль" if ($b62 > 0) { $b64 = $b62 * 0.9; @@ -1259,18 +1258,18 @@ class MotivationService } $motivationDataTableSort[$indMap[self::CODE_NET_PROFIT_THRESHOLD_RUB]]["plan"] = $b64; // "Минимальный порог Чистой прибыли, руб." } - if ($ind >= 1 && $ind <= 4) { + if ($indexItem >= 1 && $indexItem <= 4) { $motivationDataTableSort[$indMap[self::CODE_NET_PROFIT_THRESHOLD_RUB]][$column] = // "Минимальный порог Чистой прибыли, руб." $motivationDataTableSort[$indMap[self::CODE_NET_PROFIT_THRESHOLD_RUB]]["plan"] / $lastDayOfMonth * 7; // "Минимальный порог Чистой прибыли, руб." } - if ($ind == 5) { + if ($indexItem == 5) { $motivationDataTableSort[$indMap[self::CODE_NET_PROFIT_THRESHOLD_RUB]][$column] = // "Минимальный порог Чистой прибыли, руб." $motivationDataTableSort[$indMap[self::CODE_NET_PROFIT_THRESHOLD_RUB]]["plan"] / $lastDayOfMonth * ($lastDayOfMonth - 4 * 7); // "Минимальный порог Чистой прибыли, руб." } - if ($ind == 7) { + if ($indexItem == 7) { $sum = 0; - foreach (range(1, 5) as $index) { - $sum += $motivationDataTableSort[$indMap[self::CODE_NET_PROFIT_THRESHOLD_RUB]]['week' . $index]; // "Минимальный порог Чистой прибыли, руб." + foreach (range(1, 5) as $indexItem) { + $sum += $motivationDataTableSort[$indMap[self::CODE_NET_PROFIT_THRESHOLD_RUB]]['week' . $indexItem]; // "Минимальный порог Чистой прибыли, руб." } $motivationDataTableSort[$indMap[self::CODE_NET_PROFIT_THRESHOLD_RUB]][$column] = $sum; // "Минимальный порог Чистой прибыли, руб." } diff --git a/erp24/views/motivation/index.php b/erp24/views/motivation/index.php index 82dbbf55..dd04fd36 100644 --- a/erp24/views/motivation/index.php +++ b/erp24/views/motivation/index.php @@ -2,6 +2,7 @@ use \yii\helpers\Html; use kartik\select2\Select2; +use yii\helpers\Json; use yii\widgets\ActiveForm; use yii\base\DynamicModel; use kartik\grid\GridView; @@ -353,5 +354,4 @@ $this->registerJsFile('/js/motivation/index.js', ['position' => \yii\web\View::P - \ No newline at end of file