From: Vladimir Fomichev Date: Tue, 9 Sep 2025 13:21:08 +0000 (+0300) Subject: Добавление кнопок архивации X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=3af7d0160ee77a31bc629893720262b0b3b3b547;p=erp24_rep%2Fyii-erp24%2F.git Добавление кнопок архивации --- diff --git a/erp24/controllers/MatrixBouquetActualityController.php b/erp24/controllers/MatrixBouquetActualityController.php index 4256f036..6468a78f 100644 --- a/erp24/controllers/MatrixBouquetActualityController.php +++ b/erp24/controllers/MatrixBouquetActualityController.php @@ -13,10 +13,7 @@ use yii\web\Controller; use yii\web\NotFoundHttpException; use yii\filters\VerbFilter; use yii_app\records\MatrixType; -use yii_app\records\Products1cAdditionalCharacteristics; -use yii_app\records\Products1cNomenclature; -use yii_app\records\Products1cNomenclatureActuality; -use yii_app\records\Products1cPropType; + /** * MatrixBouquetActualityController implements the CRUD actions for MatrixBouquetActuality model. @@ -198,22 +195,38 @@ class MatrixBouquetActualityController extends Controller }]); } + $bouquets = $query->orderBy(['bc.name' => SORT_ASC])->all(); + + $rows = []; + foreach ($bouquets as $bouquet) { + $acts = $bouquet->actualities; + if ($acts) { + foreach ($acts as $act) { + $rows[] = [ + 'product' => $bouquet, + 'actuality' => $act, + ]; + } + } else { + $rows[] = [ + 'product' => $bouquet, + 'actuality' => null, + ]; + } + } + - $dataProvider = new ActiveDataProvider([ - 'query' => $query->orderBy(['bc.name' => SORT_ASC]), - 'pagination' => ['pageSize' => 100], + $dataProvider = new \yii\data\ArrayDataProvider([ + 'allModels' => $rows, + 'pagination' => ['pageSize' => 1000], 'sort' => [ 'attributes' => [ - 'name' => [ - 'asc' => ['bc.name' => SORT_ASC], - 'desc' => ['bc.name' => SORT_DESC], - ], - 'price' => [ - 'asc' => ['price' => SORT_ASC], - 'desc' => ['price' => SORT_DESC], - ], + 'product.name', + 'product.price', + 'actuality.date_from', + 'actuality.date_to' ], - 'defaultOrder' => ['name' => SORT_ASC], + 'defaultOrder' => ['product.name' => SORT_ASC], ], ]); } @@ -232,7 +245,7 @@ class MatrixBouquetActualityController extends Controller ->andWhere(['<>', 'deleted', 1]) ->orderBy(['name' => SORT_ASC]) ->asArray()->all(); - var_dump($dataProvider);die(); + return $this->render('index', [ 'filter' => $filter, 'dataProvider' => $dataProvider, diff --git a/erp24/views/matrix-bouquet-actuality/index.php b/erp24/views/matrix-bouquet-actuality/index.php index db2dfacc..26c733a6 100644 --- a/erp24/views/matrix-bouquet-actuality/index.php +++ b/erp24/views/matrix-bouquet-actuality/index.php @@ -10,6 +10,8 @@ use yii_app\records\Products1cNomenclatureActuality; /* @var $this yii\web\View */ /* @var $filter yii\base\DynamicModel */ /* @var $dataProvider yii\data\ActiveDataProvider */ +/* @var $groups array */ +/* @var $subgroups array */ $this->title = 'Актуализация букетов'; @@ -36,9 +38,17 @@ $monthOptions = ''; foreach ($months as $k => $v) { $monthOptions .= ""; } + +$subgroupItems = []; +$subgroupOptionAttrs = []; +foreach ($subgroups as $sg) { + $id = (string)$sg['id']; + $subgroupItems[$id] = $sg['name']; + $subgroupOptionAttrs[$id] = ['data-parent' => (string)$sg['parent_id']]; +} ?> -
+

title) ?>

