From 4707752033d6259b207cd3caad0ce19374428b1e Mon Sep 17 00:00:00 2001 From: fomichev Date: Fri, 11 Apr 2025 17:00:02 +0300 Subject: [PATCH] =?utf8?q?=D0=9F=D0=BE=D0=BB=D1=83=D1=87=D0=B5=D0=BD=D0=B8?= =?utf8?q?=D0=B5=20=D0=B1=D1=83=D0=BA=D0=B5=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/controllers/BouquetController.php | 8 +++++++ erp24/services/StorePlanService.php | 28 +++++++++++++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/erp24/controllers/BouquetController.php b/erp24/controllers/BouquetController.php index 0309da31..86087582 100644 --- a/erp24/controllers/BouquetController.php +++ b/erp24/controllers/BouquetController.php @@ -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(); + + } } diff --git a/erp24/services/StorePlanService.php b/erp24/services/StorePlanService.php index 10bdd8e2..25382b77 100755 --- a/erp24/services/StorePlanService.php +++ b/erp24/services/StorePlanService.php @@ -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(); + } + + } -- 2.39.5