]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-417
authormarina <m.zozirova@gmail.com>
Mon, 26 May 2025 06:58:41 +0000 (09:58 +0300)
committermarina <m.zozirova@gmail.com>
Mon, 26 May 2025 06:58:41 +0000 (09:58 +0300)
erp24/views/write_offs_erp/_form.php

index f25cca791921fb4c827db0da9213bfdb7e7eb140..017ea126cf689fdd69a851a3f0fd8b6c08df7033 100644 (file)
@@ -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
+);
 
 ?>
 <style>
     .multiple-input-list .multiple-input-list__btn.js-input-plus {
         width: 40px;
-        background-color: #42c48a  !important;
+        background-color: #42c48a !important;
     }
+
     .multiple-input-list .multiple-input-list__btn.js-input-remove {
         width: 40px;
         background-color: #ff0000 !important;
     }
+
     .btn-file {
-        height:32px !important;
+        height: 32px !important;
     }
+
     .custom_css_class_file_input {
         float: left;
         margin-right: 60px;
@@ -71,7 +74,7 @@ JS);
 </style>
 <div class="write-offs-erp-form">
 
-    <?php $form = ActiveForm::begin(    [
+    <?php $form = ActiveForm::begin([
         'id' => 'dynamic-form',
         'enableClientValidation' => false,
         'enableAjaxValidation' => true,
@@ -101,7 +104,8 @@ JS);
 
     <?= $form->field($model, 'comment')->textInput() ?>
 
-    <div><b>Разрешённые форматы для загрузки фотографий " jpg и png " !</b></div><br>
+    <div><b>Разрешённые форматы для загрузки фотографий " jpg и png " !</b></div>
+    <br>
     <?php
     $isNewRecord = $model->isNewRecord;
     $checkBoxType = BaseColumn::TYPE_HIDDEN_INPUT;
@@ -114,217 +118,216 @@ JS);
     }
     ?>
     <div style="overflow-x: scroll;">
-    <?= $form->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
+        <?= $form->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' => '<i class="glyphicon glyphicon-picture 12345"></i>',
-                        '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' => '<div class="file-preview-frame" style="height:auto;width:100%">{caption}</div>'
+                            ],
+                            'maxFileSize' => 51200,
+                            'allowedFileExtensions' => ['mp4', 'mov', 'avi'],
+                            'maxFileCount' => 1,
+                            'layoutTemplates' => [
+                                'main1' => '{preview}<div class="kv-upload-progress hide"></div>{remove}{cancel}{upload}{browse}'
                             ]
                         ],
-                        'initialPreviewAsData' => true,
-                        'previewSettings' => [
-                            'video' => '{width}: "100%", height: "auto"'
-                        ],
-                        'previewTemplates' => [
-                            'video' => '<div class="file-preview-frame" style="height:auto;width:100%">{caption}</div>'
-                        ],
-                        'maxFileSize' => 51200,
-                        'allowedFileExtensions' => ['mp4', 'mov', 'avi'],
-                        'maxFileCount' => 1,
-                        'layoutTemplates' => [
-                            'main1' => '{preview}<div class="kv-upload-progress hide"></div>{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); ?>
     </div>
 
     <?php
-    if (in_array($model->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С])) {
         ?>
         <div class="form-group">
             <?= Html::button('Сохранить', ['class' => 'btn btn-success submitter']) ?>
@@ -345,5 +348,4 @@ JS);
     ?>
 
 
-
 </div>