Перенести в новый фактический табель все смены сотрудников, которые были до 13.06
$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()
$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();
}
}
}
const TIMESLOT_WEEKEND = 6;
const TIMESLOT_FREELANCE = 7;
+ public $is_exist;
+
public static function instantiate($row): self
{
if ($row['tabel'] == self::TABLE_PLAN) {
['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 ? 'Да' : 'Нет';
+ }
+ ]
)
?>