]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
добавление can_open Timetable.php
authormarina <m.zozirova@gmail.com>
Thu, 19 Sep 2024 08:08:44 +0000 (11:08 +0300)
committermarina <m.zozirova@gmail.com>
Thu, 19 Sep 2024 08:08:44 +0000 (11:08 +0300)
erp24/api3/modules/v1/models/timetable/Timetable.php
erp24/records/TimetableFactModel.php

index c9681b24954a987f33be13436d8b7889aa3224d7..5515766995ecb24f4a15b7547d332b6810e213eb 100644 (file)
@@ -10,6 +10,8 @@ use yii_app\records\AdminGroup;
 use yii_app\records\CityStore;
 use yii_app\records\GradePrice;
 use yii_app\records\Shift;
+use yii_app\records\TimetableFact;
+use yii_app\records\TimetableFactModel;
 
 class Timetable extends \yii_app\records\TimetableV3
 {
@@ -151,7 +153,10 @@ class Timetable extends \yii_app\records\TimetableV3
             'time_end',
             'work_time',
             'status',
-            'checkInCount'
+            'checkInCount',
+            'can_open' => fn($x) => !TimetableFactModel::find()
+                ->andWhere(['is_close' => false])
+                ->andWhere(['plan_id' => $x->id])->exists() && ($x->date >= date('Y-m-d'))
         ];
 
         return $fields;
@@ -174,7 +179,7 @@ class Timetable extends \yii_app\records\TimetableV3
                 'name' => $x->store->name,
                 'name_full' => $x->store->name_full,
             ],
-            'checkIns'
+            'checkIns',
         ];
     }
 
index f81580682c449afa6d709ce7d0a1c8aa82faf628..33af9f50dea488373859f3a53eab7bab19718d7c 100644 (file)
@@ -246,12 +246,11 @@ class TimetableFactModel extends ActiveRecord
 
     public function getCheckInCount()
     {
-        return $this->is_close ? 0 : 1;
-//        return $this->hasMany(AdminCheckin::class, ['admin_id' => 'admin_id'])
-//            ->andWhere(['BETWEEN', 'time',
-//                date('Y-m-d H:i:s', strtotime($this->date_start . ' ' . $this->time_start)),
-//                date('Y-m-d H:i:s', strtotime($this->date_end . ' ' . $this->time_end))])
-//            ->count();
+        return $this->hasMany(AdminCheckin::class, ['admin_id' => 'admin_id'])
+            ->andWhere(['BETWEEN', 'time',
+                date('Y-m-d H:i:s', strtotime($this->date_start . ' ' . $this->time_start)),
+                date('Y-m-d H:i:s', strtotime($this->date_end . ' ' . $this->time_end))])
+            ->count();
     }
 
     public function getAdmin()