]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-282 Нужно сделать интерфейс настройки магазина
authormarina <m.zozirova@gmail.com>
Tue, 28 Jan 2025 06:34:30 +0000 (09:34 +0300)
committermarina <m.zozirova@gmail.com>
Tue, 28 Jan 2025 06:34:30 +0000 (09:34 +0300)
erp24/controllers/CityStoreParamsController.php
erp24/views/city-store-params/index.php
erp24/web/js/city-store-params/city-store-params.js

index f549d26ad3fe3920506e766042c5e1df121b1e97..c9b1b571caee2d7a8e96c8c8022897e1e533240b 100644 (file)
@@ -166,8 +166,6 @@ class CityStoreParamsController extends Controller
         $store = CityStore::findOne($storeId);
         if (!$store) return ['success' => false, 'message' => 'Магазин не найден'];
 
-        $bushId = StoreDynamic::findOne(['store_id' => $storeId, 'category' => 1, 'active' => 1])->value_int ?? null;
-
         return [
             'success' => true,
             'data' => [
@@ -185,7 +183,10 @@ class CityStoreParamsController extends Controller
                 'freezeArea' => $params->freeze_area ?? null,
                 'freezeVolume' => $params->freeze_volume ?? null,
                 'matrixType' => !empty($params->matrix_type) ? explode(',', $params->matrix_type) : null,
-                'territorialManagerArray' => ArrayHelper::map(Admin::findAll(['id' => StoreDynamic::find()->andWhere(['category' => 3, 'active' => 1])->select('value_int')->column()]), 'id', 'name'),
+                'territorialManagerArray' => array_unique(array_merge(
+                    ArrayHelper::map(Admin::findAll(['group_id' => AdminGroup::GROUP_BUSH_DIRECTOR]), 'id', 'name'),
+                    ArrayHelper::map(Admin::findAll(['id' => StoreDynamic::find()->andWhere(['category' => 3, 'active' => 1])->select('value_int')->column()]), 'id', 'name')
+                ), SORT_REGULAR),
                 'storeTypeArray' => ArrayHelper::map(StoreType::find()->all(), 'id', 'name'),
                 'regionArray' => ArrayHelper::map(StoreCityList::findAll(['type' => StoreCityList::TYPE_REGION]), 'id', 'name'),
                 'cityArray' => ArrayHelper::map(StoreCityList::findAll(['type' => StoreCityList::TYPE_CITY]), 'id', 'name'),
index 8b8598a18552d0126f7b7321979f7ebe61429d08..f3cd0a03e75b0d5dc9978ee5bd79524459e7a8b3 100644 (file)
@@ -27,7 +27,7 @@ $this->registerJsFile('/js/city-store-params/city-store-params.js', ['position'
 
     <div class="row">
         <div class="col-md-2">
-            <div class="card p-3 bg-light shadow-sm">
+            <div class="card p-2 bg-light shadow-sm">
                 <?= Select2::widget([
                     'name' => 'address_region',
                     'value' => null,
@@ -48,53 +48,109 @@ $this->registerJsFile('/js/city-store-params/city-store-params.js', ['position'
             </div>
         </div>
         <div class="col-md-2">
-            <div class="card p-3 bg-light shadow-sm">
-                <?= Html::dropDownList('address_city', null,
-                    ArrayHelper::map(StoreCityList::findAll(['type' => StoreCityList::TYPE_CITY]), 'id', 'name'),
-                    ['prompt' => 'Город', 'class' => 'form-select', 'id' => 'address_city']);
+            <div class="card p-2 bg-light shadow-sm">
+                <?= Select2::widget([
+                    'name' => 'address_city',
+                    'value' => null,
+                    'data' => ArrayHelper::map(StoreCityList::findAll(['type' => StoreCityList::TYPE_CITY]), 'id', 'name'),
+                    'options' => [
+                        'placeholder' => 'Город',
+                        'class' => 'form-select',
+                        'id' => 'address_city',
+                    ],
+                    'pluginOptions' => [
+                        'allowClear' => true,
+                    ],
+                ]);
+                ?>
+                <?= Html::a('Редактировать', [
+                    Url::to('/store-city-list')], ['class' => 'd-block mt-2 text-decoration-none']);
                 ?>
             </div>
         </div>
         <div class="col-md-2 border-end border-2">
-            <div class="card p-3 bg-light shadow-sm">
-                <?= Html::dropDownList('address_district', null,
-                    ArrayHelper::map(StoreCityList::findAll(['type' => StoreCityList::TYPE_DISTRICT]), 'id', 'name'),
-                    ['prompt' => 'Район', 'class' => 'form-select', 'id' => 'address_district']);
+            <div class="card p-2 bg-light shadow-sm">
+                <?= Select2::widget([
+                    'name' => 'address_district',
+                    'value' => null,
+                    'data' => ArrayHelper::map(StoreCityList::findAll(['type' => StoreCityList::TYPE_DISTRICT]), 'id', 'name'),
+                    'options' => [
+                        'placeholder' => 'Район',
+                        'class' => 'form-select',
+                        'id' => 'address_district',
+                    ],
+                    'pluginOptions' => [
+                        'allowClear' => true,
+                    ],
+                ]);
+                ?>
+                <?= Html::a('Редактировать', [
+                    Url::to('/store-city-list')], ['class' => 'd-block mt-2 text-decoration-none']);
                 ?>
             </div>
         </div>
         <div class="col-md-2 border-end border-2">
-            <div class="card p-3 bg-light shadow-sm">
-                <?= Html::dropDownList('store_type', null,
-                    ArrayHelper::map(StoreType::find()->all(), 'id', 'name'),
-                    ['prompt' => 'Тип магазина', 'class' => 'form-select', 'id' => 'store_type']);
+            <div class="card p-2 bg-light shadow-sm">
+                <?= Select2::widget([
+                    'name' => 'store_type',
+                    'value' => null,
+                    'data' => ArrayHelper::map(StoreType::find()->all(), 'id', 'name'),
+                    'options' => [
+                        'placeholder' => 'Тип магазина',
+                        'class' => 'form-select',
+                        'id' => 'store_type',
+                    ],
+                    'pluginOptions' => [
+                        'allowClear' => true,
+                    ],
+                ]);
                 ?>
                 <?= Html::a('Редактировать', [\yii\helpers\Url::to('/store-type')], ['class' => 'd-block mt-2 text-decoration-none']); ?>
             </div>
         </div>
         <div class="col-md-2 border-end border-2">
-            <div class="card p-3 bg-light shadow-sm">
-                <?= Html::dropDownList('territorial_manager', null,
-                    ArrayHelper::map(Admin::findAll(['group_id' => AdminGroup::GROUP_BUSH_DIRECTOR]), 'id', 'name_full'),
-                    ['prompt' => 'Территориального управляющего', 'class' => 'form-select', 'id' => 'territorial_manager']);
-                ?>
+            <div class="card p-2 pb-6 bg-light shadow-sm">
+                <?= Select2::widget([
+                    'name' => 'territorial_manager',
+                    'value' => null,
+                    'data' => ArrayHelper::map(Admin::findAll(['group_id' => AdminGroup::GROUP_BUSH_DIRECTOR]), 'id', 'name_full'),
+                    'options' => [
+                        'placeholder' => 'Территориальный управляющий',
+                        'class' => 'form-select',
+                        'id' => 'territorial_manager',
+                    ],
+                    'pluginOptions' => [
+                        'allowClear' => true,
+                    ],
+                ]); ?>
             </div>
         </div>
         <div class="col-md-2 border-end border-2">
-            <div class="card p-3 bg-light shadow-sm">
-                <?= Html::dropDownList('bush_chef_florist', null,
-                    ArrayHelper::map(Admin::findAll(['group_id' => \yii_app\records\AdminGroup::GROUP_BUSH_CHEF_FLORIST]), 'id', 'name_full'),
-                    ['prompt' => 'Кустового шеф флориста', 'class' => 'form-select', 'id' => 'bush_chef_florist']);
-                ?>
+            <div class="card p-3 pb-6 bg-light shadow-sm">
+                <?= Select2::widget([
+                    'name' => 'bush_chef_florist',
+                    'value' => null,
+                    'data' => ArrayHelper::map(Admin::findAll(['group_id' => AdminGroup::GROUP_BUSH_CHEF_FLORIST]), 'id', 'name_full'),
+                    'options' => [
+                        'placeholder' => 'Кустовой шеф-флорист',
+                        'class' => 'form-select',
+                        'id' => 'bush_chef_florist',
+                    ],
+                    'pluginOptions' => [
+                        'allowClear' => true,
+                    ],
+                ]); ?>
             </div>
         </div>
     </div>
     <div class="row mt-3">
-        <div class="col-md-2"></div>
-        <div class="col-md-2"></div>
-        <div class="col-md-2"></div>
-        <div class="col-md-2"></div>
-        <div class="col-md-2"></div>
+        <div class="col-md-10">
+            <?php if (Yii::$app->session->hasFlash($flash)): ?>
+                <?= Html::tag('div', Yii::$app->session->getFlash($flash), [
+                    'class' => 'alert text-center flash-message mb-1 py-1 alert-' . Html::encode($flash),
+                ]) ?>
+            <?php endif; ?>
+        </div>
         <div class="col-md-2 d-flex justify-content-center align-items-center">
             <div class="card p-45 bg-light shadow-sm w-100">
                 <?= Html::button('Применить', ['class' => 'btn btn-primary w-100', 'id' => 'apply-button']); ?>
@@ -119,11 +175,6 @@ $this->registerJsFile('/js/city-store-params/city-store-params.js', ['position'
             <?= Html::button('Редактировать', ['class' => 'btn btn-primary w-100 mt-2 py-1', 'id' => 'edit-button']); ?>
         </div>
         <div class="col-md-9">
-            <?php if (Yii::$app->session->hasFlash($flash)): ?>
-                <?= Html::tag('div', Yii::$app->session->getFlash($flash), [
-                    'class' => 'alert text-center flash-message alert-' . Html::encode($flash),
-                ]) ?>
-            <?php endif; ?>
             <div class="form-group">
                 <div class="row">
                     <div class="col-md-4 d-flex align-items-center gap-3">
@@ -134,7 +185,19 @@ $this->registerJsFile('/js/city-store-params/city-store-params.js', ['position'
                     </div>
                     <div class="col-md-4">
                         <?= Html::label('Тип магазина', null); ?>
-                        <?= Html::dropDownList('CityStoreParams[store_type]', null, [], ['prompt' => 'Тип магазина', 'class' => 'form-select', 'id' => 'store-type']); ?>
+                        <?= Select2::widget([
+                            'name' => 'CityStoreParams[store_type]',
+                            'value' => null,
+                            'data' => [],
+                            'options' => [
+                                'placeholder' => 'Тип магазина',
+                                'class' => 'form-select',
+                                'id' => 'store-type'
+                            ],
+                            'pluginOptions' => [
+                                'allowClear' => true,
+                            ],
+                        ]); ?>
                         <?= Html::a('Редактировать', [Url::to('/store-type')], ['class' => 'd-block mt-2 text-decoration-none']); ?>
                     </div>
                 </div>
@@ -144,15 +207,51 @@ $this->registerJsFile('/js/city-store-params/city-store-params.js', ['position'
                     </div>
                     <div class="col-md-3">
                         <?= Html::label('Регион'); ?>
-                        <?= Html::dropDownList('CityStoreParams[address_region]', null, [], ['prompt' => 'Регион', 'class' => 'form-select', 'id' => 'region']); ?>
+                        <?=  Select2::widget([
+                            'name' => 'CityStoreParams[address_region]',
+                            'value' => null,
+                            'data' =>  [],
+                            'options' => [
+                                'placeholder' => 'Регион',
+                                'class' => 'form-select',
+                                'id' => 'region',
+                            ],
+                            'pluginOptions' => [
+                                'allowClear' => true,
+                            ],
+                        ]); ?>
                     </div>
                     <div class="col-md-3">
                         <?= Html::label('Город'); ?>
-                        <?= Html::dropDownList('CityStoreParams[address_city]', null, [], ['prompt' => 'Город', 'class' => 'form-select', 'id' => 'city']); ?>
+                        <?=  Select2::widget([
+                            'name' => 'CityStoreParams[address_city]',
+                            'value' => null,
+                            'data' => [],
+                            'options' => [
+                                'placeholder' => 'Город',
+                                'class' => 'form-select',
+                                'id' => 'city',
+                            ],
+                            'pluginOptions' => [
+                                'allowClear' => true,
+                            ],
+                        ]); ?>
                     </div>
                     <div class="col-md-3">
                         <?= Html::label('Район'); ?>
-                        <?= Html::dropDownList('CityStoreParams[address_district]', null, [], ['prompt' => 'Район', 'class' => 'form-select', 'id' => 'district']); ?>
+                        <?=  Select2::widget([
+                            'name' => 'CityStoreParams[address_district]',
+                            'value' => null,
+                            'data' =>  [],
+                            'options' => [
+                                'placeholder' => 'Район',
+                                'class' => 'form-select',
+                                'id' => 'district',
+                            ],
+                            'pluginOptions' => [
+                                'allowClear' => true,
+                            ],
+                        ]); ?>
                     </div>
                 </div>
                 <div class="row">
@@ -161,7 +260,19 @@ $this->registerJsFile('/js/city-store-params/city-store-params.js', ['position'
                         <?= Html::a('Редактировать', [Url::to('/crud/cluster-admin/')], ['class' => 'd-block mb-5 text-decoration-none']); ?>
                     </div>
                     <div class="col-md-9">
-                        <?= Html::dropDownList('CityStoreParams[territorial_manager]', null, [], ['prompt' => 'Территориально управляющий', 'class' => 'form-select', 'id' => 'territorial-manager']); ?>
+                        <?=  Select2::widget([
+                            'name' => 'CityStoreParams[territorial_manager]',
+                            'value' => null,
+                            'data' => [],
+                            'options' => [
+                                'placeholder' => 'Территориально управляющий',
+                                'class' => 'form-select',
+                                'id' => 'territorial-manager',
+                            ],
+                            'pluginOptions' => [
+                                'allowClear' => true,
+                            ],
+                        ]); ?>
                     </div>
                 </div>
                 <div class="row border-bottom pb-2">
@@ -169,7 +280,19 @@ $this->registerJsFile('/js/city-store-params/city-store-params.js', ['position'
                         <?= Html::label('КШФ') ?>
                     </div>
                     <div class="col-md-9">
-                        <?= Html::dropDownList('CityStoreParams[bush_chef_florist]', null, [], ['prompt' => 'Кустовой шеф-флорист', 'class' => 'form-select', 'id' => 'bush-chef-florist']); ?>
+                        <?=  Select2::widget([
+                            'name' => 'CityStoreParams[bush_chef_florist]',
+                            'value' => null,
+                            'data' =>  ArrayHelper::map(Admin::findAll(['group_id' => AdminGroup::GROUP_BUSH_DIRECTOR]), 'id', 'name_full'),
+                            'options' => [
+                                'placeholder' => 'Кустовой шеф-флорист',
+                                'class' => 'form-select',
+                                'id' => 'bush-chef-florist',
+                            ],
+                            'pluginOptions' => [
+                                'allowClear' => true,
+                            ],
+                        ]); ?>
                     </div>
                 </div>
                 <div class="row">
index 8e1565455604c07d926fbef693e5d87cdd808903..ac65c58a995895aedd1ee148e9ebd760180f1590 100644 (file)
@@ -128,24 +128,16 @@ function validateDecimal(input) {
     input.value = value;
 }
 
-
 $(document).ready(function () {
-    if ($('.flash-message').length) {
-        sessionStorage.setItem('flashMessage', $('.flash-message').html());
-    }
-
-    if ($('#selected-store').val()?.length > 0) {
+    if ($('#selected-store').val().length > 0) {
         $('#edit-button').click();
     }
 
-    if (sessionStorage.getItem('flashMessage')) {
-        $('body').prepend('<div class="flash-message">' + sessionStorage.getItem('flashMessage') + '</div>');
-        sessionStorage.removeItem('flashMessage');
+    if ($('.flash-message').hasClass('alert-info') || $('.flash-message').hasClass('alert-success')) {
+        setTimeout(function () {
+            $('.flash-message').fadeOut(2000, function() {
+                $(this).remove();
+            });
+        }, 5000);
     }
-});
-
-
-
-
-
-
+});
\ No newline at end of file