From: marina Date: Tue, 16 Jul 2024 08:29:18 +0000 (+0300) Subject: ERP-112 Изменения в скрипте объединения фактов смен X-Git-Tag: 1.4~78^2 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=a8d01a3a61c8f9c363a78f104fdd29e2e5162a76;p=erp24_rep%2Fyii-erp24%2F.git ERP-112 Изменения в скрипте объединения фактов смен --- 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']) ?> +