]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Fix erp 5
authorMarina Zozirova <marina.zozirova@erp-flowers.ru>
Fri, 14 Jun 2024 05:25:46 +0000 (05:25 +0000)
committerAleksey Filippov <aleksey.filippov@erp-flowers.ru>
Fri, 14 Jun 2024 05:25:46 +0000 (05:25 +0000)
erp24/actions/timetable/StartShiftStepOneAction.php

index 716aff22f4be8b2bf1f1b576a7360ab8002321e9..3dbf471ba5152b199ff80987156621e2ad30e485 100755 (executable)
@@ -11,6 +11,7 @@ use yii_app\records\AdminCheckin;
 use yii_app\records\AdminDesktop;
 use yii_app\records\CityStore;
 use yii_app\records\Shift;
+use yii_app\records\Timetable;
 
 class StartShiftStepOneAction extends Action
 {
@@ -51,7 +52,15 @@ class StartShiftStepOneAction extends Action
         if ($modelTypeId == AdminCheckin::TYPE_END) {
             $adminStores = CityStore::getNames([$lastCheckin->store_id]);
             $lastCheckinFact = TimetableFactModel::findOne(['checkin_start_id' => $lastCheckin->id]);
-            $shiftArray = $lastCheckinFact ? ['id' => $lastCheckinFact->shift_id, 'name' => $lastCheckinFact->shift->name] : [];
+            if(!empty($lastCheckinFact)) {
+                $shiftArray = array('id' => $lastCheckinFact->shift_id, 'name' => $lastCheckinFact->shift->name);
+            } else {
+                $plan = Timetable::find()
+                    ->andWhere(['store_id' => $lastCheckin->store_id])
+                    ->andWhere(['date' => $lastCheckin->date])
+                    ->one();
+                $shiftArray = array('id' => $plan->shift->id, 'name' => $plan->shift->name);
+            }
         } else {
             $adminStores = ArrayHelper::map($userModel->getStores(), 'id', 'name');
             $shiftArray = ArrayHelper::map(Shift::find()->andWhere(['not in', 'id', [3, 4, 6, 7]])->all(), 'id', 'name');