]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Добавляем метод определение списка смен
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Tue, 9 Dec 2025 08:09:18 +0000 (11:09 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Tue, 9 Dec 2025 08:09:18 +0000 (11:09 +0300)
erp24/api3/core/services/ReportService.php
erp24/records/Shift.php

index dac199c5138155a964ac116050bc41c545f046df..82f302d866edb55d50d463577f8ae8656929556b 100644 (file)
@@ -344,7 +344,7 @@ class ReportService
         while ($currentDate <= $data->date_end) {
             $report = [];
 
-            $shift_id = $data->shift_type == 0 ? [1, 2, 5, 8] : ($data->shift_type == 1 ? [1, 5, 8] : [2]);
+            $shift_id = Shift::getShiftIdsByShiftType($data->shift_type);
 
             // Получаем сотрудников из фактических смен за месяц
             $timetablesMonthData = TimetableFactModel::find()
@@ -682,7 +682,7 @@ class ReportService
 
                 // Определяем админов из продаж, которых нет в смене
                 $missingAdminIds = [];
-                foreach ($salesAdminIds as $adminId => $_) {
+                foreach ($salesAdminIds as $adminId => $value) {
                     $adminExists = false;
                     foreach ($adminNames[$store->id] as $admin) {
                         if ($admin['id'] == $adminId) {
@@ -705,6 +705,11 @@ class ReportService
                         ->all();
 
                     foreach ($missingAdminIds as $adminId) {
+                        // Если запрашивается конкретный тип смены (не 0), не добавляем из продаж без shift_id
+                        if ($data->shift_type != 0) {
+                            continue;
+                        }
+
                         $adminNames[$store->id][] = [
                             'id' => $adminId,
                             'name' => $missingAdmins[$adminId]['name'] ?? 'Unknown',
@@ -949,7 +954,7 @@ class ReportService
         $cityStoreNames = ArrayHelper::map(CityStore::find()->where(['visible' => '1'])->all(), 'id', 'name');
 
         // Набор идентификаторов смен согласно типу (день/ночь/обе)
-        $shiftIds = $data->shift_type == 0 ? [1, 2, 5, 8] : ($data->shift_type == 1 ? [1, 5, 8] : [2]);
+        $shiftIds = Shift::getShiftIdsByShiftType($data->shift_type);
 
         $eitStores = ExportImportTable::find()->where(['export_val' => $data->stores])
             ->select(['entity_id', 'export_val'])
@@ -1456,7 +1461,7 @@ class ReportService
 
         $cityStoreNames = ArrayHelper::map(CityStore::find()->where(['visible' => '1'])->all(), 'id', 'name');
 
-        $shiftIds = $data->shift_type == 0 ? [1, 2, 5, 8] : ($data->shift_type == 1 ? [1, 5, 8] : [2]);
+        $shiftIds = Shift::getShiftIdsByShiftType($data->shift_type);
 
         $eitStores = ExportImportTable::find()->where(['export_val' => $data->stores])
             ->select(['entity_id', 'export_val'])
index e420a04ea5adfc3a0eb32cf520ccdc3dc7746352..78063bb8f6e5277035bdc26ffa667bb650916a10 100755 (executable)
@@ -109,4 +109,8 @@ class Shift extends ActiveRecord
     {
         return Shift::NIGHT === (int) $shiftId ;
     }
+
+    public static function getShiftIdsByShiftType ($shiftType) {
+        return $shiftType == 0 ? [1, 2, 5, 8] : ($shiftType == 1 ? [1, 5, 8] : [2]);
+    }
 }
\ No newline at end of file