+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];
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])) {