]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-302 Редактирование букета
authormarina <m.zozirova@gmail.com>
Tue, 11 Feb 2025 08:30:16 +0000 (11:30 +0300)
committermarina <m.zozirova@gmail.com>
Tue, 11 Feb 2025 08:30:16 +0000 (11:30 +0300)
erp24/controllers/BouquetController.php
erp24/migrations/m250211_064121_create_bouquet_forecast_table.php [new file with mode: 0644]
erp24/records/BouquetForecast.php [new file with mode: 0644]

index 502574908f5bd4ff110acd63588019d5813c7b26..4851bc0fb9ec6e72410ef6b47f944dc77ae477ef 100644 (file)
@@ -10,6 +10,7 @@ use yii\web\NotFoundHttpException;
 use yii\web\UploadedFile;
 use yii_app\records\BouquetComposition;
 use yii_app\records\BouquetCompositionProducts;
+use yii_app\records\BouquetForecast;
 use yii_app\records\CityStore;
 use yii_app\records\Products1c;
 use yii_app\records\Products1cNomenclature;
@@ -25,10 +26,12 @@ class BouquetController extends Controller
         return $this->render('index');
     }
 
-    public function actionView()
+    public function actionView($id)
     {
-        $storesTypeList =  ArrayHelper::map(StoreType::find()->orderBy('sequence_number')->all(), 'id', 'name');
-        $storesList = ArrayHelper::map(CityStore::findAll(['visible' => CityStore::IS_VISIBLE]), 'id', 'name');
+
+        BouquetForecast::findAll(['bouquet_id' => $id]);
+        $storesTypeList =  ArrayHelper::map(BouquetForecast::findAll(['bouquet_id' => $id]) ?? StoreType::find()->orderBy('sequence_number')->all(), 'id', 'name');
+        $storesList = ArrayHelper::map(BouquetForecast::findAll(['bouquet_id' => $id]) ?? CityStore::findAll(['visible' => CityStore::IS_VISIBLE]), 'id', 'name');
 
         return $this->render('view', [
             'storesList' => $storesList,
diff --git a/erp24/migrations/m250211_064121_create_bouquet_forecast_table.php b/erp24/migrations/m250211_064121_create_bouquet_forecast_table.php
new file mode 100644 (file)
index 0000000..4037f70
--- /dev/null
@@ -0,0 +1,37 @@
+<?php
+
+use yii\db\Migration;
+
+/**
+ * Handles the creation of table `{{%bouquet_forecast}}`.
+ */
+class m250211_064121_create_bouquet_forecast_table extends Migration
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function safeUp()
+    {
+        $this->createTable('{{%bouquet_forecast}}', [
+            'id' => $this->primaryKey(),
+            'bouquet_id' => $this->integer()->comment('ИД букета'),
+            'year' => $this->integer()->comment('Год'),
+            'month' => $this->integer()->comment('Месяц'),
+            'type_sales' => $this->integer()->comment('Тип продаж'),
+            'store_sales_id' => $this->integer()->comment('ИД сущности типа продаж'),
+            'value' => $this->float('Значение'),
+            'created_at' => $this->dateTime()->comment('Дата создания'),
+            'updated_at' => $this->dateTime()->comment('Дата обновления'),
+            'created_by' => $this->integer()->comment('ID создателя записи'),
+            'updated_by' => $this->integer()->comment('ID обновителя записи'),
+        ]);
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function safeDown()
+    {
+        $this->dropTable('{{%bouquet_forecast}}');
+    }
+}
diff --git a/erp24/records/BouquetForecast.php b/erp24/records/BouquetForecast.php
new file mode 100644 (file)
index 0000000..be9c4f5
--- /dev/null
@@ -0,0 +1,69 @@
+<?php
+
+namespace yii_app\records;
+
+use Yii;
+use yii\db\ActiveRecord;
+
+/**
+ * This is the model class for table "bouquet_forecast".
+ *
+ * @property int $id
+ * @property int|null $bouquet_id ИД букета
+ * @property int|null $year Год
+ * @property int|null $month Месяц
+ * @property int|null $type_sales Тип продаж
+ * @property int|null $store_sales_id ИД сущности типа продаж
+ * @property float|null $value Значение
+ * @property string|null $created_at Дата создания
+ * @property string|null $updated_at Дата обновления
+ * @property int|null $created_by ID создателя записи
+ * @property int|null $updated_by ID обновителя записи
+ */
+class BouquetForecast extends ActiveRecord
+{
+
+    public const OFFLINE_STORES = 1;
+    public const ONLINE_STORES = 2;
+    public const MARKETPLACE = 3;
+
+    /**
+     * {@inheritdoc}
+     */
+    public static function tableName()
+    {
+        return '{{%bouquet_forecast}}';
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['bouquet_id', 'year', 'month', 'type_sales', 'store_sales_id', 'created_by', 'updated_by'], 'integer'],
+            [['value'], 'number'],
+            [['created_at', 'updated_at'], 'safe'],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function attributeLabels()
+    {
+        return [
+            'id' => 'ID',
+            'bouquet_id' => 'ИД букета',
+            'year' => 'Год',
+            'month' => 'Месяц',
+            'type_sales' => 'Тип продаж',
+            'store_sales_id' => 'ИД сущности типа продаж',
+            'value' => 'Значение',
+            'created_at' => 'Дата создания',
+            'updated_at' => 'Дата обновления',
+            'created_by' => 'ID создателя записи',
+            'updated_by' => 'ID обновителя записи',
+        ];
+    }
+}