From: Vladimir Fomichev Date: Wed, 27 Aug 2025 12:02:16 +0000 (+0300) Subject: Добавление полей X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=38d7aa95b11b84051dd63852a7b4a22516adfe7a;p=erp24_rep%2Fyii-erp24%2F.git Добавление полей --- diff --git a/erp24/api2/controllers/DataController.php b/erp24/api2/controllers/DataController.php index 1b52704f..01c8868d 100644 --- a/erp24/api2/controllers/DataController.php +++ b/erp24/api2/controllers/DataController.php @@ -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; diff --git a/erp24/controllers/AnalystsBusinessOperationsTypesController.php b/erp24/controllers/AnalystsBusinessOperationsTypesController.php index 9d41a221..ef1c7861 100644 --- a/erp24/controllers/AnalystsBusinessOperationsTypesController.php +++ b/erp24/controllers/AnalystsBusinessOperationsTypesController.php @@ -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]); } diff --git a/erp24/migrations/m250825_141743_create_analysts_business_operations_table.php b/erp24/migrations/m250825_141743_create_analysts_business_operations_table.php index a30f8a9b..ebc11aa9 100644 --- a/erp24/migrations/m250825_141743_create_analysts_business_operations_table.php +++ b/erp24/migrations/m250825_141743_create_analysts_business_operations_table.php @@ -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'); diff --git a/erp24/migrations/m250826_061451_add_analysts_business_operations_types_table.php b/erp24/migrations/m250826_061451_add_analysts_business_operations_types_table.php index 7304a7c2..53661579 100644 --- a/erp24/migrations/m250826_061451_add_analysts_business_operations_types_table.php +++ b/erp24/migrations/m250826_061451_add_analysts_business_operations_types_table.php @@ -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, 'Оприходование'], diff --git a/erp24/records/AnalystsBusinessOperations.php b/erp24/records/AnalystsBusinessOperations.php index d8689144..82185b8c 100644 --- a/erp24/records/AnalystsBusinessOperations.php +++ b/erp24/records/AnalystsBusinessOperations.php @@ -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', ]; } diff --git a/erp24/records/AnalystsBusinessOperationsTypes.php b/erp24/records/AnalystsBusinessOperationsTypes.php index 0745a64f..0cd25d71 100644 --- a/erp24/records/AnalystsBusinessOperationsTypes.php +++ b/erp24/records/AnalystsBusinessOperationsTypes.php @@ -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', ]; } diff --git a/erp24/views/analysts-business-operations-types/index.php b/erp24/views/analysts-business-operations-types/index.php index 30d14411..2a454dc4 100644 --- a/erp24/views/analysts-business-operations-types/index.php +++ b/erp24/views/analysts-business-operations-types/index.php @@ -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, diff --git a/erp24/views/analysts-business-operations-types/view.php b/erp24/views/analysts-business-operations-types/view.php index c7e44f02..3a245716 100644 --- a/erp24/views/analysts-business-operations-types/view.php +++ b/erp24/views/analysts-business-operations-types/view.php @@ -32,6 +32,10 @@ $this->params['breadcrumbs'][] = $this->title; 'id', 'code', 'name', + 'alias', + 'updated_by', + 'created_by', + 'updated_at', 'created_at', ], ]) ?> diff --git a/erp24/views/analysts-business-operations/index.php b/erp24/views/analysts-business-operations/index.php index 7f385452..a68c9f51 100644 --- a/erp24/views/analysts-business-operations/index.php +++ b/erp24/views/analysts-business-operations/index.php @@ -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, diff --git a/erp24/views/analysts-business-operations/view.php b/erp24/views/analysts-business-operations/view.php index b32a733c..f472ee34 100644 --- a/erp24/views/analysts-business-operations/view.php +++ b/erp24/views/analysts-business-operations/view.php @@ -33,6 +33,7 @@ $this->params['breadcrumbs'][] = $this->title; 'name', 'type', 'type_id', + 'active', 'created_at', ], ]) ?>