From: marina Date: Tue, 23 Jul 2024 09:15:12 +0000 (+0300) Subject: ERP-122 Поправить открытие/закрытие смен на Южном бульваре X-Git-Tag: 1.4~62^2 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=bd1a777b412157ef7e5b63e4aa60e2638c78bccb;p=erp24_rep%2Fyii-erp24%2F.git ERP-122 Поправить открытие/закрытие смен на Южном бульваре --- diff --git a/erp24/actions/timetable/StartShiftStepTwoAction.php b/erp24/actions/timetable/StartShiftStepTwoAction.php index 7d998e84..b75180bf 100755 --- a/erp24/actions/timetable/StartShiftStepTwoAction.php +++ b/erp24/actions/timetable/StartShiftStepTwoAction.php @@ -82,20 +82,6 @@ class StartShiftStepTwoAction extends Action return AdminCheckin::TYPE_START; })(); - /** @var TimetablePlan[] $planSlots */ - $planSlots = TimetablePlan::find() - ->andWhere( - ($device->isFixedStore() && !$userModel->adminGroup->isRoaming()) ? - ['store_id' => $model->store_id] : - ['admin_id' => $model->admin_id] - ) - ->andWhere(['OR', - ['BETWEEN', 'datetime_start', date('Y-m-d H:i:s'), date('Y-m-d H:i:s', strtotime('+6 hour'))], - ['BETWEEN', 'datetime_end', date('Y-m-d H:i:s', strtotime('-6 hour')), date('Y-m-d H:i:s')], - ['AND', ['<', 'datetime_start', date('Y-m-d H:i:s')], ['>', 'datetime_end', date('Y-m-d H:i:s')]] - ]) - ->all(); - $model->shift_id = $request->getBodyParam('shift_id'); $model->store_id = $request->getBodyParam('store_id'); @@ -110,6 +96,18 @@ class StartShiftStepTwoAction extends Action $model->store_id = $fact->store_id; } + /** @var TimetablePlan[] $planSlots */ + $planSlots = TimetablePlan::find() + ->andWhere(['store_id' => $model->store_id]) + ->andWhere(['admin_id' => $model->admin_id]) + ->andWhere(['OR', + ['BETWEEN', 'datetime_start', date('Y-m-d H:i:s'), date('Y-m-d H:i:s', strtotime('+6 hour'))], + ['BETWEEN', 'datetime_end', date('Y-m-d H:i:s', strtotime('-6 hour')), date('Y-m-d H:i:s')], + ['AND', ['<', 'datetime_start', date('Y-m-d H:i:s')], ['>', 'datetime_end', date('Y-m-d H:i:s')]] + ]) + ->all(); + + if ($fact) { $model->plan_id = $fact->plan_id; $model->replaced_admin_id = $fact->admin_id_add; diff --git a/erp24/api3/modules/v1/controllers/timetable/FactController.php b/erp24/api3/modules/v1/controllers/timetable/FactController.php index bdbf881e..6585682a 100644 --- a/erp24/api3/modules/v1/controllers/timetable/FactController.php +++ b/erp24/api3/modules/v1/controllers/timetable/FactController.php @@ -8,8 +8,6 @@ use yii_app\api3\core\services\TimetableService; use yii_app\api3\core\traits\ServiceTrait; use yii_app\api3\modules\v1\requests\timetable\Fact; -///test -/// test /** * @property TimetableService $timetableService */ diff --git a/erp24/forms/timetable/StartForm.php b/erp24/forms/timetable/StartForm.php index 501aac7e..fb9be7a2 100755 --- a/erp24/forms/timetable/StartForm.php +++ b/erp24/forms/timetable/StartForm.php @@ -173,7 +173,7 @@ class StartForm extends Model if ($this->date != $plan->date) { $this->addError('date', 'Дата открытия не совпадает с планом'); } - $targetAdminId = $this->replaced_admin_id ?: $this->admin_id; + $targetAdminId = $this->admin_id ?: $this->replaced_admin_id; if ($targetAdminId != $plan->admin_id) { $this->addError($this->replaced_admin_id ? 'replaced_admin_id' : 'admin_id', 'Выбран неправильный пользователь в плане'); }