From: fomichev Date: Mon, 19 May 2025 09:09:08 +0000 (+0300) Subject: Поиск и сортировка по таблице загрузки букетов X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=af56582cc87824e040e6fa814ce740f0477b7071;p=erp24_rep%2Fyii-erp24%2F.git Поиск и сортировка по таблице загрузки букетов --- 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',