From a7c940aba81f686b46a2e81395df5bce7774272e Mon Sep 17 00:00:00 2001 From: marina Date: Mon, 26 May 2025 09:58:41 +0300 Subject: [PATCH] ERP-417 --- erp24/views/write_offs_erp/_form.php | 364 ++++++++++++++------------- 1 file changed, 183 insertions(+), 181 deletions(-) diff --git a/erp24/views/write_offs_erp/_form.php b/erp24/views/write_offs_erp/_form.php index f25cca79..017ea126 100644 --- a/erp24/views/write_offs_erp/_form.php +++ b/erp24/views/write_offs_erp/_form.php @@ -30,7 +30,6 @@ use yii_app\records\WriteOffsProductsErp; /** @var yii_app\forms\MultipleUploadForm $multipleUploadForm */ - $this->registerJsFile('/js/validate/validateForm.js', ['position' => \yii\web\View::POS_END]); $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]); @@ -47,21 +46,25 @@ document.addEventListener('DOMContentLoaded', function() { } }); }); -JS); +JS +); ?>
- 'dynamic-form', 'enableClientValidation' => false, 'enableAjaxValidation' => true, @@ -101,7 +104,8 @@ JS); field($model, 'comment')->textInput() ?> -
Разрешённые форматы для загрузки фотографий " jpg и png " !

