Browse Source

[Administration] Utilisateurs > liste : filtres de recherche #1270

feature/souke
Guillaume Bourgeois 1 year ago
parent
commit
3bfdbda484
4 changed files with 20 additions and 2 deletions
  1. +2
    -0
      backend/views/user/index.php
  2. +6
    -1
      common/logic/User/User/Model/User.php
  3. +7
    -1
      common/logic/User/User/Model/UserSearch.php
  4. +5
    -0
      common/logic/User/User/Service/UserSolver.php

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

use common\logic\User\UserProducer\Model\UserProducer; use common\logic\User\UserProducer\Model\UserProducer;
use common\logic\User\User\Model\User; use common\logic\User\User\Model\User;


$userManager = UserManager::getInstance();
$producerManager = ProducerManager::getInstance(); $producerManager = ProducerManager::getInstance();


$this->setTitle('Utilisateurs'); $this->setTitle('Utilisateurs');
'headerOptions' => ['class' => 'column-hide-on-mobile'], 'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'], 'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'], 'contentOptions' => ['class' => 'column-hide-on-mobile'],
'filter' => $userManager->getTypeChoicesArray(),
'value' => function ($model) { 'value' => function ($model) {
$userManager = UserManager::getInstance(); $userManager = UserManager::getInstance();
$typeArray = $userManager->getTypeChoicesArray(); $typeArray = $userManager->getTypeChoicesArray();

+ 6
- 1
common/logic/User/User/Model/User.php View File

*/ */
class User extends ActiveRecordCommon implements IdentityInterface class User extends ActiveRecordCommon implements IdentityInterface
{ {

const TYPE_INDIVIDUAL = 'individual'; const TYPE_INDIVIDUAL = 'individual';
const TYPE_LEGAL_PERSON = 'legal-person'; const TYPE_LEGAL_PERSON = 'legal-person';
const TYPE_GUEST = 'guest'; const TYPE_GUEST = 'guest';


public static array $types = [
self::TYPE_GUEST,
self::TYPE_INDIVIDUAL,
self::TYPE_LEGAL_PERSON
];

const STATUS_DELETED = 0; const STATUS_DELETED = 0;
const STATUS_ACTIVE = 10; const STATUS_ACTIVE = 10;
const STATUS_PRODUCER = 11; const STATUS_PRODUCER = 11;

+ 7
- 1
common/logic/User/User/Model/UserSearch.php View File

use common\logic\PointSale\PointSale\Model\PointSale; use common\logic\PointSale\PointSale\Model\PointSale;
use common\logic\Producer\Producer\Wrapper\ProducerManager; use common\logic\Producer\Producer\Wrapper\ProducerManager;
use common\logic\User\User\Repository\UserRepository; use common\logic\User\User\Repository\UserRepository;
use common\logic\User\User\Wrapper\UserManager;
use yii\data\ActiveDataProvider; use yii\data\ActiveDataProvider;


class UserSearch extends User class UserSearch extends User
{ {
return [ return [
[['no_mail', 'mail_distribution_monday', 'mail_distribution_tuesday', 'mail_distribution_wednesday', 'mail_distribution_thursday', 'mail_distribution_friday', 'mail_distribution_saturday', 'mail_distribution_sunday'], 'boolean'], [['no_mail', 'mail_distribution_monday', 'mail_distribution_tuesday', 'mail_distribution_wednesday', 'mail_distribution_thursday', 'mail_distribution_friday', 'mail_distribution_saturday', 'mail_distribution_sunday'], 'boolean'],
[['lastname', 'name', 'phone', 'address'], 'string'],
[['lastname', 'name', 'phone', 'address', 'type'], 'string'],
[['id_point_sale', 'inactive', 'subscribers'], 'integer'], [['id_point_sale', 'inactive', 'subscribers'], 'integer'],
[['date_last_connection', 'id_point_sale', 'username'], 'safe'], [['date_last_connection', 'id_point_sale', 'username'], 'safe'],
]; ];


public function search($params = []) public function search($params = [])
{ {
$userManager = UserManager::getInstance();
$producerManager = ProducerManager::getInstance(); $producerManager = ProducerManager::getInstance();
$producer = GlobalParam::getCurrentProducer(); $producer = GlobalParam::getCurrentProducer();


]); ]);
} }


if ($userManager->isTypeValid($this->type)) {
$query->andWhere(['user.type' => $this->type]);
}

$query->andFilterWhere([ $query->andFilterWhere([
'or', 'or',
['like', 'user.lastname', $this->username], ['like', 'user.lastname', $this->username],

+ 5
- 0
common/logic/User/User/Service/UserSolver.php View File

]; ];
} }


public function isTypeValid(string $type = null): bool
{
return in_array($type, User::$types);
}

public function getUsernameFromArray(array $modelArray, $withType = false): string public function getUsernameFromArray(array $modelArray, $withType = false): string
{ {
$username = ''; $username = '';

Loading…
Cancel
Save