|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Steven
- * Date: 2017/11/23
- * Time: 13:40
- */
-
- namespace backend\modules\hotel\models\search;
-
- use yii\data\ActiveDataProvider;
- use backend\modules\hotel\models\OrderInvoiceInfo;
-
- class searchInvoice extends OrderInvoiceInfo
- {
- public $date_from;
- public $date_to;
- public $search_key;
-
- /**
- * @inheritdoc
- */
- public function rules()
- {
- return [
- [['InvoiceType', 'PostType', 'OrderID', 'Status', 'CreateTime', 'date_from', 'date_to', 'search_key','ChannelId'], 'safe'],
- ];
- }
-
- public function attributeLabels()
- {
- return array_merge(
- parent::attributeLabels(), [
- 'date_from' => '起始日期',
- 'date_to' => '结束日期',
- ]);
- }
-
- public function search($queryParams)
- {
- $query = self::find()->select(['a.*', 'b.supplier_name'])->joinWith('baseSupplier b')->from('order_invoice_info a');
- $query->andFilterWhere(['<>', 'a.Status', '1']);
- $dataProvider = new ActiveDataProvider([
- 'query' => $query,
- 'sort' => false,
- 'pagination' => [
- 'pageSize' => 20,
- ]
- ]);
- $this->load($queryParams);
- if (!empty($this->InvoiceType)) {
- $query->andFilterWhere(['InvoiceType' => $this->InvoiceType]);
- }
- if (!empty($this->date_from) && !empty($this->date_to)) {
- $query->andFilterWhere(['between', 'a.CreateTime', $this->date_from, $this->date_to]);
- }
- if (!empty($this->PostType)) {
- $query->andFilterWhere(['PostType' => $this->PostType]);
- }
- if (!empty($this->Status)) {
- $query->andFilterWhere(['a.Status' => $this->Status]);
- }
- if (!empty($this->ChannelId)) {
- $query->andFilterWhere(['a.ChannelId' => $this->ChannelId]);
- }
-
- if (!empty(trim($this->search_key))) {
- $query->andFilterWhere(['or',
- ['like', 'a.OrderID', trim($this->search_key)],
- ['like', 'a.ReceiverName', trim($this->search_key)],
- ['like', 'a.ReceiverMobile', trim($this->search_key)],
- ['like', 'a.InvoiceTitle', trim($this->search_key)]]);
- }
-
- $query -> orderBy(['a.Status' => SORT_ASC,'a.UpdateTime' => SORT_DESC]);
- return $dataProvider;
- }
- }
|