From 4ab8dfde5bc4b3eba83019b02e18d6a1e0dd707c Mon Sep 17 00:00:00 2001 From: fomichev Date: Wed, 16 Apr 2025 15:49:32 +0300 Subject: [PATCH] =?utf8?q?=D0=AD=D0=BA=D1=81=D0=BF=D0=BE=D1=80=D1=82=20?= =?utf8?q?=D0=B2=20=D1=8D=D0=BA=D1=81=D0=B5=D0=BB=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/views/bouquet/month-goal.php | 120 ++++++++++++++++++++++++++++- 1 file changed, 119 insertions(+), 1 deletion(-) diff --git a/erp24/views/bouquet/month-goal.php b/erp24/views/bouquet/month-goal.php index b030367c..3ea81784 100644 --- a/erp24/views/bouquet/month-goal.php +++ b/erp24/views/bouquet/month-goal.php @@ -4,7 +4,7 @@ use kartik\grid\GridView; 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 */ @@ -18,6 +18,7 @@ $saleTypesLabels = [ 2 => 'Интернет магазины', 3 => 'Маркетплейсы', ]; + ?>

Цели букета на месяц: /

@@ -170,4 +171,121 @@ $saleTypesLabels = [

Нет данных.

+ +

Детальный разбор по всем магазинам

+ $speciesData) { + foreach ($speciesData as $species => $saleTypes) { + foreach ($saleTypes as $saleType => $entries) { + foreach ($entries as $entry) { + $entry['month'] = $month; + $entry['year'] = $year; + $entry['store_id'] = $storeId; + $entry['store_name'] = isset($storesMap[$storeId]) ? $storesMap[$storeId] : $storeId; + $entry['species'] = $species; + $entry['sale_type'] = $saleType; + $entry['sale_type_label']= isset($saleTypesLabels[$saleType]) ? $saleTypesLabels[$saleType] : $saleType; + $flattenedDebug[] = $entry; + } + } + } + } + } + $debugProvider = new ArrayDataProvider([ + 'allModels' => $flattenedDebug, + 'pagination' => false, + ]); + $gridColumns = [ + ['attribute' => 'month', 'label' => 'Месяц'], + ['attribute' => 'year', 'label' => 'Год'], + ['attribute' => 'store_name', 'label' => 'Магазин'], + ['attribute' => 'species', 'label' => 'Вид продукции'], + ['attribute' => 'sale_type_label', 'label' => 'Тип продаж'], + [ + 'attribute' => 'product_guid', + 'label' => 'Product GUID', + 'value' => function ($model, $key, $index, $widget) { + $product = \yii_app\records\Products1c::find()->where(['id' => $model['product_guid']])->one(); + return $product ? $product->name . " (" . $model['product_guid'] . ")" : $model['product_guid']; + } + ], + [ + 'attribute' => 'bouquet_id', + 'label' => 'Букет', + 'value' => function ($model, $key, $index, $widget) { + $bouquet = \yii_app\records\BouquetComposition::find()->where(['id' => $model['bouquet_id']])->one(); + return $bouquet ? $bouquet->name : $model['bouquet_id']; + } + ], + ['attribute' => 'price', 'label' => 'Цена'], + ['attribute' => 'count', 'label' => 'Кол-во'], + ['attribute' => 'forecast', 'label' => 'Прогноз'], + ['attribute' => 'raw_calculation', 'label' => 'Базовый расчёт'], + ['attribute' => 'rounded', 'label' => 'С наценкой за сборку'], + ]; + $exportMenu = ExportMenu::widget([ + 'dataProvider' => $debugProvider, + 'columns' => $gridColumns, + 'exportConfig' => [ + ExportMenu::FORMAT_EXCEL => [ + 'label' => 'Excel', + 'options' => ['title' => 'Сохранить в Excel'], + ], + ExportMenu::FORMAT_TEXT => false, + ExportMenu::FORMAT_HTML => false, + ExportMenu::FORMAT_CSV => false, + ExportMenu::FORMAT_PDF => false, + + ], + 'filename' => 'export_' . date('Y-m-d'), + 'showColumnSelector' => false, + 'showConfirmAlert' => false, + 'target' => ExportMenu::TARGET_SELF, + 'dropdownOptions' => [ + 'label' => 'Экспорт данных', + ], + ]); + echo $exportMenu; + 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, +// ], + ]); + + ?> +
-- 2.39.5