From: Vladimir Fomichev Date: Thu, 11 Sep 2025 09:14:47 +0000 (+0300) Subject: Добавление интервалов X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=c9f08cb2fdada8af37e21086a6fc4d9cb0510e4a;p=erp24_rep%2Fyii-erp24%2F.git Добавление интервалов --- diff --git a/erp24/controllers/MatrixBouquetActualityController.php b/erp24/controllers/MatrixBouquetActualityController.php index 413cb40c..f035d2a0 100644 --- a/erp24/controllers/MatrixBouquetActualityController.php +++ b/erp24/controllers/MatrixBouquetActualityController.php @@ -262,6 +262,8 @@ class MatrixBouquetActualityController extends Controller ]); } + + private function getMatrixTypeDescendantsIds(int $rootId): array { $all = MatrixType::find()->select(['id','parent_id']) diff --git a/erp24/views/matrix-bouquet-actuality/index.php b/erp24/views/matrix-bouquet-actuality/index.php index 8c355ccf..7e86cc85 100644 --- a/erp24/views/matrix-bouquet-actuality/index.php +++ b/erp24/views/matrix-bouquet-actuality/index.php @@ -198,7 +198,9 @@ foreach ($subgroups as $sg) { 'tableOptions' => ['class' => 'table table-bordered'], 'containerOptions' => ['style' => 'overflow:auto;'], 'rowOptions' => function($row) { - return $row['actuality'] ? ['class'=>'table-success'] : []; + $id = $row['product']->id ?? null; + $base = $row['actuality'] ? ['class' => 'table-success'] : []; + return $id ? array_merge($base, ['data-id' => $id]) : $base; }, 'columns' => [ [ @@ -207,9 +209,19 @@ foreach ($subgroups as $sg) { 'contentOptions' => ['style'=>'min-width:150px;'], 'value' => function ($row, $key, $index) { $product = $row['product']; + $price = $row['price'] ?? null; $name = Html::encode($product->name . ' (' . $product->guid . ')'); $anchor = Html::a($name, ['bouquet/view', 'id' => $product->id], ['target' => '_blank']); - return '
' . $anchor . '
'; + $btn = Html::button('+ Добавить интервал', [ + 'class' => 'btn btn-xs btn-outline-primary ms-2 add-actuality-row', + 'type' => 'button', + 'title' => 'Добавить интервал', + 'data-id' => $product->id, + 'data-guid' => $product->guid, + 'data-name' => $product->name, + 'data-price' => $price->price ?? null, + ]); + return '
' . $anchor . $btn . '
'; } ], [ diff --git a/erp24/web/js/matrix-bouquet-actuality/index.js b/erp24/web/js/matrix-bouquet-actuality/index.js index 6f259f87..c0220c85 100644 --- a/erp24/web/js/matrix-bouquet-actuality/index.js +++ b/erp24/web/js/matrix-bouquet-actuality/index.js @@ -8,6 +8,8 @@ const monthsForNewRows = extendMonthsMap({ ...baseMonths }, 0); const monthsForExisting = baseMonths; + + let actualIdx = $('#actuality-form table tbody tr').length || 0; $('.from-month').each(function () { const hasActuality = $(this).data('actuality') == 1; @@ -159,8 +161,8 @@ }); }); - const inArchiveBtns = document.getElementById('inArchiveBtn'); - const outArchiveBtns = document.getElementById('outArchiveBtn'); + 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; } }); @@ -305,4 +307,57 @@ }); }); + + $(document).on('click', '.add-actuality-row', function(){ + const btn = $(this); + const id = btn.data('id'); + const guid = btn.data('guid'); + const name = btn.data('name'); + const price = btn.data('price'); + const table = $('#actuality-form table'); + // Все строки для этого товара + const $rows = table.find('tbody tr[data-id="'+ id +'"]'); + const $lastRow = $rows.last(); + actualIdx++; + console.log('add row', id, name); + const newRow = ` + + +
${name} (${id})
Новая запись. Заполните интервал
+ + +
${price}
+ + + + +
+ + +
+ + + + + + + `; + + let $inserted; + if ($lastRow.length) { + $lastRow.after(newRow); + $inserted = $lastRow.next(); + } else { + table.find('tbody').append(newRow); + $inserted = table.find('tbody tr').last(); + } + console.log(newRow); + applyFromMonthLimits($inserted.find('.from-month'), monthsForNewRows); + syncToWithFrom($inserted.find('.from-month')); + }); + })(); \ No newline at end of file