$this->registerJsFile('/js/heic2any.min.js', ['position' => \yii\web\View::POS_END]);
$this->registerJsFile('/js/heic_to_jpg_replace.js', ['position' => \yii\web\View::POS_END]);
+$this->registerJs(<<<JS
+document.addEventListener('DOMContentLoaded', function() {
+ const form = document.getElementById('my-upload-form');
+ const fileInput = form.querySelector('input[type="file"][name="image_name"]');
+
+ form.addEventListener('submit', function(e) {
+ if (!fileInput.files || fileInput.files.length === 0) {
+ alert('Пожалуйста, загрузите хотя бы один файл!');
+ e.preventDefault();
+ }
+ });
+});
+JS);
+
?>
<style>
.multiple-input-list .multiple-input-list__btn.js-input-plus {
'title' => 'Причина списания',
'items' => $listCauseDict,
],
- [
- 'name' => 'images_row',
- 'type' => BaseColumn::TYPE_STATIC,
- 'value' => function($data) {
-// $images = WriteOffsErp::getImagesList($product->imagesWriteOffsErp);
- if (!empty($data['id'])) {
- $query = WriteOffsProductsErp::find()
- ->andWhere([
- 'write_offs_products_erp.id' => $data['id'],
- 'write_offs_products_erp.active_product' => 1,
- ]);
-
-
- $query->joinWith(['imagesWriteOffsErp']);
-
- $action = $query->createCommand()->getRawSql();
-
- $modelWriteOffsProductsErp = $query->All();
- $productImagesList = [];
- $forWidget = false;
- foreach ($modelWriteOffsProductsErp as $item) {
- $productImagesList = WriteOffsErp::getImagesList($item->imagesWriteOffsErp, $forWidget);
- }
- if (!empty($productImagesList)) {
-// $dataTable = dosamigos\gallery\Gallery::widget(['items' => $productImagesList]);
- if ($forWidget) {
- $dataTable = dosamigos\gallery\Gallery::widget(['items' => $productImagesList]);
- } else {
- $dataTable = implode('', $productImagesList);
- }
- }
- }
- $test = 33;
- return $dataTable ?? '';
- },
- 'headerOptions' => [
-// 'style' => 'width: 70px;',
- ]
- ],
- [
- 'name' => 'images_row',
- 'type' => BaseColumn::TYPE_STATIC,
- 'value' => function($data) {
-// $images = WriteOffsErp::getImagesList($product->imagesWriteOffsErp);
- if (!empty($data['id'])) {
- $query = WriteOffsProductsErp::find()
- ->andWhere([
- 'write_offs_products_erp.id' => $data['id'],
- 'write_offs_products_erp.active_product' => 1,
- ]);
-
-
- $query->joinWith(['imagesWriteOffsErp']);
-
- $action = $query->createCommand()->getRawSql();
-
- $modelWriteOffsProductsErp = $query->All();
- $productImagesList = [];
- $forWidget = false;
- foreach ($modelWriteOffsProductsErp as $item) {
- $productImagesList = WriteOffsErp::getImagesList($item->imagesWriteOffsErp, $forWidget);
- }
- if (!empty($productImagesList)) {
-// $dataTable = dosamigos\gallery\Gallery::widget(['items' => $productImagesList]);
- if ($forWidget) {
- $dataTable = dosamigos\gallery\Gallery::widget(['items' => $productImagesList]);
- } else {
- $dataTable = implode('', $productImagesList);
- }
- }
- }
- $test = 33;
- return $dataTable ?? '';
- },
- 'headerOptions' => [
-// 'style' => 'width: 70px;',
- ]
- ],
[
'name' => 'add_image',
'type' => $checkBoxType,
'accept' => 'image/*',
'name' => 'image_name',
'capture' => '',
- 'class' => 'file'
+ 'class' => 'file',
+ 'required' => true,
],
'pluginOptions' => [
// 'previewFileType' => ['jpg','png'],
'class' => 'custom_css_class_file_input'
]
],
+ [
+ 'name' => 'images_row',
+ 'type' => BaseColumn::TYPE_STATIC,
+ 'value' => function($data) {
+// $images = WriteOffsErp::getImagesList($product->imagesWriteOffsErp);
+ if (!empty($data['id'])) {
+ $query = WriteOffsProductsErp::find()
+ ->andWhere([
+ 'write_offs_products_erp.id' => $data['id'],
+ 'write_offs_products_erp.active_product' => 1,
+ ]);
+
+
+ $query->joinWith(['imagesWriteOffsErp']);
+
+ $action = $query->createCommand()->getRawSql();
+
+ $modelWriteOffsProductsErp = $query->All();
+ $productImagesList = [];
+ $forWidget = false;
+ foreach ($modelWriteOffsProductsErp as $item) {
+ $productImagesList = WriteOffsErp::getImagesList($item->imagesWriteOffsErp, $forWidget);
+ }
+ if (!empty($productImagesList)) {
+// $dataTable = dosamigos\gallery\Gallery::widget(['items' => $productImagesList]);
+ if ($forWidget) {
+ $dataTable = dosamigos\gallery\Gallery::widget(['items' => $productImagesList]);
+ } else {
+ $dataTable = implode('', $productImagesList);
+ }
+ }
+ }
+ $test = 33;
+ return $dataTable ?? '';
+ },
+ 'headerOptions' => [
+// 'style' => 'width: 70px;',
+ ]
+ ],
[
'name' => 'videoFiles',
- 'title' => 'Видео: mp4, webm, ogg, mov',
+ 'title' => 'Видео: mp4, mov, avi',
'type' => FileInput::className(),
'options' => [
'options' => [
- 'multiple' => true,
+ 'multiple' => false,
'accept' => 'video/*',
'name' => 'video_name',
- 'capture' => '',
'class' => 'file'
],
'pluginOptions' => [
- 'showPreview' => false, // отключено, т.к. видео превью не поддерживаются по умолчанию
- 'showCaption' => true,
- 'showRemove' => true,
- 'showUpload' => false,
- 'overwriteInitial' => true,
+ 'showPreview' => false, // без превью
+ 'showCaption' => true, // показать название файла
+ 'showRemove' => true, // кнопка удаления
+ 'showUpload' => false, // не показывать кнопку загрузки
'browseIcon' => '+',
'cancelIcon' => 'x',
'removeIcon' => '-',
'buttonLabelClass' => 'hidden',
'fileActionSettings' => ['showUpload' => false],
- 'maxFileCount' => 10,
- 'allowedFileExtensions' => ['mp4', 'webm', 'ogg', 'mov'],
- 'multiple' => true
+ 'maxFileSize' => 51200,
+ 'allowedFileExtensions' => ['mp4', 'mov', 'avi'],
+ 'maxFileCount' => 1
],
'model' => $multipleUploadForm,
],
'columnOptions' => [
- 'class' => 'custom_css_class_file_input'
+ 'class' => 'custom_css_class_file_input',
+ 'style' => 'min-width: 240px;'
]
],
}
?>
+
+
</div>
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
+use yii\helpers\Url;
+use yii\web\View;
use yii\widgets\DetailView;
use yii_app\helpers\File;
use yii_app\records\WriteOffsErp;
$this->params['breadcrumbs'][] = $this->title;
\yii\web\YiiAsset::register($this);
+
+$this->registerCssFile('@web/css/fancybox.css');
+$this->registerJsFile('@web/js/fancybox.umd.js', ['position' => View::POS_END]);
+
$this->registerCssFile('/css/write-offs-erp.css', ['position' => \yii\web\View::POS_HEAD]);
-?>
-<style>
- .tumb img{
- width: 100px;
+
+$this->registerJs(<<<JS
+document.addEventListener('DOMContentLoaded', function() {
+ if (typeof Fancybox !== 'undefined') {
+ Fancybox.bind('[data-fancybox="gallery"]', {
+ Toolbar: true,
+ closeButton: "top",
+ dragToClose: true,
+ animated: true
+ });
}
-</style>
+});
+JS, \yii\web\View::POS_READY);
-<div class="write-offs-erp-view">
+?>
+ <style>
+ .tumb img {
+ width: 100px;
+ }
+ </style>
- <h1><?= Html::encode($this->title) ?></h1>
+ <div class="write-offs-erp-view">
- <h3><?php echo 'Номер ' . $model->number . ' от '. $model->date;?></h3>
- <h4><b><?php echo $documentStatus;?></b></h4>
+ <h1><?= Html::encode($this->title) ?></h1>
- <div style="overflow-x: scroll;">
- <?php
+ <h3><?php echo 'Номер ' . $model->number . ' от ' . $model->date; ?></h3>
+ <h4><b><?php echo $documentStatus; ?></b></h4>
+
+ <div style="overflow-x: scroll;">
+ <?php
- echo DetailView::widget([
- 'model' => $model,
- 'attributes' => [
+ echo DetailView::widget([
+ 'model' => $model,
+ 'attributes' => [
// 'id',
- 'guid',
- 'date',
- 'number',
- [
- 'attribute' => 'created_admin_id',
- 'value' => function ($model) {
- return $model->createdAdmin ? $model->createdAdmin->name : '';
- }
- ],
- [
- 'attribute' => 'confirm_admin_id',
- 'value' => function ($model) {
- return $model->confirmAdmin ? $model->confirmAdmin->name : '';
- }
- ],
+ 'guid',
+ 'date',
+ 'number',
+ [
+ 'attribute' => 'created_admin_id',
+ 'value' => function ($model) {
+ return $model->createdAdmin ? $model->createdAdmin->name : '';
+ }
+ ],
+ [
+ 'attribute' => 'confirm_admin_id',
+ 'value' => function ($model) {
+ return $model->confirmAdmin ? $model->confirmAdmin->name : '';
+ }
+ ],
// 'updated_admin_id',
// 'store_id',
- [
- 'attribute' => 'cityStoreName',
- 'label' => 'Магазин',
- 'value'=>function ($data) {
+ [
+ '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;
- }
- ],
+ return $data->cityStoreList ? $data->cityStoreList->name_full : $data->store_id;
+ }
+ ],
// 'store_guid',
// 'based_on:ntext',
- 'write_offs_type',
- 'quantity',
- 'summ',
- 'comment:ntext',
- 'error_text:ntext',
- [
- 'attribute' => 'status',
- 'filter' => WriteOffsErp::getStatusDict(),
- 'value' => function ($data) {
- return \yii\helpers\ArrayHelper::getValue(WriteOffsErp::getStatusDict(), $data->status);
- }
- ],
- [
- 'attribute' => 'number_1c',
- 'value' => function ($data) {
- return $data->number_1c ?? '';
- }
- ],
+ 'write_offs_type',
+ 'quantity',
+ 'summ',
+ 'comment:ntext',
+ 'error_text:ntext',
+ [
+ 'attribute' => 'status',
+ 'filter' => WriteOffsErp::getStatusDict(),
+ 'value' => function ($data) {
+ return \yii\helpers\ArrayHelper::getValue(WriteOffsErp::getStatusDict(), $data->status);
+ }
+ ],
+ [
+ 'attribute' => 'number_1c',
+ 'value' => function ($data) {
+ 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 .= '<th>Название</th>';
- $dataTable .= '<th>Количество</th>';
- if (!$model->isShowSum) {
- $dataTable .= '<th>Цена</th>';
- $dataTable .= '<th>Сумма</th>';
- }
- $dataTable .= '<th>Причина списания</th>';
- $dataTable .= '<th>Коментарий</th>';
- $dataTable .= '<th>Изображения</th>';
- $dataTable .= '</tr>';
- foreach ($model->writeOffsProductsErps as $key => $product) {
- $causeName = $product['cause_id'];
- if (!empty($model->listCauseDict)) {
- $causeName = ArrayHelper::getValue($model->listCauseDict, $product['cause_id']);
+ [
+ 'attribute' => 'send_at',
+ 'value' => function ($data) {
+ return $data->send_at ?? 'не отправлен';
}
- $forWidget = false;
- $images = WriteOffsErp::getImagesList($product->imagesWriteOffsErp, $forWidget);
- $dataTable .= '<tr>';
- $dataTable .= '<td>' . $product['name'] . '</td>';
- $dataTable .= '<td>' . $product['quantity'] . '</td>';
+ ],
+// 'updated_at',
+ [
+ 'attribute' => 'productsList',
+ 'label' => 'Товары',
+ 'format' => 'raw',
+ 'value' => function ($model) {
+ $dataTable = '<table>';
+ $dataTable .= '<tr>';
+ $dataTable .= '<th>Название</th>';
+ $dataTable .= '<th>Количество</th>';
if (!$model->isShowSum) {
- $dataTable .= '<td>' . $product['price'] . '</td>';
- $dataTable .= '<td>' . $product['summ'] . '</td>';
+ $dataTable .= '<th>Цена</th>';
+ $dataTable .= '<th>Сумма</th>';
}
- $dataTable .= '<td>' . $causeName . '</td>';
- $dataTable .= '<td>' . $product['comment'] . '</td>';
- $dataTable .= '<td>';
-
- if (!empty($images)) {
- if ($forWidget) {
- $dataTable .= '<div class="gallery-container">';
- $dataTable .= dosamigos\gallery\Gallery::widget(['items' => $images]);
- $dataTable .= '</div>';
- } else {
- $dataTable .= implode('', $images);
+ $dataTable .= '<th>Причина списания</th>';
+ $dataTable .= '<th>Коментарий</th>';
+ $dataTable .= '<th>Изображения</th>';
+ $dataTable .= '<th>Видео</th>';
+ $dataTable .= '</tr>';
+ foreach ($model->writeOffsProductsErps as $key => $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>';
+ if (!$model->isShowSum) {
+ $dataTable .= '<td>' . $product['price'] . '</td>';
+ $dataTable .= '<td>' . $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(['id' => $link->image_id]);
+ if (!$image || empty($image->filename)) continue;
+ $url = $image->filename;
+ $caption = $image->original_name ?? '';
+ ?>
+ <a href="<?= Html::encode($url) ?>" data-fancybox="gallery"
+ data-caption="<?= Html::encode($caption) ?>">
+ <img src="<?= Html::encode($url) ?>" alt="<?= Html::encode($caption) ?>"
+ style="max-width: 150px; margin: 5px; cursor: pointer;">
+ </a>
+ <?php endforeach; ?>
+ </div>
+ <?php endif; ?>
+ <?
+ $dataTable .= '</td>';
+ $dataTable .= '<td>';
+
+ if (!empty($videos)) {
+ if ($forWidget) {
+ $dataTable .= '<div class="gallery-container">';
+ $dataTable .= dosamigos\gallery\Gallery::widget(['items' => $videos]);
+ $dataTable .= '</div>';
+ } else {
+ $dataTable .= implode('', $videos);
+ }
+ }
- $dataTable .= '</td>';
- $dataTable .= '</tr>';
- }
- $dataTable .= '<tr>';
- $dataTable .= '<td></td>';
- $dataTable .= '<td></td>';
- if (!$model->isShowSum) {
+
+ $dataTable .= '</td>';
+ $dataTable .= '</tr>';
+ }
+ $dataTable .= '<tr>';
$dataTable .= '<td></td>';
- $dataTable .= '<td>' . $model->summ . '</td>';
- }
- $dataTable .= '<td></td>';
- $dataTable .= '<td></td>';
- $dataTable .= '</tr>';
- $dataTable .= '</table>';
- return $dataTable;
- },
- ]
- ],
- ]) ?>
- </div>
+ $dataTable .= '<td></td>';
+ if (!$model->isShowSum) {
+ $dataTable .= '<td></td>';
+ $dataTable .= '<td>' . $model->summ . '</td>';
+ }
+ $dataTable .= '<td></td>';
+ $dataTable .= '<td></td>';
+ $dataTable .= '</tr>';
+ $dataTable .= '</table>';
+ return $dataTable;
+ },
+ ]
+ ],
+ ]) ?>
+ </div>
- <div class="row">
- <p class="error-text">
+ <div class="row">
+ <p class="error-text">
- </p>
- </div>
- <p>
- <?= Html::a('К списку', ['index'], ['class' => 'btn btn-primary']) ?>
+ </p>
+ </div>
+ <p>
+ <?= Html::a('К списку', ['index'], ['class' => 'btn btn-primary']) ?>
<?php
if ($model->status === \yii_app\records\WriteOffsErp::STATUS_CREATED) {
echo Html::a('Изменить', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
],
]);
- ?><p>
- <?php
- if ($isCanConfirmWriteOffs) {
- ?>
- <?= Html::beginForm(['/write-offs-erp/confirm-write-off'], 'POST', [
+ ?><p>
+ <?php
+ if ($isCanConfirmWriteOffs) {
+ ?>
+ <?= Html::beginForm(['/write-offs-erp/confirm-write-off'], 'POST', [
- ]); ?>
+ ]); ?>
- <?= Html::csrfMetaTags();?>
+ <?= Html::csrfMetaTags(); ?>
- <?php
- echo Html::button('Согласовать', [
- 'class' => 'btn btn-success btn-lg',
- 'onclick' => "
+ <?php
+ echo Html::button('Согласовать', [
+ 'class' => 'btn btn-success btn-lg',
+ 'onclick' => "
if (confirm('Вы уверены, что хотите согласовать этот документ?')) {
$('.error-text').text('');
$.ajax ({
}
"
- ]);
- ?>
- <?= Html::endForm(); ?>
- <?php
- }
+ ]);
?>
+ <?= Html::endForm(); ?>
+ <?php
+ }
+ ?>
</p>
<?php
}
]); ?>
- <?= Html::csrfMetaTags();?>
+ <?= Html::csrfMetaTags(); ?>
<?php
echo Html::button('Отправить повторно', [
<?php
}
?>
- </p>
+ </p>
-</div>
+ </div>
<?php
/*
*/
\ No newline at end of file