From: fomichev Date: Fri, 11 Apr 2025 14:00:02 +0000 (+0300) Subject: Получение букетов X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=4707752033d6259b207cd3caad0ce19374428b1e;p=erp24_rep%2Fyii-erp24%2F.git Получение букетов --- 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(); + } + + }