]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Фильтр неактивных записей
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 7 Aug 2025 11:03:49 +0000 (14:03 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 7 Aug 2025 11:03:49 +0000 (14:03 +0300)
erp24/controllers/Products1cNomenclatureActualityController.php
erp24/views/products1c-nomenclature-actuality/index.php
erp24/web/js/products1cNomenclatureActuality/index.js

index fd600e7cf491a2d76eb2b5fef02daf916bf6e573..c4b330b24e13282d74f117f3b6d1822ba355878b 100644 (file)
@@ -157,7 +157,7 @@ class Products1cNomenclatureActualityController extends Controller
                     }
                 }
             }
-
+            
 
             $dataProvider = new \yii\data\ActiveDataProvider([
                 'query' => $query,
index 8491d17863f903f99113dc1bd81841ffedc36a9a..02296dd202d17ce76c56403fa7e99b9d59a640a5 100644 (file)
@@ -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) ?>
+
                 <?= $formFilter->field($filter, 'onlyInactive')->checkbox([
                     'label' => 'Только неактивные',
                     'uncheck' => 0,
                     'checked' => (bool)$filter->onlyInactive,
+                    'id' => 'onlyInactiveCheckbox'
                 ])->label(false) ?>
             </div>
         </div>
@@ -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, [
index 4019d4b2cc9fd9ca97a858eb0a2d26470dbd1abb..1e4a04364d884c64ca249c8029e97b4f5b2dfbeb 100644 (file)
@@ -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