|
- <?php
-
-
-
- namespace common\models ;
-
- use common\helpers\GlobalParam;
- use common\models\CreditHistory ;
-
- class CreditHistorySearch extends CreditHistory
- {
-
- public function rules()
- {
- return [
- [['id_user', 'id_user_action', 'id_order', 'id_producer'], 'integer'],
- [['date'], 'safe'],
- [['amount'], 'double'],
- [['type', 'mean_payment', 'comment'], 'string', 'max' => 255],
- ];
- }
-
- public function search($params)
- {
- $optionsSearch = self::defaultOptionsSearch() ;
-
- $query = CreditHistory::find()
- ->with($optionsSearch['with'])
- ->innerJoinWith($optionsSearch['join_with'], true)
- ->where(['credit_history.id_producer' => GlobalParam::getCurrentProducerId()])
- ->orderBy('id DESC')
- ;
-
- $dataProvider = new ActiveDataProvider([
- 'query' => $query,
- 'sort' => false,
- 'pagination' => [
- 'pageSize' => 20,
- ],
- ]);
-
- $this->load($params);
- if (!$this->validate()) {
- return $dataProvider;
- }
-
- if(isset($this->id_user) && is_numeric($this->id_user)) {
- $query->andWhere([
- 'credit_history.id_user' => $this->id_user
- ]) ;
- }
-
- return $dataProvider;
- }
-
- }
|