]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
ERP-360 Сборка страницы автопм
authormarina <m.zozirova@gmail.com>
Mon, 9 Jun 2025 21:17:23 +0000 (00:17 +0300)
committermarina <m.zozirova@gmail.com>
Mon, 9 Jun 2025 21:17:23 +0000 (00:17 +0300)
erp24/controllers/AutoPlannogrammaController.php
erp24/views/auto-plannogramma/index.php
erp24/web/js/autoplannogramma/autoplannogramma.js

index 3c6b29ee784bdb45bb35afb6d87393ea018c980a..af22e1351008d8786a59955da9003e10a3d88611 100644 (file)
@@ -190,37 +190,36 @@ class AutoPlannogrammaController extends BaseController
     public function actionGetVisibleStores()
     {
         Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
-        $f = Yii::$app->request->get();
+        $filters = Yii::$app->request->get();
 
-        $q = CityStoreParams::find()
+        $query = CityStoreParams::find()
             ->alias('p')
             ->joinWith(['store s'])
             ->select('p.store_id')
             ->where(['s.visible' => CityStore::IS_VISIBLE]);
 
-        foreach ([
-                     'city' => 'p.address_city',
-                     'storeType' => 'p.store_type',
-                     'region' => 'p.address_region',
-                     'district' => 'p.address_district'
-                 ] as $param => $col) {
-            if (!empty($f[$param])) $q->andWhere([$col => $f[$param]]);
+        $query->andFilterWhere(['=', 'p.address_city', $filters['city']]);
+        $query->andFilterWhere(['=', 'p.store_type', $filters['store_type']]);
+        $query->andFilterWhere(['=', 'p.address_region', $filters['region']]);
+        $query->andFilterWhere(['=', 'p.address_district', $filters['district']]);
+
+        if (!empty($filters['territorial_manager'])) {
+            $territorialManagerStoreIds = StoreDynamic::find()
+                ->select('store_id')
+                ->where(['category' => 3, 'active' => 1, 'value_int' => $filters['territorial_manager']])
+                ->column();
+            $query->andWhere(['in', 'a.store_id', $territorialManagerStoreIds ?: [-1]]);
         }
 
-        foreach ([
-                     'territorialManager' => 3,
-                     'bushChefFlorist' => 2
-                 ] as $param => $cat) {
-            if (!empty($f[$param])) {
-                $ids = StoreDynamic::find()
-                    ->select('store_id')
-                    ->where(['category' => $cat, 'active' => 1, 'value_int' => $f[$param]])
-                    ->column();
-                $q->andWhere(['p.store_id' => $ids ?: [-1]]);
-            }
+        if (!empty($filters['bush_chef_florist'])) {
+            $bushChefFloristStoreIds = StoreDynamic::find()
+                ->select('store_id')
+                ->where(['category' => 2, 'active' => 1, 'value_int' => $filters['bush_chef_florist']])
+                ->column();
+            $query->andWhere(['in', 'a.store_id', $bushChefFloristStoreIds ?: [-1]]);
         }
 
-        return array_values($q->column());
+        return array_values($query->column());
     }
 
     public function action1()
index d2ce7e788aa0b4a8b8ad728c81cfbea3bad6bb22..5e992d71c3731344500a0fd8614755d000c6affe 100644 (file)
@@ -123,7 +123,7 @@ $this->registerJsFile('/js/autoplannogramma/autoplannogramma.js', ['position' =>
             </div>
             <div class="row">
                 <div class="col-md d-flex">
-                    <?= Html::label('Месяц: ', [], ['class' => 'month-label']) ?>
+                    <?= Html::label('Месяц: ', [], ['class' => 'month-label ms-4']) ?>
                 </div>
                 <div class="col-md d-flex">
                     <?= Select2::widget([
@@ -152,7 +152,10 @@ $this->registerJsFile('/js/autoplannogramma/autoplannogramma.js', ['position' =>
             </div>
         </div>
     </div>
-    <div class="table-wrapper">
+    <div class="div alert">
+        <div class="alert text-center flash-message alert-info mb-1 py-1 m-5">Для редактирования планограммы необходимо выбрать неделю и год!</div>
+    </div>
+    <div class="table-wrapper" style=" pointer-events: none; opacity: 0.5;">
         <table class="table">
             <thead>
             <tr class="head">
index 439556d61b6d256dabbe38355dcaf2138dcd6667..bbd0512d7a3047cb4a5787eee72b1189b527fa59 100644 (file)
@@ -273,7 +273,15 @@ function resetStoreFilter() {
 
 $('.btn-apply').on('click', function () {
     applyStoreFilter();
-    console.log($('#week').val(),$('#year').val(), getMonthByWeek($('#week').val(), $('#year').val()))
+    if ($('#week').val() && $('#year').val()) {
+        $('.table-wrapper').css({
+            'pointer-events': 'auto',
+            'opacity': '1'
+        });
+        $('.flash-message').css({
+            'display': 'none'
+        });
+    }
     $('tr.inserted-row').remove();
 });
 $('.btn-reset').on('click', resetStoreFilter);
@@ -291,3 +299,16 @@ function getMonthByWeek(week, year) {
 
     return startMonth === endMonth ? startMonth : `${startMonth} - ${endMonth}`;
 }
+
+$(document).ready(function () {
+    if ($('#week').val().length > 0) {
+        $('#edit-button').click();
+    }
+
+    const flashMessage = $('.flash-message');
+
+    if (flashMessage.length) {
+        const delayTime = flashMessage.hasClass('alert-success') ? 5000 : 15000;
+        setTimeout(() => flashMessage.fadeOut(2000, () => flashMessage.remove()), delayTime);
+    }
+});
\ No newline at end of file