From 1d0b53c23f6f5a70b37865d83af995dfe39e2f87 Mon Sep 17 00:00:00 2001 From: Marina Zozirova Date: Fri, 14 Jun 2024 05:25:46 +0000 Subject: [PATCH] Fix erp 5 --- erp24/actions/timetable/StartShiftStepOneAction.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/erp24/actions/timetable/StartShiftStepOneAction.php b/erp24/actions/timetable/StartShiftStepOneAction.php index 716aff22..3dbf471b 100755 --- a/erp24/actions/timetable/StartShiftStepOneAction.php +++ b/erp24/actions/timetable/StartShiftStepOneAction.php @@ -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'); -- 2.39.5