From: fomichev Date: Fri, 16 May 2025 13:24:42 +0000 (+0300) Subject: Экспорт данных X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=ee9ff5bc21b85e8e7adafe14e6f1f630d2ecd65a;p=erp24_rep%2Fyii-erp24%2F.git Экспорт данных --- diff --git a/erp24/controllers/BouquetController.php b/erp24/controllers/BouquetController.php index 79d38467..e5feba46 100644 --- a/erp24/controllers/BouquetController.php +++ b/erp24/controllers/BouquetController.php @@ -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]) diff --git a/erp24/views/bouquet/month-goal-forecast.php b/erp24/views/bouquet/month-goal-forecast.php index 3026eb77..727e0199 100644 --- a/erp24/views/bouquet/month-goal-forecast.php +++ b/erp24/views/bouquet/month-goal-forecast.php @@ -1,11 +1,10 @@ Url::to(['bouquet/month-goal-forecast']), - 'method' => 'post', + 'method' => 'get', ]); ?> 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' => '', -// ], + ]) ?> @@ -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, -// ], ]); ?>