]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
[ERP-231] исправляет matrix-erp раздел: рефактор
authorAlexander Smirnov <fredeom@mail.ru>
Sat, 26 Oct 2024 15:19:00 +0000 (18:19 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Sat, 26 Oct 2024 15:19:00 +0000 (18:19 +0300)
erp24/helpers/File.php
erp24/records/MatrixErp.php
erp24/views/matrix_erp/index.php

index 0a21adeccd9576c28a49bc7579ff5382a0aafcf9..e21a859846ed1880619e31826eb9e4040b08f8f6 100644 (file)
@@ -121,7 +121,7 @@ class File extends FileHelper
                $resizedPath = $uploadDir . "/images/resize/{$substr}/{$w}_{$h}_{$quality}";
                $resizedFile = "{$resizedPath}/{$filename}";
 
-        if (!file_exists($imagePath)) {
+        if (!file_exists($imagePath ?? '')) {
             $filePath = self::src($filename);
             self::ResizeImage($filePath, $w, $h, $quality);
         }
index c09f030334509ea51e5ed503915c3b8c546564c8..c7c184cd9a10e67f56b33993926b9b56011a3cc8 100644 (file)
@@ -96,7 +96,6 @@ class MatrixErp extends \yii\db\ActiveRecord
         if (!empty($componentsArray)) {
             $this->componentsArray = self::getProducts($componentsArray);
         }
-    $test = 1;
     }
 
 
@@ -124,6 +123,4 @@ class MatrixErp extends \yii\db\ActiveRecord
         return $products;
     }
 
-
-
 }
index f0e0bf970a796b8b0556c0fe9429d298c9dc8264..9af4385983474e76dbbc83aa9080946ba24bfd4c 100644 (file)
@@ -200,11 +200,10 @@ $this->params['breadcrumbs'][] = $this->title;
                                                                         <th>Количество</th>
                                                                     </tr>
                                                                     <?php
+                                                                    $item->setComponentsArray();
                                                                     if (!empty($item->componentsArray)) {
                                                                         $components = $item->componentsArray;
                                                                         foreach ($components as $component) {
-
-
                                                                             ?>
                                                                             <tr>
                                                                                 <td><?=$component['name'] ?? ''?></td>
@@ -237,9 +236,6 @@ $this->params['breadcrumbs'][] = $this->title;
                                                                             if (!empty($imagesArray)) {
                                                                                 $images = implode('', $imagesArray);
                                                                             }
-
-
-
                                                                             ?>
                                                                                 <td><?=$images ?? ''?></td>
                                                                                 <td class="description"><?=$matrixProperty->description ?? ''?></td>
@@ -253,52 +249,34 @@ $this->params['breadcrumbs'][] = $this->title;
                                                             <div class="tab-pane" id="tab<?= $num_row ?>3">
                                                                 <table class="table detail-transaction">
                                                                     <tbody>
-                                                                    <tr>
-                                                                        <th>Название</th>
-                                                                        <th>Ссылка</th>
-                                                                    </tr>
-                                                                    <?php
-                                                                    if (!empty($matrixProperty->url_link_video)) {
-                                                                        ?>
                                                                         <tr>
-                                                                            <td>Ссылка на видео</td>
-                                                                            <td><?= Html::a(
-                                                                                    $matrixProperty->url_link_video,
-                                                                                    $matrixProperty->url_link_video,
-                                                                                    [
-                                                                                        'class' => 'profile-link',
-                                                                                        'target'=>'_blank'
-                                                                                    ]
-                                                                                );?>
-                                                                            </td>
+                                                                            <th>Название</th>
+                                                                            <th>Ссылка</th>
                                                                         </tr>
-                                                                        <?php
-                                                                    }
-                                                                    if (!empty($matrixMediaRow)) {
-                                                                        foreach ($matrixMediaRow as $matrixErpMediaRow) {
-
-                                                                            $filesList = [];
-                                                                            $fileRow = null;
-                                                                            /** @var \yii_app\records\MatrixErpMedia $matrixErpMediaRow */
-                                                                            $filesQuery = $matrixErpMediaRow->getFiles();
-                                                                            $filesRow = $filesQuery->one();
-                                                                                //        foreach($MatrixErpMedia as $matrixErpMediaRow) {
-                                                                            //$filesRow = ArrayHelper::getValue($matrixErpMediaRow->getRelatedRecords(),'files');
-                                                                            if (!empty($filesRow)) {
-                                                                                $fileRow = FileService::getFile($filesRow);
-                                                                            }
-
-                                                                            ?>
+                                                                        <?php if (!empty($matrixProperty->url_link_video)): ?>
                                                                             <tr>
-
-                                                                                <td> <?= $matrixErpMediaRow->name?> </td>
-                                                                                <td> <?= $fileRow ?? ''?> </td>
+                                                                                <td>Ссылка на видео</td>
+                                                                                <td><?= Html::a(
+                                                                                        $matrixProperty->url_link_video,
+                                                                                        $matrixProperty->url_link_video,
+                                                                                        [
+                                                                                            'class' => 'profile-link',
+                                                                                            'target'=>'_blank'
+                                                                                        ]
+                                                                                    );?>
+                                                                                </td>
                                                                             </tr>
-                                                                            <?php
-                                                                        }
-                                                                    }
-                                                                    ?>
-
+                                                                        <?php endif; ?>
+                                                                        <?php if (!empty($matrixMediaRow)): ?>
+                                                                            <?php foreach ($matrixMediaRow as $matrixErpMediaRow):
+                                                                            /** @var \yii_app\records\MatrixErpMedia $matrixErpMediaRow */?>
+                                                                                <tr>
+                                                                                    <td> <?= $matrixErpMediaRow->name?> </td>
+                                                                                    <td> <?= $matrixErpMediaRow->file ?
+                                                                                            (FileService::getFile($matrixErpMediaRow->file) ?? '') : '' ?> </td>
+                                                                                </tr>
+                                                                            <?php endforeach; ?>
+                                                                        <?php endif; ?>
                                                                     </tbody>
                                                                 </table>
                                                             </div>