From: marina Date: Mon, 3 Feb 2025 13:46:06 +0000 (+0300) Subject: ERP-302 Редактирование букета X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=27f78f825d8a3e63701d56c56ed3598351b16179;p=erp24_rep%2Fyii-erp24%2F.git ERP-302 Редактирование букета --- diff --git a/erp24/controllers/BouquetController.php b/erp24/controllers/BouquetController.php new file mode 100644 index 00000000..1444a2f2 --- /dev/null +++ b/erp24/controllers/BouquetController.php @@ -0,0 +1,39 @@ +render('index'); + } + + public function actionView() { + return $this->render('view'); + } + + public function actionUpdate() { + return $this->render('update'); + } + + public function actionGetList() + { + \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; + + $products = Products1c::find() + ->where(['tip' => Products1c::TYPE_PRODUCTS, 'view' => Products1c::IS_VISIBLE]) + ->asArray() + ->all(); + + return ArrayHelper::map($products, 'id', 'name'); + } +} diff --git a/erp24/records/BouquetComposition.php b/erp24/records/BouquetComposition.php new file mode 100644 index 00000000..7e14a46e --- /dev/null +++ b/erp24/records/BouquetComposition.php @@ -0,0 +1,61 @@ + 255], + ]; + } + + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'guid' => 'GUID букета', + 'name' => 'Название букета', + 'matrix_type_id' => 'ИД типа матрицы', + 'photo_id' => 'ИД фото', + 'video_id' => 'ИД видео', + 'created_at' => 'Дата создания', + 'updated_at' => 'Дата обновления', + 'created_by' => 'ID создателя записи', + 'updated_by' => 'ID обновителя записи', + ]; + } + + public function getBouquetCompositionProducts() + { + return $this->hasMany(BouquetCompositionProducts::class, ['bouquet_id' => 'id']); + } +} diff --git a/erp24/records/BouquetCompositionProducts.php b/erp24/records/BouquetCompositionProducts.php new file mode 100644 index 00000000..c71005ed --- /dev/null +++ b/erp24/records/BouquetCompositionProducts.php @@ -0,0 +1,58 @@ + 255], + [['bouquet_id'], 'exist', 'skipOnError' => true, 'targetClass' => BouquetComposition::class, 'targetAttribute' => ['bouquet_id' => 'id']], + ]; + } + + public function attributeLabels() + { + return [ + 'id' => 'ID', + 'bouquet_id' => 'ID букета', + 'product_guid' => 'GUID продукта', + 'count' => 'Количество продукта', + 'created_at' => 'Дата создания', + 'updated_at' => 'Дата обновления', + 'created_by' => 'ID создателя записи', + 'updated_by' => 'ID обновителя записи', + ]; + } + + public function getBouquet() + { + return $this->hasOne(BouquetComposition::class, ['id' => 'bouquet_id']); + } +} diff --git a/erp24/records/Products1c.php b/erp24/records/Products1c.php index b72a9f23..64de0abf 100644 --- a/erp24/records/Products1c.php +++ b/erp24/records/Products1c.php @@ -21,6 +21,9 @@ use yii\helpers\ArrayHelper; class Products1c extends \yii\db\ActiveRecord { + public const TYPE_PRODUCTS = 'products'; + public const IS_VISIBLE = 1; + const PRODUCT1C_FIELDS = ['id', 'parent_id', 'tip', 'code', 'name', 'articule', 'view', 'components', 'AdditionCharacteristics']; /** diff --git a/erp24/views/bouquet/index.php b/erp24/views/bouquet/index.php new file mode 100644 index 00000000..2a3f0916 --- /dev/null +++ b/erp24/views/bouquet/index.php @@ -0,0 +1,16 @@ +title = 'Составы букетов'; +?> +
+

title) ?>

+ +

+ 'btn btn-success']) ?> +

+ +
diff --git a/erp24/views/bouquet/update.php b/erp24/views/bouquet/update.php new file mode 100644 index 00000000..83a862af --- /dev/null +++ b/erp24/views/bouquet/update.php @@ -0,0 +1,72 @@ +title = 'Три гладиолуса'; +$this->params['breadcrumbs'][] = ['label' => 'Букеты', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ 'h4']) ?> +

title) ?>

+ +
+
+
+ 'form-select', 'prompt' => 'Выберите категорию']) ?> +
+
+ 'form-select', 'prompt' => 'Выберите вид']) ?> +
+
+ 'form-select', 'prompt' => 'Выберите тип']) ?> +
+
+ 'form-select', 'prompt' => 'Выберите размер']) ?> +
+
+ 'form-select', 'prompt' => 'Выберите цвет']) ?> +
+ + 'btn btn-primary w-100 mb-3', 'id' => 'apply-button']) ?> + +
+

Себестоимость: 0 ₽

+

Наценка: 0 %

+

Цена: 0 ₽

+
+
+ +
+ 'products', + 'items' => ArrayHelper::map( + Products1c::findAll(['tip' => Products1c::TYPE_PRODUCTS, 'view' => Products1c::IS_VISIBLE]), + 'id', 'name' + ), + 'ajaxUrl' => ['/bouquet/get-list'], // для асинхронной загрузки данных + 'options' => [ + 'multiple' => true, + 'size' => 10, + ], + 'triggerButton' => 'apply-button', // Кнопка, которая будет обновлять список + 'clientOptions' => [ + 'moveOnSelect' => false, + 'nonSelectedListLabel' => 'Выбор', + 'selectedListLabel' => 'Состав букета', + 'filterTextClear' => 'Показать всё', + 'filterPlaceHolder' => 'Фильтр...', + 'infoText' => 'Показано {0}', + 'infoTextFiltered' => '{0} из {1}', + 'infoTextEmpty' => 'Список пуст', + ], + ]); ?> +
+
+
diff --git a/erp24/views/bouquet/view.php b/erp24/views/bouquet/view.php new file mode 100644 index 00000000..ae401014 --- /dev/null +++ b/erp24/views/bouquet/view.php @@ -0,0 +1,85 @@ +title = $model->name; +$this->title = 'Три гладиолуса'; +//$this->title = $model->name; +$this->params['breadcrumbs'][] = ['label' => 'Букеты', 'url' => ['index']]; +$this->params['breadcrumbs'][] = $this->title; +?> +
+ 'h4']) ?> +

title) ?>

+ +
+
+ Тут типа расчеты +
+
+
+
+ 'h4']) ?> + 'attachment_4', + 'disabled' => true + ]); ?> +
+
+
+ +
+ 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']) ?> +
+ +
+
+
+
+
+
+ diff --git a/erp24/widgets/DualList.php b/erp24/widgets/DualList.php new file mode 100644 index 00000000..8aab21fd --- /dev/null +++ b/erp24/widgets/DualList.php @@ -0,0 +1,66 @@ +getView(); + + // Проверяем, что URL и кнопка переданы + if (!$this->ajaxUrl || !$this->triggerButton) { + return; + } + + // Получаем URL для AJAX-запроса и кнопки + $ajaxUrl = Url::to($this->ajaxUrl); + $triggerButton = $this->triggerButton ? '#' . $this->triggerButton : null; + + // Скрипт для обработки клика по кнопке и отправки AJAX-запроса + $js = << ``); + $('#$id').html(options.join('')); // Очищаем список и добавляем новые данные + $('#$id').bootstrapDualListbox('refresh'); // Обновляем плагин + } + }, + error: function(xhr) { + console.error('Ошибка загрузки данных:', xhr); + } + }); + } + + // Проверим, что кнопка существует + $(document).on('click', '$triggerButton', function() { + console.log('Кнопка с ID $triggerButton нажата!'); + loadDualListboxData(); + }); + + // Печать, чтобы проверить, загружен ли скрипт + console.log('JavaScript был загружен и привязан!'); +JS; + + // Регистрируем JS скрипт + $view->registerJs($js); + } +} + + +