+
Разрешённые форматы для загрузки фотографий " jpg и png " !
+
isNewRecord; $checkBoxType = BaseColumn::TYPE_HIDDEN_INPUT; @@ -114,217 +118,216 @@ JS); } ?>
- field($model, 'modelsProducts')->widget(MultipleInput::className(), [ - 'min' => 0, - 'max' => 100, - 'columns' => [ - [ - 'name' => 'id', - 'type' => BaseColumn::TYPE_HIDDEN_INPUT, - 'value' => function($data) { - return $data['id'] ?? ''; - }, - 'headerOptions' => [ - 'style' => 'width: 70px;', - ] - ], - [ - 'name' => 'num_row', - 'type' => BaseColumn::TYPE_HIDDEN_INPUT, - 'value' => function($data) { - return $data['num_row'] ?? ''; - }, - 'headerOptions' => [ - 'style' => 'width: 70px;', - ] - ], - [ - 'name' => 'product_id', - 'type' => Select2::classname(), - 'enableError' => true, - 'title' => 'Товар', - 'options' => [ - 'data' => $listProductsDict + field($model, 'modelsProducts')->widget(MultipleInput::className(), [ + 'min' => 0, + 'max' => 100, + 'columns' => [ + [ + 'name' => 'id', + 'type' => BaseColumn::TYPE_HIDDEN_INPUT, + 'value' => function ($data) { + return $data['id'] ?? ''; + }, + 'headerOptions' => [ + 'style' => 'width: 70px;', + ] ], - 'items' => $listProductsDict, - ], - [ - 'name' => 'quantity', - 'type' => 'textInput', - 'title' => 'Количество', + [ + 'name' => 'num_row', + 'type' => BaseColumn::TYPE_HIDDEN_INPUT, + 'value' => function ($data) { + return $data['num_row'] ?? ''; + }, + 'headerOptions' => [ + 'style' => 'width: 70px;', + ] + ], + [ + 'name' => 'product_id', + 'type' => Select2::classname(), + 'enableError' => true, + 'title' => 'Товар', + 'options' => [ + 'data' => $listProductsDict + ], + 'items' => $listProductsDict, + ], + [ + 'name' => 'quantity', + 'type' => 'textInput', + 'title' => 'Количество', - ], - [ - 'name' => 'cause_id', - 'type' => 'dropDownList', - 'title' => 'Причина списания', - 'items' => $listCauseDict, - ], - [ - 'name' => 'add_image', - 'type' => $checkBoxType, - 'title' => 'Добавить файлы', - 'options' => [ - 'data' => [0,1] ], -// 'items' => [0,1], - ], - [ - 'name' => 'imageFiles', - 'title' => 'Фотографии: jpg и png', - 'type' => FileInput::className(), - 'options' => [ + [ + 'name' => 'cause_id', + 'type' => 'dropDownList', + 'title' => 'Причина списания', + 'items' => $listCauseDict, + ], + [ + 'name' => 'add_image', + 'type' => $checkBoxType, + 'title' => 'Добавить файлы', 'options' => [ - 'multiple' => true, - 'accept' => 'image/*', - 'name' => 'image_name', - 'capture' => '', - 'class' => 'file', - 'required' => true, + 'data' => [0, 1] ], - 'pluginOptions' => [ +// 'items' => [0,1], + ], + [ + 'name' => 'imageFiles', + 'title' => 'Фотографии: jpg и png', + 'type' => FileInput::className(), + 'options' => [ + 'options' => [ + 'multiple' => true, + 'accept' => 'image/*', + 'name' => 'image_name', + 'capture' => '', + 'class' => 'file', + 'required' => true, + ], + 'pluginOptions' => [ // 'previewFileType' => ['jpg','png'], // 'allowedFileExtensions'=>['jpg','png'], - 'showPreview' => false, - 'showCaption' => true, - 'showRemove' => true, - 'showUpload' => false, - //'uploadClass' => 'hide', + 'showPreview' => false, + 'showCaption' => true, + 'showRemove' => true, + 'showUpload' => false, + //'uploadClass' => 'hide', // 'initialPreview'=> $initalImages, - 'overwriteInitial'=>true, + 'overwriteInitial' => true, // 'initialPreviewAsData'=>true, - //initialPreviewAsData: false, + //initialPreviewAsData: false, // 'bsColCssPrefixes'=>3, - // 'uploadUrl' => Url::to(['/site/image-manager-upload']), - 'browseIcon' => '+', - 'cancelIcon' => 'x', - 'removeIcon' => '-', - 'buttonLabelClass' => 'hidden', + // 'uploadUrl' => Url::to(['/site/image-manager-upload']), + 'browseIcon' => '+', + 'cancelIcon' => 'x', + 'removeIcon' => '-', + 'buttonLabelClass' => 'hidden', // 'browseIcon' => '', - 'fileActionSettings' =>['showUpload' => false], - 'maxFileCount' => 10, - 'multiple' => true + 'fileActionSettings' => ['showUpload' => false], + 'maxFileCount' => 10, + 'multiple' => true + ], + 'model' => $multipleUploadForm, ], - 'model' => $multipleUploadForm, + 'columnOptions' => [ + 'class' => 'custom_css_class_file_input' + ] ], - 'columnOptions' => [ - 'class' => 'custom_css_class_file_input' - ] - ], - [ - 'name' => 'images_row', - 'type' => BaseColumn::TYPE_STATIC, - 'value' => function($data) { + [ + '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, - ]); + 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']); + $query->joinWith(['imagesWriteOffsErp']); - $action = $query->createCommand()->getRawSql(); + $action = $query->createCommand()->getRawSql(); - $modelWriteOffsProductsErp = $query->All(); - $productImagesList = []; - $forWidget = false; - foreach ($modelWriteOffsProductsErp as $item) { - $productImagesList = WriteOffsErp::getImagesList($item->imagesWriteOffsErp, $forWidget); - } - if (!empty($productImagesList)) { + $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); + if ($forWidget) { + $dataTable = dosamigos\gallery\Gallery::widget(['items' => $productImagesList]); + } else { + $dataTable = implode('', $productImagesList); + } } } - } - $test = 33; - return $dataTable ?? ''; - }, - 'headerOptions' => [ + $test = 33; + return $dataTable ?? ''; + }, + 'headerOptions' => [ // 'style' => 'width: 70px;', - ] - ], - [ - 'name' => 'videoFiles', - 'title' => 'Видео: mp4, mov, avi', - 'type' => FileInput::className(), - 'value' => function ($data) { - var_dump(basename(Files::findOne(['entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, 'entity_id' => $data['id']])->url ?? ''));die(); - return $data; - }, // Текущее значение (название файла) - 'options' => [ + ] + ], + [ + 'name' => 'videoFiles', + 'title' => 'Видео: mp4, mov, avi', + 'type' => FileInput::className(), + 'value' => function ($data) { + return basename(Files::findOne(['entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, 'entity_id' => $data['id']])->url ?? ''); + }, 'options' => [ - 'multiple' => false, - 'accept' => 'video/*', - 'name' => 'video_name', - 'class' => 'file' - ], - 'pluginOptions' => [ - 'showPreview' => true, - 'showCaption' => true, - 'showRemove' => true, - 'showUpload' => false, - 'browseIcon' => '+', - 'cancelIcon' => 'x', - 'removeIcon' => '-', - 'buttonLabelClass' => 'hidden', - 'fileActionSettings' => [ - 'showUpload' => false, - 'showZoom' => false, - 'showDrag' => false + 'options' => [ + 'multiple' => false, + 'accept' => 'video/*', + 'name' => 'video_name', + 'class' => 'file' ], - 'initialPreview' => [ + 'pluginOptions' => [ + 'showPreview' => true, + 'showCaption' => true, + 'showRemove' => true, + 'showUpload' => false, + 'browseIcon' => '+', + 'cancelIcon' => 'x', + 'removeIcon' => '-', + 'buttonLabelClass' => 'hidden', + 'fileActionSettings' => [ + 'showUpload' => false, + 'showZoom' => false, + 'showDrag' => false + ], + 'initialPreview' => [ // $model->video_name // Показываем текущее название файла - ], - 'initialPreviewConfig' => [ - [ + ], + 'initialPreviewConfig' => [ + [ // 'caption' => $model->video_name, // Подпись под файлом - 'type' => 'video', // Тип файла + 'type' => 'video', // Тип файла // 'size' => filesize($model->getVideoPath()), // Размер файла (если нужно) + ] + ], + 'initialPreviewAsData' => true, + 'previewSettings' => [ + 'video' => '{width}: "100%", height: "auto"' + ], + 'previewTemplates' => [ + 'video' => '
{caption}
' + ], + 'maxFileSize' => 51200, + 'allowedFileExtensions' => ['mp4', 'mov', 'avi'], + 'maxFileCount' => 1, + 'layoutTemplates' => [ + 'main1' => '{preview}
{remove}{cancel}{upload}{browse}' ] ], - 'initialPreviewAsData' => true, - 'previewSettings' => [ - 'video' => '{width}: "100%", height: "auto"' - ], - 'previewTemplates' => [ - 'video' => '
{caption}
' - ], - 'maxFileSize' => 51200, - 'allowedFileExtensions' => ['mp4', 'mov', 'avi'], - 'maxFileCount' => 1, - 'layoutTemplates' => [ - 'main1' => '{preview}
{remove}{cancel}{upload}{browse}' - ] + 'model' => $multipleUploadForm, ], - 'model' => $multipleUploadForm, + 'columnOptions' => [ + 'class' => 'custom_css_class_file_input', + 'style' => 'min-width: 240px;' + ] ], - 'columnOptions' => [ - 'class' => 'custom_css_class_file_input', - 'style' => 'min-width: 240px;' - ] - ], - [ - 'name' => 'comment', - 'type' => 'textInput', - 'title' => 'Комментарий', + [ + 'name' => 'comment', + 'type' => 'textInput', + 'title' => 'Комментарий', - ], + ], - ], - 'addButtonPosition' => MultipleInput::POS_FOOTER, // show add button in the header - ])->label(false);?> + ], + 'addButtonPosition' => MultipleInput::POS_FOOTER, // show add button in the header + ])->label(false); ?>
status,[\yii_app\records\WriteOffsErp::STATUS_CREATED,\yii_app\records\WriteOffsErp::STATUS_ERROR_1С])) { + if (in_array($model->status, [\yii_app\records\WriteOffsErp::STATUS_CREATED, \yii_app\records\WriteOffsErp::STATUS_ERROR_1С])) { ?>
'btn btn-success submitter']) ?> @@ -345,5 +348,4 @@ JS); ?> -
-- 2.39.5