backend/models/search/MailqSearch.php
/**
     * Creates data provider instance with search query applied
     *
     * @param array $params
     *
     * @return ActiveDataProvider
     */
Creates data provider instance with search query applied
@param array $params


Creates data provider instance with search query applied @param array $params
public function search($params)
    {
        $query = Mailq::find();
        $dataProvider = new ActiveDataProvider([
            'query' => $query,
            'sort'=> [
                'defaultOrder' => ['mail_created'=>SORT_DESC],
                'attributes' => [
                    'mail_created',
                    'template_key',
                    'mail_from',
                    'mail_to',
                    'mail_reply_to',
                    'mailer_letter_status',
                    'remote_ip',
                ]
            ],
            'pagination' => [
                'pageSize' => 100,
            ],
        ]);
        $this->load($params);
        if (!$this->validate()) {
            return $dataProvider;
        }
        $query->andFilterWhere([
            'mail_id' => $this->mail_id,
            'user_id' => $this->user_id,
            'node_id' => $this->node_id,
            'mailer_letter_status' => $this->mailer_letter_status,
        ]);
        if (($ip = ip2long($this->remote_ip)) !== false) {
            $query->andFilterWhere(['remote_ip' => $ip]);
        }
        $query->andFilterWhere(['ilike', 'mail_from', $this->mail_from])
            ->andFilterWhere(['ilike', 'mail_to', $this->mail_to])
            ->andFilterWhere(['ilike', 'mail_reply_to', $this->mail_reply_to])
            ->andFilterWhere(['ilike', 'mail_subject', $this->mail_subject])
            ->andFilterWhere(['ilike', 'mail_body', $this->mail_body])
            ->andFilterWhere(['ilike', 'mailer_letter_id', $this->mailer_letter_id])
            ->andFilterWhere(['ilike', 'mailer_answer', $this->mailer_answer])
            ->andFilterWhere(['ilike', 'template_key', $this->template_key]);
        if(!empty($this->mail_created) && strpos($this->mail_created, '-') !== false) {
            $tmp = explode(' - ', $this->mail_created);
            if (isset($tmp[0], $tmp[1])) {
                $start_date = $tmp[0];
                $end_date = $tmp[1];
                $query->andFilterWhere([
                    'between',
                    'mail_created',
                    date(SQL_DATE_FORMAT, Functions::getTimestampBeginOfDayByTimestamp(strtotime($start_date))),
                    date(SQL_DATE_FORMAT, Functions::getTimestampEndOfDayByTimestamp(strtotime($end_date))),
                ]);
            }
        }
        return $dataProvider;
    }
public function search ( $ params ) { $ query = Mailq :: find ( ) ; $ dataProvider = new ActiveDataProvider ( [ 'query' => $ query , 'sort' => [ 'defaultOrder' => [ 'mail_created' => SORT_DESC ] , 'attributes' => [ 'mail_created' , 'template_key' , 'mail_from' , 'mail_to' , 'mail_reply_to' , 'mailer_letter_status' , 'remote_ip' , ] ] , 'pagination' => [ 'pageSize' => 100 , ] , ] ) ; $ this -> load ( $ params ) ; if ( ! $ this -> validate ( ) ) { return $ dataProvider ; } $ query -> andFilterWhere ( [ 'mail_id' => $ this -> mail_id , 'user_id' => $ this -> user_id , 'node_id' => $ this -> node_id , 'mailer_letter_status' => $ this -> mailer_letter_status , ] ) ; if ( ( $ ip = ip2long ( $ this -> remote_ip ) ) !== false ) { $ query -> andFilterWhere ( [ 'remote_ip' => $ ip ] ) ; } $ query -> andFilterWhere ( [ 'ilike' , 'mail_from' , $ this -> mail_from ] ) -> andFilterWhere ( [ 'ilike' , 'mail_to' , $ this -> mail_to ] ) -> andFilterWhere ( [ 'ilike' , 'mail_reply_to' , $ this -> mail_reply_to ] ) -> andFilterWhere ( [ 'ilike' , 'mail_subject' , $ this -> mail_subject ] ) -> andFilterWhere ( [ 'ilike' , 'mail_body' , $ this -> mail_body ] ) -> andFilterWhere ( [ 'ilike' , 'mailer_letter_id' , $ this -> mailer_letter_id ] ) -> andFilterWhere ( [ 'ilike' , 'mailer_answer' , $ this -> mailer_answer ] ) -> andFilterWhere ( [ 'ilike' , 'template_key' , $ this -> template_key ] ) ; if ( ! empty ( $ this -> mail_created ) && strpos ( $ this -> mail_created , '-' ) !== false ) { $ tmp = explode ( ' - ' , $ this -> mail_created ) ; if ( isset ( $ tmp [ 0 ] , $ tmp [ 1 ] ) ) { $ start_date = $ tmp [ 0 ] ; $ end_date = $ tmp [ 1 ] ; $ query -> andFilterWhere ( [ 'between' , 'mail_created' , date ( SQL_DATE_FORMAT , Functions :: getTimestampBeginOfDayByTimestamp ( strtotime ( $ start_date ) ) ) , date ( SQL_DATE_FORMAT , Functions :: getTimestampEndOfDayByTimestamp ( strtotime ( $ end_date ) ) ) , ] ) ; } } return $ dataProvider ; }
Creates data provider instance with search query applied
 @param array $params
Creates data provider instance with search query applied @param array $params
// add conditions that should always apply here // uncomment the following line if you do not want to return any records when validation fails // $query->where('0=1'); // grid filtering conditions //'mail_created' => $this->mail_created, //->andFilterWhere(['ilike', 'mailer_letter_status', $this->mailer_letter_status]) // do we have values? if so, add a filter to our query