From 1629e782c5c031792fc6b6469171cbeac86f23e8 Mon Sep 17 00:00:00 2001 From: marina Date: Thu, 4 Jul 2024 11:17:16 +0300 Subject: [PATCH] =?utf8?q?ERP-65=20=D0=9F=D0=B5=D1=80=D0=B5=D0=BD=D0=B5?= =?utf8?q?=D1=81=D1=82=D0=B8=20=D0=B2=20=D0=BD=D0=BE=D0=B2=D1=8B=D0=B9=20?= =?utf8?q?=D1=84=D0=B0=D0=BA=D1=82=D0=B8=D1=87=D0=B5=D1=81=D0=BA=D0=B8?= =?utf8?q?=D0=B9=20=D1=82=D0=B0=D0=B1=D0=B5=D0=BB=D1=8C=20=D0=B2=D1=81?= =?utf8?q?=D0=B5=20=D1=81=D0=BC=D0=B5=D0=BD=D1=8B=20=D1=81=D0=BE=D1=82?= =?utf8?q?=D1=80=D1=83=D0=B4=D0=BD=D0=B8=D0=BA=D0=BE=D0=B2,=20=D0=BA=D0=BE?= =?utf8?q?=D1=82=D0=BE=D1=80=D1=8B=D0=B5=20=D0=B1=D1=8B=D0=BB=D0=B8=20?= =?utf8?q?=D0=B4=D0=BE=2013.06?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/controllers/TimetableFactController.php | 10 +++++++--- erp24/records/Timetable.php | 2 ++ erp24/views/timetable-fact/add-old-shifts.php | 17 +++++++++++------ 3 files changed, 20 insertions(+), 9 deletions(-) diff --git a/erp24/controllers/TimetableFactController.php b/erp24/controllers/TimetableFactController.php index 14c40a1c..ef1f830d 100644 --- a/erp24/controllers/TimetableFactController.php +++ b/erp24/controllers/TimetableFactController.php @@ -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(); } } } diff --git a/erp24/records/Timetable.php b/erp24/records/Timetable.php index 764b1195..2548100e 100755 --- a/erp24/records/Timetable.php +++ b/erp24/records/Timetable.php @@ -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) { diff --git a/erp24/views/timetable-fact/add-old-shifts.php b/erp24/views/timetable-fact/add-old-shifts.php index 6f306ceb..4da0df11 100644 --- a/erp24/views/timetable-fact/add-old-shifts.php +++ b/erp24/views/timetable-fact/add-old-shifts.php @@ -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 ? 'Да' : 'Нет'; + } + ] ) ?> -- 2.39.5