]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-302 Редактирование букета
authormarina <m.zozirova@gmail.com>
Thu, 27 Feb 2025 07:28:35 +0000 (10:28 +0300)
committermarina <m.zozirova@gmail.com>
Thu, 27 Feb 2025 07:28:35 +0000 (10:28 +0300)
erp24/controllers/BouquetController.php
erp24/records/BouquetComposition.php
erp24/records/BouquetCompositionProducts.php
erp24/views/bouquet/_product_edit.php
erp24/views/bouquet/_product_list.php
erp24/views/bouquet/index.php
erp24/views/bouquet/update.php

index dc2aa78e013573e2b19bfbf0408445eec4034c16..a3c31f76054ce516e1d225591c72452f07f258ff 100644 (file)
@@ -5,6 +5,7 @@ namespace app\controllers;
 use Exception;
 use Yii;
 use yii\db\Expression;
+use yii\helpers\ArrayHelper;
 use yii\helpers\Url;
 use yii\web\Controller;
 use yii\web\NotFoundHttpException;
@@ -16,6 +17,7 @@ use yii_app\records\{BouquetComposition,
     CityStore,
     Files,
     MatrixType,
+    Products1cNomenclature,
     StoreType,
     WriteOffsErp};
 
@@ -174,6 +176,21 @@ class BouquetController extends Controller
             'marketplace' => $marketplaceList,
         ];
     }
+
+    public function actionGetList()
+    {
+        Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
+
+        $query = Products1cNomenclature::find()
+            ->andFilterWhere(['size' => Yii::$app->request->post('size')])
+            ->andFilterWhere(['type' => Yii::$app->request->post('type')])
+            ->andFilterWhere(['species' => Yii::$app->request->post('species')])
+            ->andFilterWhere(['color' => Yii::$app->request->post('color')])
+            ->andFilterWhere(['category' => Yii::$app->request->post('category')]);
+
+        return ArrayHelper::map($query->all(), 'id', 'name');
+    }
+
     public function actionConfirm(int $id): \yii\web\Response
     {
         $model = BouquetComposition::findOne($id) ?? throw new NotFoundHttpException('Букет не найден');
index 115ebf68a9c90c0df17bd907cf560cee6ebf0b31..4b08d316b7822b28e244522eedd7b58893afe738 100644 (file)
@@ -25,6 +25,7 @@ use yii_app\services\FileService;
  * @property string|null $date_confirm
  * @property string|null $date_1c_send
  * @property string|null $confirm_admin
+ * @property string|null $error_text
  *
  * @property BouquetCompositionProducts[] $bouquetCompositionProducts
  * @property BouquetCompositionMatrixTypeHistory $matrixType
@@ -87,6 +88,7 @@ class BouquetComposition extends ActiveRecord
             [['created_by', 'updated_by', 'status', 'date_1c_send', 'date_confirm'], 'integer', 'message' => '{attribute} должен быть целым числом'],
             [['created_at', 'updated_at', 'admin_confirm'], 'safe'],
             [['guid', 'name'], 'string', 'max' => 255, 'tooLong' => '{attribute} не должен превышать 255 символов'],
+            [['error_text'], 'string'],
             [['photo_bouquet'], 'file',
                 'extensions' => 'jpg, jpeg, png, gif',
                 'maxFiles' => 10,
@@ -116,7 +118,7 @@ class BouquetComposition extends ActiveRecord
             'confirm_admin' => 'ID подтвердившего',
             'updated_by' => 'ID обновителя записи',
             'status' => 'Статус',
-
+            'error_text' => 'Ошибка',
         ];
     }
 
index 4156da4898c9df5d3e5744cd6188a926c66b636b..17a280e8b73d562f98f10acb38240fcddf34b2f7 100644 (file)
@@ -114,8 +114,7 @@ class BouquetCompositionProducts extends ActiveRecord
      */
     public static function getAvailableItems(bool $isNewRecord, ?int $bouquetId = null): array
     {
-        $query = Products1c::find()
-            ->where(['view' => Products1c::IS_VISIBLE, 'tip' => Products1c::TYPE_PRODUCTS]);
+        $query = Products1cNomenclature::find();
 
         if (!$isNewRecord && $bouquetId) {
             $selectedIds = self::find()
index dbf0f56a720e17f7922da6ecf11e46035eccc078..3f7d9bf0ba14b053b5740f048eda23a0125106ff 100644 (file)
@@ -14,7 +14,7 @@ use yii_app\records\BouquetComposition;
     'showQuantity' => true,
     'listContainerSize' => $listContainerSize,
     'triggerButton' => 'apply-button',
-    'filterFields' => ['size', 'color', 'species', 'category', 'type-num']
+    'filterFields' => ['size', 'color', 'species', 'category', 'type']
 ]) ?>
 <br>
 
index c5b5358ddcb8d23888e1f858782c2d1db68207a9..b198550182a8450efd1fd0d94abbede4f3a9a587 100644 (file)
             'class' => 'btn btn-success btn-edit w-100 mt-4'
         ]) ?>
     </div>
