]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Выгрузка в учсуд
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Tue, 18 Feb 2025 06:54:08 +0000 (09:54 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Tue, 18 Feb 2025 06:54:08 +0000 (09:54 +0300)
erp24/composer.json
erp24/config/web.php
erp24/views/products1c-nomenclature/index.php

index ec2445cc15904742c448d2f728edca1e42877719..02825c64541a8462f937c85d4526eb109a6bc5b5 100644 (file)
@@ -38,7 +38,8 @@
         "enqueue/amqp-lib": "^0.10.19",
         "vlucas/phpdotenv": "^5.6",
         "softark/yii2-dual-listbox": "^1.0",
-        "kartik-v/yii2-widget-depdrop": "dev-master"
+        "kartik-v/yii2-widget-depdrop": "dev-master",
+        "kartik-v/yii2-export": "@dev"
     },
     "require-dev": {
         "yiisoft/yii2-debug": "~2.1.0",
index 5046e664ae7fed4cb63d125f3e805845bcb96842..874a787cffbab6fa48529b26386c64cf4b859def 100644 (file)
@@ -18,7 +18,8 @@ $config = [
     ],
     'modules' => [
         'gridview' => [
-            'class' => '\kartik\grid\Module'
+            'class' => '\kartik\grid\Module',
+            'downloadAction' => 'gridview/export/download',
         ],
         'crud' => [
             'class' => \yii\base\Module::class,
index 815e5d1cbe2049279e84eb9f724a28c9a61b14b4..b68c2ae173df71d2ff77bee4e10fa164cf344cb3 100644 (file)
@@ -1,5 +1,6 @@
 <?php
 
+use kartik\export\ExportMenu;
 use kartik\grid\ActionColumn;
 use kartik\grid\GridView;
 use kartik\grid\SerialColumn;
@@ -18,33 +19,72 @@ $this->params['breadcrumbs'][] = $this->title;
 
     <h1><?= Html::encode($this->title) ?></h1>
 
+    <?php
+    $gridColumns = [
+        ['class' => SerialColumn::class],
+        'id',
+        'location',
+        'name',
+        'type_num',
+        'category',
+        'subcategory',
+        'species',
+        'sort',
+        'type',
+        'size',
+        'measure',
+        'color',
+        [
+            'class' => ActionColumn::class,
+            'header' => 'Действия',
+            'template' => '{view}',
+            'urlCreator' => function ($action, Products1cNomenclature $model, $key, $index, $column) {
+                return Url::toRoute([$action, 'id' => $model->id]);
+            }
+        ],
+    ];
+    $exportMenu = ExportMenu::widget([
+        'dataProvider' => $dataProvider,
+        'columns' => $gridColumns,
+        'exportConfig' => [
+            ExportMenu::FORMAT_EXCEL => [
+                'label' => 'Excel',
+                'filename' => 'export_' . date('Y-m-d'),
+            ],
+        ],
+        'dropdownOptions' => [
+            'label' => 'Экспорт данных',
+            'class' => 'btn btn-secondary',
+        ],
+    ]); ?>
+
     <?= GridView::widget([
         'dataProvider' => $dataProvider,
         'filterModel' => $searchModel,
 
-        'columns' => [
-            ['class' => SerialColumn::class],
-            'id',
-            'location',
-            'name',
-            'type_num',
-            'category',
-            'subcategory',
-            'species',
-            'sort',
-            'type',
-            'size',
-            'measure',
-            'color',
-            [
-                'class' => ActionColumn::class,
-
-                'template' => '{view}',
-                'urlCreator' => function ($action, Products1cNomenclature $model, $key, $index, $column) {
-                    return Url::toRoute([$action, 'id' => $model->id]);
-                }
+        'columns' => $gridColumns,
+        'export' => [
+            'label' => 'Экспорт',
+            'header' => '<li role="presentation" class="dropdown-header">Экспорт страницы</li>',
+            'fontAwesome' => false,
+            'showConfirmAlert' => false,
+            'target' => GridView::TARGET_BLANK,
+        ],
+        'exportConfig' => [
+            GridView::EXCEL => [
+                'label' => 'Excel',
+                'icon' => 'file-excel',
+                'filename' => 'export_' . date('Y-m-d'),
+                'options' => ['title' => 'Сохранить в Excel'],
             ],
         ],
+        'toolbar' => [
+            '{export}',
+                    ],
+        'panel' => [
+            'type' => GridView::TYPE_SECONDARY,
+            'heading' => '<h3 class="panel-title">Список товаров</h3>',
+        ],
     ]);  ?>