Exemplo n.º 1
0
 public function searchForUser($params, $pagesize = 20)
 {
     $query = Transaction::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['created_at' => SORT_DESC]], 'pagination' => ['pageSize' => $pagesize, 'pageSizeParam' => false]]);
     $this->load($params);
     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;
     }
     $query->andFilterWhere(['id' => $this->id, 'user_id' => $this->user_id, 'deposit_before' => $this->deposit_before, 'value' => $this->value, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'descr', $this->descr]);
     return $dataProvider;
 }
Exemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Transaction::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     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;
     }
     $query->andFilterWhere(['id' => $this->id, 'code' => $this->code, 'status' => $this->status, 'created' => $this->created, 'ttl' => $this->ttl]);
     $query->andFilterWhere(['like', 'description', $this->description]);
     return $dataProvider;
 }
Exemplo n.º 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Transaction::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $dataProvider->setSort(['class' => 'yii\\data\\Sort', 'attributes' => ['id', 'ttl', 'status', 'user_id' => ['asc' => ['user.username' => SORT_ASC], 'desc' => ['user.username' => SORT_DESC]], 'description', 'resp_status', 'resp_code', 'resp_description']]);
     $this->load($params);
     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;
     }
     $query->andFilterWhere(['id' => $this->id, 'ttl' => $this->ttl, 'status' => $this->status, 'resp_code' => $this->resp_code, 'user_id' => $this->user_id, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'resp_status', $this->resp_status])->andFilterWhere(['like', 'resp_description', $this->resp_description]);
     return $dataProvider;
 }
Exemplo n.º 4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Transaction::find()->joinWith('user');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     $this->load($params);
     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;
     }
     //echo'<pre>';var_dump($this->trans_type);echo'</pre>';die;
     $query->andFilterWhere(['{{%transaction}}.id' => $this->id, '{{%user}}.id' => $this->user_id, '{{%user}}.nickname' => $this->nickname, 'deposit_before' => $this->deposit_before, 'value' => $this->value, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at]);
     $query->andFilterWhere(['like', 'descr', $this->descr]);
     if (floatval($this->value_from) < floatval($this->value_to) && floatval($this->value_to) != 0) {
         $query->andFilterWhere(['between', 'value', floatval($this->value_from), floatval($this->value_to)]);
     } elseif (floatval($this->value_from) != 0 && floatval($this->value_to) == 0) {
         $query->andFilterWhere(['>=', 'value', floatval($this->value_from)]);
     } elseif (floatval($this->value_from) == 0 && floatval($this->value_to) != 0) {
         $query->andFilterWhere(['<=', 'value', floatval($this->value_to)]);
     }
     if ($this->trans_user_type != self::TR_USER_TYPE_ALL) {
         $admins = User::getAdministratorsIds();
         if ($this->trans_user_type == self::TR_USER_TYPE_ADM) {
             $query->andFilterWhere(['in', 'user_id', $admins]);
         } else {
             $query->andFilterWhere(['not in', 'user_id', $admins]);
         }
     }
     if (is_array($this->trans_type)) {
         if (count($this->trans_type)) {
             $trans_type_arr = ['or'];
             foreach ($this->trans_type as $trans_type) {
                 $trans_type_arr[] = '(`descr` like "' . $trans_type . ',%")';
             }
             //echo'<pre>';print_r($trans_type_arr);echo'</pre>';//die;
             if (count($trans_type_arr)) {
                 $query->andFilterWhere($trans_type_arr);
             }
         }
     }
     return $dataProvider;
 }
Exemplo n.º 5
0
 public static function find()
 {
     return parent::find()->andWhere(['user_id' => Yii::$app->getUser()->id]);
 }
 /**
  * Lists all Transaction models.
  * @return mixed
  */
 public function actionIndex()
 {
     $dataProvider = new ActiveDataProvider(['query' => Transaction::find()]);
     return $this->render('index', ['dataProvider' => $dataProvider]);
 }