From 61920135e65fc902d7986e8c2f32f46684e6a4c2 Mon Sep 17 00:00:00 2001 From: marina Date: Thu, 18 Jul 2024 15:18:26 +0300 Subject: [PATCH] =?utf8?q?=D0=98=D0=B7=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?utf8?q?=D0=B8=D0=B5=20=D0=BE=D1=82=20=D0=BE=D1=82=D0=BC=D0=B5=D1=82?= =?utf8?q?=D0=BE=D0=BA=20=D0=B4=D0=BB=D1=8F=20=D0=B0=D0=B4=D0=BC=D0=B8?= =?utf8?q?=D0=BD=D0=BE=D0=B2=20=D0=B8=20=D0=BF=D0=B5=D1=80=D0=B5=D1=85?= =?utf8?q?=D0=BE=D0=B4=20=D0=BE=D0=BE=D1=82=20=D1=87=D0=B5=D0=BA=D0=B8?= =?utf8?q?=D0=BD=D0=BE=D0=B2=20=D0=BA=20=D1=84=D0=B0=D0=BA=D1=82=D1=83=20?= =?utf8?q?=D0=BD=D0=B0=20=D0=BF=D0=B5=D1=80=D0=B2=D0=BE=D0=BC=20=D1=88?= =?utf8?q?=D0=B0=D0=B3=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../timetable/StartShiftStepOneAction.php | 36 +++------- .../views/timetable/start_shift_step_one.php | 65 +++++++++---------- 2 files changed, 42 insertions(+), 59 deletions(-) diff --git a/erp24/actions/timetable/StartShiftStepOneAction.php b/erp24/actions/timetable/StartShiftStepOneAction.php index f7f6ba94..65322668 100755 --- a/erp24/actions/timetable/StartShiftStepOneAction.php +++ b/erp24/actions/timetable/StartShiftStepOneAction.php @@ -30,37 +30,21 @@ class StartShiftStepOneAction extends Action return $this->controller->redirect('/'); } - /** @var AdminCheckin[] $dayCheckins */ - $dayCheckins = AdminCheckin::find() + $fact = TimetableFactModel::getOpening($userModel->id, date('Y-m-d')); + $plan = Timetable::find() ->andWhere(['admin_id' => $userModel->id]) - ->andWhere(['>', 'time', date('Y-m-d H:i:s', strtotime('-1 day'))]) - ->orderBy(['time' => SORT_ASC]) - ->all(); - $lastCheckin = end($dayCheckins); + ->andWhere(['date' => date('Y-m-d')]) + ->andWhere(['tabel' => 0]) + ->one(); - $modelTypeId = (function () use ($userModel, $lastCheckin) { - if ($userModel->adminGroup->isRoaming()) { - return AdminCheckin::TYPE_APPEAR; - } - if ($lastCheckin && $lastCheckin->isStart()) { + $modelTypeId = (function () use ($fact, $userModel) { + if ($fact) { return AdminCheckin::TYPE_END; } return AdminCheckin::TYPE_START; })(); - if ($modelTypeId == AdminCheckin::TYPE_END) { - $adminStores = CityStore::getNames([$lastCheckin->store_id]); - $lastCheckinFact = TimetableFactModel::findOne(['checkin_start_id' => $lastCheckin->id]); - 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 { + if ($modelTypeId == AdminCheckin::TYPE_START) { $adminStores = ArrayHelper::map($userModel->getStores(), 'id', 'name'); $shiftArray = ArrayHelper::map(Shift::find()->andWhere(['not in', 'id', [3, 4, 6, 7]])->all(), 'id', 'name'); } @@ -70,8 +54,8 @@ class StartShiftStepOneAction extends Action 'userModel' => $userModel, 'adminStores' => $adminStores, 'device' => $device, - 'dayCheckins' => $dayCheckins, - 'lastCheckin' => $lastCheckin, + 'fact' => $fact, + 'plan' => $plan, 'shiftArray' => $shiftArray, ]); } diff --git a/erp24/views/timetable/start_shift_step_one.php b/erp24/views/timetable/start_shift_step_one.php index ad702cfd..284ec28d 100644 --- a/erp24/views/timetable/start_shift_step_one.php +++ b/erp24/views/timetable/start_shift_step_one.php @@ -4,11 +4,10 @@ * @var \yii_app\records\Admin $userModel * @var StartForm $model * @var \yii_app\records\AdminDesktop $device - * @var AdminCheckin[] $dayCheckins - * @var AdminCheckin $lastCheckin * @var TimetablePlan[] $planSlots * @var array $adminStores * @var array $shiftArray + * @var \yii_app\records\TimetableFactModel $fact */ use yii\helpers\ArrayHelper; @@ -24,16 +23,11 @@ use yii_app\forms\timetable\StartForm; // $this->registerJsFile('/js/timetable/script.js', ['position' => \yii\web\View::POS_END]); $textButton = ''; - if ($userModel->adminGroup->isRoaming()) { - $textButton = 'Отметится'; + + if ($fact) { + $textButton = 'Закрытие смены'; } else { - if (!empty($lastCheckin)) { - if (!empty($lastCheckin->type_id)) { - $textButton = ($lastCheckin->isStart()) ? 'Закрытие смены' : 'Открытие смены'; - } - } else { - $textButton = 'Открытие смены'; - } + $textButton = 'Открытие смены'; } ?> @@ -63,7 +57,7 @@ use yii_app\forms\timetable\StartForm; >
type_id) || $lastCheckin->isEnd()) { + if (empty($fact) && empty($plan)) { echo 'Выберите магазин'; } ?>
@@ -78,7 +72,7 @@ use yii_app\forms\timetable\StartForm;
type_id) || $lastCheckin->isEnd()) { + if (empty($fact) && empty($plan)) { echo 'Выберите нужный магазин и откройте свою смену'; } ?> @@ -98,20 +92,22 @@ use yii_app\forms\timetable\StartForm; type_id) || $lastCheckin->isEnd() || $userModel->adminGroup->isRoaming()) { - echo Html::dropDownList( - 'store_id', - null, - $adminStores, - [ - 'class' => "form-select", - 'aria-label' => "Пример выбора по умолчанию", - ] - ); + if (empty($fact)) { + if (empty($plan)) { + echo Html::dropDownList( + 'store_id', + null, + $adminStores, + [ + 'class' => "form-select", + 'aria-label' => "Пример выбора по умолчанию", + ] + ); + } else { + echo '
' . $plan->store->name . '
'; + } } else { - echo $adminStores[array_key_first($adminStores)]; - - echo Html::hiddenInput('store_id', array_key_first($adminStores)); + echo '
' . $fact->store->name . '
'; } ?> @@ -120,14 +116,17 @@ use yii_app\forms\timetable\StartForm;
Тип смены
type_id) || $lastCheckin->isEnd() || $userModel->adminGroup->isRoaming()) { - echo Html::dropDownList('shift_id', null, $shiftArray, [ - 'class' => "form-select", - 'aria-label' => "Пример выбора по умолчанию", - ]); + if (empty($fact)) { + if (empty($plan)) { + echo Html::dropDownList('shift_id', null, $shiftArray, [ + 'class' => "form-select", + 'aria-label' => "Пример выбора по умолчанию", + ]); + } else { + echo '
' . $plan->shift->name . '
'; + } } else { - echo $shiftArray['name']; - echo Html::hiddenInput('shift_id', $shiftArray['id']); + echo '
' . $fact->shift->name . '
'; } ?> -- 2.39.5