]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Закомментировал архив
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 11 Sep 2025 07:04:43 +0000 (10:04 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 11 Sep 2025 07:04:43 +0000 (10:04 +0300)
erp24/controllers/MatrixBouquetActualityController.php
erp24/views/matrix-bouquet-actuality/index.php
erp24/web/js/matrix-bouquet-actuality/index.js

index ebc5696d498f0be62edd56b522305c28d51c42fa..413cb40c70a3d691efc0469e320846e0806d9543 100644 (file)
@@ -7,6 +7,7 @@ use yii\data\ActiveDataProvider;
 use yii\helpers\ArrayHelper;
 use yii\web\BadRequestHttpException;
 use yii\web\Response;
+use yii_app\records\AdminGroup;
 use yii_app\records\BouquetComposition;
 use yii_app\records\BouquetCompositionMatrixTypeHistory;
 use yii_app\records\MatrixBouquetActuality;
@@ -477,4 +478,19 @@ class MatrixBouquetActualityController extends Controller
 
         throw new NotFoundHttpException('The requested page does not exist.');
     }
+
+    private function checkAccess() {
+        $groupId = Yii::$app->user->identity->group_id;
+
+        if (!in_array($groupId, [
+            AdminGroup::GROUP_IT,
+            AdminGroup::GROUP_BUSH_CHEF_FLORIST,
+            AdminGroup::GROUP_BUSH_DIRECTOR,
+            AdminGroup::GROUP_RS_DIRECTOR,
+        ], true)) {
+            return $this->render('/site/index');
+        }
+
+        return null;
+    }
 }
index 9f95d87f2bc90ffb2a2fc63475793477e24235bd..32eab955bd27897980bfaacaca544e714ebf195d 100644 (file)
@@ -162,12 +162,12 @@ foreach ($subgroups as $sg) {
                 ])->label(false) ?>
             </div>
             <div class="mb-3">
-                <?= $formFilter->field($filter, 'is_archive')->checkbox([
-                    'label' => 'Архивные',
-                    'uncheck' => 0,
-                    'checked' => (bool)$filter->is_archive,
-                    'id' => 'isArchiveCheckbox'
-                ])->label(false) ?>
+<!--                --><?php //= $formFilter->field($filter, 'is_archive')->checkbox([
+//                    'label' => 'Архивные',
+//                    'uncheck' => 0,
+//                    'checked' => (bool)$filter->is_archive,
+//                    'id' => 'isArchiveCheckbox'
+//                ])->label(false) ?>
 
             </div>
 
@@ -266,21 +266,36 @@ foreach ($subgroups as $sg) {
                 'contentOptions' => ['style'=>'width:160px; text-align:center;'],
                 'value' => function ($row, $key, $index) {
                     $product = $row['product'];
-                    $btnArchOn = Html::button('В архив', [
-                        'class' => 'btn btn-xs btn-danger ms-2 add-actuality-row',
+                    $actuality = $row['actuality'];
+                    $btnArchOnOptions = [
+                        'class' => 'btn btn-xs btn-danger ms-2 add-actuality-row archiv-in-btn',
                         'type' => 'button',
                         'title' => 'В архив',
-                        'data-guid' => $product->id,
+                        'data-archiv-in' => $actuality ? $actuality->id : $product->id,
+                        'data-id' => $product->id,
                         'data-name' => $product->name,
-                    ]);
-                    $btnArchOff = Html::button('Из архива', [
-                        'class' => 'btn btn-xs btn-secondary ms-2 add-actuality-row',
+                    ];
+                    if ($actuality && $actuality->is_archive == 1) {
+                        $btnArchOnOptions['disabled'] = true;
+                    }
+
+                    $btnArchOffOptions = [
+                        'class' => 'btn btn-xs btn-secondary ms-2 add-actuality-row archiv-out-btn',
                         'type' => 'button',
                         'title' => 'Из архива',
-                        'data-guid' => $product->id,
+                        'data-archiv-out' =>  $actuality ? $actuality->id : $product->id,
+                        'data-id' => $product->id,
                         'data-name' => $product->name,
-                    ]);
-                    return '<div class="d-flex justify-content-start">' . $btnArchOn . $btnArchOff . '</div>';
+                    ];
+
+                    if ($actuality && $actuality->is_archive == 0 || !$actuality) {
+                        $btnArchOffOptions['disabled'] = true;
+                    }
+
+                    $btnArchOn = Html::button('В архив', $btnArchOnOptions);
+                    $btnArchOff = Html::button('Из архива', $btnArchOffOptions);
+                    //return '<div class="d-flex justify-content-start">' . $btnArchOn . $btnArchOff . '</div>';
+                    return '<div class="d-flex justify-content-start">' . '</div>';
                 }
             ],
 
index eb1b3ef271d3ba96d969bef5f60e6e8d5442e192..6f259f87c7836fb28f2647b6c82b6521945f6db9 100644 (file)
     });
 
 
-    const onlyActive    = document.getElementById('onlyActiveCheckbox');
-    const onlyInactive  = document.getElementById('onlyInactiveCheckbox');
+
+    document.querySelectorAll('.archiv-in-btn[data-archiv-in]').forEach(btn => {
+        btn.addEventListener('click', () => {
+            const targetId = btn.getAttribute('data-archiv-in');
+            if (!confirm('Отправить в архив?')) {
+                return;
+            }
+
+            $.ajax({
+                url: '/matrix-bouquet-actuality/ajax-delete',
+                type: 'POST',
+                data: {id: targetId, _csrf: yii.getCsrfToken()},
+                success: function (response) {
+                    if (response.success) {
+
+                        alert(response.message);
+                    } else {
+                        alert('Ошибка: ' + response.message);
+                    }
+                },
+                error: function () {
+                    alert('Произошла ошибка при удалении');
+                }
+            });
+        });
+    });
+
+    document.querySelectorAll('.archiv-out-btn[data-archiv-out]').forEach(btn => {
+        btn.addEventListener('click', () => {
+            const targetId = btn.getAttribute('data-archiv-out');
+            if (!confirm('Убрать из архива?')) {
+                return;
+            }
+
+            $.ajax({
+                url: '/matrix-bouquet-actuality/ajax-delete',
+                type: 'POST',
+                data: {id: targetId, _csrf: yii.getCsrfToken()},
+                success: function (response) {
+                    if (response.success) {
+
+                        alert(response.message);
+                    } else {
+                        alert('Ошибка: ' + response.message);
+                    }
+                },
+                error: function () {
+                    alert('Произошла ошибка при удалении');
+                }
+            });
+        });
+    });
+
+    const inArchiveBtns    = document.getElementById('inArchiveBtn');
+    const outArchiveBtns  = document.getElementById('outArchiveBtn');
     if (onlyActive && onlyInactive) {
         onlyActive.addEventListener('change', () => { if (onlyActive.checked) { onlyInactive.checked = false; } });
         onlyInactive.addEventListener('change', () => { if (onlyInactive.checked) { onlyActive.checked = false; } });