From ade355ea79c0511db55c4c445cedf1328867a056 Mon Sep 17 00:00:00 2001 From: Aleksey Filippov Date: Wed, 10 Jul 2024 00:24:28 +0300 Subject: [PATCH] =?utf8?q?=D0=9F=D0=B5=D1=80=D0=B5=D0=B2=D0=BE=D0=B4=20?= =?utf8?q?=D0=BB=D0=B8=D1=87=D0=BD=D0=BE=D0=B3=D0=BE=20=D0=BA=D0=B0=D0=B1?= =?utf8?q?=D0=B8=D0=BD=D0=B5=D1=82=D0=B0=20=D0=BD=D0=B0=20=D0=BD=D0=BE?= =?utf8?q?=D0=B2=D1=8B=D0=B9=20=D1=84=D0=B0=D0=BA=D1=82=20=D1=81=D0=BC?= =?utf8?q?=D0=B5=D0=BD=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/services/CabinetService.php | 71 ++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/erp24/services/CabinetService.php b/erp24/services/CabinetService.php index c8e21ddc..b8aa354a 100755 --- a/erp24/services/CabinetService.php +++ b/erp24/services/CabinetService.php @@ -4043,6 +4043,26 @@ Group BY admin_id { $timetable = []; + if ($date < '2024-07-01') { + $timetable = $this->getTimetablePlanAdminData($shiftId, $storeId, $date); + } else { + $timetable = $this->getTimetableFactAdminData($shiftId, $storeId, $date); + } + + return $timetable; + } + + + /** + * @param $timeTabelType + * @param $dateFrom + * @param $dateTo + * @return array + */ + public function getTimetablePlanAdminData($shiftId, $storeId, $date): array + { + $timetable = []; + $dict = [ 1 => [ 1, 5, 7, 8], 2 => [ 2], @@ -4069,7 +4089,7 @@ Group BY admin_id $timetable = Timetable::find() ->joinWith('admin') ->andWhere(['date' => $date]) - ->andWhere(['<>','admin.group_id', -1]) + ->andWhere(['<>','admin.group_id', -1]) ->andWhere(['shift_id' => $shiftIdForDict]) ->andWhere(['timetable.store_id' => $storeId]) ->andWhere(['slot_type_id' => $slotTypeId]) @@ -4082,6 +4102,55 @@ Group BY admin_id return $timetable; } + + /** + * @param $timeTabelType + * @param $dateFrom + * @param $dateTo + * @return array + */ + public function getTimetableFactAdminData($shiftId, $storeId, $date): array + { + $dict = [ + 1 => [ 1, 5, 7, 8], + 2 => [ 2], + 5 => [ 1, 5, 7, 8], + 7 => [ 1, 5, 7, 8], + 8 => [ 1, 5, 7, 8], + ]; + + $shiftIdForDict = ArrayHelper::getValue($dict, $shiftId); + + $query = TimetableFactModel::find() + ->joinWith('admin') + ->andWhere(['date_shift' => $date]) + ->andWhere(['<>','admin.group_id', -1]) + ->andWhere(['timetable_fact.store_id' => $storeId]) + ->andWhere(['shift_id' => $shiftIdForDict]) + ; + + $query->indexBy(['id']); + + $action = $query->createCommand()->getRawSql(); + + $timetableFactPrepared = $query->asArray()->all(); + + $timetableFact = []; + $listDateCount = []; + if (!empty($timetableFactPrepared)) { + foreach ($timetableFactPrepared as $key => $row) { + if (!array_key_exists($row['date_shift'], $listDateCount)) { + $listDateCount[$row['date_shift']] = 1; + $timetableFact[$key] = $row; + $timetableFact[$key]['date'] = $row['date_shift']; + } + } + } + + return $timetableFact; + } + + /** * @param $date * @param $adminFloristPrepared -- 2.39.5