]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Экспорт данных
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Fri, 16 May 2025 13:24:42 +0000 (16:24 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Fri, 16 May 2025 13:24:42 +0000 (16:24 +0300)
erp24/controllers/BouquetController.php
erp24/views/bouquet/month-goal-forecast.php

index 79d3846760cdaa28afaeca05e87ddc85906fa36e..e5feba46e61a485775eaa0680c780fe690ea0a03 100644 (file)
@@ -304,35 +304,34 @@ class BouquetController extends Controller
     public function actionMonthGoalForecast()
     {
         $request = Yii::$app->request;
-        $post = $request->post();
-        $month = $post['DynamicModel']['month'] ?? 5;
-        $year = $post['DynamicModel']['year'] ?? 2025;
-        $storeId = $post['DynamicModel']['storeId'] ?? 2;
-        $matrix = $post['DynamicModel']['matrix'] ?? [];
+        $params = array_merge(
+            $request->get('DynamicModel', []),
+            $request->post('DynamicModel', [])
+        );
+
+        $month   = $params['month']   ?? 5;
+        $year    = $params['year']    ?? 2025;
+        $storeId = $params['storeId'] ?? 2;
+        $matrix  = $params['matrix']  ?? [];
 
         $model = DynamicModel::validateData(
-            ['month' => $month, 'year' => $year, 'storeId' => $storeId, 'matrix' => $matrix],
+            ['month'=>$month, 'year'=>$year, 'storeId'=>$storeId, 'matrix'=>$matrix],
             [
-                ['matrix', 'each', 'rule' => ['string']],
-                [['month', 'year', 'storeId'], 'required'],
-                ['month', 'integer', 'min' => 1, 'max' => 12],
-                ['storeId', 'integer', 'min' => 1, 'max' => 100],
-                ['year', 'integer', 'min' => 2000, 'max' => 2100],
+                ['matrix', 'each', 'rule'=>['string']],
+                [['month','year','storeId'], 'required'],
+                ['month','integer','min'=>1,'max'=>12],
+                ['storeId','integer','min'=>1],
+                ['year','integer','min'=>2000,'max'=>2100],
             ]
         );
 
-        if ($request->isPost && $model->validate()) {
-            $month = $model->month;
-            $year  = $model->year;
-            $storeId  = $model->storeId;
-        } else {
-            $model->month = $month;
-            $model->year  = $year;
-            $model->storeId  = $storeId;
-        }
+        $model->month   = $month;
+        $model->year    = $year;
+        $model->storeId = $storeId;
+        $model->matrix  = $matrix;
 
                $result = StorePlanService::getBouquetSpiecesMonthGoalFromForecast($month, $year, $storeId, $matrix);
-//var_dump($result); die();
+
         $stores = CityStore::find()
             ->select(['id', 'name'])
             ->where(['visible' => CityStore::IS_VISIBLE])
index 3026eb771e962584f77ad65b6180b21bed4101b0..727e0199608edc1af654131ce488ab43b5724fa5 100644 (file)
@@ -1,11 +1,10 @@
 <?php
-
+use kartik\export\ExportMenu;
 use kartik\grid\GridView;
-use kartik\select2\Select2;
 use yii\helpers\Html;
 use yii\helpers\Url;
 use yii\widgets\ActiveForm;
-use kartik\export\ExportMenu;
+
 use yii\data\ArrayDataProvider;
 
 /* @var $model yii\base\DynamicModel */
@@ -29,7 +28,7 @@ $saleTypesLabels = [
 
         <?php $form = ActiveForm::begin([
             'action' => Url::to(['bouquet/month-goal-forecast']),
-            'method' => 'post',
+            'method' => 'get',
         ]); ?>
 
         <?= $form->field($model, 'month')->input('number')->label('Месяц') ?>
@@ -144,39 +143,7 @@ $saleTypesLabels = [
                         ['attribute' => 'raw_calculation',  'label' => 'Базовый расчёт'],
                         ['attribute' => 'rounded',          'label' => 'С наценкой за сборку'],
                     ],
-//                    'export' => [
-//                        'fontAwesome' => true
-//                    ],
-//                    'exportConfig' => [
-//                        'html' => [],
-//                        'csv' => [
-//                                'label' => Yii::t('kvgrid', 'CSV'),
-//                            'icon' => '',
-//                            'iconOptions' => ['class' => 'text-primary'],
-//                            'showHeader' => true,
-//                            'showPageSummary' => true,
-//                            'showFooter' => true,
-//                            'showCaption' => true,
-//                            'filename' => Yii::t('kvgrid', 'grid-export'),
-//                            'alertMsg' => Yii::t('kvgrid', 'The CSV export file will be generated for download.'),
-//                            'options' => ['title' => Yii::t('kvgrid', 'Comma Separated Values')],
-//                            'mime' => 'application/csv',
-//                            'config' => [
-//                                'colDelimiter' => ",",
-//                                'rowDelimiter' => "\r\n",
-//                                ],
-//                            ],
-//                        'txt' => [],
-//                        'xls' => [],
-//                        'pdf' => [],
-//                        'json' => [],
-//                    ],
-//                    'panel' => [
-//                        'after' => '',
-//                        'heading' =>  Html::encode($storesMap[$storeId] ?? $storeId) ,
-//                        'type' => 'primary',
-//                        'before' => '',
-//                    ],
+
                 ]) ?>
             <?php endforeach; ?>
         <?php endforeach; ?>
@@ -212,6 +179,8 @@ $saleTypesLabels = [
         'allModels'  => $flattenedDebug,
         'pagination' => false,
     ]);
