From: Vladimir Fomichev Date: Fri, 5 Dec 2025 12:33:22 +0000 (+0300) Subject: корректировка дней X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=b6527b8821a4a2f7309ef784f8edbf1952fe4de5;p=erp24_rep%2Fyii-erp24%2F.git корректировка дней --- diff --git a/erp24/api3/core/services/ReportService.php b/erp24/api3/core/services/ReportService.php index 0234afa1..cb9a8e91 100644 --- a/erp24/api3/core/services/ReportService.php +++ b/erp24/api3/core/services/ReportService.php @@ -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 = [];