]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
корректировка дней
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Fri, 5 Dec 2025 12:33:22 +0000 (15:33 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Fri, 5 Dec 2025 12:33:22 +0000 (15:33 +0300)
erp24/api3/core/services/ReportService.php

index 0234afa174e43ec768167dbe9d4727f7f7cd3f3b..cb9a8e915569e1a88f4143546c0a523c2ebce692 100644 (file)
@@ -16,6 +16,7 @@ use yii_app\records\ExportImportTable;
 use yii_app\records\Products1c;
 use yii_app\records\ProductsClass;
 use yii_app\records\Sales;
+use yii_app\records\Shift;
 use yii_app\records\StoreStaffing;
 use yii_app\records\StoreVisitors;
 use yii_app\records\WriteOffs;
@@ -1463,7 +1464,7 @@ class ReportService
             // Для обеих смен нужны уникальные комбинации admin_id и shift_id
             $allAdminsInPeriod = $allAdminsInPeriodQuery
                 ->select(['admin_id', 'shift_id'])
-                ->distinct()
+                //->distinct()
                 ->asArray()
                 ->all();
             $employeeCountTotal = count($allAdminsInPeriod);
@@ -1473,14 +1474,14 @@ class ReportService
         } else {
             // Для конкретной смены используем фильтр и distinct
             if ($data->shift_type == 1) {
-                $allAdminsInPeriodQuery->andWhere(['shift_id' => \yii_app\records\Shift::DAY]);
+                $allAdminsInPeriodQuery->andWhere(['shift_id' => Shift::DAY]);
             } elseif ($data->shift_type == 2) {
-                $allAdminsInPeriodQuery->andWhere(['shift_id' => \yii_app\records\Shift::NIGHT]);
+                $allAdminsInPeriodQuery->andWhere(['shift_id' => Shift::NIGHT]);
             }
             
             $allAdminsInPeriod = $allAdminsInPeriodQuery
                 ->select(['admin_id'])
-                ->distinct()
+                //->distinct()
                 ->asArray()
                 ->all();
             $adminIdsInPeriod = ArrayHelper::getColumn($allAdminsInPeriod, 'admin_id');
@@ -1517,14 +1518,14 @@ class ReportService
                 if ($data->shift_type == 0) {
                     $employees = $employeesQuery
                         ->select(['admin_id', 'shift_id'])
-                        ->distinct()
+                        //->distinct()
                         ->asArray()
                         ->all();
                 } else {
                     // Для конкретной смены используем distinct
                     $employees = $employeesQuery
                         ->select(['admin_id'])
-                        ->distinct()
+                        //->distinct()
                         ->asArray()
                         ->all();
                 }
@@ -1543,18 +1544,18 @@ class ReportService
             // Дедупликация $allDayEmployees для корректного подсчета total
             // Для shift_type == 0 дедуплицируем по (admin_id, shift_id)
             // Для других типов дедуплицируем по admin_id
-            $uniqueEmployees = [];
-            foreach ($allDayEmployees as $employee) {
-                if ($data->shift_type == 0) {
-                    $key = $employee['admin_id'] . '_' . $employee['shift_id'];
-                } else {
-                    $key = $employee['admin_id'];
-                }
-                if (!isset($uniqueEmployees[$key])) {
-                    $uniqueEmployees[$key] = $employee;
-                }
-            }
-            $allDayEmployees = array_values($uniqueEmployees);
+//            $uniqueEmployees = [];
+//            foreach ($allDayEmployees as $employee) {
+//                if ($data->shift_type == 0) {
+//                    $key = $employee['admin_id'] . '_' . $employee['shift_id'];
+//                } else {
+//                    $key = $employee['admin_id'];
+//                }
+//                if (!isset($uniqueEmployees[$key])) {
+//                    $uniqueEmployees[$key] = $employee;
+//                }
+//            }
+        //    $allDayEmployees = array_values($uniqueEmployees);
 
 
             $storeVisitorsQuantityTotal = [];