Quellcode durchsuchen

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

feature/souke
Guillaume Bourgeois vor 1 Jahr
Ursprung
Commit
3bfdbda484
4 geänderte Dateien mit 20 neuen und 2 gelöschten Zeilen
  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 Datei anzeigen

@@ -45,6 +45,7 @@ use common\logic\Order\Order\Model\Order;
use common\logic\User\UserProducer\Model\UserProducer;
use common\logic\User\User\Model\User;

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

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

+ 6
- 1
common/logic/User/User/Model/User.php Datei anzeigen

@@ -51,11 +51,16 @@ use common\components\ActiveRecordCommon;
*/
class User extends ActiveRecordCommon implements IdentityInterface
{

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

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

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

+ 7
- 1
common/logic/User/User/Model/UserSearch.php Datei anzeigen

@@ -42,6 +42,7 @@ use common\helpers\GlobalParam;
use common\logic\PointSale\PointSale\Model\PointSale;
use common\logic\Producer\Producer\Wrapper\ProducerManager;
use common\logic\User\User\Repository\UserRepository;
use common\logic\User\User\Wrapper\UserManager;
use yii\data\ActiveDataProvider;

class UserSearch extends User
@@ -55,7 +56,7 @@ class UserSearch extends User
{
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'],
[['lastname', 'name', 'phone', 'address'], 'string'],
[['lastname', 'name', 'phone', 'address', 'type'], 'string'],
[['id_point_sale', 'inactive', 'subscribers'], 'integer'],
[['date_last_connection', 'id_point_sale', 'username'], 'safe'],
];
@@ -63,6 +64,7 @@ class UserSearch extends User

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

@@ -143,6 +145,10 @@ class UserSearch extends User
]);
}

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

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

+ 5
- 0
common/logic/User/User/Service/UserSolver.php Datei anzeigen

@@ -20,6 +20,11 @@ class UserSolver extends AbstractService implements SolverInterface
];
}

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

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

Laden…
Abbrechen
Speichern