]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-310] проценты
authorAlexander Smirnov <fredeom@mail.ru>
Tue, 4 Mar 2025 09:57:58 +0000 (12:57 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Tue, 4 Mar 2025 09:57:58 +0000 (12:57 +0300)
erp24/controllers/CategoryPlanController.php
erp24/controllers/MatrixStatisticsController.php
erp24/views/matrix-statistics/index.php

index 3658d954efed4b627e5630632efbaed873e03836..bec963648c1c2bc84c6b0f45dd46e84fb1e88349 100644 (file)
@@ -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;
index 21ef47fd2fdbabf6c1330c001324b55112cea4c4..ca8e8b32230e11dd934241069fc12538ad3de513 100644 (file)
@@ -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() {
index 167089f95f25d0a0a7c0910791038e09c6777143..0ffe287ec7ac68515199a1a51e82a0e1c0d1a4c0 100644 (file)
@@ -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\
     </div>
     <div class="row">
         <div class="col-1 text-right">% цели магазина</div>
-        <div class="col-2">27%</div>
+        <div class="col-2"><?= number_format($withoutMatrix > 0 ? $total * 100.0 / $withoutMatrix : 0, 0, '.', ' ')?>%</div>
     </div>
     <div class="row">
         <div class="col-1 text-right">% цели матрицы</div>
-        <div class="col-2">-3%</div>
+        <div class="col-2"><?= number_format($withOnlyMatrix > 0 ? $total * 100.0 / $withOnlyMatrix : 0, 0, '.', ' ')?>%</div>
     </div>
 
     <div class="row">