]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Добавление Название документа в 1с
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Fri, 20 Dec 2024 09:26:54 +0000 (12:26 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Fri, 20 Dec 2024 09:26:54 +0000 (12:26 +0300)
erp24/api2/controllers/DataController.php
erp24/migrations/m241210_090957_waybill_write_offs.php
erp24/migrations/m241220_084001_add_name_1c_to_waybill_write_offs.php [new file with mode: 0644]
erp24/records/WaybillWriteOffs.php
erp24/views/waybill-write-offs/view.php

index 05e252ea48485b64aeebd338928f0431e33a20e9..e16dc9f56032952e8e70f42609dfe17a9c2fd668 100644 (file)
@@ -1119,10 +1119,10 @@ class DataController extends BaseController
                                     );
                                 }
                             }
-                            if (!empty($waybillWriteOffsErp)) {
+                            if (!empty($waybillWriteOffsErp) && isset($arr["held"]) && $arr["held"]) {
                                 /** @var WaybillWriteOffs $waybillWriteOffsErp */
                                 $waybillWriteOffsErp->status = WriteOffsErp::STATUS_CREATED_1С;
-                                $waybillWriteOffsErp->number_1c = $arr["number"] ?? '';
+                                $waybillWriteOffsErp->number_1c = $arr["name"] ?? '';
                                 $waybillWriteOffsErp->save();
                                 if ($waybillWriteOffsErp->getErrors()) {
                                     LogService::apiErrorLog(
index c5d058a2d4d06ff7937b04fa940a6e6e1b9a1cdf..89b31980eaf23f500c5f971140f454c54278872e 100644 (file)
@@ -26,7 +26,7 @@ class m241210_090957_waybill_write_offs extends Migration
                 'store_id' => $this->integer()->notNull()->comment('id магазина в ERP'),
                 'store_guid' => $this->string(100)->notNull()->comment('GUID магазина из 1с'),
                 'number' => $this->string(100)->notNull()->comment('Название документа'),
-                'number_1c' => $this->string(100)->null()->comment('Ð\9dазвание документа в 1с'),
+                'number_1c' => $this->string(100)->null()->comment('Ð\9dомеÑ\80 документа в 1с'),
                 'date' => $this->dateTime()->notNull()->comment('Дата документа'),
                 'comment' => $this->text()->null()->comment('Комментарий'),
                 'quantity' => $this->float()->notNull()->comment('Количество'),
diff --git a/erp24/migrations/m241220_084001_add_name_1c_to_waybill_write_offs.php b/erp24/migrations/m241220_084001_add_name_1c_to_waybill_write_offs.php
new file mode 100644 (file)
index 0000000..e70f54d
--- /dev/null
@@ -0,0 +1,54 @@
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Class m241220_084001_add_name_1c_to_waybill_write_offs
+ */
+class m241220_084001_add_name_1c_to_waybill_write_offs extends Migration
+{
+    const TABLE_NAME = 'erp24.waybill_write_offs';
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeUp()
+    {
+        $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+        if ($tableSchema !== null && !isset($tableSchema->columns['name_1c'])) {
+            $this->addColumn(
+                self::TABLE_NAME,
+                'name_1c',
+                $this->string(255)
+                    ->null()
+                ->comment('Название документа в 1с')
+            );
+        }
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeDown()
+    {
+        $tableSchema = $this->db->getTableSchema(self::TABLE_NAME);
+        if ($tableSchema !== null && isset($tableSchema->columns['name_1c'])) {
+            $this->dropColumn(self::TABLE_NAME, 'name_1c');
+        }
+    }
+
+    /*
+    // Use up()/down() to run migration code without a transaction.
+    public function up()
+    {
+
+    }
+
+    public function down()
+    {
+        echo "m241220_084001_add_name_1c_to_waybill_write_offs cannot be reverted.\n";
+
+        return false;
+    }
+    */
+}
index 5f5b8f68c9590a0eddd3eb2a1185d36866373cf7..2d1d90ba9b89b35c3853579a7d6e4fb09c68c688 100644 (file)
@@ -20,7 +20,8 @@ use yii_app\helpers\DataHelper;
  * @property int $store_id id магазина в ERP
  * @property string $store_guid GUID магазина из 1с
  * @property string $number Название документа
- * @property string|null $number_1c Название документа в 1с
+ * @property string|null $number_1c Номер документа в 1с
+ * @property string|null $name_1c Название документа в 1с
  * @property string $date Дата документа
  * @property string|null $comment Комментарий
  * @property float $quantity Количество
@@ -55,7 +56,7 @@ class WaybillWriteOffs extends \yii\db\ActiveRecord
             [['shift_transfer_id', 'status', 'created_admin_id', 'updated_admin_id', 'store_id'], 'default', 'value' => null],
             [['shift_transfer_id', 'status', 'created_admin_id', 'updated_admin_id', 'store_id'], 'integer'],
             [['date', 'created_at', 'updated_at', 'send_at'], 'safe'],
-            [['comment', 'error_text'], 'string'],
+            [['comment', 'error_text', 'name_1c'], 'string'],
             [['quantity', 'summ', 'summ_self_cost'], 'number'],
             [['guid', 'store_guid', 'number', 'number_1c'], 'string', 'max' => 100],
             [['guid'], 'unique'],
@@ -95,7 +96,8 @@ class WaybillWriteOffs extends \yii\db\ActiveRecord
             'store_id' => 'id магазина в ERP',
             'store_guid' => 'GUID магазина из 1с',
             'number' => 'Название документа',
-            'number_1c' => 'Название документа в 1с',
+            'number_1c' => 'Номер документа в 1с',
+            'name_1c' => 'Название документа в 1с',
             'date' => 'Дата документа',
             'comment' => 'Комментарий',
             'quantity' => 'Количество',
@@ -133,9 +135,11 @@ class WaybillWriteOffs extends \yii\db\ActiveRecord
 
             WaybillWriteOffsProducts::setData($model, $shiftTransfer);
 
-            if (!WaybillWriteOffsProducts::find()
+            if (
+                !WaybillWriteOffsProducts::find()
                 ->andWhere(['waybill_write_offs_id' => $model->id])
-                ->exists()) {
+                ->exists()
+            ) {
                 $model->delete();
                 return;
             }
@@ -157,7 +161,6 @@ class WaybillWriteOffs extends \yii\db\ActiveRecord
                     'summ_self_cost' => $summaries['total_summ_self_cost']
                 ]);
             }
-            
         } catch (\Exception $exception) {
             throw new \Exception($exception);
         }
index 885d0e8c3f94fdfa03924e0ff1326efdd889b25f..d9d2b1476de28c1e9f972f2d21a57ecea05fba69 100644 (file)
@@ -25,7 +25,13 @@ $this->params['breadcrumbs'][] = $this->title;
             'id',
             'guid',
             'number',
-            'date',
+            [
+                'label' => 'Дата документа',
+                'attribute' => 'date',
+                'value' => function ($model) {
+                    return date('d-m-Y H:i:s', strtotime($model->date));
+                }
+            ],
             [
                 'label' => 'Магазин',
                 'attribute' => 'store_id',
@@ -48,8 +54,19 @@ $this->params['breadcrumbs'][] = $this->title;
                 'label' => 'Текст ошибки',
                 'attribute' => 'error_text',
                 'value' => function ($model) {
-                    return $model->status == 8 ? $model->error_text : '';
-                }
+                    return $model->status == \yii_app\records\WriteOffsErp::STATUS_ERROR_1С ? $model->error_text : '';
+                },
+                'visible' => $model->status == \yii_app\records\WriteOffsErp::STATUS_ERROR_1С,
+            ],
+            [
+                'label' => 'Название документа в 1С',
+                'attribute' => 'name_1c',
+                'value' => function ($model) {
+                    return
+                        $model->status == \yii_app\records\WriteOffsErp::STATUS_CREATED_1С ?
+                            $model->name_1c : '';
+                },
+                'visible' => $model->status == \yii_app\records\WriteOffsErp::STATUS_CREATED_1С,
             ],
             [
                 'label' => 'Номер документа в 1С',
@@ -58,11 +75,16 @@ $this->params['breadcrumbs'][] = $this->title;
                     return
                         $model->status == \yii_app\records\WriteOffsErp::STATUS_CREATED_1С ?
                             $model->number_1c : '';
-                }
+                },
+                'visible' => $model->status == \yii_app\records\WriteOffsErp::STATUS_CREATED_1С && isset($model->number_1c),
             ],
             [
                 'label' => 'Отправлено в 1С',
                 'attribute' => 'send_at',
+                'visible' => $model->status == \yii_app\records\WriteOffsErp::STATUS_SEND,
+                'value' => function ($model) {
+                    return date('d-m-Y H:i:s', strtotime($model->send_at));
+                }
             ],
             [
                 'label' => 'Создан пользователем',
@@ -71,9 +93,20 @@ $this->params['breadcrumbs'][] = $this->title;
                     return Admin::findOne([$model->created_admin_id])->name;
                 }
             ],
-
-            'created_at',
-            'updated_at',
+            [
+                'label' => 'Дата создания',
+                'attribute' => 'created_at',
+                'value' => function ($model) {
+                    return date('d-m-Y H:i:s', strtotime($model->created_at));
+                }
+            ],
+            [
+                'label' => 'Дата обновления',
+                'attribute' => 'updated_at',
+                'value' => function ($model) {
+                    return $model->updated_at ? date('d-m-Y H:i:s', strtotime($model->updated_at)) : '';
+                }
+            ],
         ],
     ]) ?>