From: Vladimir Fomichev Date: Thu, 4 Sep 2025 08:07:04 +0000 (+0300) Subject: Провекра X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=601832b506d99238f9d1ce4d2dd21fdc149833e5;p=erp24_rep%2Fyii-erp24%2F.git Провекра --- diff --git a/erp24/controllers/Products1cNomenclatureActualityController.php b/erp24/controllers/Products1cNomenclatureActualityController.php index e6efb5fe..58540640 100644 --- a/erp24/controllers/Products1cNomenclatureActualityController.php +++ b/erp24/controllers/Products1cNomenclatureActualityController.php @@ -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(); diff --git a/erp24/web/js/products1cNomenclatureActuality/index.js b/erp24/web/js/products1cNomenclatureActuality/index.js index ee376eb1..361ce16a 100644 --- a/erp24/web/js/products1cNomenclatureActuality/index.js +++ b/erp24/web/js/products1cNomenclatureActuality/index.js @@ -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('Произошла ошибка при удалении'); + } + }); });