From a8d01a3a61c8f9c363a78f104fdd29e2e5162a76 Mon Sep 17 00:00:00 2001 From: marina Date: Tue, 16 Jul 2024 11:29:18 +0300 Subject: [PATCH] =?utf8?q?ERP-112=20=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5?= =?utf8?q?=D0=BD=D0=B8=D1=8F=20=D0=B2=20=D1=81=D0=BA=D1=80=D0=B8=D0=BF?= =?utf8?q?=D1=82=D0=B5=20=D0=BE=D0=B1=D1=8A=D0=B5=D0=B4=D0=B8=D0=BD=D0=B5?= =?utf8?q?=D0=BD=D0=B8=D1=8F=20=D1=84=D0=B0=D0=BA=D1=82=D0=BE=D0=B2=20?= =?utf8?q?=D1=81=D0=BC=D0=B5=D0=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/controllers/TimetableFactController.php | 32 +++++++++++++++++++ erp24/views/timetable-fact/merge-shifts.php | 2 ++ 2 files changed, 34 insertions(+) diff --git a/erp24/controllers/TimetableFactController.php b/erp24/controllers/TimetableFactController.php index c05bc0cc..89f6c0a0 100644 --- a/erp24/controllers/TimetableFactController.php +++ b/erp24/controllers/TimetableFactController.php @@ -317,6 +317,38 @@ class TimetableFactController extends Controller $end = end($facts); + if ($start->id > $end->id) { + $temp = $start; + $start = $end; + $end = $temp; + } + + $start->setAttribute('date_end', $end->date_start); + $start->setAttribute('time_end', $end->time_start); + $start->setAttribute('checkin_end_id', $end->checkin_start_id); + $start->setAttribute('work_time', min(abs(strtotime($end->date_start . $end->time_start) + 600 - strtotime($start->date_start . $start->time_start)) / 3600, TimetableFactModel::WORK_HOURS_TIME)); + $start->setAttribute('autoclosed', 0); + $start->save(); + $end->delete(); + } + } + } else if ($action == 'withoutPlan') { + $facts = TimetableFactModel::find() + ->andWhere(['is_opening' => false]) + ->andWhere(['checkin_end_id' => null]) + ->all(); + + foreach ($facts as $fact) { + $start = $fact; + $end = TimetableFactModel::find() + ->andWhere(['admin_id' => $fact->admin_id]) + ->andWhere(['store_id' => $fact->store_id]) + ->andWhere(['!=', 'id', $fact->id]) + ->andWhere(['date_shift' => $fact->date_shift]) + ->andWhere(['shift_id' => $fact->shift_id]) + ->one(); + + if ($end && $start) { if ($start->id > $end->id) { $temp = $start; $start = $end; diff --git a/erp24/views/timetable-fact/merge-shifts.php b/erp24/views/timetable-fact/merge-shifts.php index 3d74e412..637dba1c 100644 --- a/erp24/views/timetable-fact/merge-shifts.php +++ b/erp24/views/timetable-fact/merge-shifts.php @@ -36,6 +36,8 @@ use \yii\widgets\ActiveForm; 'btn btn-warning btn-lg', 'name' => 'action', 'value' => 'applyPlus']) ?> + 'btn btn-warning btn-lg', 'name' => 'action', 'value' => 'withoutPlan']) ?> +
-- 
2.39.5