]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
fix code problems
authorvladfo <fvv2011@gmail.com>
Mon, 22 Jul 2024 15:33:17 +0000 (18:33 +0300)
committervladfo <fvv2011@gmail.com>
Mon, 22 Jul 2024 15:33:17 +0000 (18:33 +0300)
erp24/actions/motivation/BaseMotivationAction.php [new file with mode: 0644]
erp24/actions/motivation/DeleteValueAction.php
erp24/actions/motivation/UpdateValueAction.php
erp24/migrations/m240719_090134_create_motivation_values_table.php [deleted file]
erp24/migrations/m240722_054604_create_motivation_costs_items_table.php
erp24/views/motivation/values.php

diff --git a/erp24/actions/motivation/BaseMotivationAction.php b/erp24/actions/motivation/BaseMotivationAction.php
new file mode 100644 (file)
index 0000000..6a58342
--- /dev/null
@@ -0,0 +1,18 @@
+<?php
+
+namespace yii_app\actions\motivation;
+
+use yii\base\Action;
+use yii_app\records\MotivationCostsItem;
+use yii\web\NotFoundHttpException;
+
+abstract class BaseMotivationAction extends Action
+{
+    protected function findModel($id)
+    {
+        if (($model = MotivationCostsItem::findOne($id)) !== null) {
+            return $model;
+        }
+        throw new NotFoundHttpException('The requested page does not exist.');
+    }
+}
\ No newline at end of file
index d6dc6ea9e7426b1cb2c2c1334d33de9c0a20b580..54f4acbf9a79eaba4f07e44cf1ead5ae3174c7d5 100644 (file)
@@ -7,7 +7,7 @@ use yii_app\records\MotivationCostsItem;
 use yii\web\NotFoundHttpException;
 use yii\base\Action;
 
-class DeleteValueAction extends Action
+class DeleteValueAction extends BaseMotivationAction
 {
     public function run($id)
     {
@@ -16,12 +16,5 @@ class DeleteValueAction extends Action
         return $this->controller->redirect(['values']);
     }
 
-    private function findModel($id)
-    {
-        if (($model = MotivationCostsItem::findOne($id)) !== null) {
-            return $model;
-        }
-
-        throw new NotFoundHttpException('Данной записи не существует');
-    }
+    
 }
\ No newline at end of file
index 9b9ebd755774c22d365e12c28a4ce6d75b77a8c5..128cd395799680f71f4710b39b39a5ec8bfb7ad3 100644 (file)
@@ -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 (file)
index d55d37f..0000000
+++ /dev/null
@@ -1,47 +0,0 @@
-<?php
-
-use yii\db\Migration;
-
-/**
- * Handles the creation of table `{{%motivation_costs_items}}`.
- */
-
-class m240719_090134_create_motivation_values_table extends Migration
-{
-    /**
-     * {@inheritdoc}
-     */
-    public function safeUp()
-    {
-        //$this->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
index 31553f71a71d01f9d67b0d88b9d6ceb43112140e..9b1244bd24fd8fd282007f120ce92ef6a45e30ae 100644 (file)
@@ -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);
+       
     }
 
     /**
index 15f950f611d513fd7e5ff974806684da9a0c4cf4..49d58a8f7f5b3c07ac5bf8030e00897a95118d6a 100644 (file)
@@ -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',