]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Корректировка недельного отчета
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Mon, 8 Dec 2025 08:43:21 +0000 (11:43 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Mon, 8 Dec 2025 08:43:21 +0000 (11:43 +0300)
erp24/api3/core/services/ReportService.php

index 58208ef5f958c1e81cca3b9ee1bef44004e595af..dac199c5138155a964ac116050bc41c545f046df 100644 (file)
@@ -948,6 +948,9 @@ 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]);
+
         $eitStores = ExportImportTable::find()->where(['export_val' => $data->stores])
             ->select(['entity_id', 'export_val'])
             ->where(['export_id' => 1, 'entity' => 'city_store'])
@@ -973,6 +976,7 @@ class ReportService
             ->where(['store_id' => $data->stores])
             ->andWhere($cond)
             ->andWhere(['>', 'work_time', 0])
+            ->andWhere(['shift_id' => $shiftIds])
             ->asArray()
             ->all();
 
@@ -992,12 +996,13 @@ class ReportService
             // Получаем сотрудников из фактических смен за неделю
             foreach ($data->stores as $store_id) {
                 $employees = TimetableFactModel::find()
-                    ->select(['admin_id'])
+                    ->select(['admin_id', 'shift_id'])
                     //->distinct()
                     ->where(['store_id' => $store_id])
                     ->andWhere(['>=', 'date', date("Y-m-d", strtotime($dateStartEnd[0]))])
                     ->andWhere(['<=', 'date', date("Y-m-d", strtotime($dateStartEnd[1]))])
                     ->andWhere(['>', 'work_time', 0])
+                    ->andWhere(['shift_id' => $shiftIds])
                     ->asArray()
                     ->all();