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

index e8995e5c020a2ba3b4dfd80aea1f5c026d90e622..51050cd9b0bdfad26bee128efe8072ee8d905320 100644 (file)
@@ -138,12 +138,13 @@ class CityStoreParamsController extends Controller
             ->andFilterWhere([
                 'visible' => CityStore::IS_VISIBLE,
                 'city' => $addressCity,
-                'district' => $addressRegion,
-                'type' => $addressDistrict,
+                'region' => $addressRegion,
+                'district' => $addressDistrict,
                 'type' => $storeType,
             ])
             ->andFilterWhere(['in', 'id', $bushChefFloristStoreIds])
             ->andFilterWhere(['in', 'id', $territorialManagerStoreIds])
+            ->orderBy('id')
             ->all();
 
         return [
index 03379c6d7d4ac23270b6c7002540e52b1b506b5a..b923ae26132f03a71dac22347489b22bc6ead1b8 100644 (file)
@@ -6,6 +6,7 @@ use yii\helpers\Html;
 use yii\helpers\Url;
 use yii_app\records\Admin;
 use yii_app\records\AdminGroup;
+use yii_app\records\CityStore;
 use yii_app\records\StoreCityList;
 use yii_app\records\StoreType;
 
@@ -95,12 +96,15 @@ $this->registerJsFile('/js/city-store-params/city-store-params.js', ['position'
     <div class="row">
         <div class="col-md-3">
             <?= Html::dropDownList('CityStoreParams[selected_store]', null,
-                ArrayHelper::map(\yii_app\records\CityStore::find()->all(), 'id', 'name'), [
-                'multiple' => true,
-                'size' => 16,
-                'class' => 'form-control',
-                'id' => 'selected-store',
-            ]) ?>
+                ArrayHelper::map(CityStore::find()->where(['visible' => CityStore::IS_VISIBLE])->orderBy('id')->all(), 'id', function ($store) {
+                    return $store->id . ' ' . $store->name;
+                }),
+                [
+                    'multiple' => true,
+                    'size' => 16,
+                    'class' => 'form-control',
+                    'id' => 'selected-store',
+                ]) ?>
             <?= Html::button('Редактировать', ['class' => 'btn btn-primary w-100 mt-2 py-1', 'id' => 'edit-button']); ?>
         </div>
         <div class="col-md-9">
@@ -164,6 +168,7 @@ $this->registerJsFile('/js/city-store-params/city-store-params.js', ['position'
                             'placeholder' => 'Введите число',
                             'oninput' => 'validateDecimal(this)'
                         ]); ?>
+
                         <?= Html::label('Витрина (M3)', null, ['class' => 'form-label']); ?>
                         <?= Html::input('text', 'CityStoreParams[showcase_volume]', null, [
                             'id' => 'showcase-volume',
@@ -171,6 +176,7 @@ $this->registerJsFile('/js/city-store-params/city-store-params.js', ['position'
                             'placeholder' => 'Введите число',
                             'oninput' => 'validateDecimal(this)'
                         ]); ?>
+
                         <?= Html::label('Холодильник (M2)', null, ['class' => 'form-label']); ?>
                         <?= Html::input('text', 'CityStoreParams[freeze_area]', null, [
                             'id' => 'freeze-area',
@@ -178,6 +184,7 @@ $this->registerJsFile('/js/city-store-params/city-store-params.js', ['position'
                             'placeholder' => 'Введите число',
                             'oninput' => 'validateDecimal(this)'
                         ]); ?>
+
                         <?= Html::label('Холодильник (M3)', null, ['class' => 'form-label']); ?>
                         <?= Html::input('text', 'CityStoreParams[freeze_volume]', null, [
                             'id' => 'freeze-volume',
@@ -188,14 +195,14 @@ $this->registerJsFile('/js/city-store-params/city-store-params.js', ['position'
                     </div>
                     <div class="col-md-8">
                         <div class="container mt-5">
-                            <?= Html::label('Тип матрицы')?>
+                            <?= Html::label('Тип матрицы') ?>
                             <?= Html::a('Редактировать', [Url::to('/matrix-type')], ['class' => 'd-block mb-5 text-decoration-none']); ?>
                             <?= Select2::widget([
                                 'name' => 'CityStoreParams[matrix_type]',
                                 'data' => [],
                                 'language' => 'ru-RU',
                                 'options' => [
-                                        'id' => 'matrix-type',
+                                    'id' => 'matrix-type',
                                     'placeholder' => 'Выберите тип матрицы',
                                     'multiple' => true,
                                 ],
@@ -203,7 +210,7 @@ $this->registerJsFile('/js/city-store-params/city-store-params.js', ['position'
                         </div>
                     </div>
                     <div class="d-flex justify-content-end">
-                       <?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
+                        <?= Html::submitButton('Сохранить', ['class' => 'btn btn-success']) ?>
                     </div>
                 </div>
             </div>
index f68a1a7906202943ac3470d1c371258dba8f28c9..158c80140387a91993ff953cf07b01d650cf3531 100644 (file)
@@ -138,6 +138,15 @@ function populateDualListbox(matrixTypeArray, matrixType) {
     select.val(matrixType).trigger('change');
 }
 
+function validateDecimal(input) {
+    let value = input.value;
+    value = value.replace(/[^0-9.]/g, '');
+    if (value.indexOf('.') !== -1) {
+        value = value.replace(/(\.\d{2})\d+$/, '$1');
+    }
+    input.value = value;
+}
+