]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
исправление ошибок
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Fri, 30 Aug 2024 07:45:15 +0000 (10:45 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Fri, 30 Aug 2024 07:45:15 +0000 (10:45 +0300)
erp24/actions/motivation/IndexAction.php
erp24/services/MotivationService.php
erp24/views/motivation/index.php

index a65b645d96fb68008fec5c5a6a0bd32a1c6c0a7d..1aaeb10c12a276a5e8701498f37cc0e7b3c76757 100644 (file)
@@ -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')
         );
     }
index 6186c5d9f9718e62be9a9368c1992ca0b27f6974..a720cf8f21c2f6129463e2e2cf7290c11c177a50 100644 (file)
@@ -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; // "Минимальный порог Чистой прибыли, руб."
             }
index 82dbbf5545c295bf95c9cf56e1b6086665b32e42..dd04fd36775af4c1d591b90bed3327ec9d1ef721 100644 (file)
@@ -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
             <?php endif; ?>
         <?php endif; ?>
 
-
     </div>
\ No newline at end of file