From: marina Date: Wed, 28 May 2025 11:53:00 +0000 (+0300) Subject: ERP-417 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=55da4d40098588ce3cfea966f140d8e3d064a0c1;p=erp24_rep%2Fyii-erp24%2F.git ERP-417 --- diff --git a/erp24/controllers/WriteOffsErpController.php b/erp24/controllers/WriteOffsErpController.php index 6a9df064..3a3348c5 100644 --- a/erp24/controllers/WriteOffsErpController.php +++ b/erp24/controllers/WriteOffsErpController.php @@ -835,16 +835,18 @@ class WriteOffsErpController extends Controller $imageFiles = ArrayHelper::getValue($productFilesArray, 'imageFiles', []); $videoFile = ArrayHelper::getValue($productFilesArray, 'videoFiles'); $hasNewPhotos = !empty(array_filter($imageFiles)); - $hasVideo = !empty($videoFile); - if ((int)$modelProduct->add_image !== 1 && !$hasNewPhotos && !$hasVideo) { - ImageDocumentLink::deleteCurrentLinkImage($writeOffsErpId, $modelProductId, $documentGroupId, $adminId); + $flagAddImage = (int)$modelProduct->add_image; + + if (!$flagAddImage) { + if ($hasNewPhotos) { + ImageDocumentLink::deleteCurrentLinkImage($writeOffsErpId, $modelProductId, $documentGroupId, $adminId); + } } - + if ($hasNewPhotos) { - foreach ($imageFiles as $index => $imageFile) { + foreach ($imageFiles as $imageFile) { if (Images::isImageFile($imageFile)) { - Yii::info("Загружаем фото #$index: " . ($imageFile->name ?? 'нет имени'), __METHOD__); $image = new Images(); $imageId = $image->loadImage($imageFile); if ($imageId) { @@ -856,14 +858,10 @@ class WriteOffsErpController extends Controller ->setDocumentId($writeOffsErpId) ->setDocumentItemId($modelProductId) ->setImageId($imageId); - if (!$imageDocumentLink->validate() || !$imageDocumentLink->save()) { - Yii::warning("Ошибки валидации/saving ImageDocumentLink для фото #$index", __METHOD__); + if ($imageDocumentLink->validate()) { + $imageDocumentLink->save(); } - } else { - Yii::warning("Не удалось загрузить фото #$index", __METHOD__); } - } else { - Yii::info("Файл #$index не является изображением", __METHOD__); } } }