]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
добавки к фильтрам
authorAlexander Smirnov <fredeom@mail.ru>
Tue, 28 Jan 2025 13:33:43 +0000 (16:33 +0300)
committerAlexander Smirnov <fredeom@mail.ru>
Tue, 28 Jan 2025 13:33:43 +0000 (16:33 +0300)
docker-compose.yml
erp24/controllers/CategoryPlanController.php
erp24/views/category-plan/index.php
erp24/web/js/category-plan/index.js

index 38d9ac3412362aeb89cd6817f0770e64c786005a..bb5160523999634f9ae59247eab3faa34728054c 100644 (file)
@@ -1,4 +1,3 @@
-version: '2'
 services:
   nginx-yii_erp24:
     build: ./docker/nginx
index 012410c3c77c2066a2e8a75db02f974c489246c8..29f3705da9e63a2c437419d5477f85d823b08331 100644 (file)
@@ -6,6 +6,7 @@ use Yii;
 use yii\base\DynamicModel;
 use yii\helpers\ArrayHelper;
 use yii\web\Controller;
+use yii\web\Response;
 use yii_app\records\CityStore;
 use yii_app\records\ExportImportTable;
 use yii_app\records\Sales;
@@ -138,4 +139,30 @@ class CategoryPlanController extends Controller {
         return $this->render('index', compact('model', 'years', 'stores', 'table', 'tableOnline',
             'tableWriteOffs', 'types', 'salesWriteOffsPlan'));
     }
+
+    public function actionGetStores() {
+        Yii::$app->response->format = Response::FORMAT_JSON;
+        $cityId = Yii::$app->request->post('city_id');
+        $regionId = Yii::$app->request->post('region_id');
+        $raionId = Yii::$app->request->post('raion_id');
+        $storeTypeId = Yii::$app->request->post('store_type_id');
+//        $territoryManagerId = Yii::$app->request->post('territory_manager_id');
+//        $kshfId = Yii::$app->request->post('kshf_id');
+
+        $stores = CityStore::find()
+            ->andFilterWhere([
+                'visible' => 1,
+                'city' => $cityId,
+                'region' => $regionId,
+                'district' => $raionId,
+                'type' => $storeTypeId,
+            ])
+//            ->andFilterWhere(['in', 'id', $bushChefFloristStoreIds])
+//            ->andFilterWhere(['in', 'id', $territorialManagerStoreIds])
+            ->orderBy('id')
+            ->all();
+
+
+        return ArrayHelper::map($stores, 'id', 'name');
+    }
 }
index cc702415f22e1d5eee849e7ff8a78e101ea00736..40ee2c64d32da2beddd2544a87f9255fd5151c1e 100644 (file)
@@ -3,10 +3,12 @@
 use yii\helpers\Html;
 use yii\base\DynamicModel;
 use yii\widgets\ActiveForm;
+use yii\helpers\ArrayHelper;
 
 use kartik\select2\Select2;
 use yii_app\helpers\HtmlHelper;
 use yii_app\records\SalesWriteOffsPlan;
+use yii_app\records\StoreCityList;
 
 /* @var $model DynamicModel */
 /* @var $years array */
@@ -37,7 +39,7 @@ $this->registerJsFile('/js/category-plan/index.js', ['position' => \yii\web\View
                 </div>
                 <div class="col-4">
                     <?= $form->field($model, 'city_id')->widget(Select2::class, [
-                        'data' => [0 => 'Москва', 1 => 'Нижний Новгород'],
+                        'data' => ArrayHelper::map(StoreCityList::findAll(['type' => StoreCityList::TYPE_CITY]), 'id', 'name'),
                         'language' => 'ru',
                         'options' => ['placeholder' => 'Города...'],
                         'pluginOptions' => [
@@ -77,7 +79,7 @@ $this->registerJsFile('/js/category-plan/index.js', ['position' => \yii\web\View
                 </div>
                 <div class="col-4">
                     <?= $form->field($model, 'region_id')->widget(Select2::class, [
-                        'data' => [0 => 'Московская обл.', 1 => 'Нижегородская обл.'],
+                        'data' => ArrayHelper::map(StoreCityList::findAll(['type' => StoreCityList::TYPE_REGION]), 'id', 'name'),
                         'language' => 'ru',
                         'options' => ['placeholder' => 'Регион...'],
                         'pluginOptions' => [
@@ -102,7 +104,7 @@ $this->registerJsFile('/js/category-plan/index.js', ['position' => \yii\web\View
                 </div>
                 <div class="col-4">
                     <?= $form->field($model, 'raion_id')->widget(Select2::class, [
-                        'data' => [0 => 'Автозаводский', 1 => 'Канавинский'],
+                        'data' => ArrayHelper::map(StoreCityList::findAll(['type' => StoreCityList::TYPE_DISTRICT]), 'id', 'name'),
                         'language' => 'ru',
                         'options' => ['placeholder' => 'Район...'],
                         'pluginOptions' => [
@@ -127,7 +129,7 @@ $this->registerJsFile('/js/category-plan/index.js', ['position' => \yii\web\View
                 <div class="col-1">
                     <div class="row" style="min-height: 150px; align-items: center;">
                         <div class="col-12">
-                            <button>
+                            <button onclick="updateStores(); return false;">
                                 <svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" fill="currentColor" class="bi bi-play-fill" viewBox="0 0 16 16">
                                     <path d="m11.596 8.697-6.363 3.692c-.54.313-1.233-.066-1.233-.697V4.308c0-.63.692-1.01 1.233-.696l6.363 3.692a.802.802 0 0 1 0 1.393"/>
                                 </svg>
index 6b5a48589eee55d9e7c36dd3fd7579e25ec06f2c..9687070b2f40b4f7bd07e97a73bb386b70df4385 100644 (file)
@@ -3,6 +3,30 @@
 const param26 = $('meta[name=csrf-param]').attr('content');
 const token26 = $('meta[name=csrf-token]').attr('content');
 
+function updateStores() {
+    const city_id = $('#dynamicmodel-city_id').val();
+    const region_id = $('#dynamicmodel-region_id').val();
+    const raion_id = $('#dynamicmodel-raion_id').val();
+    const store_type_id = $('#dynamicmodel-store_type_id').val();
+    const territory_manager_id = $('#dynamicmodel-territory_manager_id').val();
+    const kshf_id = $('#dynamicmodel-kshf_id').val();
+    $.ajax({
+        method: "POST",
+        url: '/category-plan/get-stores',
+        data: { city_id, region_id, raion_id, store_type_id, territory_manager_id, kshf_id, [param26] : token26 },
+        dataType: 'json',
+        success: function (data) {
+            $('#selected-store').empty();
+            $.each(data, (key, value) => {
+                const option = document.createElement('OPTION');
+                option.value = key;
+                option.text = value;
+                $('#selected-store').append(option);
+            });
+        }
+    });
+}
+
 $(document).ready(() => {
     $('#categoryPlan').DataTable({
         sorting: false,