]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-65
authormarina <m.zozirova@gmail.com>
Fri, 5 Jul 2024 02:29:04 +0000 (05:29 +0300)
committermarina <m.zozirova@gmail.com>
Fri, 5 Jul 2024 02:29:04 +0000 (05:29 +0300)
Перенести в новый фактический табель все смены сотрудников, которые были до 13.06

erp24/controllers/TimetableFactController.php
erp24/records/Timetable.php
erp24/views/timetable-fact/add-old-shifts.php

index 38d8595fdf534e81b1f8a42181b8fa3bc761f346..ae3366b8742d1bfeb776bd312153f2d601e8096e 100644 (file)
@@ -156,20 +156,15 @@ class TimetableFactController extends Controller
         $query = Timetable::find()
             ->alias('t')
             ->leftJoin('timetable_fact tf', 'tf.plan_id = t.plan_id')
-            ->andWhere(['>=', 'date', '2024-06-01'])
-            ->andWhere(['<', 'date', date('Y-m-d')])
-            ->andWhere(['is not', 't.plan_id', null])
+            ->andWhere(['>=', 't.date', '2024-06-01'])
+            ->andWhere(['<', 't.date', date('Y-m-d')])
             ->select([
                 't.*',
-                new \yii\db\Expression('CASE WHEN tf.plan_id IS NOT NULL THEN true ELSE false END AS is_exist')
+                new \yii\db\Expression('(SELECT ARRAY(SELECT ac.id FROM admin_checkin ac WHERE ac.plan_id = t.id)) AS admin_checkin_ids'),
             ]);
 
         if ($action == 'applyPlus') {
-            $timetables = Timetable::find()
-                ->andWhere(['>=', 'date', '2024-06-01'])
-                ->andWhere(['<', 'date', date('Y-m-d')])
-                ->andWhere(['is not', 'plan_id', null])
-                ->all();
+            $timetables = $query->all();
 
             foreach ($timetables as $timetable) {
                 $newFact = TimetableFactModel::find()
@@ -184,12 +179,12 @@ class TimetableFactController extends Controller
                     $newFact->save();
                 } else {
                     $adminCheckinStart = AdminCheckin::find()
-                        ->where(['plan_id' => $timetable->plan_id])
+                        ->where(['plan_id' => $timetable->id])
                         ->orderBy('id asc')
                         ->one();
 
                     $adminCheckinEnd = AdminCheckin::find()
-                        ->where(['plan_id' => $timetable->plan_id])
+                        ->where(['plan_id' => $timetable->id])
                         ->orderBy('id desc')
                         ->one();
 
index fda09a223af9e2f257165ab964bf3817ced448db..7cdc852102b54d4d2431a8ca23130049bb2696d2 100755 (executable)
@@ -53,8 +53,6 @@ class Timetable extends ActiveRecord
     const TIMESLOT_WEEKEND = 6;
     const TIMESLOT_FREELANCE = 7;
 
-    public $is_exist;
-
     public static function instantiate($row): self
     {
         if ($row['tabel'] == self::TABLE_PLAN) {
index 4da0df115dda56539f79a067c641cb88d126061a..e5e3f844b5eb83e78a3c7e8284b11ff113ceb3ec 100644 (file)
@@ -25,19 +25,13 @@ use \yii\widgets\ActiveForm;
     ],
     'datetime_start:datetime',
     'datetime_end:datetime',
-    [
-        'label' => 'Есть ли в новом факте?',
-        'attribute' => 'isNewRecord',
-        'value' => function ($data) {
-            return $data->is_exist ? 'Да' : 'Нет';
-        }
-    ]
 )
 ?>
 
 
 <div class="bonusAdd m-5">
 
+    <?= Html::label('Данные для сверки. Все !рабочие! смены с 1.06.2024 по текущую дату, без фильтрации'); ?>
     <?php ActiveForm::begin() ?>
 
     <?= Html::submitButton('Перенести', ['class' => 'btn btn-warning btn-lg', 'name' => 'action', 'value' => 'applyPlus']) ?>