]> gitweb.erp-flowers.ru Git - erp24_rep/yii-erp24/.git/commitdiff
Поиск и сортировка по таблице загрузки букетов
authorfomichev <vladimir.fomichev@erp-flowers.ru>
Mon, 19 May 2025 09:09:08 +0000 (12:09 +0300)
committerfomichev <vladimir.fomichev@erp-flowers.ru>
Mon, 19 May 2025 09:09:08 +0000 (12:09 +0300)
erp24/controllers/BouquetController.php
erp24/records/MatrixBouquetForecastSearch.php [new file with mode: 0644]
erp24/views/bouquet/get-guid-bouquet.php

index e5feba46e61a485775eaa0680c780fe690ea0a03..2ab8ce8a73d0f4a5c65cb9b97e4da36b20700c6c 100644 (file)
@@ -25,6 +25,7 @@ use yii_app\records\{BouquetComposition,
     CityStoreParams,
     Files,
     MatrixBouquetForecast,
+    MatrixBouquetForecastSearch,
     MatrixType,
     PricesDynamic,
     Products1c,
@@ -433,13 +434,12 @@ class BouquetController extends Controller
                 Yii::$app->session->setFlash('success', 'Импорт завершён: записи добавлены или обновлены.');
             }
         }
+        $searchModel = new MatrixBouquetForecastSearch();
+        $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
 
-        $dataProvider = new ActiveDataProvider([
-            'query' => MatrixBouquetForecast::find()->orderBy(['id' => SORT_ASC]),
-            'pagination' => ['pageSize' => 200],
-        ]);
 
         return $this->render('get-guid-bouquet', [
+            'searchModel' => $searchModel,
             'model' => $model,
             'dataProvider' => $dataProvider,
         ]);
diff --git a/erp24/records/MatrixBouquetForecastSearch.php b/erp24/records/MatrixBouquetForecastSearch.php
new file mode 100644 (file)
index 0000000..babc796
--- /dev/null
@@ -0,0 +1,81 @@
+<?php
+
+namespace yii_app\records;
+
+use yii\base\Model;
+use yii\data\ActiveDataProvider;
+use yii_app\records\MatrixBouquetForecast;
+
+/**
+ * MatrixBouquetForecastSearch represents the model behind the search form of `yii_app\records\MatrixBouquetForecast`.
+ */
+class MatrixBouquetForecastSearch extends MatrixBouquetForecast
+{
+    /**
+     * {@inheritdoc}
+     */
+    public function rules()
+    {
+        return [
+            [['id', 'year', 'month', 's_store', 'm_store', 'l_store', 'xl_store', 'marketplace', 'internet'], 'integer'],
+            [['guid', 'name', 'group', 'created_at', 'updated_at'], 'safe'],
+        ];
+    }
+
+    /**
+     * {@inheritdoc}
+     */
+    public function scenarios()
+    {
+        // bypass scenarios() implementation in the parent class
+        return Model::scenarios();
+    }
+
+    /**
+     * Creates data provider instance with search query applied
+     *
+     * @param array $params
+     * @param string|null $formName Form name to be used into `->load()` method.
+     *
+     * @return ActiveDataProvider
+     */
+    public function search($params, $formName = null)
+    {
+        $query = MatrixBouquetForecast::find();
+
+        // add conditions that should always apply here
+
+        $dataProvider = new ActiveDataProvider([
+            'query' => $query,
+        ]);
+
+        $this->load($params, $formName);
+
+        if (!$this->validate()) {
+            // uncomment the following line if you do not want to return any records when validation fails
+            // $query->where('0=1');
+            return $dataProvider;
+        }
+
+        // grid filtering conditions
+        $query->andFilterWhere([
+            'id' => $this->id,
+            'year' => $this->year,
+            'month' => $this->month,
+            's_store' => $this->s_store,
+            'm_store' => $this->m_store,
+            'l_store' => $this->l_store,
+            'xl_store' => $this->xl_store,
+            'marketplace' => $this->marketplace,
+            'internet' => $this->internet,
+            'created_at' => $this->created_at,
+            'updated_at' => $this->updated_at,
+        ]);
+
+        $query->andFilterWhere(['ilike', 'guid', $this->guid])
+            ->andFilterWhere(['ilike', 'name', $this->name])
+            ->andFilterWhere(['ilike', 'group', $this->group]);
+
+        return $dataProvider;
+    }
+}
index e63d9a14d3f1ca493957b70fb726342d59b80c64..f51b1c2ec9d63e66d10add9861e8fe346547de87 100644 (file)
@@ -3,10 +3,12 @@
 use yii\widgets\ActiveForm;
 use yii\helpers\Html;
 use kartik\grid\GridView;
+use yii_app\records\MatrixBouquetForecastSearch;
 
 /** @var yii\web\View $this */
 /** @var yii\data\ActiveDataProvider $dataProvider */
 /** @var \yii\base\DynamicModel $model */
+/** @var yii_app\records\MatrixBouquetForecastSearch $searchModel */
 
 $this->title = 'Импорт прогноза по букетам';
 ?>
@@ -23,6 +25,7 @@ $this->title = 'Импорт прогноза по букетам';
 <?php if (!empty($dataProvider)): ?>
     <?= GridView::widget([
         'dataProvider' => $dataProvider,
+        'filterModel' => $searchModel,
         'columns' => [
             'id',
             'guid',