]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
суммирование возвратов и вычитание продаж
authormarina <m.zozirova@gmail.com>
Mon, 26 May 2025 10:12:23 +0000 (13:12 +0300)
committermarina <m.zozirova@gmail.com>
Mon, 26 May 2025 10:12:23 +0000 (13:12 +0300)
erp24/views/write_offs_erp/_form.php

index 1aa13999a0dc26d90b399b0f7fc5e542e7b37458..ec59f13d4e6e67efaf483d36050b1850826cc8b6 100644 (file)
@@ -186,7 +186,7 @@ JS
                             'capture' => '',
                             'class' => 'file',
                             'required' => true,
-                               ],
+                        ],
                         'pluginOptions' => [
                             'showPreview' => true,
                             'showCaption' => true, // ✅ Должно быть true
@@ -270,21 +270,7 @@ JS
                             'entity_id' => $data['id']
                         ]);
 
-                        if (!$file) return null;
-
-                        $initialPreview = [$file->url];
-                        $initialPreviewConfig = [[
-                            'type' => 'video',
-                            'caption' => basename($file->url),
-                            'url' => Url::to(['delete-video', 'id' => $data['id']])
-                        ]];
-
-                        return [
-                            'caption' => basename($file->url),
-                            'url' => $file->url,
-                            'initialPreview' => $initialPreview,
-                            'initialPreviewConfig' => $initialPreviewConfig
-                        ];
+                        return $file ? $file->url : null;  // Return just the URL string
                     },
                     'options' => [
                         'options' => [
@@ -301,6 +287,26 @@ JS
                             'allowedFileTypes' => ['video'],
                             'allowedFileExtensions' => ['mp4', 'mov', 'avi'],
                             'maxFileSize' => 10240,
+                            'initialPreview' => function ($data) {
+                                if (!$data || !isset($data['id'])) return [];
+                                $file = Files::findOne([
+                                    'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO,
+                                    'entity_id' => $data['id']
+                                ]);
+                                return $file ? [$file->url] : [];
+                            },
+                            'initialPreviewConfig' => function ($data) {
+                                if (!$data || !isset($data['id'])) return [];
+                                $file = Files::findOne([
+                                    'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO,
+                                    'entity_id' => $data['id']
+                                ]);
+                                return $file ? [[
+                                    'type' => 'video',
+                                    'caption' => basename($file->url),
+                                    'url' => Url::to(['delete-video', 'id' => $data['id']])
+                                ]] : [];
+                            }
                         ],
                     ],
                 ],