Products1cNomenclature,
StoreType,
WriteOffsErp};
+use yii_app\services\StorePlanService;
class BouquetController extends Controller
{
return $data;
}
+
+ public function actionMonthGoal()
+ {
+ $bouquets = StorePlanService::getBouqetsByDate(5, 2025, 2);
+ var_dump($bouquets);die();
+
+ }
}
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;
use yii_app\records\Sales;
use yii_app\records\SalesProducts;
use yii_app\records\StorePlan;
+use yii_app\records\WriteOffsErp;
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();
+ }
+
+
}