From af56582cc87824e040e6fa814ce740f0477b7071 Mon Sep 17 00:00:00 2001 From: fomichev Date: Mon, 19 May 2025 12:09:08 +0300 Subject: [PATCH] =?utf8?q?=D0=9F=D0=BE=D0=B8=D1=81=D0=BA=20=D0=B8=20=D1=81?= =?utf8?q?=D0=BE=D1=80=D1=82=D0=B8=D1=80=D0=BE=D0=B2=D0=BA=D0=B0=20=D0=BF?= =?utf8?q?=D0=BE=20=D1=82=D0=B0=D0=B1=D0=BB=D0=B8=D1=86=D0=B5=20=D0=B7?= =?utf8?q?=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA=D0=B8=20=D0=B1=D1=83=D0=BA?= =?utf8?q?=D0=B5=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- erp24/controllers/BouquetController.php | 8 +- erp24/records/MatrixBouquetForecastSearch.php | 81 +++++++++++++++++++ erp24/views/bouquet/get-guid-bouquet.php | 3 + 3 files changed, 88 insertions(+), 4 deletions(-) create mode 100644 erp24/records/MatrixBouquetForecastSearch.php diff --git a/erp24/controllers/BouquetController.php b/erp24/controllers/BouquetController.php index e5feba46..2ab8ce8a 100644 --- a/erp24/controllers/BouquetController.php +++ b/erp24/controllers/BouquetController.php @@ -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 index 00000000..babc7968 --- /dev/null +++ b/erp24/records/MatrixBouquetForecastSearch.php @@ -0,0 +1,81 @@ +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; + } +} diff --git a/erp24/views/bouquet/get-guid-bouquet.php b/erp24/views/bouquet/get-guid-bouquet.php index e63d9a14..f51b1c2e 100644 --- a/erp24/views/bouquet/get-guid-bouquet.php +++ b/erp24/views/bouquet/get-guid-bouquet.php @@ -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 = 'Импорт прогноза по букетам'; $dataProvider, + 'filterModel' => $searchModel, 'columns' => [ 'id', 'guid', -- 2.39.5