From 043f9b4d01b61edb20e3846262c6e4c9bfe7acc6 Mon Sep 17 00:00:00 2001 From: marina Date: Thu, 19 Sep 2024 11:08:44 +0300 Subject: [PATCH] =?utf8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD?= =?utf8?q?=D0=B8=D0=B5=20can=5Fopen=20Timetable.php?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/api3/modules/v1/models/timetable/Timetable.php | 9 +++++++-- erp24/records/TimetableFactModel.php | 11 +++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/erp24/api3/modules/v1/models/timetable/Timetable.php b/erp24/api3/modules/v1/models/timetable/Timetable.php index c9681b24..55157669 100644 --- a/erp24/api3/modules/v1/models/timetable/Timetable.php +++ b/erp24/api3/modules/v1/models/timetable/Timetable.php @@ -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', ]; } diff --git a/erp24/records/TimetableFactModel.php b/erp24/records/TimetableFactModel.php index f8158068..33af9f50 100644 --- a/erp24/records/TimetableFactModel.php +++ b/erp24/records/TimetableFactModel.php @@ -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() -- 2.39.5