]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
return city-store/index.js from old project
authorAlexander Smirnov <fredeom@mail.ru>
Fri, 24 May 2024 10:33:02 +0000 (13:33 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Fri, 24 May 2024 10:33:02 +0000 (13:33 +0300)
erp24/web/js/city-store/index.js [new file with mode: 0644]

diff --git a/erp24/web/js/city-store/index.js b/erp24/web/js/city-store/index.js
new file mode 100644 (file)
index 0000000..7fe1616
--- /dev/null
@@ -0,0 +1,37 @@
+/* jshint esversion: 6 */
+const param30 = $('meta[name=csrf-param]').attr("content");
+const token30 = $('meta[name=csrf-token]').attr("content");
+
+
+function setTgDialog(storeId, tg_chat_id) {
+    const $mainModal = $('#mainModal');
+    const $modalBody = $mainModal.find('.modal-body');
+    $modalBody.html('<input type="number">');
+    const $modalFooter = $mainModal.find('.modal-footer');
+    $modalFooter.html('');
+    $modalFooter.get(0).insertAdjacentHTML('beforeend', '<button>Сохранить</button>');
+    const $saveButton = $modalFooter.find('button');
+    $saveButton.addClass(['btn', 'btn-success', 'btn-lg']);
+    $saveButton.on('click', () => {
+        $.ajax({
+            method: 'POST',
+            url: window.location.href,
+            data: {action: 'saveTg', storeId, tgInput: $tgInput.val(), [param30]: token30},
+            dataType: "text",
+            success: function (data) {
+                console.log(data);
+                if (data === 'ok') {
+                    window.location.reload();
+                }
+            }
+        });
+    })
+    const $tgInput = $modalBody.find('input');
+    if (tg_chat_id) {
+        $tgInput.val(tg_chat_id);
+    }
+    $mainModal.find('.modal-title').html('Установка Телеграм чата');
+    $mainModal.find('.close').on('click', () => $('#mainModal').modal('hide'));
+
+    $mainModal.modal('show');
+}
\ No newline at end of file