From 0785fcb8b76c57fdb268d5f05b6a5a904494562c Mon Sep 17 00:00:00 2001 From: Vladimir Fomichev Date: Wed, 18 Mar 2026 16:07:18 +0300 Subject: [PATCH] =?utf8?q?=D0=BF=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD=D0=B8?= =?utf8?q?=D0=B5=20=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D0=BD=D0=B8=D0=BA=D0=BE?= =?utf8?q?=D0=B2=20=D0=BD=D0=B0=20=D1=81=D0=BC=D0=B5=D0=BD=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/api2/controllers/DataTestController.php | 39 ++++++++++++------- 1 file changed, 26 insertions(+), 13 deletions(-) diff --git a/erp24/api2/controllers/DataTestController.php b/erp24/api2/controllers/DataTestController.php index 998a5127..b4f4ff90 100644 --- a/erp24/api2/controllers/DataTestController.php +++ b/erp24/api2/controllers/DataTestController.php @@ -8,9 +8,7 @@ use Yii; use yii\helpers\Json; use yii_app\records\ApiCronTest; use yii_app\records\ExportImportTable; -use yii_app\records\Shift; use yii_app\records\TimetableFact; -use yii_app\records\Timetable; class DataTestController extends BaseController { @@ -368,19 +366,34 @@ class DataTestController extends BaseController { $shiftType = (int) ($input['shift_type'] ?? 0); try { - $shiftIds = Shift::getShiftIdsByShiftType($shiftType); + $dateObj = new \DateTime($date); + $nextDateStr = (clone $dateObj)->modify('+1 day')->format('Y-m-d'); - $rows = TimetableFact::find() + $query = TimetableFact::find() ->select(['timetable.admin_id']) - ->with('admin') - ->andWhere([ - 'store_id' => $storeId, - 'date' => $date, - 'shift_id' => $shiftIds, - 'slot_type_id' => [Timetable::TIMESLOT_WORK, Timetable::TIMESLOT_INTERNSHIP], - ]) - ->asArray() - ->all(); + ->andWhere(['store_id' => $storeId]); + + if ($shiftType === 1) { + // Дневная: 08:00 – 20:00 + $query->andWhere(['between', 'datetime_start', + $date . ' 08:00:00', + $date . ' 19:59:59', + ]); + } elseif ($shiftType === 2) { + // Ночная: 20:00 – 08:00 следующего дня + $query->andWhere(['OR', + ['between', 'datetime_start', $date . ' 20:00:00', $date . ' 23:59:59'], + ['between', 'datetime_start', $nextDateStr . ' 00:00:00', $nextDateStr . ' 07:59:59'], + ]); + } else { + // Все смены за дату + $query->andWhere(['between', 'datetime_start', + $date . ' 00:00:00', + $date . ' 23:59:59', + ]); + } + + $rows = $query->asArray()->all(); if (empty($rows)) { return $this->asJson(['success' => true, 'data' => []]); -- 2.39.5