From: Vladimir Fomichev Date: Wed, 11 Jun 2025 06:56:02 +0000 (+0300) Subject: Правки по ревью X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=33654ae45fd4f236666e4c037af76c160624c986;p=erp24_rep%2Fyii-erp24%2F.git Правки по ревью --- diff --git a/erp24/records/MarketplaceOrder1cStatusesRelations.php b/erp24/records/MarketplaceOrder1cStatusesRelations.php index 45a13923..96b00caf 100644 --- a/erp24/records/MarketplaceOrder1cStatusesRelations.php +++ b/erp24/records/MarketplaceOrder1cStatusesRelations.php @@ -67,19 +67,23 @@ class MarketplaceOrder1cStatusesRelations extends \yii\db\ActiveRecord ]; } - public function beforeValidate() + public function beforeSave($insert) { - if (parent::beforeValidate()) { - if ($this->status_id_from !== null && $this->order === null) { - // Получаем из БД максимальный order для этого status_id_from - $maxOrder = (int) self::find() - ->where(['status_id_from' => $this->status_id_from]) - ->max('`order`'); - $this->order = $maxOrder + 1; - } - return true; + if (!parent::beforeSave($insert)) { + return false; } - return false; + + if ($this->status_id_from !== null && $this->order === null) { + $last = self::find() + ->where(['status_id_from' => $this->status_id_from]) + ->orderBy(['order' => SORT_DESC]) + ->one(); + + $this->order = ($last !== null ? $last->order : 0) + 1; + } + + return true; } + } diff --git a/erp24/views/crud/marketplace-order1c-statuses/_form.php b/erp24/views/crud/marketplace-order1c-statuses/_form.php index 98a26a06..1857d767 100644 --- a/erp24/views/crud/marketplace-order1c-statuses/_form.php +++ b/erp24/views/crud/marketplace-order1c-statuses/_form.php @@ -58,13 +58,13 @@ $this->registerJsFile( $rel): $initialOrder = $rel->order ?: ($i + 1); ?> -
- ☰ +
+ ☰ Порядок: 'rel-order-input']) ?> -
+
'control-label']) ?> registerJsFile( ); ?>
-
+
'control-label']) ?> registerJsFile( ); ?>
-
+
'control-label']) ?> registerJsFile( ); ?>
-
- @@ -116,14 +115,14 @@ $this->registerJsFile( -