From: marina Date: Mon, 26 May 2025 07:44:13 +0000 (+0300) Subject: ERP-417 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=c49ce323dc10234cd691f86a8b58cb1f0a5791b3;p=erp24_rep%2Fyii-erp24%2F.git ERP-417 --- diff --git a/erp24/views/write_offs_erp/_form.php b/erp24/views/write_offs_erp/_form.php index 0bce8243..1bae11c0 100644 --- a/erp24/views/write_offs_erp/_form.php +++ b/erp24/views/write_offs_erp/_form.php @@ -263,7 +263,6 @@ JS if ($data === null || !isset($data['id'])) { return null; } - $file = Files::findOne([ 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, 'entity_id' => $data['id'] @@ -292,22 +291,33 @@ JS 'showDrag' => false ], 'initialPreview' => function($data) { + if ($data === null || !isset($data['id'])) { + return []; + } $file = Files::findOne([ 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, 'entity_id' => $data['id'] ]); - return $file ? [$file->url] : []; + return $file ? [Yii::getAlias('@web') . $file->url] : []; }, 'initialPreviewConfig' => function($data) { + if ($data === null || !isset($data['id'])) { + return []; + } $file = Files::findOne([ 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, 'entity_id' => $data['id'] ]); - return $file ? [[ + if (!$file) { + return []; + } + $filePath = Yii::getAlias('@webroot') . $file->url; + return [[ 'caption' => basename($file->url), 'type' => 'video', - 'size' => @filesize(Yii::getAlias('@webroot') . $file->url) - ]] : []; + 'size' => file_exists($filePath) ? filesize($filePath) : 0, + 'filetype' => mime_content_type($filePath) // (опционально) + ]]; }, 'initialPreviewAsData' => true, 'previewSettings' => [