From 69cf9f20f779b02736ccfde439b29b8889f81a2b Mon Sep 17 00:00:00 2001 From: Marina Zozirova Date: Wed, 17 Jul 2024 13:29:23 +0000 Subject: [PATCH] =?utf8?q?=D0=9F=D1=80=D0=B0=D0=B2=D0=BA=D0=B0=20=D1=82?= =?utf8?q?=D0=BE=D0=B3=D0=BE=20=D1=87=D1=82=D0=BE=20=D0=BD=D0=B5=20=D1=83?= =?utf8?q?=20=D0=B2=D1=81=D0=B5=D1=85=20=D0=BD=D0=BE=D1=80=D0=BC=D0=B0?= =?utf8?q?=D0=BB=D1=8C=D0=BD=D0=BE=20=D0=BE=D1=82=D0=BA=D1=80=D1=8B=D0=B2?= =?utf8?q?=D0=B0=D0=BB=D0=B8=D1=81=D1=8C=20=D1=81=D0=BC=D0=B5=D0=BD=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../timetable/StartShiftStepTwoAction.php | 2 +- erp24/commands/TimetableController.php | 3 ++- erp24/records/TimetableFactModel.php | 25 +++++++++++++++---- 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/erp24/actions/timetable/StartShiftStepTwoAction.php b/erp24/actions/timetable/StartShiftStepTwoAction.php index 161b9195..ef031243 100755 --- a/erp24/actions/timetable/StartShiftStepTwoAction.php +++ b/erp24/actions/timetable/StartShiftStepTwoAction.php @@ -135,7 +135,7 @@ class StartShiftStepTwoAction extends Action $is_start = ($model->d_id == AdminGroup::GROUP_ADMINISTRATORS) ? (count($dayCheckins) % 2 == 0 ? true : false) : - ($model->status == AdminCheckin::TYPE_START ? true : false); + ($model->checkinModel->type_id == AdminCheckin::TYPE_START ? true : false); TimetableFactModel::setValues($model, $is_start); diff --git a/erp24/commands/TimetableController.php b/erp24/commands/TimetableController.php index ed2f7fb6..e3ce4e3b 100644 --- a/erp24/commands/TimetableController.php +++ b/erp24/commands/TimetableController.php @@ -14,7 +14,8 @@ class TimetableController extends Controller $timetableFactModels = TimetableFactModel::find() ->with(['checkinStart']) ->andWhere(['!=', 'is_close', true]) - ->andWhere(['<=', new Expression('CONCAT(date_start, \' \', time_start)'), date('Y-m-d H:i:s', strtotime('-14 hours', time()))])->all(); + ->andWhere(['<=', new Expression('CONCAT(date_start, \' \', time_start)'), date('Y-m-d H:i:s', strtotime('-14 hours', time()))]) + ->all(); foreach ($timetableFactModels as $timetableFactModel) { /** @var $timetableFactModel TimetableFactModel */ diff --git a/erp24/records/TimetableFactModel.php b/erp24/records/TimetableFactModel.php index 734563ad..5183cd10 100644 --- a/erp24/records/TimetableFactModel.php +++ b/erp24/records/TimetableFactModel.php @@ -105,16 +105,17 @@ class TimetableFactModel extends ActiveRecord //is_start моя пометка для выравнивания открытия/закрытия натыканных флористами смен /** + * @param $adminCheckin + * @param $is_start + * @return void * @throws \Exception */ public static function setValues($adminCheckin, $is_start = true) { - if ($model = self::find() - ->where(['admin_id' => $adminCheckin->admin_id, 'is_opening' => true]) - ->andWhere(['between', 'date_shift', date('Y-m-d', strtotime($adminCheckin->date . ' -1 day')), date('Y-m-d', strtotime($adminCheckin->date))]) - ->andWhere(['status' => array(AdminCheckin::TYPE_START, AdminCheckin::TYPE_APPEAR)]) - ->one()) { + $model = self::getOpening($adminCheckin->admin_id, $adminCheckin->date); + /** @var $model TimetableFactModel */ + if ($model) { $model->date_end = date("Y-m-d", strtotime($adminCheckin->time)); $model->time_end = date("H:i:s", strtotime($adminCheckin->time)); $model->work_time = min(abs(strtotime($model->date_end . $model->time_end) + 600 - strtotime($model->date_start . $model->time_start)) / 3600, self::WORK_HOURS_TIME); @@ -168,6 +169,20 @@ class TimetableFactModel extends ActiveRecord } } + /** + * Проверка на то есть ли открытый факт + * @param int $adminId + * @param $date + * @return array|ActiveRecord|null + */ + public static function getOpening(int $adminId, $date) { + return self::find() + ->where(['admin_id' => $adminId, 'is_opening' => true]) + ->andWhere(['date_shift' => $date]) +// ->andWhere(['status' => array(AdminCheckin::TYPE_START, AdminCheckin::TYPE_APPEAR)]) + ->orderBy('id desc') + ->one(); + } public function getAdmin() { -- 2.39.5