]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Провекра
authorVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 4 Sep 2025 08:07:04 +0000 (11:07 +0300)
committerVladimir Fomichev <vladimir.fomichev@erp-flowers.ru>
Thu, 4 Sep 2025 08:07:04 +0000 (11:07 +0300)
erp24/controllers/Products1cNomenclatureActualityController.php
erp24/web/js/products1cNomenclatureActuality/index.js

index e6efb5fe6a353e013ae8fa1399e4781ca4f3b537..5854064077b73a95395f0b77e7bf43e96bb971e7 100644 (file)
@@ -4,6 +4,7 @@ namespace app\controllers;
 
 use Yii;
 use yii\db\Query;
+use yii\web\BadRequestHttpException;
 use yii\web\Response;
 use yii_app\api3\modules\v1\models\Sales;
 use yii_app\records\Products1cAdditionalCharacteristics;
@@ -539,10 +540,16 @@ class Products1cNomenclatureActualityController extends Controller
         return $this->redirect(['index']);
     }
 
-    public function actionAjaxDelete($id)
+    public function actionAjaxDelete()
     {
         Yii::$app->response->format = Response::FORMAT_JSON;
 
+        $request = Yii::$app->request;
+        $id = $id ?? $request->post('id') ?? $request->get('id');
+        Yii::error(json_encode($id), JSON_UNESCAPED_UNICODE);
+        if (empty($id)) {
+            throw new BadRequestHttpException('Missing parameter: id');
+        }
         try {
             $model = $this->findModel($id);
             $model->delete();
index ee376eb18f0c915a023d8a3d02381ca449cd21f2..361ce16a3edc069d168406a90754447e4137d89b 100644 (file)
@@ -260,33 +260,49 @@ document.addEventListener("DOMContentLoaded", () => {
         }
     }
 
-    $(document).on('click', '.clear-interval-btn', function () {
-        let btn = $(this);
-        let id = btn.data('id');
+});
 
-        if (!confirm('Удалить запись?')) {
-            return;
-        }
 
-        $.ajax({
-            url: '/products1c-nomenclature-actuality/ajax-delete',
-            type: 'POST',
-            data: {id: id, _csrf: yii.getCsrfToken()},
-            success: function (response) {
-                if (response.success) {
-                    btn.closest('tr, .item-row').fadeOut(300, function () {
-                        $(this).remove();
-                    });
-                } else {
-                    alert('Ошибка: ' + response.message);
-                }
-            },
-            error: function () {
-                alert('Произошла ошибка при удалении');
-            }
-        });
-    });
+$(document).on('click', '.clear-interval-btn', function () {
+    let btn = $(this);
+    let id = btn.data('id');
+
+    if (!confirm('Удалить запись?')) {
+        return;
+    }
 
 
 
+    $.ajax({
+        url: '/products1c-nomenclature-actuality/ajax-delete',
+        type: 'POST',
+        data: {id: id, _csrf: yii.getCsrfToken()},
+        success: function (response) {
+            if (response.success) {
+                btn.closest('tr, .table-success').removeClass('table-success');
+                const scope = btn.closest('td');
+                const selects = scope.find('select.from-month, select.to-month');
+                selects.each(function () {
+                    const s = $(this);
+
+                    s.prop('selectedIndex', 0).val('');
+
+                    if (s.hasClass('select2-hidden-accessible')) {
+                        s.val(null).trigger('change.select2');
+                    } else {
+                        s.trigger('change');
+                    }
+                });
+                // btn.closest('tr, .table-success').fadeOut(300, function () {
+                //     $(this).remove();
+                // });
+                alert(response.message);
+            } else {
+                alert('Ошибка: ' + response.message);
+            }
+        },
+        error: function () {
+            alert('Произошла ошибка при удалении');
+        }
+    });
 });