]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Отправка guid через type_id
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Tue, 7 Oct 2025 15:03:03 +0000 (18:03 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Tue, 7 Oct 2025 15:03:03 +0000 (18:03 +0300)
erp24/api2/controllers/DataController.php
erp24/migrations/m251007_143455_add_show_field_to_analysts_business_operations_table.php [new file with mode: 0644]
erp24/records/AnalystsBusinessOperations.php
erp24/views/analysts-business-operations/_form.php
erp24/views/analysts-business-operations/index.php
erp24/views/analysts-business-operations/view.php

index f08e3ce6e010143b0fb2ecf3a57fc091c3ddc713..c24156978fee7b97b5a73d40f0812a7a4371f779 100644 (file)
@@ -479,6 +479,9 @@ class DataController extends BaseController
                 }
                 $analytics = AnalystsBusinessOperations::find()
                     ->select(['guid'])
+                    ->where(['type_id' => 2])
+                    ->andWhere(['active' => 1])
+                    ->andWhere(['show' => 1])
                     ->indexBy('name')
                     ->asArray()
                     ->all();
@@ -533,6 +536,10 @@ class DataController extends BaseController
                     ];
                 }
 
+                $nameWaybillWriteOffsType = AnalystsBusinessOperations::find()
+                    ->select(['name'])
+                    ->where(['id' => AnalystsBusinessOperations::TYPE_ID_WAYBILL_WRITE_OFFS])
+                    ->scalar();
                 foreach ($waybillWriteOffs as $row) {
                     $waybillProductsRow = $waybillWriteOffProducts[$row['id']] ?? [];
                     /*if (!empty($waybillProductsRow)) {
@@ -546,7 +553,8 @@ class DataController extends BaseController
                     $writeOffResult[] = [
                         'id' => $row['guid'],
                         'store_id' => $row['store_guid'],
-                        'type' => 'ревизия при передаче смены',
+                        'type' => $nameWaybillWriteOffsType,
+                        'type_id' => AnalystsBusinessOperations::TYPE_ID_WAYBILL_WRITE_OFFS,
                         'cause' => $cause,
                         'items' => $waybillProductsRow,
                         'summ' => $row['summ'],
@@ -625,13 +633,17 @@ class DataController extends BaseController
                         $waybillIncoming[$key]['items'] = $waybillIncomingProductsRow;
                     }
                 }
-
+                $nameWaybillIncomingType = AnalystsBusinessOperations::find()
+                    ->select(['name'])
+                    ->where(['id' => AnalystsBusinessOperations::TYPE_ID_WAYBILL_INCOMING])
+                    ->scalar();
                 foreach ($waybillIncoming as $row) {
                     $cause = 'Документ ревизии при передаче смены в ERP ' . $row['number'];
                     $waybillIncomingResult[] = [
                         'id' => $row['guid'],
                         'store_id' => $row['store_guid'],
-                        'type' => 'ревизия при передаче смены',
+                        'type' => $nameWaybillIncomingType,
+                        'type_id' => AnalystsBusinessOperations::TYPE_ID_WAYBILL_INCOMING,
                         'cause' => $cause,
                         'items' => $row['items'],
                         'summ' => $row['summ_self_cost'],
@@ -711,13 +723,17 @@ class DataController extends BaseController
                         $replacementInvoice[$key]['items'] = $replacementInvoiceProductsRow;
                     }
                 }
-
+                $nameReplacementInvoiceType = AnalystsBusinessOperations::find()
+                    ->select(['name'])
+                    ->where(['id' => AnalystsBusinessOperations::TYPE_ID_REPLACEMENT])
+                    ->scalar();
                 foreach ($replacementInvoice as $row) {
                     $cause = 'Документ пересортица при передаче смены в ERP ' . $row['number'];
                     $replacementInvoiceResult[] = [
                         'id' => $row['guid'],
                         'store_id' => $row['store_guid'],
-                        'type' => 'ревизия пересортица при передаче смены',
+                        'type' => $nameReplacementInvoiceType,
+                        'type_id' => AnalystsBusinessOperations::TYPE_ID_REPLACEMENT,
                         'cause' => $cause,
                         'comment' => $cause . ' ' . $row['comment'],
                         'items' => $row['items'],
diff --git a/erp24/migrations/m251007_143455_add_show_field_to_analysts_business_operations_table.php b/erp24/migrations/m251007_143455_add_show_field_to_analysts_business_operations_table.php
new file mode 100644 (file)
index 0000000..2985308
--- /dev/null
@@ -0,0 +1,51 @@
+<?php
+
+use yii\db\Migration;
+
+class m251007_143455_add_show_field_to_analysts_business_operations_table extends Migration
+{
+    const TABLE_NAME = 'erp24.analysts_business_operations';
+    /**
+     * {@inheritdoc}
+     */
+    public function safeUp()
+    {
+        $table = $this->db->schema->getTableSchema(self::TABLE_NAME);
+        if ($table === null) {
+            return;
+        }
+
+        if (!$this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('show')) {
+            $this->addColumn(
+                self::TABLE_NAME,
+                'show',
+                $this->tinyInteger()->notNull()->defaultValue(0)->comment('видимость типа бизнес операции')
+            );
+        }
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeDown()
+    {
+        if ($this->db->schema->getTableSchema(self::TABLE_NAME, true)->getColumn('show')) {
+            $this->dropColumn(self::TABLE_NAME, 'show');
+        }
+    }
+
+    /*
+    // Use up()/down() to run migration code without a transaction.
+    public function up()
+    {
+
+    }
+
+    public function down()
+    {
+        echo "m251007_143455_add_show_field_to_analysts_business_operations_table cannot be reverted.\n";
+
+        return false;
+    }
+    */
+}
index 32c9280df4a4833255c62688c59a615f34af47f6..e485f738f8e8120afbdc267ba2020db4ebbecf2a 100644 (file)
@@ -12,11 +12,15 @@ use Yii;
  * @property int $type Вид использования хозяйственной операции
  * @property int|null $type_id Активность записи
  * @property int|null $active ID Вида
+ * @property int $show Видимость типа бизнес операции
  * @property string $created_at
  */
 class AnalystsBusinessOperations extends \yii\db\ActiveRecord
 {
-    const TYPE_ID_WAYBILL_WRITE_OFFS = '';
+    const TYPE_ID_WAYBILL_WRITE_OFFS = 'a3d4e24f-3373-11e9-babd-408d5cd22d1e';
+    const TYPE_ID_WAYBILL_INCOMING = 'a3d4e24f-3373-11e9-babd-408d5cd22d1e';
+    const TYPE_ID_REPLACEMENT = 'a3d4e24f-3373-11e9-babd-408d5cd22d1e';
+
 
 
     /**
@@ -34,10 +38,11 @@ class AnalystsBusinessOperations extends \yii\db\ActiveRecord
     {
         return [
             [['active'], 'default', 'value' => null],
+            [['show'], 'default', 'value' => 0],
             [['type_id'], 'default', 'value' => 1],
             [['id', 'name', 'type'], 'required'],
-            [['type', 'type_id', 'active'], 'default', 'value' => null],
-            [['type', 'type_id', 'active'], 'integer'],
+            [['type', 'type_id', 'active', 'show'], 'default', 'value' => null],
+            [['type', 'type_id', 'active', 'show'], 'integer'],
             [['created_at'], 'safe'],
             [['id', 'name'], 'string', 'max' => 255],
             [['id'], 'unique'],
@@ -55,6 +60,7 @@ class AnalystsBusinessOperations extends \yii\db\ActiveRecord
             'type' => 'Type',
             'type_id' => 'Type ID',
             'active' => 'Active',
+            'show' => 'Видимость',
             'created_at' => 'Created At',
         ];
     }
index c63c304384cc324c9e38abc973558b56fe6f879b..a7ccfde6c0f23dd227b7813447be2b006d23c5e6 100644 (file)
@@ -23,6 +23,10 @@ use yii\widgets\ActiveForm;
         Активность
     <?= $form->field($model, 'active')->checkbox()->label(false)?>
     </label>
+    <label>
+        Видимость
+    <?= $form->field($model, 'show')->checkbox()->label(false)?>
+    </label>
 
     <?= $form->field($model, 'created_at')->textInput()->hiddenInput()->label(false) ?>
 
index a68c9f513c5c5d0610dd4803700f55ee3fba8531..127c0e7c67bbeedcd57b214dbbe1cb96cfbbda43 100644 (file)
@@ -44,6 +44,13 @@ $isIt  = $admin && (int)$admin->group_id === AdminGroup::GROUP_IT;
                     return $model->active == 1 ? 'Да' : 'Нет';
                 },
             ],
+            [
+                'attribute' => 'show',
+                'label' => 'Видимость',
+                'value' => function ($model) {
+                    return $model->show == 1 ? 'Да' : 'Нет';
+                },
+            ],
             'created_at',
             [
                 'class' => \yii\grid\ActionColumn::class,
index 20a768b156a6e70263193d64d483d699b437cae8..5c65e758cf0f6ea53080ea8b74b123edf0bd9320 100644 (file)
@@ -34,6 +34,7 @@ $this->params['breadcrumbs'][] = $this->title;
             'type',
             'type_id',
             'active',
+            'show',
             'created_at',
         ],
     ]) ?>