]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-417
authormarina <m.zozirova@gmail.com>
Fri, 23 May 2025 14:35:22 +0000 (17:35 +0300)
committermarina <m.zozirova@gmail.com>
Fri, 23 May 2025 14:35:22 +0000 (17:35 +0300)
erp24/views/write_offs_erp/view.php

index 5b444aa8306b4d1e65c622d50c5763511e593db3..2729e1f11f6537678f9d957b766b8755282340e8 100644 (file)
@@ -40,11 +40,9 @@ $this->registerCssFile('/css/write-offs-erp.css', ['position' => \yii\web\View::
 
         <div style="overflow-x: scroll;">
             <?php
-
             echo DetailView::widget([
                 'model' => $model,
                 'attributes' => [
-//            'id',
                     'guid',
                     'date',
                     'number',
@@ -60,20 +58,13 @@ $this->registerCssFile('/css/write-offs-erp.css', ['position' => \yii\web\View::
                             return $model->confirmAdmin ? $model->confirmAdmin->name : '';
                         }
                     ],
-//            'updated_admin_id',
-//            'store_id',
                     [
                         'attribute' => 'cityStoreName',
                         'label' => 'Магазин',
                         'value' => function ($data) {
-//                    $cityStore = \yii\helpers\ArrayHelper::getValue($data->getRelatedRecords(),'cityStore');
-//                    return $cityStore ? $cityStore->name_full : $data->store_id;
-//                    $cityStore = \yii\helpers\ArrayHelper::getValue($data->getRelatedRecords(),'cityStore');
                             return $data->cityStoreList ? $data->cityStoreList->name_full : $data->store_id;
                         }
                     ],
-//            'store_guid',
-//            'based_on:ntext',
                     'write_offs_type',
                     'quantity',
                     'summ',
@@ -92,25 +83,19 @@ $this->registerCssFile('/css/write-offs-erp.css', ['position' => \yii\web\View::
                             return $data->number_1c ?? '';
                         }
                     ],
-
-//            'summ_retail',
-//            'created_at',
-//            'send_at',
-
                     [
                         'attribute' => 'send_at',
                         'value' => function ($data) {
                             return $data->send_at ?? 'не отправлен';
                         }
                     ],
-//            'updated_at',
                     [
                         'attribute' => 'productsList',
                         'label' => 'Товары',
                         'format' => 'raw',
                         'value' => function ($model) {
-                            $dataTable = '<table>';
-                            $dataTable .= '<tr>';
+                            $dataTable = '<table class="table table-bordered">';
+                            $dataTable .= '<thead><tr>';
                             $dataTable .= '<th>Название</th>';
                             $dataTable .= '<th>Количество</th>';
                             if (!$model->isShowSum) {
@@ -118,72 +103,71 @@ $this->registerCssFile('/css/write-offs-erp.css', ['position' => \yii\web\View::
                                 $dataTable .= '<th>Сумма</th>';
                             }
                             $dataTable .= '<th>Причина списания</th>';
-                            $dataTable .= '<th>Коментарий</th>';
+                            $dataTable .= '<th>Ð\9aомменÑ\82аÑ\80ий</th>';
                             $dataTable .= '<th>Изображения</th>';
                             $dataTable .= '<th>Видео</th>';
-                            $dataTable .= '</tr>';
+                            $dataTable .= '</tr></thead>';
+                            $dataTable .= '<tbody>';
 
                             $products = WriteOffsProductsErp::find()
                                 ->where(['write_offs_erp_id' => $model->id, 'active_product' => 1])
                                 ->orderBy(['num_row' => SORT_ASC])
                                 ->all();
-                            foreach ($products as $key => $product) {
+
+                            foreach ($products as $product) {
                                 $causeName = $product['cause_id'];
                                 if (!empty($model->listCauseDict)) {
                                     $causeName = ArrayHelper::getValue($model->listCauseDict, $product['cause_id']);
                                 }
-                                $forWidget = false;
-                                $images = WriteOffsErp::getImagesList($product->imagesWriteOffsErp, $forWidget);
+
                                 $dataTable .= '<tr>';
-                                $dataTable .= '<td>' . $product['name'] . '</td>';
-                                $dataTable .= '<td>' . $product['quantity'] . '</td>';
+                                $dataTable .= '<td>' . Html::encode($product['name']) . '</td>';
+                                $dataTable .= '<td>' . Html::encode($product['quantity']) . '</td>';
+
                                 if (!$model->isShowSum) {
-                                    $dataTable .= '<td>' . $product['price'] . '</td>';
-                                    $dataTable .= '<td>' . $product['summ'] . '</td>';
+                                    $dataTable .= '<td>' . Html::encode($product['price']) . '</td>';
+                                    $dataTable .= '<td>' . Html::encode($product['summ']) . '</td>';
                                 }
-                                $dataTable .= '<td>' . $causeName . '</td>';
-                                $dataTable .= '<td>' . $product['comment'] . '</td>';
-                                $dataTable .= '<td>';?>
-                                <?php $images = $model->imagesWriteOffsErp; ?>
-                                <?php if (!empty($images)): ?>
-                                    <div class="gallery-container">
-                                        <?php foreach ($images as $link): ?>
-                                            <?php
-                                            $image = \yii_app\records\Images::findOne($link->image_id);
-                                            if (!$image || empty($image->filename)) continue;
-                                            $url = Url::to($image->filename, true);
-                                            $caption = htmlspecialchars($image->original_name ?? '', ENT_QUOTES);
-                                            ?>
-                                            <a href="<?= $url ?>" data-fancybox="gallery" data-caption="<?= $caption ?>">
-                                                <img src="<?= $url ?>" alt="<?= $caption ?>" style="max-width: 150px; margin: 5px; cursor: pointer;">
-                                            </a>
-                                        <?php endforeach; ?>
-                                    </div>
-                                  <?  $dataTable .= '</td>';
-                                                        $dataTable .= '<td>';
 
-                                    $video = $product->video;
-                                    if (!empty($video)) {
-                                        $dataTable .= '<div class="video-container">';
-                                        $dataTable .= '<video width="320" height="240" controls>
-        <source src="' . $video->url . '" type="video/mp4">
-        Видео не поддерживается
-    </video>';
+                                $dataTable .= '<td>' . Html::encode($causeName) . '</td>';
+                                $dataTable .= '<td>' . Html::encode($product['comment']) . '</td>';
+
+                                // Изображения
+                                $dataTable .= '<td>';
+                                $images = $product->imagesWriteOffsErp;
+                                if (!empty($images)) {
+                                    $forWidget = true; // или false в зависимости от вашей логики
+                                    if ($forWidget) {
+                                        $dataTable .= '<div class="gallery-container">';
+                                        $dataTable .= dosamigos\gallery\Gallery::widget([
+                                            'items' => WriteOffsErp::getImagesList($images, $forWidget)
+                                        ]);
                                         $dataTable .= '</div>';
+                                    } else {
+                                        foreach ($images as $image) {
+                                            $dataTable .= Html::img($image->url, ['style' => 'max-width: 100px; margin: 5px;']);
+                                        }
                                     }
-                                        $dataTable .= '</td>';
-                                                            $dataTable .= '</tr>';?>
-                                <?php endif;
-                                $dataTable .= '<tr>';
-                            }
+                                }
+                                $dataTable .= '</td>';
 
-                            if (!$model->isShowSum) {
-                                $dataTable .= '<td></td>';
-                                $dataTable .= '<td>' . $model->summ . '</td>';
+                                // Видео
+                                $dataTable .= '<td>';
+                                $video = $product->video;
+                                if (!empty($video)) {
+                                    $dataTable .= '<div class="video-container" style="max-width: 200px;">';
+                                    $dataTable .= '<video width="100%" controls>';
+                                    $dataTable .= '<source src="' . Html::encode($video->url) . '" type="video/mp4">';
+                                    $dataTable .= 'Ваш браузер не поддерживает видео.';
+                                    $dataTable .= '</video>';
+                                    $dataTable .= '</div>';
+                                }
+                                $dataTable .= '</td>';
+
+                                $dataTable .= '</tr>';
                             }
-                            $dataTable .= '<td></td>';
-                            $dataTable .= '<td></td>';
-                            $dataTable .= '</tr>';
+
+                            $dataTable .= '</tbody>';
                             $dataTable .= '</table>';
                             return $dataTable;
                         },