]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-310] total
authorAlexander Smirnov <fredeom@mail.ru>
Tue, 18 Feb 2025 17:01:41 +0000 (20:01 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Tue, 18 Feb 2025 17:01:41 +0000 (20:01 +0300)
erp24/controllers/MatrixStatisticsController.php
erp24/views/matrix-statistics/index.php

index cbd605d853651e702f4506ee0cd3c6b6114ed47d..dfdd4173daed722e78069d99e32d52a8794f86d4 100644 (file)
@@ -35,10 +35,11 @@ class MatrixStatisticsController extends Controller {
         $model->load(Yii::$app->request->get());
 
         ///////////////////////////////////////////
-        $sales = Sales::find()->where(['operation' => Sales::OPERATION_SALE])
+        $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 . '-t 23:59:59')])
-            ->all();
+            ->andWhere(['<=', 'date', date($model->year . '-' . $model->month . '-10 23:59:59')])
+            ->asArray()->one();
+        $total = $sales['total'] ?? 0;
         ///////////////////////////////////////////
         $years = [];
         for ($i = 3; $i >= 0; $i--) {
@@ -48,7 +49,7 @@ class MatrixStatisticsController extends Controller {
         $stores = ArrayHelper::map(CityStore::find()->andWhere(['visible' => '1'])->all(), 'id', 'name');
 
 
-        return $this->render('index', compact('model', 'years', 'stores'));
+        return $this->render('index', compact('model', 'years', 'stores', 'total'));
     }
 
     public function actionGetStores() {
index 12d558ede6c13f3d8d73bcaf314b4e1519842367..a2ce919537426e6211c101f0eab019503c8f3fc7 100644 (file)
@@ -15,7 +15,7 @@ use yii_app\records\StoreType;
 /* @var $model DynamicModel */
 /* @var $years array */
 /* @var $stores array */
-
+/* @var $total float */
 
 $this->registerJsFile('/js/matrix-statistics/index.js', ['position' => \yii\web\View::POS_END]);
 
@@ -147,7 +147,7 @@ $this->registerJsFile('/js/matrix-statistics/index.js', ['position' => \yii\web\
 
     <div class="row">
         <div class="col-1 text-right">Сумма тотал</div>
-        <div class="col-2">976 250 р</div>
+        <div class="col-2"><?= number_format($total, 0, '.', ' ')?>р</div>
     </div>
     <div class="row">
         <div class="col-1 text-right">% цели магазина</div>