]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Получение букетов
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Fri, 11 Apr 2025 14:00:02 +0000 (17:00 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Fri, 11 Apr 2025 14:00:02 +0000 (17:00 +0300)
erp24/controllers/BouquetController.php
erp24/services/StorePlanService.php

index 0309da311986b9d37a6618b5b19d460e35d62073..86087582031e4629a2321e7c1b0d42ac8b0b8ec3 100644 (file)
@@ -21,6 +21,7 @@ use yii_app\records\{BouquetComposition,
     Products1cNomenclature,
     StoreType,
     WriteOffsErp};
+use yii_app\services\StorePlanService;
 
 class BouquetController extends Controller
 {
@@ -247,4 +248,11 @@ class BouquetController extends Controller
 
         return $data;
     }
+
+    public function actionMonthGoal()
+    {
+        $bouquets = StorePlanService::getBouqetsByDate(5, 2025, 2);
+        var_dump($bouquets);die();
+
+    }
 }
index 10bdd8e29af713992822b0e6900b6064ff0192a0..25382b77fedd0a623d926507710ef0ecff8f8965 100755 (executable)
@@ -5,6 +5,7 @@ namespace yii_app\services;
 use DateTime;
 use yii\db\Expression;
 use yii\helpers\ArrayHelper;
+use yii_app\records\BouquetComposition;
 use yii_app\records\CityStore;
 use yii_app\records\Motivation;
 use yii_app\records\PricesDynamic;
@@ -12,6 +13,7 @@ use yii_app\records\Products1cAdditionalCharacteristics;
 use yii_app\records\Sales;
 use yii_app\records\SalesProducts;
 use yii_app\records\StorePlan;
+use yii_app\records\WriteOffsErp;
 
 class StorePlanService
 {
@@ -748,5 +750,31 @@ class StorePlanService
         ];
     }
 
+
+    public static function getBouqetsByDate($month, $year, $matrix_type = null) {
+        $query = BouquetComposition::find()
+            ->orderBy(['id' => SORT_DESC])
+            ->groupBy('bouquet_composition.id')
+            ->andWhere(['status' => [
+                WriteOffsErp::STATUS_CREATED_1С,
+
+            ]])
+            ->joinWith('bouquetForecast as bf')
+            ->andWhere(['bf.year' => $year])
+            ->andWhere(['bf.month' => $month]);
+
+        if ($matrix_type) {
+            $query->leftJoin(
+                'erp24.bouquet_composition_matrix_type_history mth', // Добавили схему
+                'mth.bouquet_id = bouquet_composition.id'
+            )->andWhere([
+                'mth.matrix_type_id' => $matrix_type,
+                'mth.is_active' => true // Используем true без константы
+            ]);
+        }
+        return $query->all();
+    }
+
+
 }