From 0f4945de804d04e600bcdbda86de3ff16a40a30e Mon Sep 17 00:00:00 2001 From: Vladimir Fomichev Date: Wed, 30 Jul 2025 11:14:42 +0300 Subject: [PATCH] =?utf8?q?=D0=A4=D0=B8=D0=BB=D1=8C=D1=82=D1=80=D0=B0=D1=86?= =?utf8?q?=D0=B8=D1=8F=20=D0=B0=D0=BA=D1=82=D1=83=D0=B0=D0=BB=D1=8C=D0=BD?= =?utf8?q?=D1=8B=D1=85=20=D0=BF=D0=BE=20=D0=B4=D0=B0=D1=82=D0=B0=D0=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- ...ducts1cNomenclatureActualityController.php | 23 ++++++++--- .../index.php | 38 +------------------ .../products1cNomenclatureActuality/index.js | 33 ++++++++++++++++ 3 files changed, 53 insertions(+), 41 deletions(-) create mode 100644 erp24/web/js/products1cNomenclatureActuality/index.js diff --git a/erp24/controllers/Products1cNomenclatureActualityController.php b/erp24/controllers/Products1cNomenclatureActualityController.php index c7a3f3ca..24407d04 100644 --- a/erp24/controllers/Products1cNomenclatureActualityController.php +++ b/erp24/controllers/Products1cNomenclatureActualityController.php @@ -94,22 +94,35 @@ class Products1cNomenclatureActualityController extends Controller if ($filter->date_from || $filter->date_to) { $query->innerJoin( - Products1cNomenclatureActuality::tableName() . ' a', + Products1cNomenclatureActuality::tableName().' a', 'a.guid = n.id AND a.active = 1' ); - if ($filter->date_from) { + + if ($filter->date_from && $filter->date_to) { + $dfObj = \DateTime::createFromFormat('Y-m', $filter->date_from); + $dtObj = \DateTime::createFromFormat('Y-m', $filter->date_to); + $dfObj->setTime(0,0,0); + $dtObj->modify('last day of this month')->setTime(23,59,59); + + $query->andWhere(['<=', 'a.date_from', $dtObj->format('Y-m-d H:i:s')]) + ->andWhere(['>=', 'a.date_end', $dfObj->format('Y-m-d H:i:s')]); + } + + elseif ($filter->date_from) { $df = \DateTime::createFromFormat('Y-m', $filter->date_from) ->format('Y-m-01 00:00:00'); - $query->andWhere(['>=', 'a.date_from', $df]); + $query->andWhere(['>=', 'a.date_end', $df]); } - if ($filter->date_to) { + + elseif ($filter->date_to) { $dt = \DateTime::createFromFormat('Y-m', $filter->date_to); $dt->modify('last day of this month')->setTime(23,59,59); - $query->andWhere(['<=', 'a.date_end', $dt->format('Y-m-d H:i:s')]); + $query->andWhere(['<=', 'a.date_from', $dt->format('Y-m-d H:i:s')]); } } + $attrMap = [ 'type' => ['type','тип'], 'color' => ['цвет','color'], diff --git a/erp24/views/products1c-nomenclature-actuality/index.php b/erp24/views/products1c-nomenclature-actuality/index.php index 8b900703..8774a8f8 100644 --- a/erp24/views/products1c-nomenclature-actuality/index.php +++ b/erp24/views/products1c-nomenclature-actuality/index.php @@ -3,6 +3,7 @@ use kartik\form\ActiveForm; use kartik\grid\GridView; use yii\helpers\Html; +use yii\web\View; /* @var $this yii\web\View */ @@ -18,7 +19,7 @@ use yii\helpers\Html; $this->title = 'Актуализация номенклатуры'; $this->params['breadcrumbs'][] = $this->title; - +$this->registerJsFile('/js/products1cNomenclatureActuality/index.js', ['position' => View::POS_END]); // Список месяцев-годов для выпадающих списков function monthList() { @@ -295,38 +296,3 @@ $months = monthList(); -= from); - }); - if (to.val() < from) { - to.val(from); - } -}); - - $('#filter-date-from').on('change', function(){ - var from = $(this).val(); - var to = $('#filter-date-to'); - to.find('option').each(function(){ - var val = $(this).val(); - if (val === '' || val >= from) { - $(this).show(); - } else { - $(this).hide(); - } - }); - if (to.val() && to.val() < from) { - to.val(from); - } - }); -$('.clear-btn').on('click', function(){ - var target = $(this).data('target'); - $('#' + target).val(null).trigger('change'); -}); -JS; -$this->registerJs($js); -?> diff --git a/erp24/web/js/products1cNomenclatureActuality/index.js b/erp24/web/js/products1cNomenclatureActuality/index.js new file mode 100644 index 00000000..4019d4b2 --- /dev/null +++ b/erp24/web/js/products1cNomenclatureActuality/index.js @@ -0,0 +1,33 @@ +document.addEventListener("DOMContentLoaded", () => { +$('.from-month').on('change', function(){ + var from = $(this).val(), + to = $(this).closest('td').find('.to-month'); + to.find('option').each(function(){ + $(this).toggle($(this).val() >= from); + }); + if (to.val() < from) { + to.val(from); + } +}); + +$('#filter-date-from').on('change', function(){ + var from = $(this).val(); + var to = $('#filter-date-to'); + to.find('option').each(function(){ + var val = $(this).val(); + if (val === '' || val >= from) { + $(this).show(); + } else { + $(this).hide(); + } + }); + if (to.val() && to.val() < from) { + to.val(from); + } +}); +$('.clear-btn').on('click', function(){ + var target = $(this).data('target'); + $('#' + target).val(null).trigger('change'); +}); + +}); \ No newline at end of file -- 2.39.5