]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-272] время создания и обновления а также кто это сделал feature_smirnov_erp-272_sales_write_offs_plan origin/feature_smirnov_erp-272_sales_write_offs_plan
authorAlexander Smirnov <fredeom@mail.ru>
Fri, 27 Dec 2024 06:51:08 +0000 (09:51 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Fri, 27 Dec 2024 06:51:08 +0000 (09:51 +0300)
erp24/controllers/SalesWriteOffsPlanController.php
erp24/migrations/m241225_131333_create_table_sales_write_offs_plan.php
erp24/records/SalesWriteOffsPlan.php

index 0afdd7187c42af1cb8165d59a8e291f4ad4a7a66..8f693165d994ee3427cd66d59766f0fb11dcd056 100644 (file)
@@ -63,12 +63,16 @@ class SalesWriteOffsPlanController extends Controller
             $salesWriteOffsPlan->year = $year;
             $salesWriteOffsPlan->month = $month;
             $salesWriteOffsPlan->store_id = $storeId;
+            $salesWriteOffsPlan->created_by = Yii::$app->user->id;
+            $salesWriteOffsPlan->created_at = date('Y-m-d H:i:s');
         }
         $salesWriteOffsPlan->total_sales_plan = $total_sales_plan;
         $salesWriteOffsPlan->write_offs_plan = $write_offs_plan;
         $salesWriteOffsPlan->offline_sales_plan = $offline_sales_plan;
         $salesWriteOffsPlan->online_sales_shop_plan = $online_sales_shop_plan;
         $salesWriteOffsPlan->online_sales_marketplace_plan = $online_sales_marketplace_plan;
+        $salesWriteOffsPlan->updated_by = Yii::$app->user->id;
+        $salesWriteOffsPlan->updated_at = date('Y-m-d H:i:s');
         $salesWriteOffsPlan->save();
         if ($salesWriteOffsPlan->getErrors()) {
             throw new \Exception(Json::encode($salesWriteOffsPlan->getErrors()));
index 6d05f5f8554705a6bdfcd565b41cb007830a1c75..95f08867efba7008a04448215ee093fc30ddc6fc 100755 (executable)
@@ -23,6 +23,10 @@ class m241225_131333_create_table_sales_write_offs_plan extends Migration
             'offline_sales_plan' => $this->float()->null()->comment('План продаж офлайн'),
             'online_sales_shop_plan' => $this->float()->null()->comment('План online продаж магазина'),
             'online_sales_marketplace_plan' => $this->float()->null()->comment('План online продаж маркетплейса'),
+            'created_at' => $this->dateTime()->notNull()->comment('Дата создания'),
+            'updated_at' => $this->dateTime()->notNull()->comment('Дата обновления'),
+            'created_by' => $this->integer()->notNull()->comment('ID создателя записи'),
+            'updated_by' => $this->integer()->notNull()->comment('ID обновителя записи'),
         ]);
     }
 
index a48c94d6a569eaafd1a4c6377e58e4ed99838910..6580092e7c964a4e71a286f47fe7d79f79ca9e5b 100644 (file)
@@ -3,6 +3,8 @@
 namespace yii_app\records;
 
 use Yii;
+use yii\behaviors\TimestampBehavior;
+use yii\db\Expression;
 
 /**
  * This is the model class for table "sales_write_offs_plan".
@@ -16,6 +18,10 @@ use Yii;
  * @property float|null $offline_sales_plan План продаж офлайн
  * @property float|null $online_sales_shop_plan План online продаж магазина
  * @property float|null $online_sales_marketplace_plan План online продаж маркетплейса
+ * @property string $created_at Дата создания
+ * @property string $updated_at Дата обновления
+ * @property int $created_by ID создателя записи
+ * @property int $updated_by ID обновителя записи
  */
 class SalesWriteOffsPlan extends \yii\db\ActiveRecord
 {
@@ -33,10 +39,23 @@ class SalesWriteOffsPlan extends \yii\db\ActiveRecord
     public function rules()
     {
         return [
-            [['year', 'month', 'store_id'], 'required'],
-            [['year', 'month', 'store_id'], 'default', 'value' => null],
-            [['year', 'month', 'store_id'], 'integer'],
+            [['year', 'month', 'store_id', 'created_at', 'updated_at', 'created_by', 'updated_by'], 'required'],
+            [['year', 'month', 'store_id', 'created_by', 'updated_by'], 'default', 'value' => null],
+            [['year', 'month', 'store_id', 'created_by', 'updated_by'], 'integer'],
             [['total_sales_plan', 'write_offs_plan', 'offline_sales_plan', 'online_sales_shop_plan', 'online_sales_marketplace_plan'], 'number'],
+            [['created_at', 'updated_at'], 'safe'],
+        ];
+    }
+
+    public function behaviors()
+    {
+        return [
+            [
+                'class' => TimestampBehavior::class,
+                'createdAtAttribute' => 'created_at',
+                'updatedAtAttribute' => 'updated_at',
+                'value' => new Expression('NOW()'),
+            ],
         ];
     }
 
@@ -55,6 +74,10 @@ class SalesWriteOffsPlan extends \yii\db\ActiveRecord
             'offline_sales_plan' => 'Offline Sales Plan',
             'online_sales_shop_plan' => 'Online Sales Shop Plan',
             'online_sales_marketplace_plan' => 'Online Sales Marketplace Plan',
+            'created_at' => 'Created At',
+            'updated_at' => 'Updated At',
+            'created_by' => 'Created By',
+            'updated_by' => 'Updated By',
         ];
     }
 }