]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Убрал активность
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 7 Aug 2025 15:05:34 +0000 (18:05 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 7 Aug 2025 15:05:34 +0000 (18:05 +0300)
erp24/controllers/Products1cNomenclatureActualityController.php
erp24/migrations/m250729_101715_create_products_1c_nomenclature_actuality_table.php
erp24/records/Products1cNomenclature.php
erp24/records/Products1cNomenclatureActuality.php
erp24/views/products1c-nomenclature-actuality/index.php

index 0b9070d3ac547a0bd9a996061bce347389bf8a6c..0b478c093146b0045b603ca4a69e84b0aeb8351f 100644 (file)
@@ -111,7 +111,6 @@ class Products1cNomenclatureActualityController extends Controller
                         ->where(['property_id' => $propIds, 'value' => $filter->$attr])
                         ->column();
                     if (empty($ids)) {
-                        // если нет подходящих свойств — сразу пустая выборка
                         $query->andWhere('0=1');
                         break;
                     }
@@ -121,20 +120,24 @@ class Products1cNomenclatureActualityController extends Controller
 
             $needJoin = $filter->onlyActive || $filter->onlyInactive || $filter->date_from || $filter->date_to;
             if ($needJoin) {
-                $query->innerJoin(
-                    Products1cNomenclatureActuality::tableName() . ' a',
-                    'a.guid = n.id'
-                );
+
 
                 if ($filter->onlyActive) {
-                    $query->andWhere(['a.active' => 1]);
+                    $query->innerJoin(
+                        Products1cNomenclatureActuality::tableName() . ' a',
+                        'a.guid = n.id'
+                    );
+                    $query->andWhere(['a.guid'  => 'n.id']);
                 } elseif ($filter->onlyInactive) {
-                    $query->andWhere(['a.active' => 0]);
+                   // $query->andWhere([ 'not', 'a.guid = n.id']);
                 }
 
                 if ($filter->date_from || $filter->date_to) {
                     if (!$filter->onlyActive && !$filter->onlyInactive) {
-                        $query->andWhere(['a.active' => 1]);
+                        $query->innerJoin(
+                            Products1cNomenclatureActuality::tableName() . ' a',
+                            'a.guid = n.id'
+                        );
                     }
 
                     if ($filter->date_from && $filter->date_to) {
index a0cfdcdc10a7cee3203704400980bbe9c9109e78..cd564110496238e19705ff37ec022c3b798cc789 100644 (file)
@@ -21,7 +21,6 @@ class m250729_101715_create_products_1c_nomenclature_actuality_table extends Mig
                 'guid' => $this->string()->notNull(),
                 'date_from' => $this->dateTime()->notNull()->comment('Дата и время начала активности'),
                 'date_to' => $this->dateTime()->null()->comment('Дата и время окончания активности'),
-                'active' => $this->tinyInteger()->notNull()->defaultValue(1)->comment('Активность записи'),
                 'created_at' => $this->dateTime()->notNull()->comment('Дата создания'),
                 'updated_at' => $this->dateTime()->null()->comment('Дата обновления'),
                 'created_by' => $this->integer()->notNull()->comment('ИД создателя'),
index 345275708570df0204abe51762527f00681cc3e5..f48b07411b1ba5dedf0ea34fb8e61bd2f8c0a314 100644 (file)
@@ -78,38 +78,9 @@ class Products1cNomenclature extends \yii\db\ActiveRecord
         );
     }
 
-    /**
-     * Relation: единственная (первыей) активная запись актуальности
-     */
-    public function getActiveActuality(): ActiveQuery
+    public function hasActuality() : bool
     {
-        return $this->hasOne(
-            Products1cNomenclatureActuality::class,
-            ['guid' => 'id']
-        )->andWhere(['active' => 1]);
+        return $this->getActualities()->exists();
     }
 
-    /**
-     * Проверяет, есть ли для этой номенклатуры активная запись
-     * @return bool
-     */
-    public function hasActiveActuality(): bool
-    {
-        return (bool)$this->getActiveActuality()->exists();
-    }
-
-    /**
-     * Проверяет, есть ли для этой номенклатуры запись актуальности с active = 0
-     *
-     * @return bool
-     */
-    public function hasInactiveActuality(): bool
-    {
-        return (bool) Products1cNomenclatureActuality::find()
-            ->where([
-                'guid'   => $this->id,
-                'active' => 0,
-            ])
-            ->exists();
-    }
 }
index e1ad21d655da3fa49493fe260e48e0a78b340a67..34b6318f4f2cbfa242a46d74aa33d4cfa72db22e 100644 (file)
@@ -11,7 +11,6 @@ use Yii;
  * @property string $guid
  * @property string $date_from Дата и время начала активности
  * @property string|null $date_to Дата и время окончания активности
- * @property int $active Активность записи
  * @property string $created_at Дата создания
  * @property string|null $updated_at Дата обновления
  * @property int $created_by ИД создателя
@@ -36,11 +35,10 @@ class Products1cNomenclatureActuality extends \yii\db\ActiveRecord
     {
         return [
             [['date_to', 'updated_at', 'updated_by'], 'default', 'value' => null],
-            [['active'], 'default', 'value' => 1],
             [['guid', 'date_from', 'created_at', 'created_by'], 'required'],
             [['date_from', 'date_to', 'created_at', 'updated_at'], 'safe'],
-            [['active', 'created_by', 'updated_by'], 'default', 'value' => null],
-            [['active', 'created_by', 'updated_by'], 'integer'],
+            [['created_by', 'updated_by'], 'default', 'value' => null],
+            [['created_by', 'updated_by'], 'integer'],
             [['guid'], 'string', 'max' => 255],
         ];
     }
@@ -55,7 +53,6 @@ class Products1cNomenclatureActuality extends \yii\db\ActiveRecord
             'guid' => 'Guid',
             'date_from' => 'Date From',
             'date_to' => 'Date End',
-            'active' => 'Active',
             'created_at' => 'Created At',
             'updated_at' => 'Updated At',
             'created_by' => 'Created By',
index f0998b1fd7ef81a369e35666b6ae2513125b0dbe..130760a1bc7d7b16d355844aad01dd1f908dbba9 100644 (file)
@@ -245,11 +245,7 @@ $months = monthList();
         'tableOptions' => ['class' => 'table table-bordered'],
         'containerOptions' => ['style' => 'overflow:auto; max-height:500px;'],
         'rowOptions' => function($model) use ($filter) {
-            if ($filter->onlyInactive) {
-                if ($model->hasInactiveActuality()) {
-                    return ['class' => 'table-danger'];
-                }
-            } elseif ($model->hasActiveActuality()) {
+            if ($model->hasActuality()) {
                 return ['class' => 'table-success'];
             }
             return [];
@@ -269,29 +265,21 @@ $months = monthList();
                 'format' => 'raw',
                 'contentOptions' => ['style'=>'white-space:nowrap; min-width:200px;'],
                 'value' => function ($m, $k, $i) use ($months, $filter) {
-                    if ($filter->onlyInactive) {
-                        $actuality = Products1cNomenclatureActuality::find()
-                            ->where(['guid' => $m->id, 'active' => 0])
+                        $actuality = $m->getActualities()
                             ->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, [
                                 'class'=>'form-select from-month form-select-sm me-1',
                                 'prompt'=>'от',
-                                'disabled' => $filter->onlyInactive ? true : null
+
                             ])
                             . Html::dropDownList("actuality[$i][to]", $to, $months, [
                                 'class'=>'form-select to-month form-select-sm',
                                 'prompt'=>'до',
-                                'disabled' => $filter->onlyInactive ? true : null
+
                             ]),
                             ['class'=>'d-flex align-items-center']
                         );
@@ -303,7 +291,7 @@ $months = monthList();
                 'contentOptions' => ['style'=>'width:60px; text-align:center;'],
                 'value' => function ($m, $k, $i) use ($filter){
                     return Html::checkbox("actuality[$i][warehouse_nn]", false, [
-                        'disabled' => $filter->onlyInactive ? true : null
+
                     ]);
                 }
             ],
@@ -313,7 +301,7 @@ $months = monthList();
                 'contentOptions' => ['style'=>'width:60px; text-align:center;'],
                 'value' => function ($m, $k, $i) use ($filter){
                     return Html::checkbox("actuality[$i][warehouse_msk]", false, [
-                        'disabled' => $filter->onlyInactive ? true : null
+
                     ]);
                 }
             ],