@@ -57,8 +67,8 @@ foreach ($months as $k => $v) {
- field($filter, 'category', ['options' => ['class' => 'w-90']])->dropDownList( - $categories, + field($filter, 'group_id', ['options' => ['class' => 'w-90']])->dropDownList( + $groups, ['prompt' => 'Категория', 'id' => 'filter-category'] )->label(false) ?> @@ -67,37 +77,21 @@ foreach ($months as $k => $v) {
-
-
- field($filter, 'type', ['options' => ['class' => 'w-90']])->dropDownList( - $types, - ['prompt' => 'Тип', 'id' => 'filter-type'] - )->label(false) ?> -
- -
-
-
-
-
- field($filter, 'color', ['options' => ['class' => 'w-90']])->dropDownList( - $colors, - ['prompt' => 'Цвет', 'id' => 'filter-color'] - )->label(false) ?> -
- -
-
-
- field($filter, 'subcategory', ['options' => ['class' => 'w-90']])->dropDownList( - $subcategories, - ['prompt' => 'Подкатегория', 'id' => 'filter-subcategory', 'class' => 'w-100'] + field($filter, 'subgroup_id', ['options' => ['class' => 'w-90']]) + ->dropDownList( + $subgroupItems, + [ + 'prompt' => 'Подкатегория', + 'id' => 'filter-subcategory', + 'class' => 'w-100', + 'options' => $subgroupOptionAttrs, + ] )->label(false) ?>
@@ -105,42 +99,12 @@ foreach ($months as $k => $v) {
-
-
- field($filter, 'sort', ['options' => ['class' => 'w-90']])->dropDownList( - $sorts, - ['prompt' => 'Сорт', 'id' => 'filter-sort'] - )->label(false) ?> -
- -
-
-
+
-
-
- field($filter, 'species', ['options' => ['class' => 'w-90']])->dropDownList( - $species, - ['prompt' => 'Вид', 'id' => 'filter-species'] - )->label(false) ?> -
- -
-
-
-
-
- field($filter, 'size', ['options' => ['class' => 'w-90']])->dropDownList( - $sizes, - ['prompt' => 'Размер', 'id' => 'filter-size'] - )->label(false) ?> -
- -
-
-
+ +
@@ -201,26 +165,17 @@ foreach ($months as $k => $v) {
Поставщики
+ field($filter, 'is_archive')->checkbox([ + 'label' => 'Архивные', + 'uncheck' => 0, + 'checked' => (bool)$filter->is_archive, + 'id' => 'isArchiveCheckbox' + ])->label(false) ?> -
- 'form-select', 'id' => 'filter-supplier', 'prompt' => 'Поставщик']) ?> -
- -
-
-
- 'form-select', 'id' => 'filter-plantation', 'prompt' => 'Плантация']) ?> -
- -
-
+
@@ -259,16 +214,16 @@ foreach ($months as $k => $v) { 'value' => function ($row, $key, $index) { $product = $row['product']; $name = Html::encode($product->name . ' (' . $product->id . ')'); - $btn = Html::button('+ Добавить интервал', [ - 'class' => 'btn btn-xs btn-outline-primary ms-2 add-actuality-row', - 'type' => 'button', - 'title' => 'Добавить интервал', - 'data-guid' => $product->id, - 'data-name' => $product->name, - ]); - return '
' . $name . $btn . '
'; + + return '
' . $name . '
'; } ], + [ + 'attribute' => 'price', + 'label' => 'Цена', + 'value' => function($row) { return $row['price']; }, + 'format' => ['decimal', 2], + ], [ 'label' => 'Актуальность ассортимента', 'format' => 'raw', @@ -306,33 +261,29 @@ foreach ($months as $k => $v) { } ], [ - 'label' => 'Склад NN', + 'label' => 'Управление', 'format' => 'raw', - 'contentOptions' => ['style'=>'width:60px; text-align:center;'], - 'value' => function ($m, $k, $i) use ($filter){ - return Html::checkbox("actuality[$i][warehouse_nn]", false, [ - + 'contentOptions' => ['style'=>'width:160px; text-align:center;'], + 'value' => function ($row, $key, $index) { + $product = $row['product']; + $btnArchOn = Html::button('+ Добавить интервал', [ + 'class' => 'btn btn-xs btn-outline-primary ms-2 add-actuality-row', + 'type' => 'button', + 'title' => 'Добавить интервал', + 'data-guid' => $product->id, + 'data-name' => $product->name, ]); - } - ], - [ - 'label' => 'Склад MSK', - 'format' => 'raw', - 'contentOptions' => ['style'=>'width:60px; text-align:center;'], - 'value' => function ($m, $k, $i) use ($filter){ - return Html::checkbox("actuality[$i][warehouse_msk]", false, [ - + $btnArchOff = Html::button('+ Добавить интервал', [ + 'class' => 'btn btn-xs btn-outline-primary ms-2 add-actuality-row', + 'type' => 'button', + 'title' => 'Добавить интервал', + 'data-guid' => $product->id, + 'data-name' => $product->name, ]); + return '
' . $btnArchOn . $btnArchOff . '
'; } ], - [ - 'label' => 'Поставщик/Плантация', - 'format' => 'text', - 'contentOptions' => ['style'=>'min-width:150px;'], - 'value' => function ($m) { - return '–'; - } - ], + ], ]); ?> @@ -347,3 +298,58 @@ foreach ($months as $k => $v) { + { + btn.addEventListener('click', () => { + const targetId = btn.getAttribute('data-target'); + const el = document.getElementById(targetId); + if (!el) return; + el.value = ''; + el.dispatchEvent(new Event('change')); + }); + }); + + // Мьютекс для чекбоксов "Только активные/неактивные" (необязательно, но удобно) + const onlyActive = document.getElementById('onlyActiveCheckbox'); + const onlyInactive = document.getElementById('onlyInactiveCheckbox'); + if (onlyActive && onlyInactive) { + onlyActive.addEventListener('change', () => { if (onlyActive.checked) { onlyInactive.checked = false; } }); + onlyInactive.addEventListener('change', () => { if (onlyInactive.checked) { onlyActive.checked = false; } }); + } + + group.addEventListener('change', filterSubgroups); + + // Первый проход (на случай когда значения уже выбраны в GET) + filterSubgroups(); +})(); +JS; + +$this->registerJs($js); +?> +