From: Alexander Smirnov Date: Fri, 28 Feb 2025 13:15:54 +0000 (+0300) Subject: [ERP-310] расчёт total X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=96e7626ad5cca92700ce9166bba8061378727cf0;p=erp24_rep%2Fyii-erp24%2F.git [ERP-310] расчёт total --- diff --git a/erp24/controllers/MatrixStatisticsController.php b/erp24/controllers/MatrixStatisticsController.php index dfdd4173..b51514c4 100644 --- a/erp24/controllers/MatrixStatisticsController.php +++ b/erp24/controllers/MatrixStatisticsController.php @@ -7,8 +7,11 @@ use yii\base\DynamicModel; use yii\helpers\ArrayHelper; use yii\web\Controller; use yii\web\Response; +use yii_app\records\BouquetComposition; +use yii_app\records\BouquetCompositionMatrixTypeHistory; use yii_app\records\CityStore; use yii_app\records\CityStoreParams; +use yii_app\records\MatrixType; use yii_app\records\Sales; use yii_app\records\StoreDynamic; @@ -35,11 +38,21 @@ 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 = $sales['total'] ?? 0; +// $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'])->all(); + $boquetCompositionMatrixTypeHistory = BouquetCompositionMatrixTypeHistory::find()->where(['is_active' => true])->all(); + $matrixCost = []; + 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; + } /////////////////////////////////////////// $years = []; for ($i = 3; $i >= 0; $i--) { @@ -49,7 +62,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')); + return $this->render('index', compact('model', 'years', 'stores', 'total', 'matrixCost', 'matrixTypes')); } public function actionGetStores() { diff --git a/erp24/views/matrix-statistics/index.php b/erp24/views/matrix-statistics/index.php index a2ce9195..8ad87724 100644 --- a/erp24/views/matrix-statistics/index.php +++ b/erp24/views/matrix-statistics/index.php @@ -11,11 +11,14 @@ use yii_app\records\StoreCityList; use yii_app\records\Admin; use yii_app\records\AdminGroup; use yii_app\records\StoreType; +use yii_app\records\MatrixType; /* @var $model DynamicModel */ /* @var $years array */ /* @var $stores array */ /* @var $total float */ +/* @var $matrixCost array */ +/* @var $matrixTypes array */ $this->registerJsFile('/js/matrix-statistics/index.js', ['position' => \yii\web\View::POS_END]); @@ -163,34 +166,13 @@ $this->registerJsFile('/js/matrix-statistics/index.js', ['position' => \yii\web\
Сумма планируемых продаж
Доля группы матрицы
-
-
-
Базовая
-
231 250 р.
-
23%
-
-
-
-
Дополнительная
-
45 000 р.
-
4%
-
-
-
-
Изюмительная
-
700 000 р.
-
71%
-
-
-
-
Маркет Яндекс
-
0 р.
-
0 %
-
-
-
-
Маркет Флау
-
0 р.
-
0 %
-
+ + +
+
+
name ?>
+
id], 0, '.', ' ')?>р.
+
id] * 100.0 / $total, 0, '.', '')?>%
+
+