From: vladfo Date: Mon, 22 Jul 2024 15:33:17 +0000 (+0300) Subject: fix code problems X-Git-Tag: 1.4~18^2^2~2 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=ed3ba8389c3c04032d2c368a1f2cc069b0a28ca0;p=erp24_rep%2Fyii-erp24%2F.git fix code problems --- diff --git a/erp24/actions/motivation/BaseMotivationAction.php b/erp24/actions/motivation/BaseMotivationAction.php new file mode 100644 index 00000000..6a58342a --- /dev/null +++ b/erp24/actions/motivation/BaseMotivationAction.php @@ -0,0 +1,18 @@ +controller->redirect(['values']); } - private function findModel($id) - { - if (($model = MotivationCostsItem::findOne($id)) !== null) { - return $model; - } - - throw new NotFoundHttpException('Данной записи не существует'); - } + } \ No newline at end of file diff --git a/erp24/actions/motivation/UpdateValueAction.php b/erp24/actions/motivation/UpdateValueAction.php index 9b9ebd75..128cd395 100644 --- a/erp24/actions/motivation/UpdateValueAction.php +++ b/erp24/actions/motivation/UpdateValueAction.php @@ -7,7 +7,7 @@ use yii_app\records\MotivationCostsItem; use yii\web\NotFoundHttpException; use yii\base\Action; -class UpdateValueAction extends Action +class UpdateValueAction extends BaseMotivationAction { public function run($id) { @@ -22,12 +22,5 @@ class UpdateValueAction extends Action ]); } - private function findModel($id) - { - if (($model = MotivationCostsItem::findOne($id)) !== null) { - return $model; - } - - throw new NotFoundHttpException('Данной записи не существует'); - } + } \ No newline at end of file diff --git a/erp24/migrations/m240719_090134_create_motivation_values_table.php b/erp24/migrations/m240719_090134_create_motivation_values_table.php deleted file mode 100644 index d55d37f6..00000000 --- a/erp24/migrations/m240719_090134_create_motivation_values_table.php +++ /dev/null @@ -1,47 +0,0 @@ -execute('SET search_path TO erp24'); - - // Создаем тип ENUM - //$this->execute("CREATE TYPE data_type_enum AS ENUM ('int', 'float', 'string')"); - - // $this->createTable('{{%motivation_values}}', [ - // 'id' => $this->primaryKey(), - // 'name' => $this->string()->notNull(), - // 'code' => $this->string()->notNull(), - // 'data_type' => "data_type_enum NOT NULL", - // 'order' => $this->integer()->notNull(), - // 'is_active' => $this->boolean()->defaultValue(true), - // 'created_at' => $this->datetime()->notNull()->comment('дата создания записи'), - // 'updated_at' => $this->datetime()->notNull()->comment('дата изменения записи'), - // ]); - - //$this->createIndex('idx-motivation_values-name', '{{%motivation_values}}', 'name', true); - } - - /** - * {@inheritdoc} - */ - public function safeDown() - { - //$this->execute('SET search_path TO erp24'); - - //$this->dropTable('{{%motivation_values}}'); - - // Удаляем тип ENUM - //$this->execute('DROP TYPE data_type_enum'); - } -} \ No newline at end of file diff --git a/erp24/migrations/m240722_054604_create_motivation_costs_items_table.php b/erp24/migrations/m240722_054604_create_motivation_costs_items_table.php index 31553f71..9b1244bd 100644 --- a/erp24/migrations/m240722_054604_create_motivation_costs_items_table.php +++ b/erp24/migrations/m240722_054604_create_motivation_costs_items_table.php @@ -28,8 +28,7 @@ class m240722_054604_create_motivation_costs_items_table extends Migration 'updated_at' => $this->datetime()->notNull()->comment('дата изменения записи'), ]); - $this->createIndex('idx-motivation_costs_items-name', '{{%motivation_costs_items}}', 'name', true); - $this->createIndex('idx-motivation_costs_items-code', '{{%motivation_costs_items}}', 'code', true); + } /** diff --git a/erp24/views/motivation/values.php b/erp24/views/motivation/values.php index 15f950f6..49d58a8f 100644 --- a/erp24/views/motivation/values.php +++ b/erp24/views/motivation/values.php @@ -22,7 +22,13 @@ $this->params['breadcrumbs'][] = $this->title; 'columns' => [ ['class' => 'yii\grid\SerialColumn'], 'name', - 'data_type', + [ + 'attribute' => 'data_type', + 'value' => function ($model) { + $dataTypeList = $model::getDataTypeList(); + return isset($dataTypeList[$model->data_type]) ? $dataTypeList[$model->data_type] : $model->data_type; + }, + ], 'code', 'order', 'is_active:boolean',