<?php
namespace App\Entity;
use App\Annotation\Exportable;
use App\Annotation\ExportableEntity;
use App\Annotation\ExportableMethod;
use App\Factory\UserExtensionFactory;
use App\Repository\UserRepository;
use App\Services\Common\Point\UserPointService;
use App\Traits\DateTrait;
use App\Traits\UserExtensionTrait;
use App\Validator\NotInPasswordHistory;
use App\Validator\UserMail;
use DateInterval;
use DateTime;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Event\PreUpdateEventArgs;
use Doctrine\ORM\Mapping as ORM;
use Exception;
use JMS\Serializer\Annotation as Serializer;
use JMS\Serializer\Annotation\Expose;
use JMS\Serializer\Annotation\Groups;
use JMS\Serializer\Annotation\SerializedName;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @ORM\Entity(repositoryClass=UserRepository::class)
* @UniqueEntity("uniqueSlugConstraint")
* @ORM\HasLifecycleCallbacks()
* @Vich\Uploadable
* @Serializer\ExclusionPolicy("ALL")
* @ExportableEntity
*/
class User implements UserInterface, PasswordAuthenticatedUserInterface
{
use DateTrait;
use UserExtensionTrait;
// TODO Check à quoi sert cette constante
public const SUPER_ADMINISTRATEUR = 1;
// tous les status utilisateur
public const STATUS_CGU_DECLINED = "cgu_declined";
public const STATUS_REGISTER_PENDING = "register_pending";
public const STATUS_CGU_PENDING = "cgu_pending";
public const STATUS_ADMIN_PENDING = "admin_pending";
public const STATUS_UNSUBSCRIBED = "unsubscribed";
public const STATUS_ENABLED = "enabled";
public const STATUS_DISABLED = "disabled";
public const STATUS_ARCHIVED = "archived";
public const STATUS_DELETED = "deleted";
public const BASE_STATUS = [
self::STATUS_ADMIN_PENDING,
self::STATUS_CGU_PENDING,
self::STATUS_ENABLED,
self::STATUS_DISABLED,
self::STATUS_CGU_DECLINED,
self::STATUS_REGISTER_PENDING
];
public const ROLE_ALLOWED_TO_HAVE_JOBS = [
'Super admin' => 'ROLE_SUPER_ADMIN',
'Administrateur' => 'ROLE_ADMIN',
'Utilisateur' => 'ROLE_USER',
];
public ?string $accountIdTmp = null;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*
* @Expose()
* @Groups({
* "default",
* "user:id",
* "user:list","user:item", "sale_order:item", "sale_order:post", "cdp", "user",
* "user_citroentf",
* "export_user_citroentf_datatable",
* "export_agency_manager_commercial_datatable",
* "export_agency_manager_datatable", "export_commercial_installer_datatable",
* "export_installer_datatable",
* "sale_order", "purchase", "get:read","post:read", "export_user_datatable", "export_admin_datatable",
* "export_commercial_datatable",
* "regate-list", "point_of_sale", "parameter", "export_request_registration_datatable"
* })
*
* @Exportable()
*/
private ?int $id = NULL;
/**
* @ORM\Column(type="string", length=130)
* @Assert\NotBlank()
* @Assert\Email(
* message = "Cette adresse email n'est pas valide."
* )
*
* @Expose()
* @Groups({
* "default",
* "user:email",
* "user:list", "user:item", "user:post", "sale_order:item", "cdp", "user","email", "user_citroentf",
* "export_user_citroentf_datatable",
* "export_purchase_declaration_datatable", "export_agency_manager_commercial_datatable",
* "export_agency_manager_datatable", "export_commercial_installer_datatable",
* "export_commercial_datatable",
* "export_installer_datatable","get:read", "export_order_datatable", "purchase", "export_user_datatable", "export_admin_datatable",
* "user_bussiness_result", "sale_order","export_request_registration_datatable", "request_registration",
* "univers", "saleordervalidation", "parameter",
* "idea_box_list", "idea_box_stats", "export_idea_box_datatable"
* })
*
* @Exportable()
* @UserMail()
*/
private ?string $email = null;
/**
* @ORM\Column(type="array")
*
* @Expose()
* @Groups({
* "user:post",
* "user:roles",
* "roles",
* "cdp", "user", "user_citroentf","get:read", "export_user_citroentf_datatable", "export_user_datatable", "export_admin_datatable",
* "idea_box_list", "idea_box_stats", "export_idea_box_datatable"
* })
*/
private $roles = [];
/**
* @ORM\Column(type="string")
*
* @Expose()
* @Groups({ "user:post" })
*/
private $password;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*
* @Expose()
* @Groups({
* "default",
* "user:first_name",
* "user:list", "user:item", "user:post", "cdp", "user","email", "user_citroentf",
* "export_order_datatable", "export_user_citroentf_datatable",
* "user_bussiness_result", "export_purchase_declaration_datatable",
* "export_agency_manager_commercial_datatable",
* "export_agency_manager_datatable", "export_commercial_installer_datatable",
* "export_commercial_datatable",
* "purchase", "sale_order","get:read", "export_user_datatable", "export_admin_datatable", "export_installer_datatable",
* "request_registration","customProductOrder:list", "parameter", "export_request_registration_datatable",
* "idea_box_list", "idea_box_stats", "export_idea_box_datatable"
* })
*
* @Exportable()
*/
private $firstName;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*
* @Expose()
* @Groups({
* "user:last_name",
* "default",
* "user:list", "user:item", "user:post", "cdp", "user","email", "user_citroentf",
* "export_order_datatable",
* "export_user_citroentf_datatable",
* "user_bussiness_result", "export_purchase_declaration_datatable",
* "export_agency_manager_commercial_datatable",
* "export_agency_manager_datatable", "export_commercial_installer_datatable",
* "export_commercial_datatable",
* "purchase", "sale_order","get:read", "export_user_datatable", "export_admin_datatable", "export_installer_datatable",
* "request_registration","export_request_registration_datatable", "customProductOrder:list", "parameter",
* "idea_box_list", "idea_box_stats", "export_idea_box_datatable"
* })
*
* @Exportable()
*/
private $lastName;
/**
* Numéro téléphone portable
*
* @ORM\Column(type="string", length=20, nullable=true)
*
* @Expose()
* @Groups({
* "user:post",
* "user:mobile",
* "commercial:mobile",
* "user:item", "user:post", "user", "export_user_citroentf_datatable",
* "export_purchase_declaration_datatable",
* "export_agency_manager_commercial_datatable",
* "export_agency_manager_datatable", "export_commercial_installer_datatable",
* "export_commercial_datatable", "export_user_datatable", "export_admin_datatable",
* "export_installer_datatable"})
*
* @Exportable()
*/
private $mobile;
/**
* Numéro téléphone fix
* @ORM\Column(type="string", length=20, nullable=true)
*
* @Expose()
* @Groups({
* "user:post",
* "user:phone",
* "user:item", "user:post", "user", "export_user_citroentf_datatable", "export_order_datatable",
* "export_purchase_declaration_datatable",
* "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
* "export_commercial_installer_datatable",
* "export_commercial_datatable","get:read", "export_user_datatable", "export_admin_datatable",
* "export_installer_datatable"})
*
* @Exportable()
*/
private $phone;
/**
* @ORM\Column(type="datetime", nullable=true)
*
* @Expose()
* @Groups({
* "user:post","welcome_email","user", "user_citroentf"
* })
*/
private $welcomeEmail;
/**
* @deprecated Utiliser la fonction getAvailablePointOfUser de PointService
* @ORM\Column(type="integer", options={"default": 0})
*/
private $availablePoint = 0;
/**
* @deprecated
* @ORM\Column(type="integer", options={"default": 0})
*/
private $potentialPoint = 0;
/**
* On passe par un userExtension maintenant
*
* @deprecated
* @ORM\Column(type="string", length=10, nullable=true)
*/
private $locale;
/**
* Code du pays
*
* @ORM\ManyToOne(targetEntity=Country::class, inversedBy="users")
* @ORM\JoinColumn(name="country_id", referencedColumnName="id",nullable="true")
*
* @Expose()
* @Groups({
* "user:post",
* "country",
* "user:item", "user:post", "export_user_datatable", "export_admin_datatable", "export_user_citroentf_datatable",
* "export_agency_manager_commercial_datatable",
* "export_agency_manager_datatable", "export_commercial_datatable"})
*
* @Exportable()
*/
private ?Country $country = NULL;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Expose()
* @Groups({
* "user:post",
* "job",
* "user:job",
* "user","get:read", "export_user_datatable", "export_admin_datatable", "univers", "parameter", "purchase" , "export_purchase_declaration_datatable"})
*
* @Exportable()
*/
private $job;
/**
* Société
*
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Expose()
* @Groups({
* "user:post",
* "user:company",
* "default",
* "user:item", "user:post", "user","email", "export_purchase_declaration_datatable",
* "export_order_datatable",
* "export_agency_manager_commercial_datatable",
* "export_agency_manager_datatable", "export_commercial_installer_datatable",
* "export_commercial_datatable",
* "export_installer_datatable", "purchase","get:read","post:read", "export_user_datatable"
* })
*
* @Exportable()
*/
private ?string $company = NULL;
/**
* Numéro de Siret
*
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Expose()
* @Groups({
* "user:post",
* "company_siret",
* "export_order_datatable",
* "export_purchase_declaration_datatable",
* "export_installer_datatable",
* "user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
*
* @Exportable()
*/
private ?string $companySiret = NULL;
/**
* Forme juridique
*
* @ORM\Column(type="string", length=128, nullable=true)
*
* @Expose()
* @Groups({
* "user:post",
* "company_legal_status",
* "user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
*
* @Exportable()
*/
private ?string $companyLegalStatus = NULL;
/**
* @deprecated
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $userToken;
/**
* @deprecated
* @ORM\Column(type="datetime", nullable=true)
*/
private $userTokenValidity;
/**
* @deprecated
* @ORM\Column(type="integer", options={"default": 0})
*/
private $userTokenAttempts = 0;
/**
* Civilité
*
* @ORM\Column(type="string", length=16, nullable=true)
*
* @Expose()
* @Groups({
* "user:civility",
* "user:item", "default", "email","user:post", "user", "export_installer_datatable",
* "export_purchase_declaration_datatable", "export_commercial_installer_datatable",
* "export_user_datatable"})
*
* @Exportable()
*/
private $civility;
/**
* Adresse
*
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Expose()
* @Groups ({
* "user:post","user", "user:address1", "user:item", "user:post", "email","export_installer_datatable",
* "export_order_datatable",
* "export_user_citroentf_datatable", "export_commercial_installer_datatable", "export_user_datatable", "export_admin_datatable",
* "export_commercial_datatable","export_agency_manager_datatable"})
*
* @Exportable()
*/
private ?string $address1 = NULL;
/**
* Complément d'adresse
*
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Expose()
* @Groups ({
* "user:post","address2", "user:item", "user:post", "email"})
*
* @Exportable()
*/
private ?string $address2 = NULL;
/**
* Code postal
*
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Expose()
* @Groups ({
* "user:post","user", "user:postcode", "user:item", "user:post", "email","export_installer_datatable",
* "export_order_datatable",
* "export_user_citroentf_datatable", "export_commercial_installer_datatable", "export_user_datatable", "export_admin_datatable",
* "export_commercial_datatable","export_agency_manager_datatable"})
*
* @Exportable()
*/
private ?string $postcode = NULL;
/**
* Ville
*
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Expose()
* @Groups({
* "user:post","user", "user:city", "user:item", "user:post", "email","export_user_datatable", "export_admin_datatable",
* "export_order_datatable", "export_installer_datatable",
* "export_commercial_installer_datatable",
* "export_commercial_datatable","export_agency_manager_datatable"})
*
* @Exportable()
*/
private ?string $city = NULL;
/**
* @ORM\Column(type="boolean", nullable=true)
*
* @Expose()
* @Groups({
* "user:post","user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
*
* @Exportable()
*/
private $canOrder = TRUE;
/**
* Date de suppression
* @ORM\Column(type="datetime", nullable=true)
*
* @Expose()
* @Groups({ "user:post","user"})
*
* @Exportable()
*/
private $deletedAt;
/**
* Date de naissance
*
* @ORM\Column(type="datetime", nullable=true)
*
* @Expose()
* @Groups({ "user:post","user"})
*
* @deprecated
*/
private ?DateTimeInterface $birthDate = NULL;
/**
* Lieu de naissance
*
* @deprecated
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $birthPlace = NULL;
/**
* Identifiant interne
*
* @ORM\Column(type="string", length=80, nullable=true)
*
* @Expose()
* @Groups({
* "user:internal_code",
* "request_registration",
* "export_user_datatable", "export_admin_datatable",
* "user:list", "user", "user:item", "user:post", "user", "export_purchase_declaration_datatable",
* "export_installer_datatable",
* "export_commercial_installer_datatable"})
*
* @Exportable()
*/
private $internalCode;
/**
* @ORM\Column(type="datetime", nullable=true)
*
* @Expose()
* @Groups({
* "user:post",
* "default",
* "user:cgu_at",
* "user", "export_installer_datatable", "export_commercial_installer_datatable"
* })
*
* @Exportable()
*/
private $cguAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*
* @Expose()
* @Groups({
* "user:post",
* "default",
* "user:register_at",
* "user", "export_installer_datatable", "export_commercial_installer_datatable"
* })
*
* @Exportable()
*/
private $registerAt;
/**
* @ORM\Column(type="datetime", nullable=true)
*
* @Expose()
* @Groups ({
* "user:imported_at",
* "export_installer_datatable", "export_commercial_installer_datatable"})
*
* @Exportable()
*/
private $importedAt;
/**
* @ORM\Column(type="boolean", options={"default": true})
*
* @Exportable()
*/
private $canBeContacted = TRUE;
/**
* @deprecated
* @ORM\Column(type="string", length=64, nullable=true)
*/
private $capacity;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Exportable()
*/
private $address3;
/**
* @ORM\Column(type="boolean", options={"default": false})
*
* @Exportable()
*/
private $optinMail = FALSE;
/**
* @ORM\Column(type="boolean", options={"default": false})
*
* @Exportable()
*/
private $optinSMS = FALSE;
/**
* @ORM\Column(type="boolean", options={"default": false})
*
* @Exportable()
*/
private $optinPostal = FALSE;
/**
* @ORM\Column(type="text", nullable=true)
*
* @Exportable()
*/
private $optinPostalAddress;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Exportable()
*/
private $source;
/**
* @deprecated
* @ORM\Column(type="integer", options={"default": 0})
*/
private $level = 0;
/**
* @deprecated
* @ORM\Column(type="datetime", nullable=true)
*/
private $level0UpdatedAt;
/**
* @deprecated
* @ORM\Column(type="datetime", nullable=true)
*/
private $level1UpdatedAt;
/**
* @deprecated
* @ORM\Column(type="datetime", nullable=true)
*/
private $level2UpdatedAt;
/**
* @deprecated
* @ORM\Column(type="datetime", nullable=true)
*/
private $level3UpdatedAt;
/**
* @deprecated
* @ORM\Column(type="datetime", nullable=true)
*/
private $levelUpdateSeenAt;
/**
* @ORM\Column(type="boolean", options={"default": true})
*
* @Expose()
* @Groups ({
* "user:is_email_ok",
* "export_installer_datatable", "export_commercial_installer_datatable"})
*/
private $isEmailOk = TRUE;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $lastEmailCheck;
/**
* @deprecated
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $apiToken;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Assert\NotBlank(groups={"installateur"})
* @Assert\Regex(
* groups={"installateur"},
* message="Le numéro SAP est invalide",
* pattern = "/^\d{6,8}$/"),
*
* @Expose()
* @Groups({
* "default",
* "user:sap_account",
* "user", "user_bussiness_result", "export_purchase_declaration_datatable",
* "export_agency_manager_commercial_datatable",
* "export_agency_manager_datatable", "export_commercial_installer_datatable",
* "export_commercial_datatable","get:read", "purchase",
* "export_installer_datatable"
* })
*
* @Exportable()
*/
private $sapAccount;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Expose()
* @Groups({
* "user:sap_distributor",
* "export_installer_datatable", "export_commercial_installer_datatable"})
*
* @Exportable()
*/
private $sapDistributor;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Expose()
* @Groups({
* "user:distributor",
* "export_installer_datatable", "export_commercial_installer_datatable"})
*
* @Exportable()
*/
private $distributor;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Expose()
* @Groups({
* "user:distributor2",
* "export_installer_datatable", "export_commercial_installer_datatable"})
*
* @Exportable()
*/
private $distributor2;
/**
* @ORM\Column(type="boolean", nullable=true)
*
* @Exportable()
*/
private $aggreement;
/**
* @ORM\Column(type="datetime", nullable=true)
*
* @Expose()
* @Groups({
* "user:post",
* "user:unsubscribed_at",
* "user","get:read","post:read", "export_installer_datatable", "export_commercial_installer_datatable"})
*
* @Exportable()
*/
private $unsubscribedAt;
/**
* True if the salesman is chauffage
* @ORM\Column(type="boolean", options={"default": false}, nullable=true)
*
* @Expose()
* @Groups ({
* "user:chauffage",
* "user", "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
* "export_commercial_datatable"})
*
* @Exportable()
*/
private $chauffage = FALSE;
/**
* @ORM\OneToMany(targetEntity=Address::class, mappedBy="user", cascade={"remove", "persist"})
*
* @Exportable("addresses")
*/
private $addresses;
/**
* @ORM\OneToMany(targetEntity=Cart::class, mappedBy="user", cascade={"remove", "persist"})
*/
private $carts;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="subAccountUsers", cascade={"persist"})
* @ORM\JoinColumn(onDelete="SET NULL", nullable=true)
*
* @var User|null
*/
private ?User $mainAccountUser = null;
/**
* @ORM\OneToMany(targetEntity=User::class, mappedBy="mainAccountUser")
*
* @var Collection|User[]
*/
private $subAccountUsers;
/**
* @ORM\ManyToMany(targetEntity=Distributor::class, inversedBy="users", cascade={"persist"})
*
* @Expose()
* @Groups({
* "user:distributors",
* "export_installer_datatable", "export_commercial_installer_datatable"})
*/
private $distributors;
/**
* @ORM\OneToMany(targetEntity=Purchase::class, mappedBy="user", cascade={"remove"})
*/
private $purchases;
/**
* @ORM\OneToMany(targetEntity=Purchase::class, mappedBy="validator", cascade={"remove"})
*/
private $purchasesIHaveProcessed;
/**
* @ORM\OneToMany(targetEntity=SaleOrder::class, mappedBy="user")
*
* @Exportable()
*/
private $orders;
/**
* @var Collection|User[]
*
* @ORM\OneToMany(targetEntity=User::class, mappedBy="godfather", orphanRemoval=true)
*/
private $godchilds;
/**
* @var User|null
*
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="godchilds")
* @ORM\JoinColumn(onDelete="SET NULL")
*/
private $godfather;
/**
* @deprecated
* @ORM\OneToMany(targetEntity=Satisfaction::class, mappedBy="user")
*/
private $satisfactions;
/**
* @ORM\OneToMany(targetEntity=RequestProductAvailable::class, mappedBy="user")
*/
private $requestProductAvailables;
/**
* @ORM\OneToMany(targetEntity=UserImportHistory::class, mappedBy="importer")
*
* @Exportable()
*/
private $userImportHistories;
/**
* @ORM\ManyToMany(targetEntity=ContactList::class, mappedBy="users")
*
* @Exportable()
*/
private $contactLists;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Expose()
* @Groups({"user", "sale_order","get:read","post:read"})
*/
private $username;
/**
* @deprecated
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $usernameCanonical;
/**
* @deprecated
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $emailCanonical;
/**
* @deprecated
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $salt;
/**
* Date de dernière connexion
*
* @ORM\Column(type="datetime", nullable=true)
*
* @Expose()
* @Groups({
* "user:last_login",
* "user", "user:item", "export_installer_datatable", "export_commercial_installer_datatable",
* "export_user_datatable"})
*
* @Exportable()
*/
private $lastLogin;
/**
* @ORM\Column(type="string", length=64, nullable=true)
*/
private $confirmationToken;
/**
* @ORM\Column(type="datetime", nullable=true)
*
* @Exportable()
*/
private $passwordRequestedAt;
/**
* @Expose()
* @Groups ({"user:post"})
*
* @NotInPasswordHistory
*/
private ?string $plainPassword = NULL;
/**
* @ORM\Column(type="boolean", nullable=true)
*
* @Expose()
* @Groups({"get:read"})
*/
private $credentialExpired;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $credentialExpiredAt;
// Arguments requis pour LaPoste
/**
* @ORM\OneToMany(targetEntity=Devis::class, mappedBy="user")
*
* @Exportable()
*/
private $devis;
/**
* @ORM\ManyToOne(targetEntity=Regate::class, inversedBy="members")
* @ORM\JoinColumn(name="regate_id", referencedColumnName="id", onDelete="SET NULL")
*
* @Expose()
* @Groups({"user", "export_user_datatable"})
*
* @Exportable()
*/
private ?Regate $regate = NULL;
/**
* @ORM\Column(type="boolean", nullable=true)
*
* @Exportable()
*/
private $donneesPersonnelles;
/**
* @var Collection|PointTransaction[]
*
* @ORM\OneToMany(targetEntity=PointTransaction::class, mappedBy="user", orphanRemoval=true, cascade={"persist"})
*
* @Exportable()
*/
private $pointTransactions;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="installers")
*
* @Expose()
* @Groups({
* "user:commercial",
* "user","export_request_registration_datatable", "request_registration", "sale_order", "purchase",
* "export_purchase_declaration_datatable",
* "export_installer_datatable", "export_commercial_installer_datatable"})
*/
private $commercial;
/**
* @ORM\OneToMany(targetEntity=User::class, mappedBy="commercial")
*
* @Expose()
* @Groups({
* "user:installers"
* })
*/
private $installers;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="heatingInstallers")
*
* @Expose()
* @Groups({
* "user:heating_commercial",
* "export_installer_datatable", "export_commercial_installer_datatable"})
*/
private $heatingCommercial;
/**
* @ORM\OneToMany(targetEntity=User::class, mappedBy="heatingCommercial")
*/
private $heatingInstallers;
/**
* @ORM\ManyToOne(targetEntity=Agence::class, inversedBy="users", fetch="EAGER")
*
* @Expose()
* @Groups({
* "default",
* "user:agency",
* "user", "user_bussiness_result", "export_purchase_declaration_datatable",
* "export_agency_manager_commercial_datatable",
* "export_agency_manager_datatable", "export_commercial_installer_datatable",
* "export_commercial_datatable","get:read", "purchase",
* "export_installer_datatable"
* })
*/
private $agency;
/**
* Date d'archivage
*
* @ORM\Column(type="datetime", nullable=true)
*
* @Expose()
* @Groups({
* "user:archived_at",
* "default",
* "user", "export_installer_datatable", "export_commercial_installer_datatable"
* })
*
* @Exportable()
*/
private $archivedAt;
/**
* @ORM\Column(type="boolean", options={"default":false})
*
* @Exportable()
*/
private $newsletter = FALSE;
/**
* @ORM\OneToMany(targetEntity=UserBusinessResult::class, mappedBy="user", cascade={"persist", "remove"})
*
* @Expose()
* @Groups({"user:userBusinessResults","user","export_user_datatable"})
*
* @Exportable()
*
* @var Collection|UserBusinessResult[]
*/
private Collection $userBusinessResults;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Expose()
* @Groups({
* "user:post","cdp", "user", "user:extension1","export_user_citroentf_datatable", "user_citroentf",
* "export_user_citroentf_datatable",
* "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
* "export_commercial_installer_datatable",
* "export_commercial_datatable", "export_user_datatable", "export_admin_datatable", "export_installer_datatable"})
*
* @Exportable()
*/
private ?string $extension1 = NULL;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Expose()
* @Groups({
* "user:post","cdp", "user", "user:extension2", "export_user_citroentf_datatable", "user_citroentf",
* "export_user_citroentf_datatable",
* "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
* "export_commercial_installer_datatable",
* "export_commercial_datatable", "export_user_datatable", "export_admin_datatable", "export_installer_datatable"})
*
* @Exportable()
*/
private ?string $extension2 = NULL;
/**
* @ORM\Column(type="integer", nullable=true, unique=true)
*
* @Exportable()
*/
private $wdg;
/**
* @ORM\Column(type="string", nullable=true, unique=true)
*
* @Exportable()
*/
private $gladyUuid;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Exportable()
*/
private $transactionalEmail;
/**
* @ORM\OneToMany(targetEntity=Project::class, mappedBy="referent")
*
* @Exportable()
*/
private $projects;
/**
* @ORM\ManyToOne(targetEntity=Programme::class, inversedBy="users")
*
* @Expose()
* @Groups({"user"})
*
* @Exportable()
*/
private $programme;
/**
* @ORM\OneToMany(targetEntity=ServiceUser::class, mappedBy="user", orphanRemoval=true)
*
* @Exportable()
*/
private $serviceUsers;
/**
* @ORM\ManyToOne(targetEntity=SaleOrderValidation::class, inversedBy="users")
*
* @Expose()
* @Groups({"user", "export_user_datatable"})
*/
private $saleOrderValidation;
/**
* @ORM\ManyToMany(targetEntity=Univers::class, inversedBy="users")
*
*/
private $universes;
/**
* @ORM\ManyToOne(targetEntity=BillingPoint::class, inversedBy="users")
*
* @Expose()
* @Groups({"user", "export_user_datatable", "export_admin_datatable", "billingpoint"})
*/
private $billingPoint;
/**
* @ORM\OneToMany(targetEntity=Score::class, mappedBy="user", cascade={"remove"})
*
* @Exportable()
*/
private $scores;
/**
* @ORM\OneToMany(targetEntity=ScoreObjective::class, mappedBy="user", cascade={"remove"})
*
* @Exportable()
*/
private $scoreObjectives;
/**
* Dans la relation : target
*
* @ORM\ManyToMany(targetEntity=User::class, inversedBy="parents", cascade={"persist"})
*/
private $children;
/**
* Dans la relation : source
*
* @ORM\ManyToMany(targetEntity=User::class, mappedBy="children", cascade={"persist"})
*/
private $parents;
/**
* @ORM\OneToMany(targetEntity=Message::class, mappedBy="sender")
*
* @Exportable()
*/
private $senderMessages;
/**
* @ORM\OneToMany(targetEntity=Message::class, mappedBy="receiver")
*
* @Exportable()
*/
private $receiverMessages;
/**
* @ORM\OneToOne(targetEntity=RequestRegistration::class, inversedBy="user", cascade={"persist", "remove"})
*
* @Exportable()
*/
private $requestRegistration;
/**
* @ORM\OneToMany(targetEntity=RequestRegistration::class, mappedBy="referent")
*
* @Exportable()
*/
private $requestRegistrationsToValidate;
/**
* @ORM\OneToMany(targetEntity=CustomProductOrder::class, mappedBy="user", orphanRemoval=true)
*
* @Exportable()
*/
private $customProductOrders;
/**
* @ORM\Column(type="string", length=255, options={"default":"cgu_pending"})
*
* @Expose()
* @Groups({
* "user:post",
* "user:status",
* "user:list", "user:item", "cdp", "user", "export_user_citroentf_datatable", "user_citroentf",
* "export_user_citroentf_datatable",
* "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
* "export_commercial_installer_datatable",
* "export_commercial_datatable","export_request_registration_datatable",
* "export_user_datatable", "export_admin_datatable", "export_installer_datatable"})
*
* @Exportable()
*/
private string $status;
/**
* @ORM\Column(type="text", nullable=true)
*/
private ?string $calculatedPoints;
/**
* @ORM\OneToMany(targetEntity=CustomProduct::class, mappedBy="createdBy")
*
* @Exportable()
*/
private $customProducts;
/**
* Adhésion de l'utilisateur
*
* @ORM\OneToOne(targetEntity=UserSubscription::class, inversedBy="user", cascade={"persist", "remove"})
* @Expose()
* @Groups({"user" ,"user:subscription", "export_user_datatable"})
*
* @Exportable()
*/
private ?UserSubscription $subscription = NULL;
/**
* @ORM\OneToMany(targetEntity=UserExtension::class, mappedBy="user", cascade={"persist", "remove"})
*
* @Exportable(type="oneToMany")
*
* @Exportable()
*/
private $extensions;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Exportable()
*/
private $avatar;
/**
* @Vich\UploadableField(mapping="user_avatar", fileNameProperty="avatar")
* @var File
*/
private $avatarFile;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Exportable()
*/
private $logo;
/**
* @Vich\UploadableField(mapping="user_logo", fileNameProperty="logo")
* @var File
*/
private $logoFile;
/**
* @ORM\ManyToOne(targetEntity=PointOfSale::class, inversedBy="users",fetch="EAGER")
*
* @Expose()
* @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
*/
private ?PointOfSale $pointOfSale = NULL;
/**
* @ORM\ManyToMany(targetEntity=PointOfSale::class, mappedBy="managers")
*/
private Collection $managedPointOfSales;
/**
* @ORM\OneToMany(targetEntity=Parameter::class, mappedBy="userRelated")
*
* @Expose()
* @Groups({"parameter"})
* @Exportable()
*/
private Collection $relatedParameters;
/**
* @ORM\OneToMany(targetEntity=PointOfSale::class, mappedBy="createdBy")
*
* @Exportable()
*/
private Collection $createdPointOfSales;
/**
* @ORM\OneToMany(targetEntity=PointConversionRate::class, mappedBy="owner", orphanRemoval=true)
*
* @Exportable()
*/
private Collection $ownerPointConversionRates;
/**
* @ORM\ManyToOne(targetEntity=PointConversionRate::class, inversedBy="users")
*/
private ?PointConversionRate $pointConversionRate = NULL;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Exportable()
*/
private ?string $fonction = NULL;
/**
* @ORM\OneToOne(targetEntity=Regate::class, inversedBy="responsable", cascade={"persist", "remove"},
* fetch="EXTRA_LAZY")
*
* @Exportable()
*/
private ?Regate $responsableRegate = NULL;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Exportable()
*/
private ?string $registrationDocument = NULL;
/**
* @Vich\UploadableField(mapping="user_registration_document", fileNameProperty="registrationDocument")
* @var File
*/
private $registrationDocumentFile;
/**
* @ORM\OneToOne(targetEntity=CoverageArea::class, inversedBy="user", cascade={"persist", "remove"})
* @ORM\JoinColumn(nullable=true)
*
* @Exportable()
*/
private $coverageArea;
/**
* @ORM\OneToMany(targetEntity=QuizUserAnswer::class, mappedBy="user")
*
* @Exportable()
*/
private $quizUserAnswers;
/**
* @ORM\OneToMany(targetEntity=IdeaBoxAnswer::class, mappedBy="user")
*
* @Expose
* @Groups({
* "user:idea_box_answers",
* "idea_box_list", "idea_box_stats", "export_idea_box_datatable"
* })
*
* @Exportable()
*/
private $ideaBoxAnswers;
/**
* @ORM\OneToMany(targetEntity=IdeaBoxRating::class, mappedBy="user")
*
* @Expose
* @Groups({
* "user:idea_box_ratings",
* "idea_box_list", "idea_box_stats", "export_idea_box_datatable"
* })
*
* @Exportable()
*/
private $ideaBoxRatings;
/**
* @ORM\OneToMany(targetEntity=IdeaBoxRecipient::class, mappedBy="user")
*
* @Expose
* @Groups({
* "user:idea_box_recipients",
* "idea_box_list", "idea_box_stats", "export_idea_box_datatable"
* })
*
* @Exportable()
*/
private $ideaBoxRecipients;
/**
* @ORM\Column(type="string", length=128, nullable=true)
*/
private ?string $oldStatus = NULL;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private ?DateTimeInterface $disabledAt = NULL;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Exportable()
*/
private $archiveReason;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Exportable()
*/
private $unsubscribeReason;
/**
* @ORM\OneToMany(targetEntity=ActionLog::class, mappedBy="user")
*
* @Expose()
* @Groups({
* "user:actionLog",
* "actionLog"
* })
*
* @Exportable()
*/
private $actionLogs;
/**
* @ORM\Column(type="integer")
*
* @Exportable()
*/
private $failedAttempts = 0;
/**
* @ORM\Column(type="datetime", nullable=true)
*
* @Exportable()
*/
private $lastFailedAttempt;
/**
* @ORM\Column(type="datetime", nullable=true)
*
* @Exportable()
*/
private $passwordUpdatedAt;
/**
* @ORM\OneToMany(targetEntity=PasswordHistory::class, mappedBy="user", orphanRemoval=true, cascade={"persist"})
*/
private $passwordHistories;
/**
* @ORM\OneToMany(targetEntity=UserFavorites::class, mappedBy="user")
*
* @Exportable()
*/
private $userFavorites;
/**
* @ORM\Column(type="datetime", nullable=true)
*
* @Exportable()
*/
private $lastActivity;
/**
* Variables pour stocker la valeur avant modification
* @Expose()
* @Groups ({"user:post"})
*/
private ?string $oldEmail = NULL;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Expose()
* @Groups({
* "default",
* "user:accountId",
* "user:post", "user:list","user:item", "cdp", "user",
* "user_bussiness_result", "user_bussiness_result:user",
* "export_user_datatable"
* })
*/
private ?string $accountId = NULL;
/**
* @ORM\Column(type="string", nullable=true, unique=true)
*/
private ?string $uniqueSlugConstraint = NULL;
/**
* @ORM\OneToMany(targetEntity=BoosterProductResult::class, mappedBy="user", orphanRemoval=true)
*/
private $boosterProductResults;
/**
* @ORM\OneToMany(targetEntity=PushSubscription::class, mappedBy="user")
*/
private $pushSubscriptions;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $azureId;
/**
* @ORM\ManyToMany(targetEntity=AzureGroup::class, mappedBy="members")
*/
private $azureGroups;
/**
* @ORM\ManyToOne(targetEntity=User::class)
*/
private ?User $activatedBy;
public function __construct()
{
$this->addresses = new ArrayCollection();
$this->subAccountUsers = new ArrayCollection();
$this->carts = new ArrayCollection();
$this->distributors = new ArrayCollection();
$this->purchases = new ArrayCollection();
$this->orders = new ArrayCollection();
$this->godchilds = new ArrayCollection();
$this->requestProductAvailables = new ArrayCollection();
$this->userImportHistories = new ArrayCollection();
$this->contactLists = new ArrayCollection();
$this->devis = new ArrayCollection();
$this->pointTransactions = new ArrayCollection();
$this->installers = new ArrayCollection();
$this->heatingInstallers = new ArrayCollection();
$this->userBusinessResults = new ArrayCollection();
$this->projects = new ArrayCollection();
$this->serviceUsers = new ArrayCollection();
$this->universes = new ArrayCollection();
$this->scores = new ArrayCollection();
$this->scoreObjectives = new ArrayCollection();
$this->children = new ArrayCollection();
$this->parents = new ArrayCollection();
$this->requestRegistrationsToValidate = new ArrayCollection();
$this->customProductOrders = new ArrayCollection();
$this->extensions = new ArrayCollection();
$this->managedPointOfSales = new ArrayCollection();
$this->relatedParameters = new ArrayCollection();
$this->createdPointOfSales = new ArrayCollection();
$this->status = self::STATUS_CGU_PENDING;
$this->ideaBoxAnswers = new ArrayCollection();
$this->ideaBoxRatings = new ArrayCollection();
$this->ideaBoxRecipients = new ArrayCollection();
$this->actionLogs = new ArrayCollection();
$this->passwordHistories = new ArrayCollection();
$this->userFavorites = new ArrayCollection();
$this->boosterProductResults = new ArrayCollection();
$this->pushSubscriptions = new ArrayCollection();
$this->azureGroups = new ArrayCollection();
}
private function generateSlug(): void
{
$parts = [$this->email, $this->accountId, $this->extension1, $this->extension2];
$parts = array_filter($parts);
$this->uniqueSlugConstraint = implode('-', $parts);
}
/**
* @ORM\PreUpdate()
*/
public function preUpdate(PreUpdateEventArgs $eventArgs): void
{
if ($eventArgs->getObject() instanceof User) {
if ($eventArgs->hasChangedField('email') || $eventArgs->hasChangedField('extension1') || $eventArgs->hasChangedField(
'extension2'
) || $eventArgs->hasChangedField('accountId')) {
$this->generateSlug();
}
}
}
// Typed property App\Entity\User::$email must not be accessed before initialization
// Modif prePersist() vers postPersist()
/**
* @ORM\PostPersist()
*/
public function postPersist(): void
{
$this->generateSlug();
}
/**
* @ORM\PostUpdate()
*/
public function postUpdate(): void
{
$this->oldEmail = NULL;
}
public function __toString(): string
{
return $this->getFullName();
}
/**
* @Serializer\VirtualProperty
* @SerializedName("fullName")
*
* @Expose()
* @Groups({"user:full_name","email", "export_order_datatable", "purchase", "service_user",
* "univers","customProductOrder:list"})
*
* @return string
*
* @ExportableMethod()
*/
public function getFullName(): string
{
$fullName = trim($this->firstName . ' ' . $this->lastName);
if (empty($fullName)) {
return $this->getEmail();
}
return $fullName;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): User
{
$email = trim($email);
if (isset($this->email)) {
$this->setOldEmail($this->email);
} else {
$this->setOldEmail($email);
}
$this->email = $email;
return $this;
}
public function __toArray(): array
{
return get_object_vars($this);
}
/**
* ============================================================================================
* =============================== FONCTIONS CUSTOM ===========================================
* ============================================================================================
*/
public function serialize(): string
{
return serialize(
[
$this->id,
],
);
}
public function __serialize(): array
{
return [
'id' => $this->id,
'email' => $this->email,
'password' => $this->password,
'salt' => $this->salt,
];
}
public function __unserialize($serialized): void
{
$this->id = $serialized[ 'id' ];
$this->email = $serialized[ 'email' ];
$this->password = $serialized[ 'password' ];
$this->salt = $serialized[ 'salt' ];
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("unsubscribed")
*
* @Expose()
* @Groups({
* "user:unsubscribed",
* "default",
* "unsubscribed",
* "user:list", "user:item", "cdp", "user", "export_user_citroentf_datatable", "user_citroentf",
* "export_user_citroentf_datatable",
* "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
* "export_commercial_installer_datatable",
* "export_commercial_datatable", "export_user_datatable", "export_admin_datatable", "export_installer_datatable"
* })
*
* @return bool
*/
public function isUnsubscribed(): bool
{
return $this->status === self::STATUS_UNSUBSCRIBED;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("enabled")
*
* @Expose()
* @Groups({
* "user:enabled",
* "default",
* "enabled",
* "user:list", "user:item", "cdp", "user", "export_user_citroentf_datatable", "user_citroentf",
* "export_user_citroentf_datatable",
* "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
* "export_commercial_installer_datatable",
* "export_commercial_datatable", "export_user_datatable", "export_admin_datatable", "export_installer_datatable"
* })
*
* @return bool
*/
public function isEnabled(): bool
{
return $this->status === self::STATUS_ENABLED;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("disabled")
*
* @Expose()
* @Groups({
* "user:disabled",
* "user:list", "user:item", "cdp", "user", "export_user_citroentf_datatable", "user_citroentf",
* "export_user_citroentf_datatable",
* "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
* "export_commercial_installer_datatable",
* "export_commercial_datatable", "export_user_datatable", "export_admin_datatable", "export_installer_datatable"})
*
* @return bool
*/
public function isDisabled(): bool
{
return $this->status === self::STATUS_DISABLED;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("cgu_pending")
*
* @Expose()
* @Groups({
* "user:cgu_pending",
* "cgu_pending",
* "user:list", "user:item", "cdp", "user", "export_user_citroentf_datatable", "user_citroentf",
* "export_user_citroentf_datatable",
* "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
* "export_commercial_installer_datatable",
* "export_commercial_datatable", "export_user_datatable", "export_admin_datatable", "export_installer_datatable"})
*
* @return bool
*/
public function isCguPending(): bool
{
return $this->status === self::STATUS_CGU_PENDING;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("cgu_declined")
*
* @Expose()
* @Groups({
* "user:cgu_declined",
* "cgu_declined",
* "user:list", "user:item", "cdp", "user", "export_user_citroentf_datatable", "user_citroentf",
* "export_user_citroentf_datatable",
* "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
* "export_commercial_installer_datatable",
* "export_commercial_datatable", "export_user_datatable", "export_admin_datatable", "export_installer_datatable"})
*
* @return bool
*/
public function isCguDeclined(): bool
{
return $this->status === self::STATUS_CGU_DECLINED;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("archived")
*
* @Expose()
* @Groups({
* "user:archived",
* "default",
* "is_archived",
* "user:list", "user:item", "cdp", "user", "export_user_citroentf_datatable", "user_citroentf",
* "export_user_citroentf_datatable",
* "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
* "export_commercial_installer_datatable",
* "export_commercial_datatable", "export_user_datatable", "export_admin_datatable", "export_installer_datatable"
* })
*
* @return bool
*/
public function isArchived(): bool
{
return $this->status === self::STATUS_ARCHIVED;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("deleted")
*
* @Expose()
* @Groups({
* "user:deleted",
* "user:list", "user:item", "cdp", "user", "export_user_citroentf_datatable", "user_citroentf",
* "export_user_citroentf_datatable",
* "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
* "export_commercial_installer_datatable",
* "export_commercial_datatable", "export_user_datatable", "export_admin_datatable", "export_installer_datatable"})
*
* @return bool
*/
public function isDeleted(): bool
{
return $this->status === self::STATUS_DELETED;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("admin_pending")
*
* @return bool
*/
public function isAdminPending(): bool
{
return $this->status === self::STATUS_ADMIN_PENDING;
}
/**
* @return bool
*/
public function isRegisterPending(): bool
{
return $this->status === self::STATUS_REGISTER_PENDING;
}
public function getUsers()
{
return $this->installers;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName("count_installers")
*
* @Expose()
* @Groups({
* "user:count_installers"
* })
*
* @return int
*/
public function countInstallers(): int
{
return count($this->installers);
}
/**
* @Serializer\VirtualProperty()
* @SerializedName("count_commercials")
*
* @Expose()
* @Groups({
* "user:count_commercials"
* })
*
* @return int
*/
public function countCommercials(): int
{
$commercials = $this->children;
if (empty($commercials)) {
return 0;
}
foreach ($commercials as $index => $commercial) {
if (!in_array('ROLE_COMMERCIAL', $commercial->getRoles())) {
unset($commercials[ $index ]);
}
}
return count($commercials);
}
public function getRoles(): ?array
{
return $this->roles;
}
public function setRoles(array $roles): User
{
$this->roles = $roles;
return $this;
}
/**
* @Serializer\VirtualProperty
* @SerializedName("preferredEmail")
*
* @Expose()
* @Groups({"email"})
*
* @return string
*/
public function getPreferredEmail(): string
{
if($this->getTransactionalEmail()) return $this->getTransactionalEmail();
if($this->isFakeUser())
{
$secondaryEmails = $this->getSecondaryEmails();
if(!empty($secondaryEmails)) return array_values($secondaryEmails)[0];
}
return $this->email;
}
public function getTransactionalEmail(): ?string
{
return $this->transactionalEmail;
}
public function setTransactionalEmail(?string $transactionalEmail): User
{
$this->transactionalEmail = $transactionalEmail;
return $this;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("roleToString")
*
* @Expose()
* @Groups({"export_user_datatable", "export_admin_datatable", "export_user_citroentf_datatable"})
*
* @return string
*/
public function roleToString(): string
{
if ($this->isDemo()) {
return 'Démo';
}
if ($this->isInstaller()) {
return 'Installateur';
}
if ($this->isValidation()) {
return 'Validation';
}
if ($this->isUser()) {
return 'Utilisateur';
}
if ($this->isCommercial()) {
if ($this->isHeatingCommercial()) {
return 'Commercial chauffage';
}
return 'Commercial';
}
if ($this->isAgencyManager()) {
return "Directeur d'agence";
}
if ($this->isDtvLogistique()) {
return "Logistique";
}
if ($this->isDtvCommercial()) {
return "Commercial";
}
if ($this->isDtvCompta()) {
return "Comptabilité";
}
if ($this->isDtvCdp()) {
return "Chef de projet";
}
if ($this->isAdmin()) {
return 'Administrateur';
}
if ($this->isSuperAdmin()) {
return 'Super Administrateur';
}
if ($this->isDeveloper()) {
return 'Développeur';
}
return 'Rôle non défini';
}
public function isDemo(): bool
{
// return in_array('ROLE_DEMO', $this->getRoles(), TRUE);
return $this->job === 'demo';
}
public function isInstaller(): bool
{
// return in_array('ROLE_INSTALLER', $this->getRoles(), TRUE);
return $this->job === 'installer';
}
public function isValidation(): bool
{
// return in_array('ROLE_VALIDATION', $this->getRoles(), TRUE);
return $this->job === 'validation';
}
public function isUser(): bool
{
return in_array('ROLE_USER', $this->getRoles(), TRUE);
}
public function isCommercial(): bool
{
// return in_array('ROLE_COMMERCIAL', $this->getRoles(), TRUE);
return $this->job === 'commercial_agent';
}
public function isHeatingCommercial(): bool
{
return in_array('ROLE_COMMERCIAL', $this->getRoles(), TRUE) && $this->getChauffage();
}
public function getChauffage(): ?bool
{
return $this->chauffage;
}
public function setChauffage(?bool $chauffage): User
{
$this->chauffage = $chauffage;
return $this;
}
public function isAgencyManager(): bool
{
return in_array('ROLE_AGENCY_MANAGER', $this->getRoles(), TRUE);
}
public function isDtvLogistique(): bool
{
return in_array('ROLE_DTV_LOGISTIQUE', $this->getRoles(), TRUE);
}
public function isDtvCommercial(): bool
{
return in_array('ROLE_DTV_COMMERCIAL', $this->getRoles(), TRUE);
}
public function isDtvCompta(): bool
{
return in_array('ROLE_DTV_COMPTA', $this->getRoles(), TRUE);
}
public function isDtvCdp(): bool
{
return in_array('ROLE_DTV_CDP', $this->getRoles(), TRUE);
}
public function isAdmin(): bool
{
return in_array('ROLE_ADMIN', $this->getRoles(), TRUE);
}
public function isSuperAdmin(): bool
{
return in_array('ROLE_SUPER_ADMIN', $this->getRoles(), TRUE);
}
public function isDeveloper(): bool
{
return in_array('ROLE_DEVELOPER', $this->getRoles(), TRUE);
}
public function isDeveloperOrSuperAdmin(): bool
{
return $this->isDeveloper() || $this->isSuperAdmin();
}
public function hasOneOfItsRoles(array $roles): bool
{
return count(array_intersect($roles, $this->getRoles())) > 0;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("nbrValidatedPurchases")
*
* @Expose()
* @Groups({
* "user:nbr_validated_purchases",
* "export_installer_datatable", "export_commercial_installer_datatable"})
*
* @return int
*/
public function getNbrValidatedPurchases(): int
{
$nbr = 0;
/** @var Purchase $purchase */
foreach ($this->purchases as $purchase) {
if ((int)$purchase->getStatus() === Purchase::STATUS_VALIDATED) {
$nbr++;
}
}
return $nbr;
}
public function getStatus(): string
{
return $this->status;
}
public function setStatus(string $status): User
{
$this->status = $status;
return $this;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("nbrPendingPurchases")
*
* @Expose()
* @Groups({"export_installer_datatable", "export_commercial_installer_datatable"})
*
* @return int
*/
public function getNbrPendingPurchases(): int
{
$nbr = 0;
/** @var Purchase $purchase */
foreach ($this->purchases as $purchase) {
if ((int)$purchase->getStatus() === Purchase::STATUS_PENDING) {
$nbr++;
}
}
return $nbr;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("nbrRejectedPurchases")
*
* @Expose()
* @Groups({
* "user:nbr_rejected_purchases",
* "export_installer_datatable", "export_commercial_installer_datatable"})
*
* @return int
*/
public function getNbrRejectedPurchases(): int
{
$nbr = 0;
/** @var Purchase $purchase */
foreach ($this->purchases as $purchase) {
if ((int)$purchase->getStatus() === Purchase::STATUS_REJECTED) {
$nbr++;
}
}
return $nbr;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("nbrReturnedPurchases")
*
* @Expose()
* @Groups({
* "user:nbr_returned_purchases",
* "export_installer_datatable", "export_commercial_installer_datatable"})
*
* @return int
*/
public function getNbrReturnedPurchases(): int
{
$nbr = 0;
/** @var Purchase $purchase */
foreach ($this->purchases as $purchase) {
if ((int)$purchase->getStatus() === Purchase::STATUS_RETURNED) {
$nbr++;
}
}
return $nbr;
}
/**
* Nombre de commandes de l'utilisateur
*
* @Serializer\VirtualProperty()
* @SerializedName ("nbrOrder")
*
* @Expose()
* @Groups({"export_user_datatable", "export_admin_datatable", "export_installer_datatable", "export_commercial_installer_datatable"})
*
* @return int
*/
public function getNbrOrder(): int
{
return count($this->orders);
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("nbrPurchases")
*
* @Expose()
* @Groups({
* "user:nbr_purchases",
* "export_installer_datatable", "export_commercial_installer_datatable"})
*
* @return int
*/
public function getNbrPurchases(): int
{
return count($this->purchases);
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("has_heating_commercial")
* @Groups ({
* "default",
* "user:has_heating_commercial",
* "user"
* })
*/
public function hasHeatingCommercial()
{
return $this->heatingCommercial instanceof User;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("pointDateExpiration")
*
* @Expose()
* @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
*
* @return null|string
*/
public function getPointDateExpiration(): ?string
{
return $this->getExtensionBySlug(\App\Constants\UserExtension::POINT_DATE_EXPIRATION);
}
/**
* Retourne la valeur d'une extension depuis son slug
*
* @param string $slug
*
* @return string|null
*/
public function getExtensionBySlug(string $slug): ?string
{
if (!empty($this->extensions)) {
foreach ($this->extensions as $extension) {
if ($extension->getSlug() === $slug) {
return $extension->getValue();
}
}
}
return NULL;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("objCa")
*
* @Expose()
* @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
*
* @return int
*/
public function getObjCa(): int
{
$value = $this->getExtensionBySlug(\App\Constants\UserExtension::OBJ_CA);
if ($value === NULL) {
return 0;
}
return intval($value);
}
public function setObjCa(?string $value): User
{
if ($value === NULL) {
return $this;
}
$this->addExtension(UserExtensionFactory::setObjCa($this, $value));
return $this;
}
public function addExtension(?UserExtension $extension): User
{
if ($extension !== NULL && !$this->extensions->contains($extension)) {
$this->extensions[] = $extension;
$extension->setUser($this);
}
return $this;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("commitment_level")
*
* @Expose()
* @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
*
* @return string
*/
public function getCommitmentLevel(): string
{
$value = $this->getExtensionBySlug(\App\Constants\UserExtension::COMMITMENT_LEVEL);
if ($value === NULL) {
return '';
}
return $value;
}
public function setCommitmentLevel(?string $value): User
{
if ($value === NULL) {
return $this;
}
$this->addExtension(UserExtensionFactory::setCommitmentLevel($this, $value));
return $this;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("objPoint")
*
* @Expose()
* @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
*
* @return int
*/
public function getObjPoint(): int
{
$value = $this->getExtensionBySlug(\App\Constants\UserExtension::OBJ_POINT);
if ($value === NULL) {
return 0;
}
return intval($value);
}
public function setObjPoint(?string $value): User
{
if ($value === NULL) {
return $this;
}
$this->addExtension(UserExtensionFactory::setObjPoint($this, $value));
return $this;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("language")
*
* @Expose()
* @Groups({ "user:language", "user:item"})
*
* @return string|null
*/
public function getLanguage(): ?string
{
return $this->getExtensionBySlug(\App\Constants\UserExtension::LANGUAGE);
}
public function setInternalIdentification1(?string $value): User
{
if ($value === NULL) {
return $this;
}
$this->addExtension(UserExtensionFactory::setInternalIdentification1($this, $value));
return $this;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("internalIdentification2")
*
* @Expose()
* @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable", "export_admin_datatable", "sale_order",
* "export_order_datatable"})
*
* @return string|null
*/
public function getInternalIdentification2(): ?string
{
return $this->getExtensionBySlug(\App\Constants\UserExtension::INTERNAL_IDENTIFICATION_2);
}
public function setInternalIdentification2(?string $value): User
{
if ($value === NULL) {
return $this;
}
$this->addExtension(UserExtensionFactory::setInternalIdentification2($this, $value));
return $this;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("internalIdentification3")
*
* @Expose()
* @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
*
* @return string|null
*/
public function getInternalIdentification3(): ?string
{
return $this->getExtensionBySlug(\App\Constants\UserExtension::INTERNAL_IDENTIFICATION_3);
}
public function setInternalIdentification3(?string $value): User
{
if ($value === NULL) {
return $this;
}
$this->addExtension(UserExtensionFactory::setInternalIdentification3($this, $value));
return $this;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("potentialPoints")
*
* @Expose
* @Groups({
* "user:potentialPoints",
* "user:list",
* "user:item", "user", "get:read", "post:read", "export_user_datatable"})
*
* @return int|null
*/
public function getPotentialPoints(): ?int
{
return $this->getExtensionBySlug(\App\Constants\UserExtension::POTENTIAL_POINTS);
}
/**
* @param $value
*
* @return $this
*/
public function setPotentialPoints($value): User
{
$this->addExtension(UserExtensionFactory::setPotentialPoints($this, (int)$value));
return $this;
}
/**
* @param int $step
*
* @return string|null
*/
public function getGoalByStep(int $step): ?string
{
$slug = \App\Constants\UserExtension::GOAL . '_' . $step;
return $this->getExtensionBySlug($slug);
}
public function setGoalByStep(string $value, int $step): User
{
$this->addExtension(UserExtensionFactory::setGoal($this, $value, $step));
return $this;
}
/**
* @param int $step
*
* @return string|null
*/
public function getBonusPro(int $step): ?string
{
$slug = \App\Constants\UserExtension::BONUS_PRO . '_' . $step;
return $this->getExtensionBySlug($slug);
}
public function setBonusPro(?string $value, int $step): User
{
if ($value === NULL) {
return $this;
}
$this->addExtension(UserExtensionFactory::setBonusPro($this, $value, $step));
return $this;
}
public function setGoalPoints(?string $value): User
{
if ($value === NULL) {
return $this;
}
$this->addExtension(UserExtensionFactory::setGoalPoints($this, $value));
return $this;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("parent_lvl_1")
* @Groups ({"user", "point_of_sale"})
*
* @return int
*/
public function getParentLvl1(): int
{
// Boucle sur les commerciaux et retourne le premier
foreach ($this->parents as $parent) {
return $parent->getId();
}
return -1;
}
/**
* ============================================================================================
* ============================= FIN FONCTIONS CUSTOM =========================================
* ============================================================================================
*/
public function getId(): ?int
{
return $this->id;
}
/**
* Le setter est obligatoire pour la partie portail lorsqu'on crée un utilisateur non mappé en bdd
*
* @param $id
*
* @return $this
*/
public function setId($id): User
{
$this->id = $id;
return $this;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("parent_lvl_1_code")
*
* @Expose()
* @Groups ({"user", "export_user_datatable", "export_admin_datatable", "sale_order", "export_order_datatable",
* "export_commercial_datatable"})
*
* @return string|null
*/
public function getParentLvl1Code(): ?string
{
// Boucle sur les commerciaux et retourne le premier
foreach ($this->parents as $parent) {
return $parent->getInternalIdentification1();
}
return NULL;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("internalIdentification1")
*
* @Expose()
* @Groups({
* "user:internal_identification_1",
* "user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable", "export_admin_datatable", "sale_order",
* "export_order_datatable",
* "export_installer_datatable",
* "export_commercial_datatable","export_agency_manager_datatable"})
*
* @return string|null
*/
public function getInternalIdentification1(): ?string
{
return $this->getExtensionBySlug(\App\Constants\UserExtension::INTERNAL_IDENTIFICATION_1);
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("parent_lvl_2")
* @Groups ({"user", "point_of_sale"})
*
* @return int
*/
public function getParentLvl2(): int
{
// Boucle sur les commerciaux
foreach ($this->parents as $parent) {
// Boucle sur les chefs d'agence et retourne le premier
foreach ($parent->getParents() as $grandParent) {
return $grandParent->getId();
}
}
return -1;
}
/**
* @return Collection<int, User>
*/
public function getParents(): Collection
{
return $this->parents;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("parent_lvl_3")
* @Groups ({"user", "point_of_sale"})
*
* @return int
*/
public function getParentLvl3(): int
{
// Boucle sur les commerciaux
foreach ($this->parents as $parent) {
// Boucle sur les chefs d'agence et retourne le premier
foreach ($parent->getParents() as $grandParent) {
// Boucle sur les admins et retourne le premier
foreach ($grandParent->getParents() as $ggparent) {
return $ggparent->getId();
}
}
}
return -1;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("pointOfSaleOfClient")
* @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
*
* @return string|null
*/
public function getPointOfSaleOfClient(): ?string
{
// Boucle sur les commerciaux
if (!empty($this->parents)) {
foreach ($this->parents as $parent) {
if ($parent->getPointOfSale() !== NULL) {
return $parent->getPointOfSale()->getCode();
} else {
return NULL;
}
}
}
return NULL;
}
public function getPointOfSale(): ?PointOfSale
{
return $this->pointOfSale;
}
public function setPointOfSale(?PointOfSale $pointOfSale): User
{
$this->pointOfSale = $pointOfSale;
return $this;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("pointOfSaleOfCommercial")
* @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
*
* @return string|null
*/
public function getPointOfSaleOfCommercial(): ?string
{
// Boucle sur les commerciaux
if ($this->getPointOfSale() !== NULL) {
return $this->getPointOfSale()->getCode();
} else {
return NULL;
}
}
/**
* Retourne la date d'adhésion du client s'il en a une
*
* @Serializer\VirtualProperty()
* @SerializedName ("subscribedAt")
* @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
*
* @return string
*/
public function getSubscribedAt(): string
{
if ($this->subscription instanceof UserSubscription) {
return $this->subscription->getSubscribedAt()->format('d/m/Y');
}
return '';
}
/**
* Retourne le label de la catégorie du taux de conversion des points
*
* @Serializer\VirtualProperty()
* @SerializedName ("pointConvertionRateLabel")
* @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
*
* @return string
*/
public function getPointConvertionRateLabel(): string
{
if ($this->pointConversionRate instanceof PointConversionRate) {
return $this->pointConversionRate->getLabel();
}
return '';
}
public function getNameCiv(): string
{
return trim($this->getCivility() . ' ' . trim($this->lastName . " " . $this->firstName));
}
public function getCivility(): ?string
{
return $this->civility;
}
public function setCivility(?string $civility): User
{
$this->civility = $civility;
return $this;
}
/*
* ============================================================================================
* ============================== FIN FONCTIONS CUSTOM ========================================
* ============================================================================================
*/
public function getCivCode(): int
{
if ($this->getCivility() == 'M.') {
return 0;
} elseif ($this->getCivility() == 'Mme') {
return 1;
} else {
return 2;
}
}
/**
* @return void
* @deprecated
*/
public function setActive()
{
$this->deletedAt = NULL;
$this->archivedAt = NULL;
}
public function isPurchaseAuthorized(): bool
{
return in_array('ROLE_INSTALLER', $this->getRoles()) || in_array('ROLE_SUPER_ADMIN', $this->getRoles());
}
public function getBillingAddresses()
{
return $this->getAddressByType(Address::TYPE_BILLING_ADDRESS);
}
/**
* @param $type
*
* @return Collection
*/
private function getAddressByType($type)
{
$shippingAddress = new ArrayCollection();
foreach ($this->getAddresses() as $address) {
if ($address->getAddressType() == $type) {
$shippingAddress->add($address);
}
}
return $shippingAddress;
}
/**
* @return Collection|Address[]
*/
public function getAddresses(): Collection
{
return $this->addresses;
}
/**
* @return DateTimeInterface|null
* @deprecated
*/
public function getLevel1UpdatedAt(): ?DateTimeInterface
{
return $this->level1UpdatedAt;
}
/**
* @param DateTimeInterface|null $level1UpdatedAt
*
* @return $this
* @deprecated
*/
public function setLevel1UpdatedAt(?DateTimeInterface $level1UpdatedAt): User
{
$this->level1UpdatedAt = $level1UpdatedAt;
return $this;
}
/**
* @return DateTimeInterface|null
* @deprecated
*/
public function getLevel2UpdatedAt(): ?DateTimeInterface
{
return $this->level2UpdatedAt;
}
/**
* @param DateTimeInterface|null $level2UpdatedAt
*
* @return $this
* @deprecated
*/
public function setLevel2UpdatedAt(?DateTimeInterface $level2UpdatedAt): User
{
$this->level2UpdatedAt = $level2UpdatedAt;
return $this;
}
/**
* @Serializer\VirtualProperty
* @SerializedName("name")
* @Groups({
* "user:name",
* "export_installer_datatable", "export_purchase_declaration_datatable",
* "export_agency_manager_commercial_datatable",
* "export_commercial_installer_datatable"})
*
* @return string
*/
public function getName(): string
{
return $this->lastName . " " . $this->firstName;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName("codeDep")
* @Expose()
* @Groups({
* "user:code_dep",
* "export_installer_datatable", "export_commercial_installer_datatable"})
*
* @return false|string|null
*/
public function getCodeDep()
{
return $this->getPostcode() !== NULL ? substr($this->getPostcode(), 0, 2) : NULL;
}
public function getPostcode(): ?string
{
return $this->postcode;
}
public function setPostcode(?string $postcode): User
{
$this->postcode = $postcode;
return $this;
}
/**
* @return Collection|Address[]
*/
public function getShippingAddresses()
{
return $this->getAddressByType(Address::TYPE_SHIPPING_ADDRESS);
}
/**
* @return Address|null
*/
public function getPreferredShippingAddress(): ?Address
{
foreach($this->getShippingAddresses() as $address)
{
if($address->getPreferred()) return $address;
}
return null;
}
/**
* GARDER POUR LA SSO
*
* @return string
*/
public function getUsername(): string
{
return (string)$this->email;
}
/**
* @return string
*/
public function getRawUsername(): string
{
return (string)$this->username;
}
/**
* @param string|null $username
*
* @return $this
* @deprecated
*/
public function setUsername(?string $username): User
{
$this->username = $username;
return $this;
}
/**
* GARDER POUR LA SSO
*
* @return string
*/
public function getUserIdentifier(): string
{
return (string)$this->email;
}
public function isDex(): bool
{
return TRUE;
}
public function getWelcomeEmail(): ?DateTimeInterface
{
return $this->welcomeEmail;
}
public function setWelcomeEmail(?DateTimeInterface $welcomeEmail): User
{
$this->welcomeEmail = $welcomeEmail;
return $this;
}
public function getAccountAddress(): string
{
return trim($this->address1 . ' ' . $this->address2) . ' ' . $this->postcode . ' ' . $this->city;
}
public function eraseCredentials()
{
// If you store any temporary, sensitive data on the user, clear it here
$this->plainPassword = NULL;
}
public function generateAndSetPassword()
{
$pwd = substr(str_shuffle('23456789QWERTYUPASDFGHJKLZXCVBNM'), 0, 12);
$this->setPassword($pwd);
return $pwd;
}
public function getOldEmail(): ?string
{
return $this->oldEmail;
}
public function setOldEmail(?string $oldEmail): void
{
if(is_string($oldEmail)) $oldEmail = trim($oldEmail);
$this->oldEmail = $oldEmail;
}
public function getPassword(): ?string
{
return $this->password;
}
public function setPassword(string $password): User
{
// Chaque fois que le mot de passe est modifié, mettre à jour la date
// et remettre à 0 le compteur d'essai
$this->passwordUpdatedAt = new DateTime();
$this->setFailedAttempts(0);
$this->password = $password;
return $this;
}
public function getSalt(): ?string
{
return $this->salt;
}
public function setSalt(?string $salt): User
{
$this->salt = $salt;
return $this;
}
public function getPlainPassword(): ?string
{
return $this->plainPassword;
}
public function setPlainPassword($plainPassword): User
{
// Ajout de l'ancien mot de passe dans l'historique
if ($plainPassword !== NULL) {
$passwordHistory = new PasswordHistory();
$passwordHistory->setUser($this);
$passwordHistory->setHashedPassword(md5($plainPassword));
$this->passwordHistories[] = $passwordHistory;
}
$this->plainPassword = $plainPassword;
return $this;
}
public function getFirstName(): ?string
{
return $this->firstName;
}
public function setFirstName(?string $firstName): User
{
if($firstName) $firstName = ucfirst(strtolower(trim($firstName)));
$this->firstName = $firstName;
return $this;
}
public function getLastName(): ?string
{
return $this->lastName;
}
public function setLastName(?string $lastName): User
{
if($lastName) $lastName = strtoupper(trim($lastName));
$this->lastName = $lastName;
return $this;
}
public function getMobile(): ?string
{
if(!$this->mobile) return null;
$mobile = str_replace(['-', '/', '.', ' '], '-', $this->mobile);
$re = '/^(?:(?:(?:\+|00)33[ ]?(?:\(0\)[ ]?)?)|0){1}[1-9]{1}([ .-]?)(?:\d{2}\1?){3}\d{2}$/m';
preg_match_all($re, '0' . $mobile, $matches, PREG_SET_ORDER);
if (!empty($matches)) {
$mobile = '0' . $mobile;
}
return $mobile;
}
public function setMobile(?string $mobile): User
{
$this->mobile = $mobile;
return $this;
}
public function getPhone(): ?string
{
if(!$this->phone) return null;
$phone = str_replace(['-', '/', '.', ' '], '-', $this->phone);
$re = '/^(?:(?:(?:\+|00)33[ ]?(?:\(0\)[ ]?)?)|0){1}[1-9]{1}([ .-]?)(?:\d{2}\1?){3}\d{2}$/m';
preg_match_all($re, '0' . $phone, $matches, PREG_SET_ORDER);
if (!empty($matches)) {
$phone = '0' . $phone;
}
return $phone;
}
public function setPhone(?string $phone): User
{
$this->phone = $phone;
return $this;
}
/**
* @return int|null
* @deprecated
*/
public function getAvailablePoint(): ?int
{
return $this->availablePoint;
}
/**
* @param int $availablePoint
*
* @return $this
* @deprecated
*/
public function setAvailablePoint(int $availablePoint): User
{
$this->availablePoint = $availablePoint;
return $this;
}
/**
* @return int|null
* @deprecated
*/
public function getPotentialPoint(): ?int
{
return $this->potentialPoint;
}
/**
* @param int $potentialPoint
*
* @return $this
* @deprecated
*/
public function setPotentialPoint(int $potentialPoint): User
{
$this->potentialPoint = $potentialPoint;
return $this;
}
/**
* @return string|null
* @deprecated
*/
public function getLocale(): ?string
{
return $this->locale;
}
/**
* @param string|null $locale
*
* @return $this
* @deprecated
*/
public function setLocale(?string $locale): User
{
$this->locale = $locale;
return $this;
}
public function getCountry(): ?Country
{
return $this->country;
}
public function setCountry(?Country $country): User
{
$this->country = $country;
return $this;
}
public function getJob(): ?string
{
if ($this->job === '') {
return NULL;
}
return $this->job;
}
public function setJob(?string $job): User
{
$this->job = $job;
return $this;
}
public function getCompany(): ?string
{
return $this->company;
}
public function setCompany(?string $company): User
{
$this->company = $company;
return $this;
}
/**
* @deprecated
*/
public function getUserToken(): ?string
{
return $this->userToken;
}
/**
* @deprecated
*/
public function setUserToken(?string $userToken): User
{
$this->userToken = $userToken;
return $this;
}
/**
* @deprecated
*/
public function getUserTokenValidity(): ?DateTimeInterface
{
return $this->userTokenValidity;
}
/**
* @deprecated
*/
public function setUserTokenValidity(?DateTimeInterface $userTokenValidity): User
{
$this->userTokenValidity = $userTokenValidity;
return $this;
}
/**
* @deprecated
*/
public function getUserTokenAttempts(): ?int
{
return $this->userTokenAttempts;
}
/**
* @deprecated
*/
public function setUserTokenAttempts(int $userTokenAttempts): User
{
$this->userTokenAttempts = $userTokenAttempts;
return $this;
}
public function getAddress1(): ?string
{
return $this->address1;
}
public function setAddress1(?string $address1): User
{
$this->address1 = $address1;
return $this;
}
public function getAddress2(): ?string
{
return $this->address2;
}
public function setAddress2(?string $address2): User
{
$this->address2 = $address2;
return $this;
}
// /**
// * @Serializer\VirtualProperty()
// * @SerializedName ("birthDate")
// * @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
// *
// *
// * @return DateTimeInterface|null
// */
// public function getBirthDate(): ?DateTimeInterface
// {
// try {
// return new DateTime( $this->getExtensionBySlug( \App\Constants\UserExtension::BIRTH_DATE ) );
// }
// catch ( Exception $e ) {
// return NULL;
// }
// }
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): User
{
$this->city = $city;
return $this;
}
public function getCanOrder(): ?bool
{
return $this->canOrder;
}
public function setCanOrder(?bool $canOrder): User
{
$this->canOrder = $canOrder;
return $this;
}
public function getDeletedAt(): ?DateTimeInterface
{
return $this->deletedAt;
}
public function setDeletedAt(?DateTimeInterface $deletedAt): User
{
$this->deletedAt = $deletedAt;
return $this;
}
/**
* @Serializer\VirtualProperty()
* @SerializedName ("birthDate")
* @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
*
*
* @return DateTimeInterface|null
*/
public function getBirthDate(): ?DateTimeInterface
{
try {
return new DateTime($this->getExtensionBySlug(\App\Constants\UserExtension::BIRTH_DATE));
} catch (Exception $e) {
return NULL;
}
}
/**
* @throws Exception
*/
public function setBirthDate($value): User
{
if ($value === NULL) {
return $this;
}
if ($value instanceof DateTimeInterface) {
$value = $value->format('Y-m-d');
}
$this->addExtension(UserExtensionFactory::setBirthDate($this, $value));
return $this;
}
public function getBirthCity(): ?string
{
return $this->getExtensionBySlug(\App\Constants\UserExtension::BIRTH_CITY);
}
public function setBirthCity(?string $value): User
{
if ($value === NULL) {
return $this;
}
$this->addExtension(UserExtensionFactory::setBirthCity($this, $value));
return $this;
}
public function getSocialSecurityNumber(): ?string
{
return $this->getExtensionBySlug(\App\Constants\UserExtension::SOCIAL_SECURITY_NUMBER);
}
public function setSocialSecurityNumber(?string $value): User
{
if ($value === NULL) {
return $this;
}
$this->addExtension(UserExtensionFactory::setSocialSecurityNbr($this, $value));
return $this;
}
/**
* @return array
*/
public function getSecondaryEmails(): array
{
$emails = $this->getExtensionBySlug(\App\Constants\UserExtension::SECONDARY_EMAILS);
if(empty($emails)) return [];
return json_decode($emails, true);
}
/**
* @param array $emails
*
* @return $this
*/
public function setSecondaryEmails(array $emails): User
{
$val = [];
foreach($emails as $email)
{
$email = trim(strtolower($email));
if(!filter_var($email, FILTER_VALIDATE_EMAIL)) throw new \InvalidArgumentException('email invalide');
$val[] = $email;
}
$this->addExtension(UserExtensionFactory::setSecondaryEmails($this, json_encode($val)));
return $this;
}
/**
* @param string $email
*
* @return $this
*/
public function addSecondaryEmail(string $email): User
{
$email = trim(strtolower($email));
if(!filter_var($email, FILTER_VALIDATE_EMAIL)) throw new \InvalidArgumentException("email ($email) invalide");
$emails = $this->getSecondaryEmails();
if(!in_array($email, $emails))
{
$emails[] = $email;
$this->addExtension(UserExtensionFactory::setSecondaryEmails($this, json_encode($emails)));
}
return $this;
}
/**
* @param string $email
*
* @return $this
*/
public function removeSecondaryEmail(string $email): User
{
$email = trim(strtolower($email));
$emails = $this->getSecondaryEmails();
$key = array_search($email, $emails);
if($key)
{
unset($emails[$key]);
$this->addExtension(UserExtensionFactory::setSecondaryEmails($this, json_encode($emails)));
}
return $this;
}
public function getInternalCode(): ?string
{
return $this->internalCode;
}
public function setInternalCode(?string $internalCode): User
{
$this->internalCode = $internalCode;
return $this;
}
public function getCguAt(): ?DateTimeInterface
{
return $this->cguAt;
}
public function setCguAt(?DateTimeInterface $cguAt): User
{
$this->cguAt = $cguAt;
return $this;
}
public function getRegisterAt(): ?DateTimeInterface
{
return $this->registerAt;
}
public function setRegisterAt(?DateTimeInterface $registerAt): User
{
$this->registerAt = $registerAt;
return $this;
}
public function getImportedAt(): ?DateTimeInterface
{
return $this->importedAt;
}
public function setImportedAt(?DateTimeInterface $importedAt): User
{
$this->importedAt = $importedAt;
return $this;
}
public function getCanBeContacted(): ?bool
{
return $this->canBeContacted;
}
public function setCanBeContacted(bool $canBeContacted): User
{
$this->canBeContacted = $canBeContacted;
return $this;
}
/**
* @deprecated
*/
public function getCapacity(): ?string
{
return $this->capacity;
}
/**
* @deprecated
*/
public function setCapacity(?string $capacity): User
{
$this->capacity = $capacity;
return $this;
}
public function getAddress3(): ?string
{
return $this->address3;
}
public function setAddress3(?string $address3): User
{
$this->address3 = $address3;
return $this;
}
public function getOptinMail(): ?bool
{
return $this->optinMail;
}
public function setOptinMail(bool $optinMail): User
{
$this->optinMail = $optinMail;
return $this;
}
public function getOptinSMS(): ?bool
{
return $this->optinSMS;
}
public function setOptinSMS(bool $optinSMS): User
{
$this->optinSMS = $optinSMS;
return $this;
}
public function getOptinPostal(): ?bool
{
return $this->optinPostal;
}
public function setOptinPostal(bool $optinPostal): User
{
$this->optinPostal = $optinPostal;
return $this;
}
public function getOptinPostalAddress(): ?string
{
return $this->optinPostalAddress;
}
public function setOptinPostalAddress(?string $optinPostalAddress): User
{
$this->optinPostalAddress = $optinPostalAddress;
return $this;
}
public function getSource(): ?string
{
return $this->source;
}
public function setSource(?string $source): User
{
$this->source = $source;
return $this;
}
/**
* @return int|null
* @deprecated {@see UserPointService::getLevel()}
*/
public function getLevel(): ?int
{
return $this->level;
}
/**
* @param int $level
*
* @return $this
* @deprecated
*/
public function setLevel(int $level): User
{
$this->level = $level;
return $this;
}
/**
* @return DateTimeInterface|null
* @deprecated
*/
public function getLevel0UpdatedAt(): ?DateTimeInterface
{
return $this->level0UpdatedAt;
}
/**
* @param DateTimeInterface|null $level0UpdatedAt
*
* @return $this
* @deprecated
*/
public function setLevel0UpdatedAt(?DateTimeInterface $level0UpdatedAt): User
{
$this->level0UpdatedAt = $level0UpdatedAt;
return $this;
}
public function getLevel3UpdatedAt(): ?DateTimeInterface
{
return $this->level3UpdatedAt;
}
/**
* @param DateTimeInterface|null $level3UpdatedAt
*
* @return $this
* @deprecated
*/
public function setLevel3UpdatedAt(?DateTimeInterface $level3UpdatedAt): User
{
$this->level3UpdatedAt = $level3UpdatedAt;
return $this;
}
/**
* @return DateTimeInterface|null
* @deprecated
*/
public function getLevelUpdateSeenAt(): ?DateTimeInterface
{
return $this->levelUpdateSeenAt;
}
/**
* @param DateTimeInterface|null $levelUpdateSeenAt
*
* @return $this
* @deprecated
*/
public function setLevelUpdateSeenAt(?DateTimeInterface $levelUpdateSeenAt): User
{
$this->levelUpdateSeenAt = $levelUpdateSeenAt;
return $this;
}
/**
* @return bool|null
*/
public function getIsEmailOk(): ?bool
{
return $this->isEmailOk;
}
/**
* @param bool $isEmailOk
*
* @return $this
*/
public function setIsEmailOk(bool $isEmailOk): User
{
$this->isEmailOk = $isEmailOk;
return $this;
}
/**
* @return DateTimeInterface|null
*/
public function getLastEmailCheck(): ?DateTimeInterface
{
return $this->lastEmailCheck;
}
/**
* @param DateTimeInterface|null $lastEmailCheck
*
* @return $this
*/
public function setLastEmailCheck(?DateTimeInterface $lastEmailCheck): User
{
$this->lastEmailCheck = $lastEmailCheck;
return $this;
}
/**
* @return string|null
* @deprecated
*/
public function getApiToken(): ?string
{
return $this->apiToken;
}
/**
* @param string|null $apiToken
*
* @return $this
* @deprecated
*/
public function setApiToken(?string $apiToken): User
{
$this->apiToken = $apiToken;
return $this;
}
public function getSapDistributor(): ?string
{
return $this->sapDistributor;
}
public function setSapDistributor(?string $sapDistributor): User
{
$this->sapDistributor = $sapDistributor;
return $this;
}
public function getDistributor(): ?string
{
return $this->distributor;
}
public function setDistributor(?string $distributor): User
{
$this->distributor = $distributor;
return $this;
}
public function getDistributor2(): ?string
{
return $this->distributor2;
}
public function setDistributor2(?string $distributor2): User
{
$this->distributor2 = $distributor2;
return $this;
}
public function getAggreement(): ?bool
{
return $this->aggreement;
}
public function setAggreement(?bool $aggreement): User
{
$this->aggreement = $aggreement;
return $this;
}
public function getUnsubscribedAt(): ?DateTimeInterface
{
return $this->unsubscribedAt;
}
public function setUnsubscribedAt(?DateTimeInterface $unsubscribedAt): User
{
$this->unsubscribedAt = $unsubscribedAt;
return $this;
}
public function addAddress(Address $address): User
{
if (!$this->addresses->contains($address)) {
$this->addresses->add($address);
$user = $address->getUser();
if($user) $user->removeAddress($address);
$address->setUser($this);
}
return $this;
}
public function removeAddress(Address $address): User
{
if ($this->addresses->removeElement($address)) {
// set the owning side to null (unless already changed)
if ($address->getUser() === $this) {
$address->setUser(NULL);
}
}
return $this;
}
public function getCarts(): Collection
{
return $this->carts;
}
public function addCart(Cart $cart): User
{
if (!$this->carts->contains($cart)) {
$this->carts[] = $cart;
$cart->setUser($this);
}
return $this;
}
public function removeCart(Cart $cart): User
{
if ($this->carts->removeElement($cart)) {
// set the owning side to null (unless already changed)
if ($cart->getUser() === $this) {
$cart->setUser(NULL);
}
}
return $this;
}
public function getSapAccount(): ?string
{
return $this->sapAccount;
}
public function setSapAccount(?string $sapAccount): User
{
$this->sapAccount = $sapAccount;
return $this;
}
/**
* @return User|null
*/
public function getMainAccountUser(): ?User
{
return $this->mainAccountUser;
}
/**
* @param User|null $mainAccountUser
*
* @return $this
*/
public function setMainAccountUser(?User $mainAccountUser = null, bool $setSubAccountUser = true): User
{
if($setSubAccountUser)
{
if($mainAccountUser) {
$mainAccountUser->addSubAccountUser($this, false);
}
elseif($this->mainAccountUser) {
$this->mainAccountUser->removeSubAccountUser($this, false);
}
}
$this->mainAccountUser = $mainAccountUser;
return $this;
}
/**
* @return Collection|User[]
*/
public function getSubAccountUsers(): Collection
{
$subAccountUsers = clone $this->subAccountUsers;
$subAccountUsers->removeElement($this);
return $subAccountUsers;
}
/**
* @param iterable|User[] $subAccountUsers
*
* @return User
*/
public function setSubAccountUsers(iterable $subAccountUsers, bool $setMainAccountUser = true): User
{
foreach($this->subAccountUsers as $subAccountUser) {
$this->removeSubAccountUser($subAccountUser, $setMainAccountUser);
}
foreach($subAccountUsers as $subAccountUser) {
$this->addSubAccountUser($subAccountUser, $setMainAccountUser);
}
return $this;
}
/**
* @param User $subAccountUser
* @param bool $setMainAccountUser
*
* @return $this
*/
public function addSubAccountUser(User $subAccountUser, bool $setMainAccountUser = true): User
{
if(!$this->subAccountUsers->contains($subAccountUser))
{
$this->subAccountUsers->add($subAccountUser);
if($setMainAccountUser) $subAccountUser->setMainAccountUser($this, false);
}
return $this;
}
/**
* @param User $subAccountUser
* @param bool $setMainAccountUser
*
* @return User
*/
public function removeSubAccountUser(User $subAccountUser, bool $setMainAccountUser = true): User
{
if($this->subAccountUsers->contains($subAccountUser))
{
$this->subAccountUsers->removeElement($subAccountUser);
if($setMainAccountUser) $subAccountUser->setMainAccountUser(null, false);
}
return $this;
}
public function getDistributors(): Collection
{
return $this->distributors;
}
public function addDistributor(Distributor $distributor): User
{
if (!$this->distributors->contains($distributor)) {
$this->distributors[] = $distributor;
}
return $this;
}
public function removeDistributor(Distributor $distributor): User
{
$this->distributors->removeElement($distributor);
return $this;
}
public function getPurchases(): Collection
{
return $this->purchases;
}
public function addPurchase(Purchase $purchase): User
{
if (!$this->purchases->contains($purchase)) {
$this->purchases[] = $purchase;
$purchase->setValidator($this);
}
return $this;
}
public function removePurchase(Purchase $purchase): User
{
if ($this->purchases->removeElement($purchase)) {
// set the owning side to null (unless already changed)
if ($purchase->getValidator() === $this) {
$purchase->setValidator(NULL);
}
}
return $this;
}
public function getPurchasesIHaveProcessed(): Collection
{
return $this->purchasesIHaveProcessed;
}
public function addPurchaseIHaveProcessed(Purchase $purchasesIHaveProcessed): User
{
if (!$this->purchasesIHaveProcessed->contains($purchasesIHaveProcessed)) {
$this->purchasesIHaveProcessed[] = $purchasesIHaveProcessed;
$purchasesIHaveProcessed->setValidator($this);
}
return $this;
}
public function removePurchaseIHaveProcessed(Purchase $purchasesIHaveProcessed): User
{
if ($this->purchasesIHaveProcessed->removeElement($purchasesIHaveProcessed)) {
// set the owning side to null (unless already changed)
if ($purchasesIHaveProcessed->getValidator() === $this) {
$purchasesIHaveProcessed->setValidator(NULL);
}
}
return $this;
}
/**
* @param array|null $status
*
* @return Collection|SaleOrder[]
*/
public function getOrders(?array $status = null): Collection
{
if(empty($status)) return $this->orders;
$orders = new ArrayCollection();
foreach($this->orders as $order)
{
if(in_array($order->getStatus(), $status)) $orders->add($order);
}
return $orders;
}
public function addOrder(SaleOrder $order): User
{
if (!$this->orders->contains($order))
{
$this->orders->add($order);
$user = $order->getUser();
if($user) $user->removeOrder($order);
$order->setUser($this);
}
return $this;
}
public function removeOrder(SaleOrder $order): User
{
if ($this->orders->removeElement($order)) {
// set the owning side to null (unless already changed)
if ($order->getUser() === $this) {
$order->setUser(NULL);
}
}
return $this;
}
/**
* @return Collection|User[]
*/
public function getGodchilds(): Collection
{
return $this->godchilds;
}
/**
* @param User $godchild
*
* @return $this
*/
public function addGodchild(User $godchild, bool $setGodFather = true): User
{
if(!$this->godchilds->contains($godchild))
{
$this->godchilds->add($godchild);
if($setGodFather) $godchild->setGodfather($this, false);
}
return $this;
}
/**
* @param User $godchild
*
* @return $this
*/
public function removeGodchild(User $godchild, bool $setGodFather = true): User
{
if($this->godchilds->removeElement($godchild) && $setGodFather)
{
$godchild->setGodfather(null, false);
}
return $this;
}
/**
* @return User
*/
public function getGodfather(): ?User
{
return $this->godfather;
}
/**
* @param User|null $godfather
*
* @return $this
*/
public function setGodfather(?User $godfather = null, bool $updateGodchild = true): User
{
if($this->godfather !== $godfather)
{
if($updateGodchild && $this->godfather) $this->godfather->removeGodchild($this, false);
if($updateGodchild && $godfather) $godfather->addGodchild($this, false);
$this->godfather = $godfather;
}
return $this;
}
/**
* @deprecated
*/
public function getSatisfactions(): Collection
{
return $this->satisfactions;
}
/**
* @deprecated
*/
public function addSatisfaction(Satisfaction $satisfaction): User
{
if (!$this->satisfactions->contains($satisfaction)) {
$this->satisfactions[] = $satisfaction;
$satisfaction->setUser($this);
}
return $this;
}
/**
* @deprecated
*/
public function removeSatisfaction(Satisfaction $satisfaction): User
{
if ($this->satisfactions->removeElement($satisfaction)) {
// set the owning side to null (unless already changed)
if ($satisfaction->getUser() === $this) {
$satisfaction->setUser(NULL);
}
}
return $this;
}
public function getRequestProductAvailables(): Collection
{
return $this->requestProductAvailables;
}
public function addRequestProductAvailable(RequestProductAvailable $requestProductAvailable): User
{
if (!$this->requestProductAvailables->contains($requestProductAvailable)) {
$this->requestProductAvailables[] = $requestProductAvailable;
$requestProductAvailable->setUser($this);
}
return $this;
}
public function removeRequestProductAvailable(RequestProductAvailable $requestProductAvailable): User
{
if ($this->requestProductAvailables->removeElement($requestProductAvailable)) {
// set the owning side to null (unless already changed)
if ($requestProductAvailable->getUser() === $this) {
$requestProductAvailable->setUser(NULL);
}
}
return $this;
}
public function getUserImportHistories(): Collection
{
return $this->userImportHistories;
}
public function addUserImportHistory(UserImportHistory $userImportHistory): User
{
if (!$this->userImportHistories->contains($userImportHistory)) {
$this->userImportHistories[] = $userImportHistory;
$userImportHistory->setImporter($this);
}
return $this;
}
public function removeUserImportHistory(UserImportHistory $userImportHistory): User
{
if ($this->userImportHistories->removeElement($userImportHistory)) {
// set the owning side to null (unless already changed)
if ($userImportHistory->getImporter() === $this) {
$userImportHistory->setImporter(NULL);
}
}
return $this;
}
public function getContactLists(): Collection
{
return $this->contactLists;
}
public function addContactList(ContactList $contactList): User
{
if (!$this->contactLists->contains($contactList)) {
$this->contactLists[] = $contactList;
$contactList->addUser($this);
}
return $this;
}
public function removeContactList(ContactList $contactList): User
{
if ($this->contactLists->removeElement($contactList)) {
$contactList->removeUser($this);
}
return $this;
}
/**
* @deprecated
*/
public function getUsernameCanonical(): ?string
{
return $this->usernameCanonical;
}
/**
* @deprecated
*/
public function setUsernameCanonical(?string $usernameCanonical): User
{
$this->usernameCanonical = $usernameCanonical;
return $this;
}
/**
* @deprecated
*/
public function getEmailCanonical(): ?string
{
return $this->emailCanonical;
}
/**
* @deprecated
*/
public function setEmailCanonical(?string $emailCanonical): User
{
$this->emailCanonical = $emailCanonical;
return $this;
}
public function getLastLogin(): ?DateTimeInterface
{
return $this->lastLogin;
}
public function setLastLogin(?DateTimeInterface $lastLogin): User
{
$this->lastLogin = $lastLogin;
return $this;
}
public function getConfirmationToken(): ?string
{
return $this->confirmationToken;
}
public function setConfirmationToken(?string $confirmationToken): User
{
$this->confirmationToken = $confirmationToken;
return $this;
}
public function getPasswordRequestedAt(): ?DateTimeInterface
{
return $this->passwordRequestedAt;
}
public function setPasswordRequestedAt(?DateTimeInterface $passwordRequestedAt): User
{
$this->passwordRequestedAt = $passwordRequestedAt;
return $this;
}
public function getCredentialExpired(): ?bool
{
return $this->credentialExpired;
}
public function setCredentialExpired(?bool $credentialExpired): User
{
$this->credentialExpired = $credentialExpired;
return $this;
}
public function getCredentialExpiredAt(): ?DateTimeInterface
{
return $this->credentialExpiredAt;
}
public function setCredentialExpiredAt(?DateTimeInterface $credentialExpiredAt): User
{
$this->credentialExpiredAt = $credentialExpiredAt;
return $this;
}
public function getDevis(): Collection
{
return $this->devis;
}
public function addDevi(Devis $devi): User
{
if (!$this->devis->contains($devi)) {
$this->devis[] = $devi;
$devi->setUser($this);
}
return $this;
}
public function removeDevi(Devis $devi): User
{
if ($this->devis->removeElement($devi)) {
// set the owning side to null (unless already changed)
if ($devi->getUser() === $this) {
$devi->setUser(NULL);
}
}
return $this;
}
public function __call($name, $arguments)
{
// TODO: Implement @method string getUserIdentifier()
}
public function getRegate(): ?Regate
{
return $this->regate;
}
public function setRegate(?Regate $regate): User
{
$this->regate = $regate;
return $this;
}
public function getDonneesPersonnelles(): ?bool
{
return $this->donneesPersonnelles;
}
public function setDonneesPersonnelles(?bool $donneesPersonnelles): User
{
$this->donneesPersonnelles = $donneesPersonnelles;
return $this;
}
/**
* @param PointTransactionType|null $type
* @param bool $sortByExpiration
*
* @return Collection|PointTransaction[]
*/
public function getPointTransactions(?PointTransactionType $type = null, bool $sortByExpiration = false): Collection
{
if(!$type && !$sortByExpiration) return $this->pointTransactions;
$points = clone $this->pointTransactions;
if($type)
{
$points = new ArrayCollection();
foreach($this->pointTransactions as $pointTransaction)
{
if($pointTransaction->getTransactionType() === $type) $points->add($pointTransaction);
}
}
if($sortByExpiration)
{
$iterator = $points->getIterator();
$iterator->uasort(function($a, $b) {
$AexpiredAt = $a->getExpiredAt();
$BexpiredAt = $b->getExpiredAt();
if($AexpiredAt && $BexpiredAt) return ($AexpiredAt < $BexpiredAt) ? - 1 : 1;
if(!$AexpiredAt) return 1;
return -1;
});
$points = new ArrayCollection(iterator_to_array($iterator));
}
return $points;
}
public function addPointTransaction(PointTransaction $pointTransaction): User
{
if (!$this->pointTransactions->contains($pointTransaction))
{
$user = $pointTransaction->getUser();
if($user) $user->removePointTransaction($pointTransaction);
$this->pointTransactions->add($pointTransaction);
$pointTransaction->setUser($this);
}
return $this;
}
public function removePointTransaction(PointTransaction $pointTransaction): User
{
if ($this->pointTransactions->removeElement($pointTransaction)) {
// set the owning side to null (unless already changed)
if ($pointTransaction->getUser() === $this) {
$pointTransaction->setUser(NULL);
}
}
return $this;
}
/**
* @return Collection|User[]
*/
public function getInstallers(): Collection
{
return $this->installers;
}
public function addInstaller(User $installer): User
{
if (!$this->installers->contains($installer)) {
$this->installers[] = $installer;
$installer->setCommercial($this);
}
return $this;
}
public function removeInstaller(User $installer): User
{
if ($this->installers->removeElement($installer)) {
// set the owning side to null (unless already changed)
if ($installer->getCommercial() === $this) {
$installer->setCommercial(NULL);
}
}
return $this;
}
public function getCommercial(): ?User
{
return $this->commercial;
}
public function setCommercial(?User $commercial): User
{
$this->commercial = $commercial;
return $this;
}
/**
* @return Collection|User[]
*/
public function getHeatingInstallers(): Collection
{
return $this->heatingInstallers;
}
public function addHeatingInstaller(User $heatingInstaller): User
{
if (!$this->heatingInstallers->contains($heatingInstaller)) {
$this->heatingInstallers[] = $heatingInstaller;
$heatingInstaller->setHeatingCommercial($this);
}
return $this;
}
public function removeHeatingInstaller(User $heatingInstaller): User
{
if ($this->heatingInstallers->removeElement($heatingInstaller)) {
// set the owning side to null (unless already changed)
if ($heatingInstaller->getHeatingCommercial() === $this) {
$heatingInstaller->setHeatingCommercial(NULL);
}
}
return $this;
}
public function getHeatingCommercial(): ?User
{
return $this->heatingCommercial;
}
public function setHeatingCommercial(?User $heatingCommercial): User
{
$this->heatingCommercial = $heatingCommercial;
return $this;
}
public function getAgency(): ?Agence
{
return $this->agency;
}
public function setAgency(?Agence $agency): User
{
$this->agency = $agency;
return $this;
}
public function getArchivedAt(): ?DateTimeInterface
{
return $this->archivedAt;
}
public function setArchivedAt(?DateTimeInterface $archivedAt): User
{
$this->archivedAt = $archivedAt;
return $this;
}
public function getNewsletter(): ?bool
{
return $this->newsletter;
}
public function setNewsletter(bool $newsletter): User
{
$this->newsletter = $newsletter;
return $this;
}
public function getCompanySiret(): ?string
{
return $this->companySiret;
}
public function setCompanySiret(?string $companySiret): User
{
$this->companySiret = $companySiret;
return $this;
}
/**
* @var bool $getCurrent highlight à null
* @var bool $getPrevious highlight non null
* @var bool $sum retourne un integer avec la somme des résultats
* @var int|null $highlight highlight spécifique
* @return Collection|UserBusinessResult[]|int
*/
public function getUserBusinessResults(bool $getCurrent = false, bool $getPrevious = false, bool $sum = false, ?int $highlight = null)
{
if(!$getCurrent && !$getPrevious && !$sum && !$highlight) return $this->userBusinessResults;
$userBusinessResults = $sum ? 0 : new ArrayCollection();
foreach($this->userBusinessResults as $userBusinessResult)
{
if((!$getCurrent && !$getPrevious && !$highlight) || (($getCurrent && $userBusinessResult->getHighlight() === null) || ($getPrevious && $userBusinessResult->getHighlight() !== null) || ($highlight && $userBusinessResult->getHighlight() == $highlight)))
{
$sum ? $userBusinessResults += $userBusinessResult->getSale() : $userBusinessResults->add($userBusinessResult);
}
}
return $userBusinessResults;
}
public function getTotalUserBusinessResults(): int
{
$total = 0;
foreach($this->userBusinessResults as $userBusinessResult)
{
$total += $userBusinessResult->getSale();
}
return $total;
}
public function addUserBusinessResult(UserBusinessResult $userBusinessResult): User
{
if(!$this->userBusinessResults->contains($userBusinessResult))
{
$this->userBusinessResults->add($userBusinessResult);
$user = $userBusinessResult->getUser();
if($user) $user->removeUserBusinessResult($userBusinessResult);
$userBusinessResult->setUser($this);
}
return $this;
}
public function removeUserBusinessResult(UserBusinessResult $userBusinessResult): User
{
if ($this->userBusinessResults->removeElement($userBusinessResult)) {
// set the owning side to null (unless already changed)
if ($userBusinessResult->getUser() === $this) {
$userBusinessResult->setUser(NULL);
}
}
return $this;
}
public function getExtension1(): ?string
{
return $this->extension1;
}
public function setExtension1(?string $extension1): User
{
$this->extension1 = $extension1;
return $this;
}
public function getExtension2(): ?string
{
return $this->extension2;
}
public function setExtension2(?string $extension2): User
{
$this->extension2 = $extension2;
return $this;
}
public function getWdg(): ?int
{
return $this->wdg;
}
public function setWdg(?int $wdg): User
{
$this->wdg = $wdg;
return $this;
}
public function getGladyUuid(): ?string
{
return $this->gladyUuid;
}
public function setGladyUuid(?string $gladyUuid): User
{
$this->gladyUuid = $gladyUuid;
return $this;
}
public function getCoverageArea(): ?CoverageArea
{
return $this->coverageArea;
}
public function setCoverageArea(?CoverageArea $coverageArea): User
{
$this->coverageArea = $coverageArea;
$coverageArea->setUser($this);
return $this;
}
/**
* @return Collection<int, Project>
*/
public function getProjects(): Collection
{
return $this->projects;
}
public function addProject(Project $project): User
{
if (!$this->projects->contains($project)) {
$this->projects[] = $project;
$project->setReferent($this);
}
return $this;
}
public function removeProject(Project $project): User
{
if ($this->projects->removeElement($project)) {
// set the owning side to null (unless already changed)
if ($project->getReferent() === $this) {
$project->setReferent(NULL);
}
}
return $this;
}
public function getProgramme(): ?Programme
{
return $this->programme;
}
public function setProgramme(?Programme $programme): User
{
$this->programme = $programme;
return $this;
}
/**
* @return Collection<int, ServiceUser>
*/
public function getServiceUsers(): Collection
{
return $this->serviceUsers;
}
public function addServiceUser(ServiceUser $serviceUser): User
{
if (!$this->serviceUsers->contains($serviceUser)) {
$this->serviceUsers[] = $serviceUser;
$serviceUser->setUser($this);
}
return $this;
}
public function removeServiceUser(ServiceUser $serviceUser): User
{
if ($this->serviceUsers->removeElement($serviceUser)) {
// set the owning side to null (unless already changed)
if ($serviceUser->getUser() === $this) {
$serviceUser->setUser(NULL);
}
}
return $this;
}
public function getSaleOrderValidation(): ?SaleOrderValidation
{
return $this->saleOrderValidation;
}
public function setSaleOrderValidation(?SaleOrderValidation $saleOrderValidation): User
{
$this->saleOrderValidation = $saleOrderValidation;
return $this;
}
/**
* @return Collection<int, Univers>
*/
public function getUniverses(): Collection
{
return $this->universes;
}
public function addUnivers(Univers $univers): User
{
if (!$this->universes->contains($univers)) {
$this->universes[] = $univers;
$univers->addUser($this);
}
return $this;
}
public function removeUniverses(Univers $universes): User
{
if ($this->universes->removeElement($universes)) {
$universes->removeUser($this);
}
return $this;
}
public function getBillingPoint(): ?BillingPoint
{
return $this->billingPoint;
}
public function setBillingPoint(?BillingPoint $billingPoint): User
{
$this->billingPoint = $billingPoint;
return $this;
}
/**
* @return Collection<int, Score>
*/
public function getScores(): Collection
{
return $this->scores;
}
public function addScore(Score $score): User
{
if (!$this->scores->contains($score)) {
$this->scores[] = $score;
$score->setUser($this);
}
return $this;
}
public function removeScore(Score $score): User
{
if ($this->scores->removeElement($score)) {
// set the owning side to null (unless already changed)
if ($score->getUser() === $this) {
$score->setUser(NULL);
}
}
return $this;
}
/**
* @return Collection<int, ScoreObjective>
*/
public function getScoreObjectives(): Collection
{
return $this->scoreObjectives;
}
public function addScoreObjective(ScoreObjective $scoreObjective): User
{
if (!$this->scoreObjectives->contains($scoreObjective)) {
$this->scoreObjectives[] = $scoreObjective;
$scoreObjective->setUser($this);
}
return $this;
}
public function removeScoreObjective(ScoreObjective $scoreObjective): User
{
if ($this->scoreObjectives->removeElement($scoreObjective)) {
// set the owning side to null (unless already changed)
if ($scoreObjective->getUser() === $this) {
$scoreObjective->setUser(NULL);
}
}
return $this;
}
/**
* @return Collection<int, User>
*/
public function getChildren(): Collection
{
return $this->children;
}
/**
* @param User|null $child
*
* @return $this
*/
public function addChild(?User $child): User
{
if ($child && !$this->children->contains($child)) {
$this->children[] = $child;
$child->addParent($this);
}
return $this;
}
/**
* @param User|null $parent
*
* @return $this
*/
public function addParent(?User $parent): User
{
if ($parent && !$this->parents->contains($parent)) {
$this->parents[] = $parent;
$parent->addChild($this);
}
return $this;
}
public function removeParent(User $parent): User
{
if ($this->parents->removeElement($parent)) {
$parent->removeChild($this);
$this->removeParent($parent);
}
return $this;
}
public function removeChild(User $child): User
{
$this->children->removeElement($child);
return $this;
}
/**
* @return Collection<int, Message>
*/
public function getSenderMessages(): Collection
{
return $this->senderMessages;
}
public function addSenderMessage(Message $senderMessage): User
{
if (!$this->senderMessages->contains($senderMessage)) {
$this->senderMessages[] = $senderMessage;
$senderMessage->setSender($this);
}
return $this;
}
public function removeSenderMessage(Message $senderMessage): User
{
if ($this->senderMessages->removeElement($senderMessage)) {
// set the owning side to null (unless already changed)
if ($senderMessage->getSender() === $this) {
$senderMessage->setSender(NULL);
}
}
return $this;
}
/**
* @return Collection<int, Message>
*/
public function getReceiverMessages(): Collection
{
return $this->receiverMessages;
}
public function addReceiverMessage(Message $receiverMessage): User
{
if (!$this->receiverMessages->contains($receiverMessage)) {
$this->receiverMessages[] = $receiverMessage;
$receiverMessage->setReceiver($this);
}
return $this;
}
public function removeReceiverMessage(Message $receiverMessage): User
{
if ($this->receiverMessages->removeElement($receiverMessage)) {
// set the owning side to null (unless already changed)
if ($receiverMessage->getReceiver() === $this) {
$receiverMessage->setReceiver(NULL);
}
}
return $this;
}
public function getRequestRegistration(): ?RequestRegistration
{
return $this->requestRegistration;
}
public function setRequestRegistration(RequestRegistration $requestRegistration): User
{
// set the owning side of the relation if necessary
if ($requestRegistration->getUser() !== $this) {
$requestRegistration->setUser($this);
}
$this->requestRegistration = $requestRegistration;
return $this;
}
/**
* @return Collection<int, RequestRegistration>
*/
public function getRequestRegistrationsToValidate(): Collection
{
return $this->requestRegistrationsToValidate;
}
public function addRequestRegistrationsToValidate(RequestRegistration $requestRegistrationsToValidate): User
{
if (!$this->requestRegistrationsToValidate->contains($requestRegistrationsToValidate)) {
$this->requestRegistrationsToValidate[] = $requestRegistrationsToValidate;
$requestRegistrationsToValidate->setReferent($this);
}
return $this;
}
public function removeRequestRegistrationsToValidate(RequestRegistration $requestRegistrationsToValidate): User
{
if ($this->requestRegistrationsToValidate->removeElement($requestRegistrationsToValidate)) {
// set the owning side to null (unless already changed)
if ($requestRegistrationsToValidate->getReferent() === $this) {
$requestRegistrationsToValidate->setReferent(NULL);
}
}
return $this;
}
/**
* @return Collection<int, CustomProductOrder>
*/
public function getCustomProductOrders(): Collection
{
return $this->customProductOrders;
}
public function addCustomProductOrder(CustomProductOrder $customProductOrder): User
{
if (!$this->customProductOrders->contains($customProductOrder)) {
$this->customProductOrders[] = $customProductOrder;
$customProductOrder->setUser($this);
}
return $this;
}
public function removeCustomProductOrder(CustomProductOrder $customProductOrder): User
{
if ($this->customProductOrders->removeElement($customProductOrder)) {
// set the owning side to null (unless already changed)
if ($customProductOrder->getUser() === $this) {
$customProductOrder->setUser(NULL);
}
}
return $this;
}
public function removeCustomProduct(CustomProduct $customProduct): User
{
if ($this->customProducts->removeElement($customProduct)) {
// set the owning side to null (unless already changed)
if ($customProduct->getCreatedBy() === $this) {
$customProduct->setCreatedBy(NULL);
}
}
return $this;
}
public function getSubscription()
{
return $this->subscription;
}
public function setSubscription(UserSubscription $subscription): User
{
// set the owning side of the relation if necessary
if ($subscription->getUser() !== $this) {
$subscription->setUser($this);
}
$this->subscription = $subscription;
return $this;
}
/**
* @return Collection<int, UserExtension>
*/
public function getExtensions(): Collection
{
return $this->extensions;
}
public function removeExtension(UserExtension $extension): User
{
if ($this->extensions->removeElement($extension)) {
// set the owning side to null (unless already changed)
if ($extension->getUser() === $this) {
$extension->setUser(NULL);
}
}
return $this;
}
/**
* @return Collection<int, CustomProduct>
*/
public function getCustomProducts(): Collection
{
return $this->customProducts;
}
public function addCustomProduct(CustomProduct $customProduct): User
{
if (!$this->customProducts->contains($customProduct)) {
$this->customProducts[] = $customProduct;
$customProduct->setCreatedBy($this);
}
return $this;
}
public function getCalculatedPoints(): ?string
{
return $this->calculatedPoints;
}
public function setCalculatedPoints(?string $calculatedPoints): User
{
$this->calculatedPoints = $calculatedPoints;
return $this;
}
public function getAvatar()
{
return $this->avatar;
}
public function setAvatar($avatar): User
{
$this->avatar = $avatar;
return $this;
}
public function getAvatarFile(): ?File
{
return $this->avatarFile;
}
/**
* @param File|UploadedFile|null $avatarFile
*/
public function setAvatarFile(?File $avatarFile = NULL): void
{
$this->avatarFile = $avatarFile;
if (NULL !== $avatarFile) {
$this->updatedAt = new DateTime();
}
}
public function getLogo()
{
return $this->logo;
}
public function setLogo($logo): User
{
$this->logo = $logo;
return $this;
}
public function getLogoFile(): ?File
{
return $this->logoFile;
}
public function setLogoFile(?File $logoFile = NULL): User
{
$this->logoFile = $logoFile;
if (NULL !== $logoFile) {
$this->updatedAt = new DateTime();
}
return $this;
}
/**
* @return Collection<int, PointOfSale>
*/
public function getManagedPointOfSales(): Collection
{
return $this->managedPointOfSales;
}
public function addManagedPointOfSale(PointOfSale $managedPointOfSale): User
{
if (!$this->managedPointOfSales->contains($managedPointOfSale)) {
$this->managedPointOfSales[] = $managedPointOfSale;
$managedPointOfSale->addManager($this);
}
return $this;
}
public function removeManagedPointOfSale(PointOfSale $managedPointOfSale): User
{
if ($this->managedPointOfSales->removeElement($managedPointOfSale)) {
$managedPointOfSale->removeManager($this);
}
return $this;
}
/**
* @return Collection<int, Parameter>
*/
public function getRelatedParameters(): Collection
{
return $this->relatedParameters;
}
public function addRelatedParameter(Parameter $relatedParameter): User
{
if (!$this->relatedParameters->contains($relatedParameter)) {
$this->relatedParameters[] = $relatedParameter;
$relatedParameter->setUserRelated($this);
}
return $this;
}
public function removeRelatedParameter(Parameter $relatedParameter): User
{
if ($this->relatedParameters->removeElement($relatedParameter)) {
// set the owning side to null (unless already changed)
if ($relatedParameter->getUserRelated() === $this) {
$relatedParameter->setUserRelated(NULL);
}
}
return $this;
}
public function getCompanyLegalStatus(): ?string
{
return $this->companyLegalStatus;
}
public function setCompanyLegalStatus(?string $companyLegalStatus): User
{
$this->companyLegalStatus = $companyLegalStatus;
return $this;
}
/**
* @return Collection<int, PointOfSale>
*/
public function getCreatedPointOfSales(): Collection
{
return $this->createdPointOfSales;
}
public function addCreatedPointOfSale(PointOfSale $createdPointOfSale): User
{
if (!$this->createdPointOfSales->contains($createdPointOfSale)) {
$this->createdPointOfSales[] = $createdPointOfSale;
$createdPointOfSale->setCreatedBy($this);
}
return $this;
}
public function removeCreatedPointOfSale(PointOfSale $createdPointOfSale): User
{
if ($this->createdPointOfSales->removeElement($createdPointOfSale)) {
// set the owning side to null (unless already changed)
if ($createdPointOfSale->getCreatedBy() === $this) {
$createdPointOfSale->setCreatedBy(NULL);
}
}
return $this;
}
/**
* Serializer\VirtualProperty()
* @Serializer\SerializedName("count_created_point_of_sales")
*
* @return int
* @Expose()
* @Groups ({"export_user_datatable", "export_admin_datatable", "user"})
*/
public function countCreatedPointOfSales(): int
{
return $this->createdPointOfSales->count();
}
public function getOwnerPointConversionRates(): Collection
{
return $this->ownerPointConversionRates;
}
public function addOwnerPointConversionRate(PointConversionRate $ownerPointConversionRate): User
{
if (!$this->ownerPointConversionRates->contains($ownerPointConversionRate)) {
$this->ownerPointConversionRates[] = $ownerPointConversionRate;
$ownerPointConversionRate->setOwner($this);
}
return $this;
}
public function removeOwnerPointConversionRate(PointConversionRate $ownerPointConversionRate): User
{
if ($this->ownerPointConversionRates->removeElement($ownerPointConversionRate)) {
// set the owning side to null (unless already changed)
if ($ownerPointConversionRate->getOwner() === $this) {
$ownerPointConversionRate->setOwner(NULL);
}
}
return $this;
}
/**
* @return PointConversionRate|null
*/
public function getPointConversionRate()
{
return $this->pointConversionRate;
}
public function setPointConversionRate($pointConversionRate)
{
$this->pointConversionRate = $pointConversionRate;
return $this;
}
public function getFonction(): ?string
{
return $this->fonction;
}
public function setFonction(?string $fonction): User
{
$this->fonction = $fonction;
return $this;
}
public function getResponsableRegate(): ?Regate
{
return $this->responsableRegate;
}
public function setResponsableRegate(?Regate $responsableRegate): User
{
$this->responsableRegate = $responsableRegate;
return $this;
}
public function getRegistrationDocument(): ?string
{
return $this->registrationDocument;
}
public function setRegistrationDocument(?string $registrationDocument): User
{
$this->registrationDocument = $registrationDocument;
return $this;
}
public function getRegistrationDocumentFile(): ?File
{
return $this->registrationDocumentFile;
}
public function setRegistrationDocumentFile(?File $registrationDocumentFile = NULL): User
{
$this->registrationDocumentFile = $registrationDocumentFile;
if (NULL !== $registrationDocumentFile) {
$this->updatedAt = new DateTime();
}
return $this;
}
public function getIdeaBoxAnswers(): ArrayCollection
{
return $this->ideaBoxAnswers;
}
public function setIdeaBoxAnswers(ArrayCollection $ideaBoxAnswers): void
{
$this->ideaBoxAnswers = $ideaBoxAnswers;
}
public function getIdeaBoxRatings(): Collection
{
return $this->ideaBoxRatings;
}
public function addIdeaBoxRating(IdeaBoxRating $ideaBoxRating): User
{
if (!$this->ideaBoxRatings->contains($ideaBoxRating)) {
$this->ideaBoxRatings[] = $ideaBoxRating;
$ideaBoxRating->setUser($this);
}
return $this;
}
public function removeIdeaBoxRating(IdeaBoxRating $ideaBoxRating): User
{
if ($this->ideaBoxRatings->removeElement($ideaBoxRating)) {
// set the owning side to null (unless already changed)
if ($ideaBoxRating->getUser() === $this) {
$ideaBoxRating->setUser(NULL);
}
}
return $this;
}
public function getIdeaBoxRecipients(): Collection
{
return $this->ideaBoxRecipients;
}
public function addIdeaBoxRecipient(IdeaBoxRecipient $ideaBoxRecipient): User
{
if (!$this->ideaBoxRecipients->contains($ideaBoxRecipient)) {
$this->ideaBoxRecipients[] = $ideaBoxRecipient;
$ideaBoxRecipient->setUser($this);
}
return $this;
}
public function removeIdeaBoxRecipient(IdeaBoxRecipient $ideaBoxRecipient): User
{
if ($this->ideaBoxRecipients->removeElement($ideaBoxRecipient)) {
// set the owning side to null (unless already changed)
if ($ideaBoxRecipient->getUser() === $this) {
$ideaBoxRecipient->setUser(NULL);
}
}
return $this;
}
public function getOldStatus(): ?string
{
return $this->oldStatus;
}
public function setOldStatus(?string $oldStatus): User
{
$this->oldStatus = $oldStatus;
return $this;
}
public function getDisabledAt(): ?DateTimeInterface
{
return $this->disabledAt;
}
public function setDisabledAt(?DateTimeInterface $disabledAt): User
{
$this->disabledAt = $disabledAt;
return $this;
}
public function getArchiveReason(): ?string
{
return $this->archiveReason;
}
public function setArchiveReason(?string $archiveReason): User
{
$this->archiveReason = $archiveReason;
return $this;
}
public function getUnsubscribeReason(): ?string
{
return $this->unsubscribeReason;
}
public function setUnsubscribeReason(?string $unsubscribeReason): User
{
$this->unsubscribeReason = $unsubscribeReason;
return $this;
}
/**
* @return Collection<int, ActionLog>
*/
public function getActionLogs(): Collection
{
return $this->actionLogs;
}
public function addActionLog(ActionLog $ActionLog): User
{
if (!$this->actionLogs->contains($ActionLog)) {
$this->actionLogs[] = $ActionLog;
$ActionLog->setUser($this);
}
return $this;
}
public function removeActionLog(ActionLog $ActionLog): User
{
if ($this->actionLogs->removeElement($ActionLog)) {
// set the owning side to null (unless already changed)
if ($ActionLog->getUser() === $this) {
$ActionLog->setUser(NULL);
}
}
return $this;
}
public function getFailedAttempts(): int
{
return $this->failedAttempts;
}
public function setFailedAttempts(int $failedAttempts): User
{
$this->failedAttempts = $failedAttempts;
return $this;
}
public function getLastFailedAttempt()
{
return $this->lastFailedAttempt;
}
public function setLastFailedAttempt($lastFailedAttempt): User
{
$this->lastFailedAttempt = $lastFailedAttempt;
return $this;
}
public function getPasswordUpdatedAt(): ?DateTimeInterface
{
return $this->passwordUpdatedAt;
}
public function setPasswordUpdatedAt(?DateTimeInterface $passwordUpdatedAt): User
{
$this->passwordUpdatedAt = $passwordUpdatedAt;
return $this;
}
public function getBirthPlace(): ?string
{
return $this->birthPlace;
}
public function setBirthPlace(?string $birthPlace): User
{
$this->birthPlace = $birthPlace;
return $this;
}
public function getQuizUserAnswers()
{
return $this->quizUserAnswers;
}
public function setQuizUserAnswers($quizUserAnswers): void
{
$this->quizUserAnswers = $quizUserAnswers;
}
public function getPasswordHistories(): Collection
{
return $this->passwordHistories;
}
public function addPasswordHistory(PasswordHistory $passwordHistory): User
{
if (!$this->passwordHistories->contains($passwordHistory)) {
$this->passwordHistories[] = $passwordHistory;
$passwordHistory->setUser($this);
}
return $this;
}
public function removePasswordHistory(PasswordHistory $passwordHistory): User
{
if ($this->passwordHistories->removeElement($passwordHistory)) {
// set the owning side to null (unless already changed)
if ($passwordHistory->getUser() === $this) {
$passwordHistory->setUser(NULL);
}
}
return $this;
}
public function getLastActivity(): ?DateTimeInterface
{
return $this->lastActivity;
}
public function setLastActivity(?DateTimeInterface $lastActivity): User
{
$this->lastActivity = $lastActivity;
return $this;
}
public function getUserFavorites(): ArrayCollection
{
return $this->userFavorites;
}
public function setUserFavorites(ArrayCollection $userFavorites): User
{
$this->userFavorites = $userFavorites;
return $this;
}
/**
* Serializer\VirtualProperty()
* @SerializedName("count_current_highlight_sale_result")
*
* @return int
* @Expose()
* @Groups ({
* "default",
* "user:count_current_highlight_sale_result",
* "user:list", "user:item", "user:post", "cdp", "user","email", "user_citroentf",
* "export_order_datatable",
* "user_bussiness_result",
* })
*/
public function getCurrentHighlightSaleResult(): int
{
$ubr = $this->userBusinessResults->filter(function (UserBusinessResult $ubr) {
return $ubr->getHighlight() === NULL;
});
$result = 0;
/** @var UserBusinessResult $item */
foreach ($ubr as $item) {
$result += $item->getSale();
}
return $result;
}
public function getAccountId(): ?string
{
return $this->accountId;
}
public function setAccountId(?string $accountId): self
{
$this->accountId = $accountId;
return $this;
}
public function getUniqueSlugConstraint(): ?string
{
return $this->uniqueSlugConstraint;
}
public function setUniqueSlugConstraint(?string $uniqueSlugConstraint): self
{
$this->uniqueSlugConstraint = $uniqueSlugConstraint;
return $this;
}
public function isFakeUser(): bool
{
return !str_contains($this->getEmail(), '@');
}
/**
* @return Collection<int, BoosterProductResult>
*/
public function getBoosterProductResults(): Collection
{
return $this->boosterProductResults;
}
public function addBoosterProductResult(BoosterProductResult $boosterProductResult): self
{
if (!$this->boosterProductResults->contains($boosterProductResult)) {
$this->boosterProductResults[] = $boosterProductResult;
$boosterProductResult->setUser($this);
}
return $this;
}
public function removeBoosterProductResult(BoosterProductResult $boosterProductResult): self
{
if ($this->boosterProductResults->removeElement($boosterProductResult)) {
// set the owning side to null (unless already changed)
if ($boosterProductResult->getUser() === $this) {
$boosterProductResult->setUser(null);
}
}
return $this;
}
/**
* @return Collection<int, PushSubscription>
*/
public function getPushSubscriptions(): Collection
{
return $this->pushSubscriptions;
}
public function addPushSubscription(PushSubscription $pushSubscription): self
{
if (!$this->pushSubscriptions->contains($pushSubscription)) {
$this->pushSubscriptions[] = $pushSubscription;
$pushSubscription->setUser($this);
}
return $this;
}
public function removePushSubscription(PushSubscription $pushSubscription): self
{
if ($this->pushSubscriptions->removeElement($pushSubscription)) {
// set the owning side to null (unless already changed)
if ($pushSubscription->getUser() === $this) {
$pushSubscription->setUser(null);
}
}
return $this;
}
/**
* @param bool $getLevel
*
* @return bool|int
* @throws \DateInvalidOperationException
*/
public function isActive(bool $getLevel = false)
{
$status = $this->getStatus();
if(!$getLevel && $this->isFakeUser()) return false;
$inactiveStatus = [self::STATUS_ARCHIVED, self::STATUS_DELETED, self::STATUS_UNSUBSCRIBED, self::STATUS_REGISTER_PENDING, self::STATUS_DISABLED, self::STATUS_ADMIN_PENDING];
if(!$getLevel && in_array($status, $inactiveStatus)) return false;
$twoYears = (new DateTime())->sub(new DateInterval('P2Y'));
$cguStatus = [self::STATUS_CGU_PENDING, self::STATUS_CGU_DECLINED];
if(!$getLevel && in_array($status, $cguStatus) && (!$this->lastLogin || $twoYears > $this->lastLogin)) return false;
if($getLevel)
{
$oneYear = (new DateTime())->sub(new DateInterval('P1Y'));
$sixMonths = (new DateTime())->sub(new DateInterval('P6M'));
$lvl = 15;
if($this->isFakeUser())
{
$lvl = 0;
}
// si l'utilisateur possède un email, son score sera au moins de 1
else
{
switch ($status)
{
case self::STATUS_DELETED:
$lvl -= 11;
break;
case self::STATUS_ARCHIVED:
$lvl -= 10;
break;
case self::STATUS_DISABLED:
case self::STATUS_UNSUBSCRIBED:
$lvl -= 9;
break;
case self::STATUS_REGISTER_PENDING:
$lvl -= 8;
break;
case self::STATUS_CGU_DECLINED:
$lvl -= 7;
break;
case self::STATUS_CGU_PENDING:
$lvl -= 6;
break;
case self::STATUS_ENABLED:
break;
default:
$lvl -= 5;
}
if(!$this->lastLogin || $twoYears > $this->lastLogin) {
$lvl -= 3;
}
elseif($oneYear > $this->lastLogin) {
$lvl -= 2;
}
elseif($sixMonths > $this->lastLogin) {
$lvl -= 1;
}
}
return $lvl;
}
return true;
}
public function getAzureId(): ?string
{
return $this->azureId;
}
public function setAzureId(?string $azureId): self
{
$this->azureId = $azureId;
return $this;
}
/**
* @return Collection<int, AzureGroup>
*/
public function getAzureGroups(): Collection
{
return $this->azureGroups;
}
public function addAzureGroup(AzureGroup $azureGroup): self
{
if (!$this->azureGroups->contains($azureGroup)) {
$this->azureGroups[] = $azureGroup;
$azureGroup->addMember($this);
}
return $this;
}
public function removeAzureGroup(AzureGroup $azureGroup): self
{
if ($this->azureGroups->removeElement($azureGroup)) {
$azureGroup->removeMember($this);
}
return $this;
}
public function getActivatedBy(): ?self
{
return $this->activatedBy;
}
public function setActivatedBy(?self $activatedBy): self
{
$this->activatedBy = $activatedBy;
return $this;
}
}