]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Добавление полей
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 27 Aug 2025 12:02:16 +0000 (15:02 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Wed, 27 Aug 2025 12:02:16 +0000 (15:02 +0300)
erp24/api2/controllers/DataController.php
erp24/controllers/AnalystsBusinessOperationsTypesController.php
erp24/migrations/m250825_141743_create_analysts_business_operations_table.php
erp24/migrations/m250826_061451_add_analysts_business_operations_types_table.php
erp24/records/AnalystsBusinessOperations.php
erp24/records/AnalystsBusinessOperationsTypes.php
erp24/views/analysts-business-operations-types/index.php
erp24/views/analysts-business-operations-types/view.php
erp24/views/analysts-business-operations/index.php
erp24/views/analysts-business-operations/view.php

index 1b52704fe77dc78666f91fe2cc622cabf9dcbd20..01c8868d1c320e6d361c1032969776249b55a847 100644 (file)
@@ -68,8 +68,8 @@ class DataController extends BaseController
 
     const OUT_DIR =
 //        __DIR__ . "/../json";
-         //   "/www/api2/json";
-        "/var/www/erp24/api2/json";
+            "/www/api2/json";
+        //"/var/www/erp24/api2/json";
 
 //          "/var/www/www-root/data/www/api.bazacvetov24.ru/data/json";
     private static function getPathJson()
@@ -2568,11 +2568,14 @@ class DataController extends BaseController
                         $newOperation->id = $operation['id'];
                         $newOperation->name = $operation['name'];
                         $newOperation->type = (int)$operation['type'];
+                        $newOperation->active = 1;
                         if (!in_array((int)$operation['type'], array_column($existingTypes, 'code'))) {
                             $newType = new AnalystsBusinessOperationsTypes();
                             $newType->code = (int)$operation['type'];
                             $newType->name = null;
+                            $newType->alias = null;
                             $newType->created_at = date('Y-m-d H:i:s');
+                            $newType->created_by = 1409;
                             if ($newType->save()) {
                                 $newOperation->type_id = $newType->id;
                             } else {
@@ -2580,7 +2583,7 @@ class DataController extends BaseController
                                Yii::error('Ошибка сохранение типа ' . json_encode($newType->getErrors(), JSON_UNESCAPED_UNICODE), __METHOD__ );
                                 LogService::apiErrorLog(
                                     json_encode(
-                                        ["error_id" => 44.1, "error" => $operation->getErrors()],
+                                        ["error_id" => 44.1, "error" => $newType->getErrors()],
                                         JSON_UNESCAPED_UNICODE
                                     )
                                 );
@@ -2605,7 +2608,9 @@ class DataController extends BaseController
                                 $newType = new AnalystsBusinessOperationsTypes();
                                 $newType->code = (int)$operation['type'];
                                 $newType->name = null;
+                                $newType->alias = null;
                                 $newType->created_at = date('Y-m-d H:i:s');
+                                $newType->created_by = 1409;
                                 if ($newType->save()) {
                                     $oldOperation->type = (int)$operation['type'];
                                     $oldOperation->type_id = $newType->id;
index 9d41a221fbf953f6be193e77d8d4b4cf3b80b5eb..ef1c78618b1435b57e24a139a6e49352d54d2e43 100644 (file)
@@ -2,6 +2,7 @@
 
 namespace app\controllers;
 
+use Yii;
 use yii\web\ForbiddenHttpException;
 use yii_app\records\Admin;
 use yii_app\records\AdminGroup;
@@ -104,11 +105,13 @@ class AnalystsBusinessOperationsTypesController extends Controller
      */
     public function actionUpdate($id)
     {
+        $adminId = Yii::$app->user->id;
         if (!$this->canEdit()) {
             throw new ForbiddenHttpException('Недостаточно прав.');
         }
         $model = $this->findModel($id);
-
+        $model->updated_at = date('Y-m-d H:i:s');
+        $model->updated_by = $adminId ?? null;
         if ($this->request->isPost && $model->load($this->request->post()) && $model->save()) {
             return $this->redirect(['view', 'id' => $model->id]);
         }
index a30f8a9bb505115afffcea1dc765a5196897dec2..ebc11aa9b3728ce5e352d25fd7bd86542facfcd5 100644 (file)
@@ -20,7 +20,8 @@ class m250825_141743_create_analysts_business_operations_table extends Migration
                 'id' => $this->string()->notNull()->unique()->comment('GUID аналитики'),
                 'name' => $this->string()->notNull()->comment('Название аналитики'),
                 'type' => $this->integer()->notNull()->comment('Вид использования хозяйственной операции'),
-                'type_id' => $this->integer()->null()->comment('ID Вида'),
+                'type_id' => $this->tinyInteger()->defaultValue(1)->comment('Активность записи'),
+                'active' => $this->integer()->null()->comment('ID Вида'),
                 'created_at' => $this->dateTime()->notNull()->defaultExpression('NOW()'),
             ]);
             $this->addPrimaryKey('pk_analytics_id', self::TABLE_NAME, 'id');
index 7304a7c2f4c91599e7483cfff3e3ab4b9afe1515..536615793d20973167de6720de698dc4804d1512 100644 (file)
@@ -16,8 +16,12 @@ class m250826_061451_add_analysts_business_operations_types_table extends Migrat
             $this->createTable(self::TABLE_NAME, [
                 'id' => $this->primaryKey()->comment('ID типа операции'),
                 'code' => $this->integer()->notNull()->unique()->comment('Код типа (0,1,2...)'),
+                'alias' => $this->string()->null()->comment('Алиас типа операции'),
                 'name' => $this->string()->null()->comment('Название типа операции'),
-                'created_at' => $this->dateTime()->notNull()->defaultExpression('NOW()'),
+                'created_by' => $this->integer()->null()->comment('Кем создано - id'),
+                'updated_by' => $this->integer()->null()->comment('Кем обновлено - id'),
+                'created_at' => $this->dateTime()->notNull()->defaultExpression('NOW()')->comment('Когда создано'),
+                'updated_at' => $this->dateTime()->null()->comment('Когда обновлено'),
             ]);
             $this->batchInsert(self::TABLE_NAME, ['code', 'name'], [
                 [0, 'Оприходование'],
index d8689144d9c1ad61d46d6822c9aef49b14f8f7dc..82185b8c89658e69fcdf4a61ef1ee91fcbc56480 100644 (file)
@@ -10,8 +10,9 @@ use Yii;
  * @property string $id GUID аналитики
  * @property string $name Название аналитики
  * @property int $type Вид использования хозяйственной операции
- * @property int|null $type_id ID Вида
- * @property string $created_at Дата создания
+ * @property int|null $type_id Активность записи
+ * @property int|null $active ID Вида
+ * @property string $created_at
  */
 class AnalystsBusinessOperations extends \yii\db\ActiveRecord
 {
@@ -31,10 +32,11 @@ class AnalystsBusinessOperations extends \yii\db\ActiveRecord
     public function rules()
     {
         return [
-            [['type_id'], 'default', 'value' => null],
-            [['id', 'name', 'type', 'created_at'], 'required'],
-            [['type'], 'default', 'value' => null],
-            [['type', 'type_id'], 'integer'],
+            [['active'], 'default', 'value' => null],
+            [['type_id'], 'default', 'value' => 1],
+            [['id', 'name', 'type'], 'required'],
+            [['type', 'type_id', 'active'], 'default', 'value' => null],
+            [['type', 'type_id', 'active'], 'integer'],
             [['created_at'], 'safe'],
             [['id', 'name'], 'string', 'max' => 255],
             [['id'], 'unique'],
@@ -47,11 +49,12 @@ class AnalystsBusinessOperations extends \yii\db\ActiveRecord
     public function attributeLabels()
     {
         return [
-            'guid' => 'GUID аналитики',
-            'name' => 'Название аналитики',
-            'type' => 'Вид использования хозяйственной операции',
-            'type_id' => 'ID Вида',
-            'created_at' => 'Дата создания',
+            'id' => 'ID',
+            'name' => 'Name',
+            'type' => 'Type',
+            'type_id' => 'Type ID',
+            'active' => 'Active',
+            'created_at' => 'Created At',
         ];
     }
 
index 0745a64f5310747f1b72cdc4b5254249996a5d23..0cd25d71e8ecb920f1ee2114c103cd55a8cbcd84 100644 (file)
@@ -9,10 +9,12 @@ use Yii;
  *
  * @property int $id ID типа операции
  * @property int $code Код типа (0,1,2...)
+ * @property string|null $alias Алиас типа операции
  * @property string|null $name Название типа операции
- * @property string $created_at
- *
- * @property AnalystsBusinessOperations[] $analystsBusinessOperations
+ * @property int|null $created_by Кем создано - id
+ * @property int|null $updated_by Кем обновлено - id
+ * @property string $created_at Когда создано
+ * @property string|null $updated_at Когда обновлено
  */
 class AnalystsBusinessOperationsTypes extends \yii\db\ActiveRecord
 {
@@ -32,11 +34,12 @@ class AnalystsBusinessOperationsTypes extends \yii\db\ActiveRecord
     public function rules()
     {
         return [
+            [['alias', 'name', 'created_by', 'updated_by', 'updated_at'], 'default', 'value' => null],
             [['code'], 'required'],
-            [['name'], 'default', 'value' => null],
-            [['code'], 'integer'],
-            [['created_at'], 'safe'],
-            [['name'], 'string', 'max' => 255],
+            [['code', 'created_by', 'updated_by'], 'default', 'value' => null],
+            [['code', 'created_by', 'updated_by'], 'integer'],
+            [['created_at', 'updated_at'], 'safe'],
+            [['alias', 'name'], 'string', 'max' => 255],
             [['code'], 'unique'],
         ];
     }
@@ -49,8 +52,12 @@ class AnalystsBusinessOperationsTypes extends \yii\db\ActiveRecord
         return [
             'id' => 'ID',
             'code' => 'Code',
+            'alias' => 'Alias',
             'name' => 'Name',
+            'created_by' => 'Created By',
+            'updated_by' => 'Updated By',
             'created_at' => 'Created At',
+            'updated_at' => 'Updated At',
         ];
     }
 
index 30d14411276a4422e239fdd9f01a7cec57d66db2..2a454dc45c3e7ad53d171c4f1b155758a0817afc 100644 (file)
@@ -30,6 +30,9 @@ $isIt  = $admin && (int)$admin->group_id === AdminGroup::GROUP_IT;
             'id',
             'code',
             'name',
+            'alias',
+            'updated_at',
+            'updated_by',
             'created_at',
             [
                 'class' => ActionColumn::class,
index c7e44f0269b4148fe84152ab1869bd0853d2c10a..3a245716f786cda22f963d0a68b5cc4a9b6d42a3 100644 (file)
@@ -32,6 +32,10 @@ $this->params['breadcrumbs'][] = $this->title;
             'id',
             'code',
             'name',
+            'alias',
+            'updated_by',
+            'created_by',
+            'updated_at',
             'created_at',
         ],
     ]) ?>
index 7f3854523f548a89c446de23361d9bb7c09751d7..a68c9f513c5c5d0610dd4803700f55ee3fba8531 100644 (file)
@@ -37,6 +37,13 @@ $isIt  = $admin && (int)$admin->group_id === AdminGroup::GROUP_IT;
             ],
             'type',
             'type_id',
+            [
+                'attribute' => 'active',
+                'label' => 'Активность',
+                'value' => function ($model) {
+                    return $model->active == 1 ? 'Да' : 'Нет';
+                },
+            ],
             'created_at',
             [
                 'class' => \yii\grid\ActionColumn::class,
index b32a733c3d552afe0180f2d99da91c277dd16c5f..f472ee341eeaf09eaea7ac51744bae5f25aa887c 100644 (file)
@@ -33,6 +33,7 @@ $this->params['breadcrumbs'][] = $this->title;
             'name',
             'type',
             'type_id',
+            'active',
             'created_at',
         ],
     ]) ?>