From c5ed58d73f01c38f769b9780f9a42e3795a5a952 Mon Sep 17 00:00:00 2001 From: fomichev Date: Tue, 14 Jan 2025 18:11:19 +0300 Subject: [PATCH] =?utf8?q?=D0=A3=D0=B1=D0=B8=D1=80=D0=B0=D0=B5=D0=BC=20?= =?utf8?q?=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D1=83=20=D1=83=D0=B4=D0=B0=D0=BB?= =?utf8?q?=D0=B8=D1=82=D1=8C=20=D0=B5=D1=81=D0=BB=D0=B8=20=D0=B5=D1=81?= =?utf8?q?=D1=82=D1=8C=20=D1=84=D0=B0=D0=BA=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/records/TimetablePlan.php | 16 +++++++++++++++- erp24/views/timetable/tabel_edit.php | 27 ++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/erp24/records/TimetablePlan.php b/erp24/records/TimetablePlan.php index 5fa6adba..b40c9ca1 100755 --- a/erp24/records/TimetablePlan.php +++ b/erp24/records/TimetablePlan.php @@ -3,6 +3,8 @@ declare(strict_types=1); namespace yii_app\records; +use Yii; + /** * План работы * @property-read TimetableFact $fact @@ -143,4 +145,16 @@ class TimetablePlan extends Timetable } return $this->fact->getDateTimeEnd() < $this->getDateTimeEnd(); } -} \ No newline at end of file + + public function softDelete() + { + $existingFact = TimetableFactModel::findOne(['plan_id' => $this->id]); +//var_dump($existingFact); die(); + if ($existingFact) { + Yii::$app->session->setFlash('error', 'Невозможно удалить запись плановой смены для которой существует факт смены.'); + return false; + } + + return parent::softDelete(); + } +} diff --git a/erp24/views/timetable/tabel_edit.php b/erp24/views/timetable/tabel_edit.php index 527395a7..528908db 100755 --- a/erp24/views/timetable/tabel_edit.php +++ b/erp24/views/timetable/tabel_edit.php @@ -9,9 +9,12 @@ use yii\grid\ActionColumn; use yii\helpers\Html; use yii\helpers\ArrayHelper; +use yii\helpers\Url; use yii_app\records\AdminGroup; use yii_app\records\Timetable; +use yii_app\records\TimetableFactModel; +$this->registerJsFile('/js/timetable/timetable-edit.js', ['position' => \yii\web\View::POS_END]); ?>
@@ -89,9 +92,27 @@ $groupId = (int) $session->get('group_id'); $numDay = Timetable::getCountDaysAllowEditShift($groupId); if (Timetable::getAllowEditShift($slot->date, $numDay)) { ?> - 'btn btn-primary']); ?> + session->hasFlash('error')): ?> +
+ session->getFlash('error') ?> +
+ + 'btn btn-primary']); ?> id) { ?> - id], ['data-role'=>'delete', 'class' => 'btn'])); ?> + andWhere(['plan_id' => $slot->id])->one())) { ?> + id]), + ['data-role'=>'delete','data-confirm' => 'Удалить?', 'class' => 'btn btn-danger'] + ); + ?> + +
+ Невозможно удалить запись плановой смены для которой существует факт смены. +
+ +

@@ -188,4 +209,4 @@ if (Timetable::getAllowEditShift($slot->date, $numDay)) { ]); ?>
- \ No newline at end of file + -- 2.39.5