From 299d63afa8d962bebcbc1ac332e23e6d75947f86 Mon Sep 17 00:00:00 2001 From: marina Date: Wed, 28 May 2025 12:37:12 +0300 Subject: [PATCH] ERP-417 --- erp24/controllers/WriteOffsErpController.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/erp24/controllers/WriteOffsErpController.php b/erp24/controllers/WriteOffsErpController.php index ca0b474b..f6434d12 100644 --- a/erp24/controllers/WriteOffsErpController.php +++ b/erp24/controllers/WriteOffsErpController.php @@ -831,13 +831,16 @@ class WriteOffsErpController extends Controller if (!empty($modelsProductsFiles) && array_key_exists($keyModelProduct, $modelsProductsFiles)) { $modelProductId = $modelProduct->id; $productFilesArray = ArrayHelper::getValue($modelsProductsFiles, $keyModelProduct); + $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 && empty($videoFile)) { + if ((int)$modelProduct->add_image !== 1 && !$hasNewPhotos && !$hasVideo) { ImageDocumentLink::deleteCurrentLinkImage($writeOffsErpId, $modelProductId, $documentGroupId, $adminId); } - + if ($hasNewPhotos) { foreach ($imageFiles as $index => $imageFile) { if (Images::isImageFile($imageFile)) { @@ -865,7 +868,6 @@ class WriteOffsErpController extends Controller } } - $videoFile = ArrayHelper::getValue($productFilesArray, 'videoFiles'); if ($videoFile) { Files::deleteAll(['entity_id' => $modelProductId, 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO]); FileService::saveUploadedFile($videoFile, WriteOffsProductsErp::WRITE_OFFS_VIDEO, $modelProductId); -- 2.39.5