<div style="overflow-x: scroll;">
<?php
-
echo DetailView::widget([
'model' => $model,
'attributes' => [
-// 'id',
'guid',
'date',
'number',
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',
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) {
$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;
},