-<?php }?>
\ No newline at end of file
+<?php }?>
+<?php if ($model && !empty($model->error_text)): ?>
+    <div class="row">
+        <span class="badge bg-danger fs-6 ms-3 text-white w-95 mb-4 d-block" style="word-wrap: break-word; white-space: normal;">
+            <?= Html::encode($model->error_text) ?>
+        </span>
+    </div>
+<?php endif; ?>
index 345b964609154b194bf27c497b106453f5181164..1522737aec1a1ec67a80ed35e02eaee7e74878bc 100644 (file)
@@ -9,6 +9,7 @@ use yii_app\records\BouquetComposition;
 use yii_app\records\Files;
 use yii_app\records\MatrixType;
 use yii_app\records\Products1c;
+use yii_app\records\WriteOffsErp;
 
 /** @var yii\web\View $this */
 $this->title = 'Содержание матрицы';
@@ -29,21 +30,9 @@ $this->title = 'Содержание матрицы';
         </div>
 
         <div class="col-md-2">
-            <div class="form-group mb-0">
-                <?= Html::dropDownList("year", Yii::$app->request->get('year'), BouquetComposition::getYears(), [
-                    'class' => 'form-control',
-                    'prompt' => 'Год'
-                ]) ?>
-            </div>
         </div>
 
         <div class="col-md-2">
-            <div class="form-group mb-0">
-                <?= Html::dropDownList("month", Yii::$app->request->get('month'), \yii_app\helpers\DateHelper::MONTH_NUMBER_NAMES, [
-                    'class' => 'form-control',
-                    'prompt' => 'Месяц'
-                ]) ?>
-            </div>
         </div>
 
         <div class="col-md-2 mt-5">
@@ -167,7 +156,34 @@ $this->title = 'Содержание матрицы';
                                 ['style' => 'width: 100%; height: 100%; object-fit: cover;']) . "
                                     </div>
                                 </div>
-
+                                <div class='col-md-3 pt-1 text-center'>
+                                    <div class='row'>
+                                        " . (!empty($model->status) ? "
+                                            <label class='h5 fw-bold mb-1'>Статус букета</label>
+                                            <span class='badge " .
+                                                                match ($model->status) {
+                                                                    WriteOffsErp::STATUS_CREATED => 'bg-info',
+                                                                    WriteOffsErp::STATUS_CONFIRM,
+                                                                    WriteOffsErp::STATUS_CREATED_1С => 'bg-success',
+                                                                    WriteOffsErp::STATUS_SEND => 'bg-warning',
+                                                                    WriteOffsErp::STATUS_DISABLE,
+                                                                    WriteOffsErp::STATUS_ERROR_1С => 'bg-danger',
+                                                                    default => 'bg-secondary',
+                                                                } .
+                                                                " fs-6 text-white px-7 w-100 mb-4 d-block'>
+                                                " . Html::encode(\yii_app\records\WriteOffsErp::STATUSES[$model->status] ?? '') . "
+                                            </span>
+                                        " : "") . "
+                                    </div>
+                                    " . (!empty($model->error_text) ? "
+                                    <div class='row'>
+                                        <label class='h5 fw-bold mb-1'>Ошибка</label>
+                                        <span class='badge bg-danger fs-6 text-white w-100 mb-4 d-block' style='word-wrap: break-word; white-space: normal;'>
+                                            " . Html::encode($model->error_text) . "
+                                        </span>
+                                    </div>
+                                    " : "") . "
+                                </div>
                                 <div class='row mt-auto text-center'>
                                     <div class='col-md-7'></div>
                                     <div class='col-md-2'>
index 6c9c7460ddd38f626936ff2053b549158662fdc8..6fc7ae1eb170ad83ea93dd2d8c88d88cc7067497 100644 (file)
@@ -41,7 +41,7 @@ $this->registerJsFile('/js/bouquet/bouquet.js', ['position' => \yii\web\View::PO
                 <?= Html::dropDownList('species', null, Products1cNomenclature::find()->select('species')->distinct()->column(), ['class' => 'form-select', 'prompt' => 'Выберите вид', 'id' => 'species']) ?>
             </div>
             <div class="row mb-2">
-                <?= Html::dropDownList('type', null, Products1cNomenclature::find()->select('type_num')->distinct()->column(), ['class' => 'form-select', 'prompt' => 'Выберите тип', 'id' => 'type_num']) ?>
+                <?= Html::dropDownList('type', null, Products1cNomenclature::find()->select('type')->distinct()->column(), ['class' => 'form-select', 'prompt' => 'Выберите тип', 'id' => 'type']) ?>
             </div>
             <div class="row mb-2">
                 <?= Html::dropDownList('size', null, Products1cNomenclature::find()->select('size')->distinct()->column(), ['class' => 'form-select', 'prompt' => 'Выберите размер', 'id' => 'size']) ?>