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
{
'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;
'name' => $x->store->name,
'name_full' => $x->store->name_full,
],
- 'checkIns'
+ 'checkIns',
];
}
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()