|
|
|
|
|
|
|
|
class InvoiceSearch extends Invoice |
|
|
class InvoiceSearch extends Invoice |
|
|
{ |
|
|
{ |
|
|
|
|
|
|
|
|
public function rules() |
|
|
|
|
|
{ |
|
|
|
|
|
return [ |
|
|
|
|
|
[[], 'safe'], |
|
|
|
|
|
[['comment', 'address', 'status'], 'string'], |
|
|
|
|
|
[['id_user'], 'integer'], |
|
|
|
|
|
[['name', 'reference'], 'string', 'max' => 255], |
|
|
|
|
|
]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function search($params) |
|
|
|
|
|
{ |
|
|
|
|
|
$optionsSearch = self::defaultOptionsSearch(); |
|
|
|
|
|
|
|
|
var $username; |
|
|
|
|
|
|
|
|
$query = Invoice::find() |
|
|
|
|
|
->with($optionsSearch['with']) |
|
|
|
|
|
->joinWith($optionsSearch['join_with']) |
|
|
|
|
|
->where(['invoice.id_producer' => GlobalParam::getCurrentProducerId()]) |
|
|
|
|
|
->orderBy('invoice.status ASC, invoice.reference DESC') |
|
|
|
|
|
->groupBy('invoice.id'); |
|
|
|
|
|
|
|
|
public function rules() |
|
|
|
|
|
{ |
|
|
|
|
|
return [ |
|
|
|
|
|
[[], 'safe'], |
|
|
|
|
|
[['comment', 'address', 'status', 'username'], 'string'], |
|
|
|
|
|
[['name', 'reference'], 'string', 'max' => 255], |
|
|
|
|
|
]; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
$dataProvider = new ActiveDataProvider([ |
|
|
|
|
|
'query' => $query, |
|
|
|
|
|
'sort' => ['attributes' => ['name', 'reference', 'date']], |
|
|
|
|
|
'pagination' => [ |
|
|
|
|
|
'pageSize' => 20, |
|
|
|
|
|
], |
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
public function search($params) |
|
|
|
|
|
{ |
|
|
|
|
|
$optionsSearch = self::defaultOptionsSearch(); |
|
|
|
|
|
|
|
|
$this->load($params); |
|
|
|
|
|
if (!$this->validate()) { |
|
|
|
|
|
return $dataProvider; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
$query = Invoice::find() |
|
|
|
|
|
->with($optionsSearch['with']) |
|
|
|
|
|
->joinWith($optionsSearch['join_with']) |
|
|
|
|
|
->where(['invoice.id_producer' => GlobalParam::getCurrentProducerId()]) |
|
|
|
|
|
->orderBy('invoice.status ASC, invoice.reference DESC') |
|
|
|
|
|
->groupBy('invoice.id'); |
|
|
|
|
|
|
|
|
$query->andFilterWhere(['like', 'invoice.name', $this->name]); |
|
|
|
|
|
$query->andFilterWhere(['like', 'invoice.reference', $this->reference]); |
|
|
|
|
|
$query->andFilterWhere(['like', 'invoice.status', $this->status]); |
|
|
|
|
|
|
|
|
$dataProvider = new ActiveDataProvider([ |
|
|
|
|
|
'query' => $query, |
|
|
|
|
|
'sort' => ['attributes' => ['name', 'reference', 'date']], |
|
|
|
|
|
'pagination' => [ |
|
|
|
|
|
'pageSize' => 20, |
|
|
|
|
|
], |
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
return $dataProvider; |
|
|
|
|
|
|
|
|
$this->load($params); |
|
|
|
|
|
if (!$this->validate()) { |
|
|
|
|
|
return $dataProvider; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$query->andFilterWhere(['like', 'invoice.name', $this->name]); |
|
|
|
|
|
$query->andFilterWhere(['like', 'invoice.reference', $this->reference]); |
|
|
|
|
|
$query->andFilterWhere(['like', 'invoice.status', $this->status]); |
|
|
|
|
|
|
|
|
|
|
|
$query->andFilterWhere([ |
|
|
|
|
|
'or', |
|
|
|
|
|
['like', 'user.lastname', $this->username], |
|
|
|
|
|
['like', 'user.name', $this->username], |
|
|
|
|
|
['like', 'user.name_legal_person', $this->username], |
|
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
return $dataProvider; |
|
|
|
|
|
} |
|
|
} |
|
|
} |