|
|
@@ -60,7 +60,29 @@ class UserSearch extends User |
|
|
|
{ |
|
|
|
$optionsSearch = self::defaultOptionsSearch() ; |
|
|
|
|
|
|
|
$query = User::find(); |
|
|
|
$query = User::find() |
|
|
|
->select( |
|
|
|
'`user`.id, ' |
|
|
|
.'`user`.username,' |
|
|
|
.'`user`.email, ' |
|
|
|
.'`user`.status, ' |
|
|
|
.'`user`.created_at, ' |
|
|
|
.'`user`.updated_at, ' |
|
|
|
.'`user`.lastname, ' |
|
|
|
.'`user`.name, ' |
|
|
|
.'`user`.phone, ' |
|
|
|
.'`user`.address, ' |
|
|
|
.'`user`.no_mail, ' |
|
|
|
.'`user`.mail_distribution_monday, ' |
|
|
|
.'`user`.mail_distribution_tuesday, ' |
|
|
|
.'`user`.mail_distribution_wednesday, ' |
|
|
|
.'`user`.mail_distribution_thursday, ' |
|
|
|
.'`user`.mail_distribution_friday, ' |
|
|
|
.'`user`.mail_distribution_saturday, ' |
|
|
|
.'`user`.mail_distribution_sunday, ' |
|
|
|
.'`user`.id_producer, ' |
|
|
|
.'`user`.date_last_connection, ' |
|
|
|
. '(SELECT COUNT(*) FROM `order` WHERE `user`.id = `order`.id_user) AS count_orders'); |
|
|
|
|
|
|
|
$dataProvider = new ActiveDataProvider([ |
|
|
|
'query' => $query, |
|
|
@@ -85,8 +107,7 @@ class UserSearch extends User |
|
|
|
return $dataProvider; |
|
|
|
} |
|
|
|
|
|
|
|
$active = (isset($this->inactive) && $this->inactive) ? 0 : 1 ; |
|
|
|
$query->innerJoin('user_producer','user.id = user_producer.id_user AND user_producer.active = '.$active.' AND user_producer.id_producer = :id_producer', [':id_producer' => Producer::getId()]) ; |
|
|
|
$query->innerJoin('user_producer','user.id = user_producer.id_user AND user_producer.id_producer = :id_producer', [':id_producer' => Producer::getId()]) ; |
|
|
|
|
|
|
|
if(isset($this->id_point_sale) && $this->id_point_sale) { |
|
|
|
$pointSale = PointSale::findOne(['id' => $this->id_point_sale]) ; |
|
|
@@ -94,11 +115,9 @@ class UserSearch extends User |
|
|
|
} |
|
|
|
|
|
|
|
if(isset($this->inactive) && $this->inactive) { |
|
|
|
$query->innerJoin( |
|
|
|
'order', |
|
|
|
'user.id = order.id_user' |
|
|
|
) |
|
|
|
->groupBy('user.id'); |
|
|
|
$query->having([ |
|
|
|
'count_orders' => 0 |
|
|
|
]) ; |
|
|
|
} |
|
|
|
|
|
|
|
$query->andFilterWhere([ |
|
|
@@ -107,7 +126,6 @@ class UserSearch extends User |
|
|
|
['like', 'user.name', $this->username] |
|
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
return $dataProvider; |
|
|
|
} |
|
|
|
|