]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Правки по ревью
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 11 Jun 2025 06:56:02 +0000 (09:56 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 11 Jun 2025 06:56:02 +0000 (09:56 +0300)
erp24/records/MarketplaceOrder1cStatusesRelations.php
erp24/views/crud/marketplace-order1c-statuses/_form.php

index 45a1392374af140d164c69a2e37bae1b06f2baa3..96b00caf869a5b95133e1692da008f14b8f1bc13 100644 (file)
@@ -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;
     }
 
+
 }
index 98a26a0691b3f71e3fd7096ec157bb08adc3afc3..1857d767e693e272439dec9448dbc9f3d6068b8f 100644 (file)
@@ -58,13 +58,13 @@ $this->registerJsFile(
         <?php foreach ($relationModels as $i => $rel):
             $initialOrder = $rel->order ?: ($i + 1);
             ?>
-            <div class="relation-item" style="border:1px solid #ddd; padding:10px; margin-bottom:10px; position: relative; background:#f9f9f9;">
-                <span class="drag-handle" style="cursor:move; font-size:18px; margin-right:8px;" title="Перетащите, чтобы изменить порядок">☰</span>
+            <div class="relation-item border border-1 border-secondary bg-light p-2 mb-3 position-relative" >
+                <span class="drag-handle cursor-move me-2 fs-5"  title="Перетащите, чтобы изменить порядок">☰</span>
                 <strong>Порядок: <span class="order-label"><?= $initialOrder ?></span></strong>
 
                 <?= Html::hiddenInput("Relations[{$i}][order]", $initialOrder, ['class' => 'rel-order-input']) ?>
 
-                <div style="margin-top:8px;">
+                <div class="mt-6">
                     <?= Html::label('Статус-назначения', null, ['class' => 'control-label']) ?>
                     <?= Html::dropDownList(
                         "Relations[{$i}][status_id_to]",
@@ -79,7 +79,7 @@ $this->registerJsFile(
                     ); ?>
                 </div>
 
-                <div style="margin-top:8px;">
+                <div class="mt-6" >
                     <?= Html::label('Описание (description)', null, ['class' => 'control-label']) ?>
                     <?= Html::textInput(
                         "Relations[{$i}][description]",
@@ -88,7 +88,7 @@ $this->registerJsFile(
                     ); ?>
                 </div>
 
-                <div style="margin-top:8px;">
+                <div class="mt-6">
                     <?= Html::label('Текст кнопки (button_text)', null, ['class' => 'control-label']) ?>
                     <?= Html::textInput(
                         "Relations[{$i}][button_text]",
@@ -97,15 +97,14 @@ $this->registerJsFile(
                     ); ?>
                 </div>
 
-                <button type="button" class="btn btn-danger btn-sm remove-relation-btn"
-                        style="position:absolute; top:10px; right:10px;">
+                <button type="button" class="btn btn-danger btn-sm remove-relation-btn position-absolute top-0 end-0 mt-2 me-2">
                    Удалить
                 </button>
             </div>
         <?php endforeach; ?>
     </div>
 
-    <button type="button" id="add-relation-btn" class="btn btn-primary btn-sm" style="margin-bottom:15px;">
+    <button type="button" id="add-relation-btn" class="btn btn-primary btn-sm mb-8" >
         &plus; Добавить ещё одну связь
     </button>
 
@@ -116,14 +115,14 @@ $this->registerJsFile(
     <?php ActiveForm::end(); ?>
 
 
-    <div id="relation-template" style="display:none;">
-        <div class="relation-item template" style="border:1px solid #ddd; padding:10px; margin-bottom:10px; position: relative; background:#f9f9f9;">
-            <span class="drag-handle" style="cursor:move; font-size:18px; margin-right:8px;" title="Перетащите, чтобы изменить порядок">☰</span>
+    <div id="relation-template d-none" >
+        <div class="relation-item template border border-1 border-secondary bg-light p-2 mb-3 position-relative">
+            <span class="drag-handle cursor-move me-2 fs-5"  title="Перетащите, чтобы изменить порядок">☰</span>
             <strong>Порядок: <span class="order-label">__order__</span></strong>
 
             <?= Html::hiddenInput("Relations[__index__][order]", "__order__", ['class' => 'rel-order-input']) ?>
 
-            <div style="margin-top:8px;">
+            <div class="mt-6">
                 <?= Html::label('Статус-назначения', null, ['class' => 'control-label']) ?>
                 <?= Html::dropDownList(
                     "Relations[__index__][status_id_to]",
@@ -137,18 +136,17 @@ $this->registerJsFile(
                 ); ?>
             </div>
 
-            <div style="margin-top:8px;">
+            <div class="mt-6">
                 <?= Html::label('Описание (description)', null, ['class' => 'control-label']) ?>
                 <?= Html::textInput("Relations[__index__][description]", null, ['class' => 'form-control']) ?>
             </div>
 
-            <div style="margin-top:8px;">
+            <div class="mt-6">
                 <?= Html::label('Текст кнопки (button_text)', null, ['class' => 'control-label']) ?>
                 <?= Html::textInput("Relations[__index__][button_text]", null, ['class' => 'form-control']) ?>
             </div>
 
-            <button type="button" class="btn btn-danger btn-sm remove-relation-btn"
-                    style="position:absolute; top:10px; right:10px;">
+            <button type="button" class="btn btn-danger btn-sm remove-relation-btn position-absolute top-0 end-0 mt-2 me-2">
                 Удалить
             </button>
         </div>