]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Перевод личного кабинета на новый факт смены origin/feature_filippov_20240709_lk_fix
authorAleksey Filippov <Aleksey.Filippov@erp-flowers.ru>
Tue, 9 Jul 2024 21:24:28 +0000 (00:24 +0300)
committerAleksey Filippov <Aleksey.Filippov@erp-flowers.ru>
Tue, 9 Jul 2024 21:24:28 +0000 (00:24 +0300)
erp24/services/CabinetService.php

index c8e21ddc8918e5d5b0e0c9344484269946b751bc..b8aa354ac08059b50c261605da67b8fb44c27ff1 100755 (executable)
@@ -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