{
$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],
$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])
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