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

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

index 14c40a1c61457c073097e18e72c7b435fbc269ad..ef1f830dc02bac19e0066f0e42b80b8056c97db5 100644 (file)
@@ -153,10 +153,15 @@ class TimetableFactController extends Controller
         $action = \Yii::$app->request->post('action');
 
         $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', 'plan_id', null])
-            ->andWhere(['not in', 'id', (new Query())->select('plan_id')->from('timetable_fact')]);
+            ->andWhere(['is not', 't.plan_id', null])
+            ->select([
+                't.*',
+                new \yii\db\Expression('CASE WHEN tf.plan_id IS NOT NULL THEN true ELSE false END AS is_exist')
+            ]);
 
         if ($action == 'applyPlus') {
             $timetables = Timetable::find()
@@ -221,7 +226,6 @@ class TimetableFactController extends Controller
                     $newCheckin->type_id = $timetable->shift_id == 5 || $timetable->shift_id = 8 ? AdminCheckin::TYPE_APPEAR : AdminCheckin::TYPE_END;
                     $newCheckin->validate();
                     TimetableFactModel::setValues($newCheckin);
-                var_dump($timetable, $newCheckin);die();
                 }
             }
         }
index 764b119576c7584d480dfb9418fec6f8ecadc13b..2548100ed41c6c5819e0bde27b6c3591058e07a6 100755 (executable)
@@ -52,6 +52,8 @@ 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 6f306cebdd03d19d10151f645786d271b167ea57..4da0df115dda56539f79a067c641cb88d126061a 100644 (file)
@@ -13,20 +13,25 @@ use \yii\widgets\ActiveForm;
     ['class' => 'yii\grid\SerialColumn'],
     [
         'attribute' => 'admin_id',
-        'value' => function($data) {
-        return $data->admin->name;
-}
+        'value' => function ($data) {
+            return $data->admin->name;
+        }
     ],
     [
         'attribute' => 'store_id',
-
-        'value' => function($data) {
+        'value' => function ($data) {
             return $data->store->name;
         }
     ],
     'datetime_start:datetime',
     'datetime_end:datetime',
-//    'attribute' => 'time_start:datetime',
+    [
+        'label' => 'Есть ли в новом факте?',
+        'attribute' => 'isNewRecord',
+        'value' => function ($data) {
+            return $data->is_exist ? 'Да' : 'Нет';
+        }
+    ]
 )
 ?>