]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-417
authormarina <m.zozirova@gmail.com>
Tue, 3 Jun 2025 07:39:57 +0000 (10:39 +0300)
committermarina <m.zozirova@gmail.com>
Tue, 3 Jun 2025 07:39:57 +0000 (10:39 +0300)
erp24/web/js/validate/validateForm.js

index accf71760485ab89b82cdcabb6613ca00bae9301..3a994a9b47a317b5a127988fa5cc5763278b2897 100755 (executable)
@@ -1,3 +1,21 @@
+function updateCommentReadonly() {
+    const currentUser = $('.admin-name').text().trim();
+    const selectedStoreId = $('#writeoffserp-store_id').val();
+    const specialStoreIds = ['1', '9', '28'];
+    const allowedCommentUsers = ['Емельянова Ольга', 'Яшенкова Алена', 'Цветкова Ольга'];
+
+    const isReadonly = specialStoreIds.includes(selectedStoreId) && !allowedCommentUsers.includes(currentUser);
+    $('#writeoffserp-comment').prop('readonly', isReadonly);
+}
+
+$(document).ready(function () {
+    updateCommentReadonly();
+
+    $('#writeoffserp-store_id').on('change', function () {
+        updateCommentReadonly();
+    });
+});
+
 $(".form-validate button").click(function (e) {
     e.preventDefault();
     var form = $(this).closest('form')[0];
@@ -51,16 +69,11 @@ $(".form-validate button").click(function (e) {
                     if (!errors['__common']) errors['__common'] = [];
                     errors['__common'].push('Пожалуйста, добавьте хотя бы одно фото к каждому списанию перед сохранением.');
                 }
-
-                if (commentValue.length > 0 && !allowedCommentUsers.includes(currentUser)) {
-                    errors['WriteOffsErp[comment]'] = [
-                        'Комментарий могут заполнять только: ' + allowedCommentUsers.join(', ') + '.'
-                    ];
-                }
             }
 
             if (Object.keys(errors).length > 0) {
                 renderErrors(errors);
+
                 let allErrors = [];
                 for (const key in errors) {
                     if (Array.isArray(errors[key])) {