From bdbe15262e10a566a1c2e10a958b6df30a3ab5de Mon Sep 17 00:00:00 2001 From: marina Date: Fri, 5 Jul 2024 05:29:04 +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 | 17 ++++++----------- erp24/records/Timetable.php | 2 -- erp24/views/timetable-fact/add-old-shifts.php | 8 +------- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/erp24/controllers/TimetableFactController.php b/erp24/controllers/TimetableFactController.php index 38d8595f..ae3366b8 100644 --- a/erp24/controllers/TimetableFactController.php +++ b/erp24/controllers/TimetableFactController.php @@ -156,20 +156,15 @@ class TimetableFactController extends Controller $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', 't.plan_id', null]) + ->andWhere(['>=', 't.date', '2024-06-01']) + ->andWhere(['<', 't.date', date('Y-m-d')]) ->select([ 't.*', - new \yii\db\Expression('CASE WHEN tf.plan_id IS NOT NULL THEN true ELSE false END AS is_exist') + new \yii\db\Expression('(SELECT ARRAY(SELECT ac.id FROM admin_checkin ac WHERE ac.plan_id = t.id)) AS admin_checkin_ids'), ]); if ($action == 'applyPlus') { - $timetables = Timetable::find() - ->andWhere(['>=', 'date', '2024-06-01']) - ->andWhere(['<', 'date', date('Y-m-d')]) - ->andWhere(['is not', 'plan_id', null]) - ->all(); + $timetables = $query->all(); foreach ($timetables as $timetable) { $newFact = TimetableFactModel::find() @@ -184,12 +179,12 @@ class TimetableFactController extends Controller $newFact->save(); } else { $adminCheckinStart = AdminCheckin::find() - ->where(['plan_id' => $timetable->plan_id]) + ->where(['plan_id' => $timetable->id]) ->orderBy('id asc') ->one(); $adminCheckinEnd = AdminCheckin::find() - ->where(['plan_id' => $timetable->plan_id]) + ->where(['plan_id' => $timetable->id]) ->orderBy('id desc') ->one(); diff --git a/erp24/records/Timetable.php b/erp24/records/Timetable.php index fda09a22..7cdc8521 100755 --- a/erp24/records/Timetable.php +++ b/erp24/records/Timetable.php @@ -53,8 +53,6 @@ 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 4da0df11..e5e3f844 100644 --- a/erp24/views/timetable-fact/add-old-shifts.php +++ b/erp24/views/timetable-fact/add-old-shifts.php @@ -25,19 +25,13 @@ use \yii\widgets\ActiveForm; ], 'datetime_start:datetime', 'datetime_end:datetime', - [ - 'label' => 'Есть ли в новом факте?', - 'attribute' => 'isNewRecord', - 'value' => function ($data) { - return $data->is_exist ? 'Да' : 'Нет'; - } - ] ) ?>
+ 'btn btn-warning btn-lg', 'name' => 'action', 'value' => 'applyPlus']) ?> -- 2.39.5