]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-417
authormarina <m.zozirova@gmail.com>
Tue, 27 May 2025 12:19:01 +0000 (15:19 +0300)
committermarina <m.zozirova@gmail.com>
Tue, 27 May 2025 12:19:01 +0000 (15:19 +0300)
erp24/views/write_offs_erp/_form.php

index c0fb4d2036c1f7d1c38f0fe00b5ff3ef42b38d70..8d866c04c1124fd9d8317c052c92eb057e51f53b 100644 (file)
@@ -37,21 +37,34 @@ $this->registerJsFile('/js/heic_to_jpg_replace.js', ['position' => \yii\web\View
 
 $js = <<<JS
 $(document).ready(function() {
-    $('form').on('submit', function(e) {
-        let hasImageInRow = $('.list-cell__images_row img').length > 0;
-        let fileInput = $('.list-cell__imageFiles input[type="file"]');
-        let hasFilesSelected = fileInput.length && fileInput[0].files.length > 0;
+    $('form').off('submit.multiImageCheck').on('submit.multiImageCheck', function(e) {
+        let allRowsHaveImage = true;
 
-        if (!hasImageInRow && !hasFilesSelected) {
+        $('.product-row').each(function() {
+            let row = $(this);
+            let hasImageInRow = row.find('.list-cell__images_row img').length > 0;
+
+            let fileInput = row.find('.list-cell__imageFiles input[type="file"]');
+            let hasFilesSelected = fileInput.length && fileInput[0].files.length > 0;
+
+            if (!hasImageInRow && !hasFilesSelected) {
+                allRowsHaveImage = false;
+                return false; 
+            }
+        });
+
+        if (!allRowsHaveImage) {
             e.preventDefault();
-            alert('Пожалуйста, добавьте хотя бы одно фото перед сохранением.');
+            alert('Ð\9fожалÑ\83йÑ\81Ñ\82а, Ð´Ð¾Ð±Ð°Ð²Ñ\8cÑ\82е Ñ\85оÑ\82Ñ\8f Ð±Ñ\8b Ð¾Ð´Ð½Ð¾ Ñ\84оÑ\82о Ð² ÐºÐ°Ð¶Ð´Ñ\83Ñ\8e Ñ\81Ñ\82Ñ\80окÑ\83 Ð¿ÐµÑ\80ед Ñ\81оÑ\85Ñ\80анением.');
             return false;
         }
     });
 });
 JS;
+
 $this->registerJs($js, \yii\web\View::POS_READY);
 ?>
+
 <style>
     .multiple-input-list .multiple-input-list__btn.js-input-plus {
         width: 40px;