From 9783be161d58f179a651638a63d04ecedfd21db5 Mon Sep 17 00:00:00 2001 From: Vladimir Fomichev Date: Thu, 7 Aug 2025 14:03:49 +0300 Subject: [PATCH] =?utf8?q?=D0=A4=D0=B8=D0=BB=D1=8C=D1=82=D1=80=20=D0=BD?= =?utf8?q?=D0=B5=D0=B0=D0=BA=D1=82=D0=B8=D0=B2=D0=BD=D1=8B=D1=85=20=D0=B7?= =?utf8?q?=D0=B0=D0=BF=D0=B8=D1=81=D0=B5=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- ...ducts1cNomenclatureActualityController.php | 2 +- .../index.php | 32 +++++++++++++------ .../products1cNomenclatureActuality/index.js | 28 ++++++++++++++++ 3 files changed, 52 insertions(+), 10 deletions(-) diff --git a/erp24/controllers/Products1cNomenclatureActualityController.php b/erp24/controllers/Products1cNomenclatureActualityController.php index fd600e7c..c4b330b2 100644 --- a/erp24/controllers/Products1cNomenclatureActualityController.php +++ b/erp24/controllers/Products1cNomenclatureActualityController.php @@ -157,7 +157,7 @@ class Products1cNomenclatureActualityController extends Controller } } } - + $dataProvider = new \yii\data\ActiveDataProvider([ 'query' => $query, diff --git a/erp24/views/products1c-nomenclature-actuality/index.php b/erp24/views/products1c-nomenclature-actuality/index.php index 8491d178..02296dd2 100644 --- a/erp24/views/products1c-nomenclature-actuality/index.php +++ b/erp24/views/products1c-nomenclature-actuality/index.php @@ -4,6 +4,7 @@ use kartik\form\ActiveForm; use kartik\grid\GridView; use yii\helpers\Html; use yii\web\View; +use yii_app\records\Products1cNomenclatureActuality; /* @var $this yii\web\View */ @@ -183,11 +184,14 @@ $months = monthList(); 'label' => 'Только активные', 'uncheck' => 0, 'checked' => (bool)$filter->onlyActive, + 'id' => 'onlyActiveCheckbox' ])->label(false) ?> + field($filter, 'onlyInactive')->checkbox([ 'label' => 'Только неактивные', 'uncheck' => 0, 'checked' => (bool)$filter->onlyInactive, + 'id' => 'onlyInactiveCheckbox' ])->label(false) ?> @@ -240,13 +244,15 @@ $months = monthList(); 'floatHeader' => false, 'tableOptions' => ['class' => 'table table-bordered'], 'containerOptions' => ['style' => 'overflow:auto; max-height:500px;'], - 'rowOptions' => function($model) { - if ($model->hasActiveActuality()) { + 'rowOptions' => function($model) use ($filter) { + if ($filter->onlyInactive) { + if ($model->hasInactiveActuality()) { + return ['class' => 'table-danger']; + } + } elseif ($model->hasActiveActuality()) { return ['class' => 'table-success']; } - if ($model->hasInactiveActuality()) { - return ['class' => 'table-danger']; - } + return []; }, 'columns' => [ [ @@ -262,10 +268,18 @@ $months = monthList(); 'label' => 'Актуальность ассортимента', 'format' => 'raw', 'contentOptions' => ['style'=>'white-space:nowrap; min-width:200px;'], - 'value' => function ($m, $k, $i) use ($months) { - $active = $m->getActiveActuality()->one(); - $from = $active ? (new \DateTime($active->date_from))->format('Y-m') : null; - $to = $active ? (new \DateTime($active->date_to))->format('Y-m') : null; + 'value' => function ($m, $k, $i) use ($months, $filter) { + if ($filter->onlyInactive) { + $actuality = Products1cNomenclatureActuality::find() + ->where(['guid' => $m->id, 'active' => 0]) + ->one(); + $from = $actuality ? (new \DateTime($actuality->date_from))->format('Y-m') : null; + $to = $actuality ? (new \DateTime($actuality->date_to))->format('Y-m') : null; + } else { + $active = $m->getActiveActuality()->one(); + $from = $active ? (new \DateTime($active->date_from))->format('Y-m') : null; + $to = $active ? (new \DateTime($active->date_to))->format('Y-m') : null; + } return Html::hiddenInput("actuality[$i][guid]", $m->id) . Html::tag('div', Html::dropDownList("actuality[$i][from]", $from, $months, [ diff --git a/erp24/web/js/products1cNomenclatureActuality/index.js b/erp24/web/js/products1cNomenclatureActuality/index.js index 4019d4b2..1e4a0436 100644 --- a/erp24/web/js/products1cNomenclatureActuality/index.js +++ b/erp24/web/js/products1cNomenclatureActuality/index.js @@ -30,4 +30,32 @@ $('.clear-btn').on('click', function(){ $('#' + target).val(null).trigger('change'); }); + var $onlyActiveCheckbox = $('#onlyActiveCheckbox'); + var $onlyInactiveCheckbox = $('#onlyInactiveCheckbox'); + + $onlyActiveCheckbox.change(function() { + if ($(this).is(':checked')) { + $onlyInactiveCheckbox.prop('checked', false); + $onlyInactiveCheckbox.prop('disabled', true); + } else { + $onlyInactiveCheckbox.prop('disabled', false); + } + }); + + $onlyInactiveCheckbox.change(function() { + if ($(this).is(':checked')) { + $onlyActiveCheckbox.prop('checked', false); + $onlyActiveCheckbox.prop('disabled', true); + } else { + $onlyActiveCheckbox.prop('disabled', false); + } + }); + + + if ($onlyActiveCheckbox.is(':checked')) { + $onlyInactiveCheckbox.prop('disabled', true); + } else if ($onlyInactiveCheckbox.is(':checked')) { + $onlyActiveCheckbox.prop('disabled', true); + } + }); \ No newline at end of file -- 2.39.5