From: Alexander Smirnov Date: Tue, 4 Mar 2025 09:57:58 +0000 (+0300) Subject: [ERP-310] проценты X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=20fc5a7a5288a47775c85fd37e99514607d064ff;p=erp24_rep%2Fyii-erp24%2F.git [ERP-310] проценты --- diff --git a/erp24/controllers/CategoryPlanController.php b/erp24/controllers/CategoryPlanController.php index 3658d954..bec96364 100644 --- a/erp24/controllers/CategoryPlanController.php +++ b/erp24/controllers/CategoryPlanController.php @@ -138,7 +138,7 @@ class CategoryPlanController extends Controller { ///////////////////////////////////////////////////////////////////////////////////// foreach ($types as $type) { - if (!isset($categoryPlan[$type])) { + if (!empty($type) && !isset($categoryPlan[$type])) { $categoryPlanNew = new CategoryPlan; $categoryPlanNew->year = $model->year; $categoryPlanNew->month = $model->month; diff --git a/erp24/controllers/MatrixStatisticsController.php b/erp24/controllers/MatrixStatisticsController.php index 21ef47fd..ca8e8b32 100644 --- a/erp24/controllers/MatrixStatisticsController.php +++ b/erp24/controllers/MatrixStatisticsController.php @@ -10,6 +10,7 @@ use yii\web\Response; use yii_app\records\BouquetComposition; use yii_app\records\BouquetCompositionMatrixTypeHistory; use yii_app\records\BouquetForecast; +use yii_app\records\CategoryPlan; use yii_app\records\CityStore; use yii_app\records\CityStoreParams; use yii_app\records\MatrixType; @@ -62,6 +63,25 @@ class MatrixStatisticsController extends Controller { $total += $count; } } + $categoryPlans = CategoryPlan::find()->where(['year' => $model->year, 'month' => $model->month, 'store_id' => $model->store_id])->all(); + $withoutMatrix = 0; + $withOnlyMatrix = 0; + foreach ($categoryPlans as $categoryPlan) { + /** @var $categoryPlan CategoryPlan */ + $category = $categoryPlan->category; + $sum = 0; + switch ($model->sale_type) { + case 0: $sum = $categoryPlan->offline + $categoryPlan->internet_shop + $categoryPlan->marketplace; break; + case 1: $sum = $categoryPlan->offline; break; + case 2: $sum = $categoryPlan->internet_shop; break; + case 3: $sum = $categoryPlan->marketplace; break; + } + if ($category == 'Матрица') { + $withOnlyMatrix += $sum; + } else { + $withoutMatrix += $sum; + } + } /////////////////////////////////////////// $years = []; for ($i = 3; $i >= 0; $i--) { @@ -71,7 +91,8 @@ class MatrixStatisticsController extends Controller { $stores = ArrayHelper::map(CityStore::find()->andWhere(['visible' => '1'])->all(), 'id', 'name'); - return $this->render('index', compact('model', 'years', 'stores', 'total', 'saleCountPlan', 'matrixTypes')); + return $this->render('index', compact('model', 'years', 'stores', 'total', + 'withoutMatrix', 'withOnlyMatrix', 'saleCountPlan', 'matrixTypes')); } public function actionGetStores() { diff --git a/erp24/views/matrix-statistics/index.php b/erp24/views/matrix-statistics/index.php index 167089f9..0ffe287e 100644 --- a/erp24/views/matrix-statistics/index.php +++ b/erp24/views/matrix-statistics/index.php @@ -17,6 +17,8 @@ use yii_app\records\MatrixType; /* @var $years array */ /* @var $stores array */ /* @var $total float */ +/* @var $withoutMatrix float */ +/* @var $withOnlyMatrix float */ /* @var $saleCountPlan array */ /* @var $matrixTypes array */ @@ -154,11 +156,11 @@ $this->registerJsFile('/js/matrix-statistics/index.js', ['position' => \yii\web\
% цели магазина
-
27%
+
0 ? $total * 100.0 / $withoutMatrix : 0, 0, '.', ' ')?>%
% цели матрицы
-
-3%
+
0 ? $total * 100.0 / $withOnlyMatrix : 0, 0, '.', ' ')?>%