From 64f24f957e7d455249310652283ad95f53a5a8d4 Mon Sep 17 00:00:00 2001 From: marina Date: Mon, 10 Feb 2025 14:31:47 +0300 Subject: [PATCH] =?utf8?q?ERP-302=20=D0=A0=D0=B5=D0=B4=D0=B0=D0=BA=D1=82?= =?utf8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B8=D0=B5=20=D0=B1=D1=83?= =?utf8?q?=D0=BA=D0=B5=D1=82=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/composer.json | 2 +- erp24/controllers/BouquetController.php | 42 ++- ...10_112755_add_new_column_on_store_type.php | 25 ++ erp24/records/BouquetComposition.php | 7 +- erp24/records/StoreType.php | 4 +- erp24/views/bouquet/view.php | 257 +++++++++++------- 6 files changed, 215 insertions(+), 122 deletions(-) create mode 100644 erp24/migrations/m250210_112755_add_new_column_on_store_type.php diff --git a/erp24/composer.json b/erp24/composer.json index ec2445cc..b408c64e 100644 --- a/erp24/composer.json +++ b/erp24/composer.json @@ -38,7 +38,7 @@ "enqueue/amqp-lib": "^0.10.19", "vlucas/phpdotenv": "^5.6", "softark/yii2-dual-listbox": "^1.0", - "kartik-v/yii2-widget-depdrop": "dev-master" + "kartik-v/yii2-widget-depdrop": "dev-master", }, "require-dev": { "yiisoft/yii2-debug": "~2.1.0", diff --git a/erp24/controllers/BouquetController.php b/erp24/controllers/BouquetController.php index a0b6d35e..32b2dfb0 100644 --- a/erp24/controllers/BouquetController.php +++ b/erp24/controllers/BouquetController.php @@ -7,10 +7,13 @@ use Yii; use yii\helpers\ArrayHelper; use yii\web\Controller; use yii\web\NotFoundHttpException; +use yii\web\UploadedFile; use yii_app\records\BouquetComposition; use yii_app\records\BouquetCompositionProducts; +use yii_app\records\CityStore; use yii_app\records\Products1c; use yii_app\records\Products1cNomenclature; +use yii_app\records\StoreType; /** * Контроллер для управления букетами и их составами. @@ -24,7 +27,11 @@ class BouquetController extends Controller public function actionView() { - return $this->render('view'); + $storesTypeList = ArrayHelper::map(StoreType::find()->all(), 'id', 'name'); + $storesList = ArrayHelper::map(CityStore::findAll(['visible' => CityStore::IS_VISIBLE]), 'id', 'name'); + return $this->render('view', [ + 'storesList' => $storesList + ]); } public function actionUpdate($id) @@ -34,13 +41,6 @@ class BouquetController extends Controller if (!$model) { throw new NotFoundHttpException('Букет не найден.'); } -// -// if (Yii::$app->request->isPost) { -// echo '
';
-//            var_dump(Yii::$app->request->post());
-//            echo '
'; -// die(); -// } if (Yii::$app->request->isPost) { try { @@ -94,30 +94,20 @@ class BouquetController extends Controller 'availableItems' => $availableItems, ]); } - public function actionUploadPhoto() { - $model = new \yii\base\DynamicModel(['images']); + public function actionUpload() + { + $model = new BouquetComposition(); if (Yii::$app->request->isPost) { - $files = UploadedFile::getInstances($model, 'images'); - $savedFiles = []; - - foreach ($files as $file) { - $filePath = 'uploads/' . $file->baseName . '.' . $file->extension; - if ($file->saveAs($filePath)) { - $savedFiles[] = $filePath; - } + $model->photo_id = UploadedFile::getInstance($model, 'photo_id'); + if ($model->validate() && $model->upload()) { + // Логика для сохранения } - - // Переадресуем обратно, передавая список загруженных файлов - return $this->render('upload', [ - 'initialPreview' => $savedFiles - ]); } - return $this->render('upload', [ - 'initialPreview' => [] - ]); + return $this->render('upload', ['model' => $model]); } + public function actionGetList() { \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; diff --git a/erp24/migrations/m250210_112755_add_new_column_on_store_type.php b/erp24/migrations/m250210_112755_add_new_column_on_store_type.php new file mode 100644 index 00000000..ce9a860a --- /dev/null +++ b/erp24/migrations/m250210_112755_add_new_column_on_store_type.php @@ -0,0 +1,25 @@ +addColumn('store_type', 'sequence_number', $this->integer()->comment('Порядковый номер')); + } + + /** + * {@inheritdoc} + */ + public function safeDown() + { + $this->dropColumn('store_type', 'sequence_number'); + } +} diff --git a/erp24/records/BouquetComposition.php b/erp24/records/BouquetComposition.php index ec122b94..c791c6ee 100644 --- a/erp24/records/BouquetComposition.php +++ b/erp24/records/BouquetComposition.php @@ -1,4 +1,5 @@ 'jpg, jpeg, png, gif'], + + [['guid', 'name'], 'string', 'max' => 255], ]; } diff --git a/erp24/records/StoreType.php b/erp24/records/StoreType.php index 36af210d..52a21a1b 100644 --- a/erp24/records/StoreType.php +++ b/erp24/records/StoreType.php @@ -16,6 +16,7 @@ use yii\db\Expression; * @property string $created_at * @property int|null $updated_by * @property string|null $updated_at + * @property int $sequence_number */ class StoreType extends \yii\db\ActiveRecord { @@ -51,7 +52,7 @@ class StoreType extends \yii\db\ActiveRecord { return [ [['name'], 'required'], - [['created_by', 'updated_by'], 'integer'], + [['created_by', 'updated_by', 'sequence_number'], 'integer'], [['created_at', 'updated_at'], 'safe'], [['name'], 'string', 'max' => 255], ]; @@ -69,6 +70,7 @@ class StoreType extends \yii\db\ActiveRecord 'created_at' => 'Дата создания', 'updated_by' => 'ИД редактировавшего', 'updated_at' => 'Дата обновления', + 'sequence_number' => 'Порядковый номер', ]; } } diff --git a/erp24/views/bouquet/view.php b/erp24/views/bouquet/view.php index a98ac849..9dc55b1d 100644 --- a/erp24/views/bouquet/view.php +++ b/erp24/views/bouquet/view.php @@ -9,6 +9,7 @@ use yii\helpers\Html; use yii\helpers\Url; use yii\widgets\ActiveForm; use yii\widgets\DetailView; +use yii_app\records\BouquetComposition; use yii_app\records\MatrixType; /** @var yii\web\View $this */ @@ -21,14 +22,25 @@ $this->title = 'Три гладиолуса'; $this->params['breadcrumbs'][] = ['label' => 'Букеты', 'url' => ['index']]; $this->params['breadcrumbs'][] = $this->title; ?> +registerCss(" + .file-caption { + max-width: 62% !important; + } + "); +?>
+ ['enctype' => 'multipart/form-data'], // Это необходимо для загрузки файлов + ]); + ?>

