]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-112 Изменения в скрипте объединения фактов смен
authormarina <m.zozirova@gmail.com>
Tue, 16 Jul 2024 08:29:18 +0000 (11:29 +0300)
committermarina <m.zozirova@gmail.com>
Tue, 16 Jul 2024 08:29:18 +0000 (11:29 +0300)
erp24/controllers/TimetableFactController.php
erp24/views/timetable-fact/merge-shifts.php

index c05bc0cce5a88aa05a33cc100ec878e607688425..89f6c0a0f6fc282ff413ba744bab28ae4573cf2d 100644 (file)
@@ -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;
index 3d74e41257a5040d6f8ac7ae03c99a4117ff099e..637dba1c47884bade5c7e69f98848a186ce535e1 100644 (file)
@@ -36,6 +36,8 @@ use \yii\widgets\ActiveForm;
     <?php ActiveForm::begin() ?>
 
     <?= Html::submitButton('Объединить', ['class' => 'btn btn-warning btn-lg', 'name' => 'action', 'value' => 'applyPlus']) ?>
+    <?= Html::submitButton('Объединить смены без плана', ['class' => 'btn btn-warning btn-lg', 'name' => 'action', 'value' => 'withoutPlan']) ?>
+
 
     <?php ActiveForm::end() ?>
     <pre>