From: Vladimir Fomichev Date: Tue, 9 Dec 2025 08:09:18 +0000 (+0300) Subject: Добавляем метод определение списка смен X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=5fa9820a732f60534f58c3e99c43cdb21409af16;p=erp24_rep%2Fyii-erp24%2F.git Добавляем метод определение списка смен --- diff --git a/erp24/api3/core/services/ReportService.php b/erp24/api3/core/services/ReportService.php index dac199c5..82f302d8 100644 --- a/erp24/api3/core/services/ReportService.php +++ b/erp24/api3/core/services/ReportService.php @@ -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']) diff --git a/erp24/records/Shift.php b/erp24/records/Shift.php index e420a04e..78063bb8 100755 --- a/erp24/records/Shift.php +++ b/erp24/records/Shift.php @@ -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