- <?php
-
-
-
- namespace common\models;
-
- use common\models\Quotation;
- use common\helpers\GlobalParam;
-
- class QuotationSearch extends Quotation
- {
-
- public function rules()
- {
- return [
- [[], 'safe'],
- [['comment', 'address', 'status'], 'string'],
- [['id_user'], 'integer'],
- [['name', 'reference'], 'string', 'max' => 255],
- ];
- }
-
- public function search($params)
- {
- $optionsSearch = self::defaultOptionsSearch();
-
- $query = Quotation::find()
- ->with($optionsSearch['with'])
- ->joinWith($optionsSearch['join_with'])
- ->where(['quotation.id_producer' => GlobalParam::getCurrentProducerId()])
- ->orderBy('quotation.status ASC, quotation.reference DESC')
- ->groupBy('quotation.id');
-
- $dataProvider = new ActiveDataProvider([
- 'query' => $query,
- 'sort' => ['attributes' => ['name', 'reference', 'date']],
- 'pagination' => [
- 'pageSize' => 20,
- ],
- ]);
-
- $this->load($params);
- if (!$this->validate()) {
- return $dataProvider;
- }
-
- $query->andFilterWhere(['like', 'quotation.name', $this->name]);
- $query->andFilterWhere(['like', 'quotation.reference', $this->reference]);
- $query->andFilterWhere(['like', 'quotation.status', $this->status]);
-
- return $dataProvider;
- }
- }
|