title) ?>

-
+
'h5 mb-0']) ?>
@@ -40,9 +52,9 @@ $this->params['breadcrumbs'][] = $this->title;
-
-
-
Название
+
+
+
Название
Кол-во
% списания
мрж-ть
@@ -50,9 +62,9 @@ $this->params['breadcrumbs'][] = $this->title;
ср.шт. в сборке
-
+
-
Гладиолусы краш
+
Гладиолусы краш
3.0
10%
30%
@@ -60,99 +72,158 @@ $this->params['breadcrumbs'][] = $this->title;
3.2%
+
+
+
+ 'btn btn-warning w-100']) ?> +
+
-
-

Загрузите файлы

+
+
+ +
'text-center font-weight-bold pt-5 h5']) ?>
+ field($model, 'photo_id[]')->widget(FileInput::class, [ + 'options' => [ + 'id' => 'bouquet-file-upload', + 'multiple' => true, // Поддержка выбора нескольких файлов + ], + 'language' => 'ru', + 'pluginOptions' => [ + 'showPreview' => true, + 'showUpload' => false, + 'showCancel' => false, + 'mainClass' => 'input-group-lg', + 'initialPreview' => [], // Задайте начальный список для предварительного просмотра (если есть) + 'maxFileSize' => 2800, // Максимальный размер файла (в килобайтах) + 'dropZoneTitle' => 'Выберите файл', // Текст на зоне для перетаскивания + 'browseOnZoneClick' => true, // Разрешить клик по зоне перетаскивания + 'fileActionSettings' => [ + 'showZoom' => false, // Убираем иконку для увеличения + ], + ], + ])->label(false) ?> +
+
+
+
'text-center font-weight-bold pt-5 h5']) ?>
+ field($model, 'photo_id[]')->widget(FileInput::class, [ + 'options' => [ + 'id' => 'video-file-upload', + 'multiple' => false, // Поддержка выбора нескольких файлов + ], + 'language' => 'ru', + 'pluginOptions' => [ + 'showPreview' => true, + 'showUpload' => false, + 'showCancel' => false, + 'mainClass' => 'input-group-lg', + 'initialPreview' => [], // Задайте начальный список для предварительного просмотра (если есть) + 'maxFileSize' => 2800, // Максимальный размер файла (в килобайтах) + 'dropZoneTitle' => 'Выберите файл', // Текст на зоне для перетаскивания + 'browseOnZoneClick' => true, // Разрешить клик по зоне перетаскивания + 'fileActionSettings' => [ + 'showZoom' => false, // Убираем иконку для увеличения + ], + ], + ])->label(false) ?> +
+
+
'text-center font-weight-bold pt-5 h5']) ?>
+ field($model, 'photo_id[]')->widget(FileInput::class, [ + 'options' => [ + 'id' => 'presentation-file-upload', + 'multiple' => false, // Поддержка выбора нескольких файлов + ], + 'language' => 'ru', + 'pluginOptions' => [ + 'showPreview' => true, + 'showUpload' => false, + 'showCancel' => false, + 'mainClass' => 'input-group-lg', + 'initialPreview' => [], // Задайте начальный список для предварительного просмотра (если есть) + 'maxFileSize' => 2800, // Максимальный размер файла (в килобайтах) + 'dropZoneTitle' => 'Выберите файл', // Текст на зоне для перетаскивания + 'browseOnZoneClick' => true, // Разрешить клик по зоне перетаскивания + 'fileActionSettings' => [ + 'showZoom' => false, // Убираем иконку для увеличения + ], + ], + ])->label(false) ?> +
+
- 'file-upload-widget', // Можно указать свой id - 'inputId' => 'file-upload', // Можно указать свой id для input - ]); - ?>
- -
- инпут поля +
'text-center font-weight-bold pt-5 h5']) ?>
+
+
+
'font-weight-bold pt-3 h6']) ?>
+
2024, 2025 => 2025], ['class' => 'form-control']) ?>
+
+
+
'font-weight-bold pt-3 h6']) ?>
+
'form-control']) ?>
+
+
+
+ 'text-center font-weight-bold pt-4 h6']) ?> +
+
+
+
+
+ +
+
+ +
+
+
+
+
+ 'text-center font-weight-bold pt-3 h6']) ?> +
+
+
+
+ + +
+
+ +
'; + } ?> +
+
+
+
+ 'text-center font-weight-bold pt-3 h6']) ?> +
+
+
+
+ + +
+
+ +
'; + } ?> +
+
+
+
+
+
+
+
+ 'btn btn-success w-100']) ?>
- - - - - 'h4']) ?> - 'attachment_4', - // 'disabled' => true - // ]); ?> - - - 'h4']) ?> - 'attachment_4', - // 'disabled' => true - // ]); ?> - - - --> - --> - --> - --> 'h4']) ?> - --> - --> - - --> - --> - --> - - -->all(), 'id', 'name'), ['class' => 'form-control', 'prompt' => 'Тип матрицы']) ?> - --> - --> - --> - - --> 'h5 text-center pt-5']) ?> - --> - --> - --> - --> 'h5 pt-2']) ?> - --> - --> - - --> 'form-control']) ?> - --> - --> - --> - --> - - --> 'h5 pt-2']) ?> - --> - --> - - --> 'form-control']) ?> - --> - --> - --> - - --> 'h5 text-center pt-5']) ?> - --> - --> - - -->all() as $number => $store) { ?> - --> - --> - name) ?> --> - --> - --> - - -->id", null, ['class' => 'form-control']) ?> - --> - --> - --> - --> - -
+
-- 2.39.5