@@ -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(); |
@@ -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; |
@@ -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], |
@@ -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 = ''; |