From: marina Date: Fri, 21 Feb 2025 10:50:52 +0000 (+0300) Subject: ERP-302 Редактирование букета X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=21813068d93b26f3dc3081bd2f348ebca0c2cb80;p=erp24_rep%2Fyii-erp24%2F.git ERP-302 Редактирование букета --- diff --git a/erp24/records/BouquetComposition.php b/erp24/records/BouquetComposition.php index a696f135..f006ed7f 100644 --- a/erp24/records/BouquetComposition.php +++ b/erp24/records/BouquetComposition.php @@ -216,9 +216,11 @@ class BouquetComposition extends ActiveRecord public static function disabledButtons($isCreate = false) { - if (!$isCreate || date('d') > 10) { + if ($isCreate) { return false; } - return true; + + return date('d') > 10; } + } diff --git a/erp24/views/bouquet/_form.php b/erp24/views/bouquet/_form.php index 9bad651c..477cb5d0 100644 --- a/erp24/views/bouquet/_form.php +++ b/erp24/views/bouquet/_form.php @@ -248,7 +248,9 @@ $form = ActiveForm::begin([
- 'btn btn-success w-100', 'disabled' => $disabledButtons]) ?> + 'btn btn-success btn-save w-100', + 'disabled' => BouquetComposition::disabledButtons(!$id)]) ?>
\ No newline at end of file diff --git a/erp24/views/bouquet/_product_edit.php b/erp24/views/bouquet/_product_edit.php index 49332ae0..dbf0f56a 100644 --- a/erp24/views/bouquet/_product_edit.php +++ b/erp24/views/bouquet/_product_edit.php @@ -1,5 +1,7 @@ 'products', @@ -18,9 +20,7 @@ use yii\helpers\Html;
-
-
@@ -37,7 +37,7 @@ use yii\helpers\Html; 'btn btn-warning calculate-btn w-100']) ?>
- 'btn btn-success w-100']) ?> + 'btn btn-success w-100', 'disabled' => BouquetComposition::disabledButtons()]) ?>
diff --git a/erp24/views/bouquet/_product_list.php b/erp24/views/bouquet/_product_list.php index d1b16019..ae20dc36 100644 --- a/erp24/views/bouquet/_product_list.php +++ b/erp24/views/bouquet/_product_list.php @@ -34,6 +34,8 @@
- id"), ['class' => $model && !BouquetComposition::disabledButtons()? 'btn btn-warning w-100' : 'btn btn-warning w-100 disabled']) ?> + $model->id]), [ + 'class' => 'btn btn-warning btn-edit w-100' . ($model && !BouquetComposition::disabledButtons() ? '' : ' disabled') + ]) ?>
\ No newline at end of file diff --git a/erp24/views/bouquet/create.php b/erp24/views/bouquet/create.php index 59997c07..b9f3e0a0 100644 --- a/erp24/views/bouquet/create.php +++ b/erp24/views/bouquet/create.php @@ -32,7 +32,7 @@ $this->registerJsFile('/js/bouquet/bouquet.js', ['position' => \yii\web\View::PO 'processUrls' => [], 'availableItems' => $availableItems, 'model' => null, - 'disabledButtons' => \yii_app\records\BouquetComposition::disabledButtons(true) + 'id' => null ]); ?> diff --git a/erp24/views/bouquet/index.php b/erp24/views/bouquet/index.php index a783c7c0..345b9646 100644 --- a/erp24/views/bouquet/index.php +++ b/erp24/views/bouquet/index.php @@ -11,10 +11,8 @@ use yii_app\records\MatrixType; use yii_app\records\Products1c; /** @var yii\web\View $this */ - $this->title = 'Содержание матрицы'; ?> -

title) ?>

