From: Aleksey Filippov Date: Tue, 9 Jul 2024 21:24:28 +0000 (+0300) Subject: Перевод личного кабинета на новый факт смены X-Git-Tag: 1.4~82^2 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=ade355ea79c0511db55c4c445cedf1328867a056;p=erp24_rep%2Fyii-erp24%2F.git Перевод личного кабинета на новый факт смены --- 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