Browse Source

[Administration] Utilisateurs : correctif tri par crédit #1209

feature/souke
Guillaume Bourgeois 1 year ago
parent
commit
f17772f08c
2 changed files with 12 additions and 9 deletions
  1. +1
    -0
      backend/views/user/index.php
  2. +11
    -9
      common/logic/User/User/Model/UserSearch.php

+ 1
- 0
backend/views/user/index.php View File

) . ' ) . '
</span> </span>
</div>'; </div>';

return $html; return $html;
} }
], ],

+ 11
- 9
common/logic/User/User/Model/UserSearch.php View File



public function search($params = []) public function search($params = [])
{ {
$userRepository = UserRepository::getInstance();
$optionsSearch = $userRepository->getDefaultOptionsSearch();

$query = User::find() $query = User::find()
->select( ->select(
'`user`.id, ' '`user`.id, '
. '`user`.type, ' . '`user`.type, '
. '(SELECT COUNT(*) FROM `order` WHERE `user`.id = `order`.id_user) AS count_orders'); . '(SELECT COUNT(*) FROM `order` WHERE `user`.id = `order`.id_user) AS count_orders');


$query->innerJoin('user_producer', 'user.id = user_producer.id_user AND user_producer.id_producer = :id_producer AND user_producer.active = 1', [':id_producer' => GlobalParam::getCurrentProducerId()]);

$dataProvider = new ActiveDataProvider([ $dataProvider = new ActiveDataProvider([
'query' => $query, 'query' => $query,
'sort' => ['attributes' => ['username', 'credit', 'orders']],
'sort' => [
'attributes' => ['username', 'credit', 'orders'],
'defaultOrder' => ['created_at' => SORT_DESC]
],
'pagination' => [ 'pagination' => [
'pageSize' => 20, 'pageSize' => 20,
], ],
]); ]);


$dataProvider->sort->attributes['created_at'] = [
'asc' => ['user.created_at' => SORT_ASC],
'desc' => ['user.created_at' => SORT_DESC],
];

$dataProvider->sort->attributes['username'] = [ $dataProvider->sort->attributes['username'] = [
'asc' => ['user.lastname' => SORT_ASC, 'user.name' => SORT_ASC], 'asc' => ['user.lastname' => SORT_ASC, 'user.name' => SORT_ASC],
'desc' => ['user.lastname' => SORT_DESC, 'user.name' => SORT_DESC], 'desc' => ['user.lastname' => SORT_DESC, 'user.name' => SORT_DESC],
return $dataProvider; return $dataProvider;
} }


$query->innerJoin('user_producer', 'user.id = user_producer.id_user AND user_producer.id_producer = :id_producer AND user_producer.active = 1', [':id_producer' => GlobalParam::getCurrentProducerId()]);

if (isset($this->id_point_sale) && $this->id_point_sale) { if (isset($this->id_point_sale) && $this->id_point_sale) {
$pointSale = PointSale::findOne(['id' => $this->id_point_sale]);
$query->innerJoin('user_point_sale', 'user.id = user_point_sale.id_user AND user_point_sale.id_point_sale = :id_point_sale', [':id_point_sale' => $this->id_point_sale]); $query->innerJoin('user_point_sale', 'user.id = user_point_sale.id_user AND user_point_sale.id_point_sale = :id_point_sale', [':id_point_sale' => $this->id_point_sale]);
} }


['like', 'user.name_legal_person', $this->username], ['like', 'user.name_legal_person', $this->username],
]); ]);


$query->orderBy('user.created_at DESC');

return $dataProvider; return $dataProvider;
} }



Loading…
Cancel
Save