Sfoglia il codice sorgente

Correction de la recherche des utilisateurs inactifs

dev
parent
commit
7616e6c393
2 ha cambiato i file con 32 aggiunte e 9 eliminazioni
  1. +5
    -0
      common/models/User.php
  2. +27
    -9
      common/models/UserSearch.php

+ 5
- 0
common/models/User.php Vedi File

@@ -225,6 +225,11 @@ class User extends ActiveRecordCommon implements IdentityInterface
return $this->hasMany(UserProducer::className(), ['id_user' => 'id']);
}

public function getOrder()
{
return $this->hasMany(Order::className(), ['id_user' => 'id']) ;
}
/**
* @inheritdoc
*/

+ 27
- 9
common/models/UserSearch.php Vedi File

@@ -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;
}

Loading…
Annulla
Salva