+    $fullDataProvider = clone $debugProvider;
+    $fullDataProvider->pagination = false;
     $gridColumns = [
         ['attribute' => 'month',           'label' => 'Месяц'],
         ['attribute' => 'year',            'label' => 'Год'],
@@ -241,7 +210,7 @@ $saleTypesLabels = [
             ['attribute' => 'rounded',         'label' => 'С наценкой за сборку'],
         ];
     $exportMenu = ExportMenu::widget([
-        'dataProvider' => $debugProvider,
+        'dataProvider' => $fullDataProvider,
         'columns' => $gridColumns,
         'exportConfig' => [
             ExportMenu::FORMAT_EXCEL => [
@@ -266,38 +235,6 @@ $saleTypesLabels = [
     echo GridView::widget([
         'dataProvider' => $debugProvider,
         'columns' =>  $gridColumns,
-//        'exportConfig' => [
-//            GridView::CSV => [
-//                'label' => 'CSV',
-//                'icon' => 'glyphicon glyphicon-download',
-//                'iconOptions' => ['class' => 'text-primary'],
-//                'showHeader' => true,
-//                'showPageSummary' => false,
-//                'showFooter' => false,
-//                'filename' => 'debug-export-' . date('Y-m-d_H-i-s'),
-//                'alertMsg' => 'CSV файл будет загружен в ближайшее время.',
-//                'options' => ['title' => 'CSV'],
-//                'mime' => 'application/csv',
-//                'config' => [
-//                    'colDelimiter' => ",",
-//                    'rowDelimiter' => "\r\n",
-//                ],
-//            ],
-//            // Другие типы экспорта можно отключить, если не нужны:
-//            GridView::HTML => false,
-//            GridView::TEXT => false,
-//            GridView::EXCEL => false,
-//            GridView::PDF => false,
-//            GridView::JSON => false,
-//        ],
-//        'toolbar' => [
-//            '{export}',
-//            '{toggleData}',
-//        ],
-//        'panel' => [
-//            'heading' => 'Детальный разбор (Debug) по всем магазинам',
-//            'type' => GridView::TYPE_PRIMARY,
-//        ],
     ]);
 
      ?>