@@ -57,7 +55,7 @@ $this->title = 'Содержание матрицы'; ]) ?>
- 'text-decoration-none', 'target' => '_blank', 'disabled' => BouquetComposition::disabledButtons()]) ?> + 'text-decoration-none', 'target' => '_blank']) ?>
@@ -133,15 +131,15 @@ $this->title = 'Содержание матрицы';
- " . Html::tag('video', '', [ - 'class' => 'video-preview', - 'src' => Url::to($model->presentation->url ?? null), - 'style' => 'width: 100%; height: 100%; object-fit: cover;', - 'autoplay' => true, - 'muted' => true, - 'loop' => true, - 'playsinline' => true - ]) . " + " . Html::tag('video', '', [ + 'class' => 'video-preview', + 'src' => Url::to($model->presentation->url ?? null), + 'style' => 'width: 100%; height: 100%; object-fit: cover;', + 'autoplay' => true, + 'muted' => true, + 'loop' => true, + 'playsinline' => true + ]) . "
Презентация
" . @@ -153,7 +151,7 @@ $this->title = 'Содержание матрицы';
" . - Html::tag('video', '', [ + Html::tag('video', '', [ 'class' => 'video-preview', 'src' => Url::to($model->buildProcess->url ?? null), 'style' => 'width: 100%; height: 100%; object-fit: cover;', @@ -173,9 +171,16 @@ $this->title = 'Содержание матрицы';
- " . Html::a('Редактировать', Url::to(['/bouquet/view', 'id' => $model['id']]), [ - 'class' => 'btn btn-warning' - ]) . " + " . + Html::a('Редактировать', Url::to(['/bouquet/view', 'id' => $model['id']]), [ + 'class' => 'btn btn-warning btn-edit' . + ((Yii::$app->request->get('year') < date('Y') || // Если год в прошлом → disabled + (Yii::$app->request->get('year') == date('Y') && Yii::$app->request->get('month') < date('m')) || + (Yii::$app->request->get('year') == date('Y') && Yii::$app->request->get('month') == date('m') && BouquetComposition::disabledButtons()) || + (Yii::$app->request->get('year') == date('Y') && Yii::$app->request->get('month') == date('m') + 1 &&BouquetComposition::disabledButtons()) + ) ? ' disabled' : ''), + ]) + . "
diff --git a/erp24/views/bouquet/view.php b/erp24/views/bouquet/view.php index 66387c36..d0433cfc 100644 --- a/erp24/views/bouquet/view.php +++ b/erp24/views/bouquet/view.php @@ -29,7 +29,7 @@ $this->registerJsFile('/js/bouquet/bouquet.js', ['position' => \yii\web\View::PO 'photoFiles' => $photoFiles, 'videoUrls' => $videoUrls, 'processUrls' => $processUrls, - 'disabledButtons' => \yii_app\records\BouquetComposition::disabledButtons(), + 'id' => $model->id ]); ?>
diff --git a/erp24/web/js/bouquet/bouquet.js b/erp24/web/js/bouquet/bouquet.js index 67765fb1..bf323e9c 100644 --- a/erp24/web/js/bouquet/bouquet.js +++ b/erp24/web/js/bouquet/bouquet.js @@ -7,14 +7,27 @@ document.addEventListener('DOMContentLoaded', function () { }); }); }); + $(document).ready(function () { if (window.location.pathname.includes('/bouquet/view')) { $('.year-picker, .month-picker').on('change', function () { + let year = $('.year-picker').val(); let month = $('.month-picker').val(); let urlParams = new URLSearchParams(window.location.search); let id = urlParams.get('id'); + + let currentYear = new Date().getFullYear(); + let currentMonth = new Date().getMonth() + 1; + + if (year >= currentYear && month > currentMonth) { + $('.btn-edit').removeClass('disabled') + $('.btn-save').prop('disabled', false); + } else { + $('.btn-edit').addClass('disabled') + $('.btn-save').prop('disabled', true); + } if (!id) { return; } diff --git a/erp24/widgets/DualList.php b/erp24/widgets/DualList.php index 97b915d9..f9fa9350 100644 --- a/erp24/widgets/DualList.php +++ b/erp24/widgets/DualList.php @@ -355,6 +355,12 @@ $('#{$id}-selected-container').on('click', '.selected-item', function() { $(this).addClass('selected'); }); +// Убираем выделение при клике вне элемента +$(document).on('click', function(e) { + if (!$(e.target).closest('.selected-item').length) { + $('#{$id}-selected-container .selected-item').removeClass('selected'); + } +}); // Фильтрация доступных элементов $('#{$id}-filter-available').on('input', function() {