From: Alexander Smirnov Date: Fri, 28 Feb 2025 14:25:16 +0000 (+0300) Subject: [ERP-310] расчёт total 3 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=a273418e29c6e52966dfd67bf87984015b43f29b;p=erp24_rep%2Fyii-erp24%2F.git [ERP-310] расчёт total 3 --- diff --git a/erp24/controllers/MatrixStatisticsController.php b/erp24/controllers/MatrixStatisticsController.php index 65ee11a3..21ef47fd 100644 --- a/erp24/controllers/MatrixStatisticsController.php +++ b/erp24/controllers/MatrixStatisticsController.php @@ -9,6 +9,7 @@ use yii\web\Controller; use yii\web\Response; use yii_app\records\BouquetComposition; use yii_app\records\BouquetCompositionMatrixTypeHistory; +use yii_app\records\BouquetForecast; use yii_app\records\CityStore; use yii_app\records\CityStoreParams; use yii_app\records\MatrixType; @@ -38,20 +39,28 @@ class MatrixStatisticsController extends Controller { $model->load(Yii::$app->request->get()); /////////////////////////////////////////// -// $sales = Sales::find()->select(['SUM(summ) as total'])->where(['operation' => Sales::OPERATION_SALE]) -// ->andWhere(['>=', 'date', date($model->year . '-' . $model->month . '-01 00:00:00')]) -// ->andWhere(['<=', 'date', date($model->year . '-' . $model->month . '-10 23:59:59')]) -// ->asArray()->one(); $total = 0; $matrixTypes = MatrixType::find()->orderBy(['id' => SORT_ASC])->all(); $boquetCompositionMatrixTypeHistory = BouquetCompositionMatrixTypeHistory::find()->where(['is_active' => true])->all(); - $matrixCost = []; + $saleCountPlan = []; foreach ($boquetCompositionMatrixTypeHistory as $bcmth) { /** @var BouquetCompositionMatrixTypeHistory $bcmth */ - $bouquetComposition = BouquetComposition::findOne($bcmth->bouquet_id); - $cost = $bouquetComposition->getCost(); - $matrixCost[$bcmth->matrix_type_id] = ($matrixCost[$bcmth->matrix_type_id] ?? 0) + $cost; - $total += $cost; + $bouquetForecastQuery = BouquetForecast::find()->where([ + 'bouquet_id' => $bcmth->bouquet_id, + 'year' => $model->year, + 'month' => $model->month + ]); + if ($model->sale_type) { + $bouquetForecastQuery->andWhere(['type_sales' => $model->sale_type]); + } + $bouquetForecast = $bouquetForecastQuery->all(); + + foreach ($bouquetForecast as $bf) { + /** @var BouquetForecast $bf */ + $count = $bf->type_sales_value ?? 0; + $saleCountPlan[$bcmth->matrix_type_id] = ($saleCountPlan[$bcmth->matrix_type_id] ?? 0) + $count; + $total += $count; + } } /////////////////////////////////////////// $years = []; @@ -62,7 +71,7 @@ class MatrixStatisticsController extends Controller { $stores = ArrayHelper::map(CityStore::find()->andWhere(['visible' => '1'])->all(), 'id', 'name'); - return $this->render('index', compact('model', 'years', 'stores', 'total', 'matrixCost', 'matrixTypes')); + return $this->render('index', compact('model', 'years', 'stores', 'total', 'saleCountPlan', 'matrixTypes')); } public function actionGetStores() { diff --git a/erp24/views/matrix-statistics/index.php b/erp24/views/matrix-statistics/index.php index 14b7a6c8..167089f9 100644 --- a/erp24/views/matrix-statistics/index.php +++ b/erp24/views/matrix-statistics/index.php @@ -17,7 +17,7 @@ use yii_app\records\MatrixType; /* @var $years array */ /* @var $stores array */ /* @var $total float */ -/* @var $matrixCost array */ +/* @var $saleCountPlan array */ /* @var $matrixTypes array */ $this->registerJsFile('/js/matrix-statistics/index.js', ['position' => \yii\web\View::POS_END]); @@ -170,10 +170,16 @@ $this->registerJsFile('/js/matrix-statistics/index.js', ['position' => \yii\web\
-
name ?>
- id] ?? 0; ?> +
name, ['/bouquet/index' , 'matrix_type_id' => $matrixType->id], ['class' => 'btn btn-link']) ?>
+ id] ?? 0; ?>
р.
%
+
+
+
+ 'btn btn-success']) ?> +
+