src/Entity/User.php line 43

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Annotation\Exportable;
  4. use App\Annotation\ExportableEntity;
  5. use App\Annotation\ExportableMethod;
  6. use App\Factory\UserExtensionFactory;
  7. use App\Repository\UserRepository;
  8. use App\Services\Common\Point\UserPointService;
  9. use App\Traits\DateTrait;
  10. use App\Traits\UserExtensionTrait;
  11. use App\Validator\NotInPasswordHistory;
  12. use App\Validator\UserMail;
  13. use DateInterval;
  14. use DateTime;
  15. use DateTimeInterface;
  16. use Doctrine\Common\Collections\ArrayCollection;
  17. use Doctrine\Common\Collections\Collection;
  18. use Doctrine\ORM\Event\PreUpdateEventArgs;
  19. use Doctrine\ORM\Mapping as ORM;
  20. use Exception;
  21. use JMS\Serializer\Annotation as Serializer;
  22. use JMS\Serializer\Annotation\Expose;
  23. use JMS\Serializer\Annotation\Groups;
  24. use JMS\Serializer\Annotation\SerializedName;
  25. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  26. use Symfony\Component\HttpFoundation\File\File;
  27. use Symfony\Component\HttpFoundation\File\UploadedFile;
  28. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  29. use Symfony\Component\Security\Core\User\UserInterface;
  30. use Symfony\Component\Validator\Constraints as Assert;
  31. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  32. /**
  33. * @ORM\Entity(repositoryClass=UserRepository::class)
  34. * @UniqueEntity("uniqueSlugConstraint")
  35. * @ORM\HasLifecycleCallbacks()
  36. * @Vich\Uploadable
  37. * @Serializer\ExclusionPolicy("ALL")
  38. * @ExportableEntity
  39. */
  40. class User implements UserInterface, PasswordAuthenticatedUserInterface
  41. {
  42. use DateTrait;
  43. use UserExtensionTrait;
  44. // TODO Check à quoi sert cette constante
  45. public const SUPER_ADMINISTRATEUR = 1;
  46. // tous les status utilisateur
  47. public const STATUS_CGU_DECLINED = "cgu_declined";
  48. public const STATUS_REGISTER_PENDING = "register_pending";
  49. public const STATUS_CGU_PENDING = "cgu_pending";
  50. public const STATUS_ADMIN_PENDING = "admin_pending";
  51. public const STATUS_UNSUBSCRIBED = "unsubscribed";
  52. public const STATUS_ENABLED = "enabled";
  53. public const STATUS_DISABLED = "disabled";
  54. public const STATUS_ARCHIVED = "archived";
  55. public const STATUS_DELETED = "deleted";
  56. public const STATUS_FAKE = "fake";
  57. public const BASE_STATUS = [
  58. self::STATUS_ADMIN_PENDING,
  59. self::STATUS_CGU_PENDING,
  60. self::STATUS_ENABLED,
  61. self::STATUS_DISABLED,
  62. self::STATUS_CGU_DECLINED,
  63. self::STATUS_REGISTER_PENDING
  64. ];
  65. public const ROLE_ALLOWED_TO_HAVE_JOBS = [
  66. 'Super admin' => 'ROLE_SUPER_ADMIN',
  67. 'Administrateur' => 'ROLE_ADMIN',
  68. 'Utilisateur' => 'ROLE_USER',
  69. ];
  70. public ?string $accountIdTmp = null;
  71. /**
  72. * @ORM\Id
  73. * @ORM\GeneratedValue
  74. * @ORM\Column(type="integer")
  75. *
  76. * @Expose()
  77. * @Groups({
  78. * "default",
  79. * "user:id",
  80. * "user:list","user:item", "sale_order:item", "sale_order:post", "cdp", "user",
  81. * "user_citroentf",
  82. * "export_user_citroentf_datatable",
  83. * "export_agency_manager_commercial_datatable",
  84. * "export_agency_manager_datatable", "export_commercial_installer_datatable",
  85. * "export_installer_datatable",
  86. * "sale_order", "purchase", "get:read","post:read", "export_user_datatable", "export_admin_datatable",
  87. * "export_commercial_datatable",
  88. * "regate-list", "point_of_sale", "parameter", "export_request_registration_datatable"
  89. * })
  90. *
  91. * @Exportable()
  92. */
  93. private ?int $id = NULL;
  94. /**
  95. * @ORM\Column(type="string", length=130)
  96. * @Assert\NotBlank()
  97. * @Assert\Email(
  98. * message = "Cette adresse email n'est pas valide."
  99. * )
  100. *
  101. * @Expose()
  102. * @Groups({
  103. * "default",
  104. * "user:email",
  105. * "user:list", "user:item", "user:post", "sale_order:item", "cdp", "user","email", "user_citroentf",
  106. * "export_user_citroentf_datatable",
  107. * "export_purchase_declaration_datatable", "export_agency_manager_commercial_datatable",
  108. * "export_agency_manager_datatable", "export_commercial_installer_datatable",
  109. * "export_commercial_datatable",
  110. * "export_installer_datatable","get:read", "export_order_datatable", "purchase", "export_user_datatable", "export_admin_datatable",
  111. * "user_bussiness_result", "sale_order","export_request_registration_datatable", "request_registration",
  112. * "univers", "saleordervalidation", "parameter",
  113. * "idea_box_list", "idea_box_stats", "export_idea_box_datatable"
  114. * })
  115. *
  116. * @Exportable()
  117. * @UserMail()
  118. */
  119. private ?string $email = null;
  120. /**
  121. * @ORM\Column(type="array")
  122. *
  123. * @Expose()
  124. * @Groups({
  125. * "user:post",
  126. * "user:roles",
  127. * "roles",
  128. * "cdp", "user", "user_citroentf","get:read", "export_user_citroentf_datatable", "export_user_datatable", "export_admin_datatable",
  129. * "idea_box_list", "idea_box_stats", "export_idea_box_datatable"
  130. * })
  131. */
  132. private array $roles = [];
  133. /**
  134. * @ORM\Column(type="string")
  135. *
  136. * @Expose()
  137. * @Groups({ "user:post" })
  138. */
  139. private ?string $password;
  140. /**
  141. * @ORM\Column(type="string", length=50, nullable=true)
  142. *
  143. * @Expose()
  144. * @Groups({
  145. * "default",
  146. * "user:first_name",
  147. * "user:list", "user:item", "user:post", "cdp", "user","email", "user_citroentf",
  148. * "export_order_datatable", "export_user_citroentf_datatable",
  149. * "user_bussiness_result", "export_purchase_declaration_datatable",
  150. * "export_agency_manager_commercial_datatable",
  151. * "export_agency_manager_datatable", "export_commercial_installer_datatable",
  152. * "export_commercial_datatable",
  153. * "purchase", "sale_order","get:read", "export_user_datatable", "export_admin_datatable", "export_installer_datatable",
  154. * "request_registration","customProductOrder:list", "parameter", "export_request_registration_datatable",
  155. * "idea_box_list", "idea_box_stats", "export_idea_box_datatable"
  156. * })
  157. *
  158. * @Exportable()
  159. */
  160. private ?string $firstName;
  161. /**
  162. * @ORM\Column(type="string", length=50, nullable=true)
  163. *
  164. * @Expose()
  165. * @Groups({
  166. * "user:last_name",
  167. * "default",
  168. * "user:list", "user:item", "user:post", "cdp", "user","email", "user_citroentf",
  169. * "export_order_datatable",
  170. * "export_user_citroentf_datatable",
  171. * "user_bussiness_result", "export_purchase_declaration_datatable",
  172. * "export_agency_manager_commercial_datatable",
  173. * "export_agency_manager_datatable", "export_commercial_installer_datatable",
  174. * "export_commercial_datatable",
  175. * "purchase", "sale_order","get:read", "export_user_datatable", "export_admin_datatable", "export_installer_datatable",
  176. * "request_registration","export_request_registration_datatable", "customProductOrder:list", "parameter",
  177. * "idea_box_list", "idea_box_stats", "export_idea_box_datatable"
  178. * })
  179. *
  180. * @Exportable()
  181. */
  182. private ?string $lastName;
  183. /**
  184. * Numéro téléphone portable
  185. *
  186. * @ORM\Column(type="string", length=20, nullable=true)
  187. *
  188. * @Expose()
  189. * @Groups({
  190. * "user:post",
  191. * "user:mobile",
  192. * "commercial:mobile",
  193. * "user:item", "user:post", "user", "export_user_citroentf_datatable",
  194. * "export_purchase_declaration_datatable",
  195. * "export_agency_manager_commercial_datatable",
  196. * "export_agency_manager_datatable", "export_commercial_installer_datatable",
  197. * "export_commercial_datatable", "export_user_datatable", "export_admin_datatable",
  198. * "export_installer_datatable"})
  199. *
  200. * @Exportable()
  201. */
  202. private ?string $mobile;
  203. /**
  204. * Numéro téléphone fix
  205. * @ORM\Column(type="string", length=20, nullable=true)
  206. *
  207. * @Expose()
  208. * @Groups({
  209. * "user:post",
  210. * "user:phone",
  211. * "user:item", "user:post", "user", "export_user_citroentf_datatable", "export_order_datatable",
  212. * "export_purchase_declaration_datatable",
  213. * "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
  214. * "export_commercial_installer_datatable",
  215. * "export_commercial_datatable","get:read", "export_user_datatable", "export_admin_datatable",
  216. * "export_installer_datatable"})
  217. *
  218. * @Exportable()
  219. */
  220. private ?string $phone;
  221. /**
  222. * @ORM\Column(type="datetime", nullable=true)
  223. *
  224. * @Expose()
  225. * @Groups({
  226. * "user:post","welcome_email","user", "user_citroentf"
  227. * })
  228. */
  229. private ?DateTimeInterface $welcomeEmail;
  230. /**
  231. * @deprecated Utiliser la fonction getAvailablePointOfUser de PointService
  232. * @ORM\Column(type="integer", options={"default": 0})
  233. */
  234. private int $availablePoint = 0;
  235. /**
  236. * @deprecated
  237. * @ORM\Column(type="integer", options={"default": 0})
  238. */
  239. private int $potentialPoint = 0;
  240. /**
  241. * On passe par un userExtension maintenant
  242. *
  243. * @deprecated
  244. * @ORM\Column(type="string", length=10, nullable=true)
  245. */
  246. private ?string $locale;
  247. /**
  248. * Code du pays
  249. *
  250. * @ORM\ManyToOne(targetEntity=Country::class, inversedBy="users")
  251. * @ORM\JoinColumn(name="country_id", referencedColumnName="id",nullable="true")
  252. *
  253. * @Expose()
  254. * @Groups({
  255. * "user:post",
  256. * "country",
  257. * "user:item", "user:post", "export_user_datatable", "export_admin_datatable", "export_user_citroentf_datatable",
  258. * "export_agency_manager_commercial_datatable",
  259. * "export_agency_manager_datatable", "export_commercial_datatable"})
  260. *
  261. * @Exportable()
  262. */
  263. private ?Country $country = NULL;
  264. /**
  265. * @ORM\Column(type="string", length=255, nullable=true)
  266. *
  267. * @Expose()
  268. * @Groups({
  269. * "user:post",
  270. * "job",
  271. * "user:job",
  272. * "user","get:read", "export_user_datatable", "export_admin_datatable", "univers", "parameter", "purchase" , "export_purchase_declaration_datatable"})
  273. *
  274. * @Exportable()
  275. */
  276. private ?string $job = null;
  277. /**
  278. * Société
  279. *
  280. * @ORM\Column(type="string", length=255, nullable=true)
  281. *
  282. * @Expose()
  283. * @Groups({
  284. * "user:post",
  285. * "user:company",
  286. * "default",
  287. * "user:item", "user:post", "user","email", "export_purchase_declaration_datatable",
  288. * "export_order_datatable",
  289. * "export_agency_manager_commercial_datatable",
  290. * "export_agency_manager_datatable", "export_commercial_installer_datatable",
  291. * "export_commercial_datatable",
  292. * "export_installer_datatable", "purchase","get:read","post:read", "export_user_datatable"
  293. * })
  294. *
  295. * @Exportable()
  296. */
  297. private ?string $company = NULL;
  298. /**
  299. * Numéro de Siret
  300. *
  301. * @ORM\Column(type="string", length=255, nullable=true)
  302. *
  303. * @Expose()
  304. * @Groups({
  305. * "user:post",
  306. * "company_siret",
  307. * "export_order_datatable",
  308. * "export_purchase_declaration_datatable",
  309. * "export_installer_datatable",
  310. * "user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
  311. *
  312. * @Exportable()
  313. */
  314. private ?string $companySiret = NULL;
  315. /**
  316. * Forme juridique
  317. *
  318. * @ORM\Column(type="string", length=128, nullable=true)
  319. *
  320. * @Expose()
  321. * @Groups({
  322. * "user:post",
  323. * "company_legal_status",
  324. * "user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
  325. *
  326. * @Exportable()
  327. */
  328. private ?string $companyLegalStatus = NULL;
  329. /**
  330. * @deprecated
  331. * @ORM\Column(type="string", length=255, nullable=true)
  332. */
  333. private ?string $userToken;
  334. /**
  335. * @deprecated
  336. * @ORM\Column(type="datetime", nullable=true)
  337. */
  338. private ?DateTimeInterface $userTokenValidity;
  339. /**
  340. * @deprecated
  341. * @ORM\Column(type="integer", options={"default": 0})
  342. */
  343. private int $userTokenAttempts = 0;
  344. /**
  345. * Civilité
  346. *
  347. * @ORM\Column(type="string", length=16, nullable=true)
  348. *
  349. * @Expose()
  350. * @Groups({
  351. * "user:civility",
  352. * "user:item", "default", "email","user:post", "user", "export_installer_datatable",
  353. * "export_purchase_declaration_datatable", "export_commercial_installer_datatable",
  354. * "export_user_datatable"})
  355. *
  356. * @Exportable()
  357. */
  358. private ?string $civility;
  359. /**
  360. * Adresse
  361. *
  362. * @ORM\Column(type="string", length=255, nullable=true)
  363. *
  364. * @Expose()
  365. * @Groups ({
  366. * "user:post","user", "user:address1", "user:item", "user:post", "email","export_installer_datatable",
  367. * "export_order_datatable",
  368. * "export_user_citroentf_datatable", "export_commercial_installer_datatable", "export_user_datatable", "export_admin_datatable",
  369. * "export_commercial_datatable","export_agency_manager_datatable"})
  370. *
  371. * @Exportable()
  372. */
  373. private ?string $address1 = NULL;
  374. /**
  375. * Complément d'adresse
  376. *
  377. * @ORM\Column(type="string", length=255, nullable=true)
  378. *
  379. * @Expose()
  380. * @Groups ({
  381. * "user:post","address2", "user:item", "user:post", "email"})
  382. *
  383. * @Exportable()
  384. */
  385. private ?string $address2 = NULL;
  386. /**
  387. * Code postal
  388. *
  389. * @ORM\Column(type="string", length=255, nullable=true)
  390. *
  391. * @Expose()
  392. * @Groups ({
  393. * "user:post","user", "user:postcode", "user:item", "user:post", "email","export_installer_datatable",
  394. * "export_order_datatable",
  395. * "export_user_citroentf_datatable", "export_commercial_installer_datatable", "export_user_datatable", "export_admin_datatable",
  396. * "export_commercial_datatable","export_agency_manager_datatable"})
  397. *
  398. * @Exportable()
  399. */
  400. private ?string $postcode = NULL;
  401. /**
  402. * Ville
  403. *
  404. * @ORM\Column(type="string", length=255, nullable=true)
  405. *
  406. * @Expose()
  407. * @Groups({
  408. * "user:post","user", "user:city", "user:item", "user:post", "email","export_user_datatable", "export_admin_datatable",
  409. * "export_order_datatable", "export_installer_datatable",
  410. * "export_commercial_installer_datatable",
  411. * "export_commercial_datatable","export_agency_manager_datatable"})
  412. *
  413. * @Exportable()
  414. */
  415. private ?string $city = NULL;
  416. /**
  417. * @ORM\Column(type="boolean", nullable=true)
  418. *
  419. * @Expose()
  420. * @Groups({
  421. * "user:post","user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
  422. *
  423. * @Exportable()
  424. */
  425. private bool $canOrder = TRUE;
  426. /**
  427. * Date de suppression
  428. * @ORM\Column(type="datetime", nullable=true)
  429. *
  430. * @Expose()
  431. * @Groups({ "user:post","user"})
  432. *
  433. * @Exportable()
  434. */
  435. private ?DateTimeInterface $deletedAt;
  436. /**
  437. * Date de naissance
  438. *
  439. * @ORM\Column(type="datetime", nullable=true)
  440. *
  441. * @Expose()
  442. * @Groups({ "user:post","user"})
  443. *
  444. * @deprecated
  445. */
  446. private ?DateTimeInterface $birthDate = NULL;
  447. /**
  448. * Lieu de naissance
  449. *
  450. * @deprecated
  451. * @ORM\Column(type="string", length=255, nullable=true)
  452. */
  453. private ?string $birthPlace = NULL;
  454. /**
  455. * Identifiant interne
  456. *
  457. * @ORM\Column(type="string", length=80, nullable=true)
  458. *
  459. * @Expose()
  460. * @Groups({
  461. * "user:internal_code",
  462. * "request_registration",
  463. * "export_user_datatable", "export_admin_datatable",
  464. * "user:list", "user", "user:item", "user:post", "user", "export_purchase_declaration_datatable",
  465. * "export_installer_datatable",
  466. * "export_commercial_installer_datatable"})
  467. *
  468. * @Exportable()
  469. */
  470. private ?string $internalCode;
  471. /**
  472. * @ORM\Column(type="datetime", nullable=true)
  473. *
  474. * @Expose()
  475. * @Groups({
  476. * "user:post",
  477. * "default",
  478. * "user:cgu_at",
  479. * "user", "export_installer_datatable", "export_commercial_installer_datatable"
  480. * })
  481. *
  482. * @Exportable()
  483. */
  484. private ?DateTimeInterface $cguAt;
  485. /**
  486. * @ORM\Column(type="datetime", nullable=true)
  487. *
  488. * @Expose()
  489. * @Groups({
  490. * "user:post",
  491. * "default",
  492. * "user:register_at",
  493. * "user", "export_installer_datatable", "export_commercial_installer_datatable"
  494. * })
  495. *
  496. * @Exportable()
  497. */
  498. private ?DateTimeInterface $registerAt;
  499. /**
  500. * @ORM\Column(type="datetime", nullable=true)
  501. *
  502. * @Expose()
  503. * @Groups ({
  504. * "user:imported_at",
  505. * "export_installer_datatable", "export_commercial_installer_datatable"})
  506. *
  507. * @Exportable()
  508. */
  509. private ?DateTimeInterface $importedAt;
  510. /**
  511. * @ORM\Column(type="boolean", options={"default": true})
  512. *
  513. * @Exportable()
  514. */
  515. private bool $canBeContacted = TRUE;
  516. /**
  517. * @deprecated
  518. * @ORM\Column(type="string", length=64, nullable=true)
  519. */
  520. private ?string $capacity;
  521. /**
  522. * @ORM\Column(type="string", length=255, nullable=true)
  523. *
  524. * @Exportable()
  525. */
  526. private ?string $address3;
  527. /**
  528. * @ORM\Column(type="boolean", options={"default": false})
  529. *
  530. * @Exportable()
  531. */
  532. private bool $optinMail = FALSE;
  533. /**
  534. * @ORM\Column(type="boolean", options={"default": false})
  535. *
  536. * @Exportable()
  537. */
  538. private bool $optinSMS = FALSE;
  539. /**
  540. * @ORM\Column(type="boolean", options={"default": false})
  541. *
  542. * @Exportable()
  543. */
  544. private bool $optinPostal = FALSE;
  545. /**
  546. * @ORM\Column(type="text", nullable=true)
  547. *
  548. * @Exportable()
  549. */
  550. private ?string $optinPostalAddress;
  551. /**
  552. * @ORM\Column(type="string", length=255, nullable=true)
  553. *
  554. * @Exportable()
  555. */
  556. private ?string $source;
  557. /**
  558. * @deprecated
  559. * @ORM\Column(type="integer", options={"default": 0})
  560. */
  561. private int $level = 0;
  562. /**
  563. * @deprecated
  564. * @ORM\Column(type="datetime", nullable=true)
  565. */
  566. private ?DateTimeInterface $level0UpdatedAt;
  567. /**
  568. * @deprecated
  569. * @ORM\Column(type="datetime", nullable=true)
  570. */
  571. private ?DateTimeInterface $level1UpdatedAt;
  572. /**
  573. * @deprecated
  574. * @ORM\Column(type="datetime", nullable=true)
  575. */
  576. private ?DateTimeInterface $level2UpdatedAt;
  577. /**
  578. * @deprecated
  579. * @ORM\Column(type="datetime", nullable=true)
  580. */
  581. private ?DateTimeInterface $level3UpdatedAt;
  582. /**
  583. * @deprecated
  584. * @ORM\Column(type="datetime", nullable=true)
  585. */
  586. private ?DateTimeInterface $levelUpdateSeenAt;
  587. /**
  588. * @ORM\Column(type="boolean", options={"default": true})
  589. *
  590. * @Expose()
  591. * @Groups ({
  592. * "user:is_email_ok",
  593. * "user",
  594. * "export_installer_datatable", "export_commercial_installer_datatable"})
  595. */
  596. private bool $isEmailOk = TRUE;
  597. /**
  598. * @ORM\Column(type="datetime", nullable=true)
  599. */
  600. private ?DateTimeInterface $lastEmailCheck;
  601. /**
  602. * @deprecated
  603. * @ORM\Column(type="string", length=255, nullable=true)
  604. */
  605. private ?string $apiToken;
  606. /**
  607. * @ORM\Column(type="string", length=255, nullable=true)
  608. * @Assert\NotBlank(groups={"installateur"})
  609. * @Assert\Regex(
  610. * groups={"installateur"},
  611. * message="Le numéro SAP est invalide",
  612. * pattern = "/^\d{6,8}$/"),
  613. *
  614. * @Expose()
  615. * @Groups({
  616. * "default",
  617. * "user:sap_account",
  618. * "user", "user_bussiness_result", "export_purchase_declaration_datatable",
  619. * "export_agency_manager_commercial_datatable",
  620. * "export_agency_manager_datatable", "export_commercial_installer_datatable",
  621. * "export_commercial_datatable","get:read", "purchase",
  622. * "export_installer_datatable"
  623. * })
  624. *
  625. * @Exportable()
  626. */
  627. private ?string $sapAccount;
  628. /**
  629. * @ORM\Column(type="string", length=255, nullable=true)
  630. *
  631. * @Expose()
  632. * @Groups({
  633. * "user:sap_distributor",
  634. * "export_installer_datatable", "export_commercial_installer_datatable"})
  635. *
  636. * @Exportable()
  637. */
  638. private ?string $sapDistributor;
  639. /**
  640. * @ORM\Column(type="string", length=255, nullable=true)
  641. *
  642. * @Expose()
  643. * @Groups({
  644. * "user:distributor",
  645. * "export_installer_datatable", "export_commercial_installer_datatable"})
  646. *
  647. * @Exportable()
  648. */
  649. private ?string $distributor;
  650. /**
  651. * @ORM\Column(type="string", length=255, nullable=true)
  652. *
  653. * @Expose()
  654. * @Groups({
  655. * "user:distributor2",
  656. * "export_installer_datatable", "export_commercial_installer_datatable"})
  657. *
  658. * @Exportable()
  659. */
  660. private ?string $distributor2;
  661. /**
  662. * @ORM\Column(type="boolean", nullable=true)
  663. *
  664. * @Exportable()
  665. */
  666. private ?bool $aggreement;
  667. /**
  668. * @ORM\Column(type="datetime", nullable=true)
  669. *
  670. * @Expose()
  671. * @Groups({
  672. * "user:post",
  673. * "user:unsubscribed_at",
  674. * "user","get:read","post:read", "export_installer_datatable", "export_commercial_installer_datatable"})
  675. *
  676. * @Exportable()
  677. */
  678. private ?DateTimeInterface $unsubscribedAt;
  679. /**
  680. * True if the salesman is chauffage
  681. * @ORM\Column(type="boolean", options={"default": false}, nullable=true)
  682. *
  683. * @Expose()
  684. * @Groups ({
  685. * "user:chauffage",
  686. * "user", "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
  687. * "export_commercial_datatable"})
  688. *
  689. * @Exportable()
  690. */
  691. private bool $chauffage = FALSE;
  692. /**
  693. * @ORM\OneToMany(targetEntity=Address::class, mappedBy="user", cascade={"remove", "persist"})
  694. *
  695. * @Exportable("addresses")
  696. */
  697. private Collection $addresses;
  698. /**
  699. * @ORM\OneToMany(targetEntity=Cart::class, mappedBy="user", cascade={"remove", "persist"})
  700. */
  701. private Collection $carts;
  702. /**
  703. * @ORM\ManyToOne(targetEntity=User::class, inversedBy="subAccountUsers", cascade={"persist"})
  704. * @ORM\JoinColumn(onDelete="SET NULL", nullable=true)
  705. *
  706. * @var User|null
  707. */
  708. private ?User $mainAccountUser = null;
  709. /**
  710. * @ORM\OneToMany(targetEntity=User::class, mappedBy="mainAccountUser")
  711. *
  712. * @var Collection|User[]
  713. */
  714. private Collection $subAccountUsers;
  715. /**
  716. * @ORM\ManyToMany(targetEntity=Distributor::class, inversedBy="users", cascade={"persist"})
  717. *
  718. * @Expose()
  719. * @Groups({
  720. * "user:distributors",
  721. * "export_installer_datatable", "export_commercial_installer_datatable"})
  722. */
  723. private Collection $distributors;
  724. /**
  725. * @ORM\OneToMany(targetEntity=Purchase::class, mappedBy="user", cascade={"remove"})
  726. */
  727. private Collection $purchases;
  728. /**
  729. * @ORM\OneToMany(targetEntity=Purchase::class, mappedBy="validator", cascade={"remove"})
  730. */
  731. private Collection $purchasesIHaveProcessed;
  732. /**
  733. * @ORM\OneToMany(targetEntity=SaleOrder::class, mappedBy="user")
  734. *
  735. * @Exportable()
  736. */
  737. private Collection $orders;
  738. /**
  739. * @var Collection|User[]
  740. *
  741. * @ORM\OneToMany(targetEntity=User::class, mappedBy="godfather", orphanRemoval=true)
  742. */
  743. private Collection $godchilds;
  744. /**
  745. * @var User|null
  746. *
  747. * @ORM\ManyToOne(targetEntity=User::class, inversedBy="godchilds")
  748. * @ORM\JoinColumn(onDelete="SET NULL")
  749. */
  750. private ?User $godfather = null;
  751. /**
  752. * @deprecated
  753. * @ORM\OneToMany(targetEntity=Satisfaction::class, mappedBy="user")
  754. */
  755. private Collection $satisfactions;
  756. /**
  757. * @ORM\OneToMany(targetEntity=RequestProductAvailable::class, mappedBy="user")
  758. */
  759. private Collection $requestProductAvailables;
  760. /**
  761. * @ORM\OneToMany(targetEntity=UserImportHistory::class, mappedBy="importer")
  762. *
  763. * @Exportable()
  764. */
  765. private Collection $userImportHistories;
  766. /**
  767. * @ORM\ManyToMany(targetEntity=ContactList::class, mappedBy="users")
  768. *
  769. * @Exportable()
  770. */
  771. private Collection $contactLists;
  772. /**
  773. * @ORM\Column(type="string", length=255, nullable=true)
  774. *
  775. * @Expose()
  776. * @Groups({"user", "sale_order","get:read","post:read"})
  777. */
  778. private ?string $username;
  779. /**
  780. * @deprecated
  781. * @ORM\Column(type="string", length=255, nullable=true)
  782. */
  783. private ?string $usernameCanonical;
  784. /**
  785. * @deprecated
  786. * @ORM\Column(type="string", length=255, nullable=true)
  787. */
  788. private $emailCanonical;
  789. /**
  790. * @deprecated
  791. * @ORM\Column(type="string", length=255, nullable=true)
  792. */
  793. private ?string $salt;
  794. /**
  795. * Date de dernière connexion
  796. *
  797. * @ORM\Column(type="datetime", nullable=true)
  798. *
  799. * @Expose()
  800. * @Groups({
  801. * "user:last_login",
  802. * "user", "user:item", "export_installer_datatable", "export_commercial_installer_datatable",
  803. * "export_user_datatable"})
  804. *
  805. * @Exportable()
  806. */
  807. private ?DateTimeInterface $lastLogin;
  808. /**
  809. * @ORM\Column(type="string", length=64, nullable=true)
  810. */
  811. private ?string $confirmationToken;
  812. /**
  813. * @ORM\Column(type="datetime", nullable=true)
  814. *
  815. * @Exportable()
  816. */
  817. private ?DateTimeInterface $passwordRequestedAt;
  818. /**
  819. * @Expose()
  820. * @Groups ({"user:post"})
  821. *
  822. * @NotInPasswordHistory
  823. */
  824. private ?string $plainPassword = NULL;
  825. /**
  826. * @ORM\Column(type="boolean", nullable=true)
  827. *
  828. * @Expose()
  829. * @Groups({"get:read"})
  830. */
  831. private ?bool $credentialExpired;
  832. /**
  833. * @ORM\Column(type="datetime", nullable=true)
  834. */
  835. private ?DateTimeInterface $credentialExpiredAt;
  836. // Arguments requis pour LaPoste
  837. /**
  838. * @ORM\OneToMany(targetEntity=Devis::class, mappedBy="user")
  839. *
  840. * @Exportable()
  841. */
  842. private Collection $devis;
  843. /**
  844. * @ORM\ManyToOne(targetEntity=Regate::class, inversedBy="members")
  845. * @ORM\JoinColumn(name="regate_id", referencedColumnName="id", onDelete="SET NULL")
  846. *
  847. * @Expose()
  848. * @Groups({"user", "export_user_datatable"})
  849. *
  850. * @Exportable()
  851. */
  852. private ?Regate $regate = NULL;
  853. /**
  854. * @ORM\Column(type="boolean", nullable=true)
  855. *
  856. * @Exportable()
  857. */
  858. private ?bool $donneesPersonnelles;
  859. /**
  860. * @var PointTransaction[]|Collection
  861. *
  862. * @ORM\OneToMany(targetEntity=PointTransaction::class, mappedBy="user", orphanRemoval=true, cascade={"persist"})
  863. *
  864. * @Exportable()
  865. */
  866. private Collection $pointTransactions;
  867. /**
  868. * @ORM\ManyToOne(targetEntity=User::class, inversedBy="installers")
  869. *
  870. * @Expose()
  871. * @Groups({
  872. * "user:commercial",
  873. * "user","export_request_registration_datatable", "request_registration", "sale_order", "purchase",
  874. * "export_purchase_declaration_datatable",
  875. * "export_installer_datatable", "export_commercial_installer_datatable"})
  876. */
  877. private $commercial;
  878. /**
  879. * @ORM\OneToMany(targetEntity=User::class, mappedBy="commercial")
  880. *
  881. * @Expose()
  882. * @Groups({
  883. * "user:installers"
  884. * })
  885. */
  886. private $installers;
  887. /**
  888. * @ORM\ManyToOne(targetEntity=User::class, inversedBy="heatingInstallers")
  889. *
  890. * @Expose()
  891. * @Groups({
  892. * "user:heating_commercial",
  893. * "export_installer_datatable", "export_commercial_installer_datatable"})
  894. */
  895. private $heatingCommercial;
  896. /**
  897. * @ORM\OneToMany(targetEntity=User::class, mappedBy="heatingCommercial")
  898. */
  899. private $heatingInstallers;
  900. /**
  901. * @ORM\ManyToOne(targetEntity=Agence::class, inversedBy="users", fetch="EAGER")
  902. *
  903. * @Expose()
  904. * @Groups({
  905. * "default",
  906. * "user:agency",
  907. * "user", "user_bussiness_result", "export_purchase_declaration_datatable",
  908. * "export_agency_manager_commercial_datatable",
  909. * "export_agency_manager_datatable", "export_commercial_installer_datatable",
  910. * "export_commercial_datatable","get:read", "purchase",
  911. * "export_installer_datatable"
  912. * })
  913. */
  914. private $agency;
  915. /**
  916. * Date d'archivage
  917. *
  918. * @ORM\Column(type="datetime", nullable=true)
  919. *
  920. * @Expose()
  921. * @Groups({
  922. * "user:archived_at",
  923. * "default",
  924. * "user", "export_installer_datatable", "export_commercial_installer_datatable"
  925. * })
  926. *
  927. * @Exportable()
  928. */
  929. private $archivedAt;
  930. /**
  931. * @ORM\Column(type="boolean", options={"default":false})
  932. *
  933. * @Exportable()
  934. */
  935. private $newsletter = FALSE;
  936. /**
  937. * @ORM\OneToMany(targetEntity=UserBusinessResult::class, mappedBy="user", cascade={"persist", "remove"})
  938. *
  939. * @Expose()
  940. * @Groups({"user:userBusinessResults","user","export_user_datatable"})
  941. *
  942. * @Exportable()
  943. *
  944. * @var Collection|UserBusinessResult[]
  945. */
  946. private Collection $userBusinessResults;
  947. /**
  948. * @ORM\Column(type="string", length=255, nullable=true)
  949. *
  950. * @Expose()
  951. * @Groups({
  952. * "user:post","cdp", "user", "user:extension1","export_user_citroentf_datatable", "user_citroentf",
  953. * "export_user_citroentf_datatable",
  954. * "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
  955. * "export_commercial_installer_datatable",
  956. * "export_commercial_datatable", "export_user_datatable", "export_admin_datatable", "export_installer_datatable"})
  957. *
  958. * @Exportable()
  959. */
  960. private ?string $extension1 = NULL;
  961. /**
  962. * @ORM\Column(type="string", length=255, nullable=true)
  963. *
  964. * @Expose()
  965. * @Groups({
  966. * "user:post","cdp", "user", "user:extension2", "export_user_citroentf_datatable", "user_citroentf",
  967. * "export_user_citroentf_datatable",
  968. * "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
  969. * "export_commercial_installer_datatable",
  970. * "export_commercial_datatable", "export_user_datatable", "export_admin_datatable", "export_installer_datatable"})
  971. *
  972. * @Exportable()
  973. */
  974. private ?string $extension2 = NULL;
  975. /**
  976. * @ORM\Column(type="integer", nullable=true, unique=true)
  977. *
  978. * @Exportable()
  979. */
  980. private $wdg;
  981. /**
  982. * @ORM\Column(type="string", nullable=true, unique=true)
  983. *
  984. * @Exportable()
  985. */
  986. private $gladyUuid;
  987. /**
  988. * @ORM\Column(type="string", length=255, nullable=true)
  989. *
  990. * @Exportable()
  991. */
  992. private $transactionalEmail;
  993. /**
  994. * @ORM\OneToMany(targetEntity=Project::class, mappedBy="referent")
  995. *
  996. * @Exportable()
  997. */
  998. private $projects;
  999. /**
  1000. * @ORM\ManyToOne(targetEntity=Programme::class, inversedBy="users")
  1001. *
  1002. * @Expose()
  1003. * @Groups({"user"})
  1004. *
  1005. * @Exportable()
  1006. */
  1007. private $programme;
  1008. /**
  1009. * @ORM\OneToMany(targetEntity=ServiceUser::class, mappedBy="user", orphanRemoval=true)
  1010. *
  1011. * @Exportable()
  1012. */
  1013. private $serviceUsers;
  1014. /**
  1015. * @ORM\ManyToOne(targetEntity=SaleOrderValidation::class, inversedBy="users")
  1016. *
  1017. * @Expose()
  1018. * @Groups({"user", "export_user_datatable"})
  1019. */
  1020. private $saleOrderValidation;
  1021. /**
  1022. * @ORM\ManyToMany(targetEntity=Univers::class, inversedBy="users")
  1023. *
  1024. */
  1025. private $universes;
  1026. /**
  1027. * @ORM\ManyToOne(targetEntity=BillingPoint::class, inversedBy="users")
  1028. *
  1029. * @Expose()
  1030. * @Groups({"user", "export_user_datatable", "export_admin_datatable", "billingpoint"})
  1031. */
  1032. private $billingPoint;
  1033. /**
  1034. * @ORM\OneToMany(targetEntity=Score::class, mappedBy="user", cascade={"remove"})
  1035. *
  1036. * @Exportable()
  1037. */
  1038. private $scores;
  1039. /**
  1040. * @ORM\OneToMany(targetEntity=ScoreObjective::class, mappedBy="user", cascade={"remove"})
  1041. *
  1042. * @Exportable()
  1043. */
  1044. private $scoreObjectives;
  1045. /**
  1046. * Dans la relation : target
  1047. *
  1048. * @ORM\ManyToMany(targetEntity=User::class, inversedBy="parents", cascade={"persist"})
  1049. */
  1050. private $children;
  1051. /**
  1052. * Dans la relation : source
  1053. *
  1054. * @ORM\ManyToMany(targetEntity=User::class, mappedBy="children", cascade={"persist"})
  1055. */
  1056. private $parents;
  1057. /**
  1058. * @ORM\OneToMany(targetEntity=Message::class, mappedBy="sender")
  1059. *
  1060. * @Exportable()
  1061. */
  1062. private $senderMessages;
  1063. /**
  1064. * @ORM\OneToMany(targetEntity=Message::class, mappedBy="receiver")
  1065. *
  1066. * @Exportable()
  1067. */
  1068. private $receiverMessages;
  1069. /**
  1070. * @ORM\OneToOne(targetEntity=RequestRegistration::class, inversedBy="user", cascade={"persist", "remove"})
  1071. *
  1072. * @Exportable()
  1073. */
  1074. private $requestRegistration;
  1075. /**
  1076. * @ORM\OneToMany(targetEntity=RequestRegistration::class, mappedBy="referent")
  1077. *
  1078. * @Exportable()
  1079. */
  1080. private $requestRegistrationsToValidate;
  1081. /**
  1082. * @ORM\OneToMany(targetEntity=CustomProductOrder::class, mappedBy="user", orphanRemoval=false)
  1083. *
  1084. * @Exportable()
  1085. */
  1086. private $customProductOrders;
  1087. /**
  1088. * @ORM\Column(type="string", length=255, options={"default":"cgu_pending"})
  1089. *
  1090. * @Expose()
  1091. * @Groups({
  1092. * "user:post",
  1093. * "user:status",
  1094. * "user:list", "user:item", "cdp", "user", "export_user_citroentf_datatable", "user_citroentf",
  1095. * "export_user_citroentf_datatable",
  1096. * "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
  1097. * "export_commercial_installer_datatable",
  1098. * "export_commercial_datatable","export_request_registration_datatable",
  1099. * "export_user_datatable", "export_admin_datatable", "export_installer_datatable"})
  1100. *
  1101. * @Exportable()
  1102. */
  1103. private string $status;
  1104. /**
  1105. * @ORM\Column(type="text", nullable=true)
  1106. */
  1107. private ?string $calculatedPoints;
  1108. /**
  1109. * @ORM\OneToMany(targetEntity=CustomProduct::class, mappedBy="createdBy")
  1110. *
  1111. * @Exportable()
  1112. */
  1113. private $customProducts;
  1114. /**
  1115. * Adhésion de l'utilisateur
  1116. *
  1117. * @ORM\OneToOne(targetEntity=UserSubscription::class, inversedBy="user", cascade={"persist", "remove"})
  1118. * @Expose()
  1119. * @Groups({"user" ,"user:subscription", "export_user_datatable"})
  1120. *
  1121. * @Exportable()
  1122. */
  1123. private ?UserSubscription $subscription = NULL;
  1124. /**
  1125. * @ORM\OneToMany(targetEntity=UserExtension::class, mappedBy="user", cascade={"persist", "remove"})
  1126. *
  1127. * @Exportable(type="oneToMany")
  1128. *
  1129. * @Exportable()
  1130. */
  1131. private $extensions;
  1132. /**
  1133. * @ORM\Column(type="string", length=255, nullable=true)
  1134. *
  1135. * @Exportable()
  1136. */
  1137. private $avatar;
  1138. /**
  1139. * @Vich\UploadableField(mapping="user_avatar", fileNameProperty="avatar")
  1140. * @var File
  1141. */
  1142. private $avatarFile;
  1143. /**
  1144. * @ORM\Column(type="string", length=255, nullable=true)
  1145. *
  1146. * @Exportable()
  1147. */
  1148. private $logo;
  1149. /**
  1150. * @Vich\UploadableField(mapping="user_logo", fileNameProperty="logo")
  1151. * @var File
  1152. */
  1153. private $logoFile;
  1154. /**
  1155. * @ORM\ManyToOne(targetEntity=PointOfSale::class, inversedBy="users",fetch="EAGER")
  1156. *
  1157. * @Expose()
  1158. * @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
  1159. */
  1160. private ?PointOfSale $pointOfSale = NULL;
  1161. /**
  1162. * @ORM\ManyToMany(targetEntity=PointOfSale::class, mappedBy="managers")
  1163. */
  1164. private Collection $managedPointOfSales;
  1165. /**
  1166. * @ORM\OneToMany(targetEntity=Parameter::class, mappedBy="userRelated")
  1167. *
  1168. * @Expose()
  1169. * @Groups({"parameter"})
  1170. * @Exportable()
  1171. */
  1172. private Collection $relatedParameters;
  1173. /**
  1174. * @ORM\OneToMany(targetEntity=PointOfSale::class, mappedBy="createdBy")
  1175. *
  1176. * @Exportable()
  1177. */
  1178. private Collection $createdPointOfSales;
  1179. /**
  1180. * @ORM\OneToMany(targetEntity=PointConversionRate::class, mappedBy="owner", orphanRemoval=true)
  1181. *
  1182. * @Exportable()
  1183. */
  1184. private Collection $ownerPointConversionRates;
  1185. /**
  1186. * @ORM\ManyToOne(targetEntity=PointConversionRate::class, inversedBy="users")
  1187. */
  1188. private ?PointConversionRate $pointConversionRate = NULL;
  1189. /**
  1190. * @ORM\Column(type="string", length=255, nullable=true)
  1191. *
  1192. * @Exportable()
  1193. */
  1194. private ?string $fonction = NULL;
  1195. /**
  1196. * @ORM\OneToOne(targetEntity=Regate::class, inversedBy="responsable", cascade={"persist", "remove"},
  1197. * fetch="EXTRA_LAZY")
  1198. *
  1199. * @Expose()
  1200. * @Groups({"user", "export_user_datatable"})
  1201. *
  1202. * @Exportable()
  1203. */
  1204. private ?Regate $responsableRegate = NULL;
  1205. /**
  1206. * @ORM\Column(type="string", length=255, nullable=true)
  1207. *
  1208. * @Exportable()
  1209. */
  1210. private ?string $registrationDocument = NULL;
  1211. /**
  1212. * @Vich\UploadableField(mapping="user_registration_document", fileNameProperty="registrationDocument")
  1213. * @var File
  1214. */
  1215. private $registrationDocumentFile;
  1216. /**
  1217. * @ORM\OneToOne(targetEntity=CoverageArea::class, inversedBy="user", cascade={"persist", "remove"})
  1218. * @ORM\JoinColumn(nullable=true)
  1219. *
  1220. * @Exportable()
  1221. */
  1222. private $coverageArea;
  1223. /**
  1224. * @ORM\OneToMany(targetEntity=QuizUserAnswer::class, mappedBy="user")
  1225. *
  1226. * @Exportable()
  1227. */
  1228. private $quizUserAnswers;
  1229. /**
  1230. * @ORM\OneToMany(targetEntity=IdeaBoxAnswer::class, mappedBy="user")
  1231. *
  1232. * @Expose
  1233. * @Groups({
  1234. * "user:idea_box_answers",
  1235. * "idea_box_list", "idea_box_stats", "export_idea_box_datatable"
  1236. * })
  1237. *
  1238. * @Exportable()
  1239. */
  1240. private Collection $ideaBoxAnswers;
  1241. /**
  1242. * @ORM\OneToMany(targetEntity=IdeaBoxRating::class, mappedBy="user")
  1243. *
  1244. * @Expose
  1245. * @Groups({
  1246. * "user:idea_box_ratings",
  1247. * "idea_box_list", "idea_box_stats", "export_idea_box_datatable"
  1248. * })
  1249. *
  1250. * @Exportable()
  1251. */
  1252. private Collection $ideaBoxRatings;
  1253. /**
  1254. * @ORM\OneToMany(targetEntity=IdeaBoxRecipient::class, mappedBy="user")
  1255. *
  1256. * @Expose
  1257. * @Groups({
  1258. * "user:idea_box_recipients",
  1259. * "idea_box_list", "idea_box_stats", "export_idea_box_datatable"
  1260. * })
  1261. *
  1262. * @Exportable()
  1263. */
  1264. private Collection $ideaBoxRecipients;
  1265. /**
  1266. * @ORM\Column(type="string", length=128, nullable=true)
  1267. */
  1268. private ?string $oldStatus = NULL;
  1269. /**
  1270. * @ORM\Column(type="datetime", nullable=true)
  1271. */
  1272. private ?DateTimeInterface $disabledAt = NULL;
  1273. /**
  1274. * @ORM\Column(type="string", length=255, nullable=true)
  1275. *
  1276. * @Exportable()
  1277. */
  1278. private ?string $archiveReason;
  1279. /**
  1280. * @ORM\Column(type="string", length=255, nullable=true)
  1281. *
  1282. * @Exportable()
  1283. */
  1284. private ?string $unsubscribeReason;
  1285. /**
  1286. * @ORM\OneToMany(targetEntity=ActionLog::class, mappedBy="user")
  1287. *
  1288. * @Expose()
  1289. * @Groups({
  1290. * "user:actionLog",
  1291. * "actionLog"
  1292. * })
  1293. *
  1294. * @Exportable()
  1295. */
  1296. private Collection $actionLogs;
  1297. /**
  1298. * @ORM\Column(type="integer")
  1299. *
  1300. * @Exportable()
  1301. */
  1302. private int $failedAttempts = 0;
  1303. /**
  1304. * @ORM\Column(type="datetime", nullable=true)
  1305. *
  1306. * @Exportable()
  1307. */
  1308. private ?DateTimeInterface $lastFailedAttempt;
  1309. /**
  1310. * @ORM\Column(type="datetime", nullable=true)
  1311. *
  1312. * @Exportable()
  1313. */
  1314. private ?DateTimeInterface $passwordUpdatedAt;
  1315. /**
  1316. * @ORM\OneToMany(targetEntity=PasswordHistory::class, mappedBy="user", orphanRemoval=true, cascade={"persist"})
  1317. */
  1318. private Collection $passwordHistories;
  1319. /**
  1320. * @ORM\OneToMany(targetEntity=UserFavorites::class, mappedBy="user")
  1321. *
  1322. * @Exportable()
  1323. */
  1324. private Collection $userFavorites;
  1325. /**
  1326. * @ORM\Column(type="datetime", nullable=true)
  1327. *
  1328. * @Exportable()
  1329. */
  1330. private ?DateTimeInterface $lastActivity;
  1331. /**
  1332. * Variables pour stocker la valeur avant modification
  1333. * @Expose()
  1334. * @Groups ({"user:post"})
  1335. */
  1336. private ?string $oldEmail = NULL;
  1337. /**
  1338. * @ORM\Column(type="string", length=255, nullable=true)
  1339. *
  1340. * @Expose()
  1341. * @Groups({
  1342. * "default",
  1343. * "user:accountId",
  1344. * "user:post", "user:list","user:item", "cdp", "user",
  1345. * "user_bussiness_result", "user_bussiness_result:user",
  1346. * "export_user_datatable"
  1347. * })
  1348. */
  1349. private ?string $accountId = NULL;
  1350. /**
  1351. * @ORM\Column(type="string", nullable=true, unique=true)
  1352. */
  1353. private ?string $uniqueSlugConstraint = NULL;
  1354. /**
  1355. * @ORM\OneToMany(targetEntity=BoosterProductResult::class, mappedBy="user", orphanRemoval=true)
  1356. */
  1357. private Collection $boosterProductResults;
  1358. /**
  1359. * @ORM\OneToMany(targetEntity=PushSubscription::class, mappedBy="user")
  1360. */
  1361. private Collection $pushSubscriptions;
  1362. /**
  1363. * @ORM\Column(type="string", length=50, nullable=true)
  1364. */
  1365. private ?string $azureId;
  1366. /**
  1367. * @ORM\ManyToMany(targetEntity=AzureGroup::class, mappedBy="members")
  1368. */
  1369. private Collection $azureGroups;
  1370. /**
  1371. * @ORM\ManyToOne(targetEntity=User::class)
  1372. */
  1373. private ?User $activatedBy;
  1374. /**
  1375. * @ORM\OneToMany(targetEntity=QuotaProductUser::class, mappedBy="user", orphanRemoval=true)
  1376. */
  1377. private Collection $quotaProductUsers;
  1378. /**
  1379. * @ORM\OneToMany(targetEntity=RankingScore::class, mappedBy="user")
  1380. */
  1381. private Collection $rankingScores;
  1382. /**
  1383. * @ORM\Column(type="text", length=255, nullable=true)
  1384. *
  1385. * @Exportable()
  1386. */
  1387. private ?string $emailUnsubscribeReason;
  1388. /**
  1389. * @ORM\Column(type="datetime", nullable=true)
  1390. */
  1391. private ?DateTimeInterface $emailUnsubscribedAt;
  1392. public function __construct()
  1393. {
  1394. $this->addresses = new ArrayCollection();
  1395. $this->subAccountUsers = new ArrayCollection();
  1396. $this->carts = new ArrayCollection();
  1397. $this->distributors = new ArrayCollection();
  1398. $this->purchases = new ArrayCollection();
  1399. $this->orders = new ArrayCollection();
  1400. $this->godchilds = new ArrayCollection();
  1401. $this->requestProductAvailables = new ArrayCollection();
  1402. $this->userImportHistories = new ArrayCollection();
  1403. $this->contactLists = new ArrayCollection();
  1404. $this->devis = new ArrayCollection();
  1405. $this->pointTransactions = new ArrayCollection();
  1406. $this->installers = new ArrayCollection();
  1407. $this->heatingInstallers = new ArrayCollection();
  1408. $this->userBusinessResults = new ArrayCollection();
  1409. $this->projects = new ArrayCollection();
  1410. $this->serviceUsers = new ArrayCollection();
  1411. $this->universes = new ArrayCollection();
  1412. $this->scores = new ArrayCollection();
  1413. $this->scoreObjectives = new ArrayCollection();
  1414. $this->children = new ArrayCollection();
  1415. $this->parents = new ArrayCollection();
  1416. $this->requestRegistrationsToValidate = new ArrayCollection();
  1417. $this->customProductOrders = new ArrayCollection();
  1418. $this->extensions = new ArrayCollection();
  1419. $this->managedPointOfSales = new ArrayCollection();
  1420. $this->relatedParameters = new ArrayCollection();
  1421. $this->createdPointOfSales = new ArrayCollection();
  1422. $this->status = self::STATUS_CGU_PENDING;
  1423. $this->ideaBoxAnswers = new ArrayCollection();
  1424. $this->ideaBoxRatings = new ArrayCollection();
  1425. $this->ideaBoxRecipients = new ArrayCollection();
  1426. $this->actionLogs = new ArrayCollection();
  1427. $this->passwordHistories = new ArrayCollection();
  1428. $this->userFavorites = new ArrayCollection();
  1429. $this->boosterProductResults = new ArrayCollection();
  1430. $this->pushSubscriptions = new ArrayCollection();
  1431. $this->azureGroups = new ArrayCollection();
  1432. $this->quotaProductUsers = new ArrayCollection();
  1433. $this->rankingScores = new ArrayCollection();
  1434. }
  1435. private function generateSlug(): void
  1436. {
  1437. $parts = [$this->email, $this->accountId, $this->extension1, $this->extension2];
  1438. $parts = array_filter($parts);
  1439. $this->uniqueSlugConstraint = implode('-', $parts);
  1440. }
  1441. /**
  1442. * @ORM\PreUpdate()
  1443. */
  1444. public function preUpdate(PreUpdateEventArgs $eventArgs): void
  1445. {
  1446. if ($eventArgs->getObject() instanceof User) {
  1447. if ($eventArgs->hasChangedField('email') || $eventArgs->hasChangedField('extension1') || $eventArgs->hasChangedField(
  1448. 'extension2'
  1449. ) || $eventArgs->hasChangedField('accountId')) {
  1450. $this->generateSlug();
  1451. }
  1452. }
  1453. }
  1454. // Typed property App\Entity\User::$email must not be accessed before initialization
  1455. // Modif prePersist() vers postPersist()
  1456. /**
  1457. * @ORM\PostPersist()
  1458. */
  1459. public function postPersist(): void
  1460. {
  1461. $this->generateSlug();
  1462. }
  1463. /**
  1464. * @ORM\PostUpdate()
  1465. */
  1466. public function postUpdate(): void
  1467. {
  1468. $this->oldEmail = NULL;
  1469. }
  1470. public function __toString(): string
  1471. {
  1472. return $this->getFullName();
  1473. }
  1474. /**
  1475. * @Serializer\VirtualProperty
  1476. * @SerializedName("fullName")
  1477. *
  1478. * @Expose()
  1479. * @Groups({"user:full_name","email", "export_order_datatable", "purchase", "service_user",
  1480. * "univers","customProductOrder:list"})
  1481. *
  1482. * @return string
  1483. *
  1484. * @ExportableMethod()
  1485. */
  1486. public function getFullName(): string
  1487. {
  1488. $fullName = trim($this->firstName . ' ' . $this->lastName);
  1489. if (empty($fullName)) {
  1490. return $this->getEmail();
  1491. }
  1492. return $fullName;
  1493. }
  1494. public function getEmail(): ?string
  1495. {
  1496. return $this->email;
  1497. }
  1498. public function setEmail(string $email): User
  1499. {
  1500. $email = trim($email);
  1501. if (isset($this->email)) {
  1502. $this->setOldEmail($this->email);
  1503. } else {
  1504. $this->setOldEmail($email);
  1505. }
  1506. $this->email = $email;
  1507. return $this;
  1508. }
  1509. public function __toArray(): array
  1510. {
  1511. return get_object_vars($this);
  1512. }
  1513. /**
  1514. * ============================================================================================
  1515. * =============================== FONCTIONS CUSTOM ===========================================
  1516. * ============================================================================================
  1517. */
  1518. public function serialize(): string
  1519. {
  1520. return serialize(
  1521. [
  1522. $this->id,
  1523. ],
  1524. );
  1525. }
  1526. public function __serialize(): array
  1527. {
  1528. return [
  1529. 'id' => $this->id,
  1530. 'email' => $this->email,
  1531. 'password' => $this->password,
  1532. 'salt' => $this->salt,
  1533. ];
  1534. }
  1535. public function __unserialize($serialized): void
  1536. {
  1537. $this->id = $serialized[ 'id' ];
  1538. $this->email = $serialized[ 'email' ];
  1539. $this->password = $serialized[ 'password' ];
  1540. $this->salt = $serialized[ 'salt' ];
  1541. }
  1542. /**
  1543. * @Serializer\VirtualProperty()
  1544. * @SerializedName ("unsubscribed")
  1545. *
  1546. * @Expose()
  1547. * @Groups({
  1548. * "user:unsubscribed",
  1549. * "default",
  1550. * "unsubscribed",
  1551. * "user:list", "user:item", "cdp", "user", "export_user_citroentf_datatable", "user_citroentf",
  1552. * "export_user_citroentf_datatable",
  1553. * "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
  1554. * "export_commercial_installer_datatable",
  1555. * "export_commercial_datatable", "export_user_datatable", "export_admin_datatable", "export_installer_datatable"
  1556. * })
  1557. *
  1558. * @return bool
  1559. */
  1560. public function isUnsubscribed(): bool
  1561. {
  1562. return $this->status === self::STATUS_UNSUBSCRIBED;
  1563. }
  1564. /**
  1565. * @Serializer\VirtualProperty()
  1566. * @SerializedName ("enabled")
  1567. *
  1568. * @Expose()
  1569. * @Groups({
  1570. * "user:enabled",
  1571. * "default",
  1572. * "enabled",
  1573. * "user:list", "user:item", "cdp", "user", "export_user_citroentf_datatable", "user_citroentf",
  1574. * "export_user_citroentf_datatable",
  1575. * "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
  1576. * "export_commercial_installer_datatable",
  1577. * "export_commercial_datatable", "export_user_datatable", "export_admin_datatable", "export_installer_datatable"
  1578. * })
  1579. *
  1580. * @return bool
  1581. */
  1582. public function isEnabled(): bool
  1583. {
  1584. return $this->status === self::STATUS_ENABLED;
  1585. }
  1586. /**
  1587. * @Serializer\VirtualProperty()
  1588. * @SerializedName ("disabled")
  1589. *
  1590. * @Expose()
  1591. * @Groups({
  1592. * "user:disabled",
  1593. * "user:list", "user:item", "cdp", "user", "export_user_citroentf_datatable", "user_citroentf",
  1594. * "export_user_citroentf_datatable",
  1595. * "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
  1596. * "export_commercial_installer_datatable",
  1597. * "export_commercial_datatable", "export_user_datatable", "export_admin_datatable", "export_installer_datatable"})
  1598. *
  1599. * @return bool
  1600. */
  1601. public function isDisabled(): bool
  1602. {
  1603. return $this->status === self::STATUS_DISABLED;
  1604. }
  1605. /**
  1606. * @Serializer\VirtualProperty()
  1607. * @SerializedName ("cgu_pending")
  1608. *
  1609. * @Expose()
  1610. * @Groups({
  1611. * "user:cgu_pending",
  1612. * "cgu_pending",
  1613. * "user:list", "user:item", "cdp", "user", "export_user_citroentf_datatable", "user_citroentf",
  1614. * "export_user_citroentf_datatable",
  1615. * "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
  1616. * "export_commercial_installer_datatable",
  1617. * "export_commercial_datatable", "export_user_datatable", "export_admin_datatable", "export_installer_datatable"})
  1618. *
  1619. * @return bool
  1620. */
  1621. public function isCguPending(): bool
  1622. {
  1623. return $this->status === self::STATUS_CGU_PENDING;
  1624. }
  1625. /**
  1626. * @Serializer\VirtualProperty()
  1627. * @SerializedName ("cgu_declined")
  1628. *
  1629. * @Expose()
  1630. * @Groups({
  1631. * "user:cgu_declined",
  1632. * "cgu_declined",
  1633. * "user:list", "user:item", "cdp", "user", "export_user_citroentf_datatable", "user_citroentf",
  1634. * "export_user_citroentf_datatable",
  1635. * "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
  1636. * "export_commercial_installer_datatable",
  1637. * "export_commercial_datatable", "export_user_datatable", "export_admin_datatable", "export_installer_datatable"})
  1638. *
  1639. * @return bool
  1640. */
  1641. public function isCguDeclined(): bool
  1642. {
  1643. return $this->status === self::STATUS_CGU_DECLINED;
  1644. }
  1645. /**
  1646. * @Serializer\VirtualProperty()
  1647. * @SerializedName ("archived")
  1648. *
  1649. * @Expose()
  1650. * @Groups({
  1651. * "user:archived",
  1652. * "default",
  1653. * "is_archived",
  1654. * "user:list", "user:item", "cdp", "user", "export_user_citroentf_datatable", "user_citroentf",
  1655. * "export_user_citroentf_datatable",
  1656. * "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
  1657. * "export_commercial_installer_datatable",
  1658. * "export_commercial_datatable", "export_user_datatable", "export_admin_datatable", "export_installer_datatable"
  1659. * })
  1660. *
  1661. * @return bool
  1662. */
  1663. public function isArchived(): bool
  1664. {
  1665. return $this->status === self::STATUS_ARCHIVED;
  1666. }
  1667. /**
  1668. * @Serializer\VirtualProperty()
  1669. * @SerializedName ("deleted")
  1670. *
  1671. * @Expose()
  1672. * @Groups({
  1673. * "user:deleted",
  1674. * "user:list", "user:item", "cdp", "user", "export_user_citroentf_datatable", "user_citroentf",
  1675. * "export_user_citroentf_datatable",
  1676. * "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
  1677. * "export_commercial_installer_datatable",
  1678. * "export_commercial_datatable", "export_user_datatable", "export_admin_datatable", "export_installer_datatable"})
  1679. *
  1680. * @return bool
  1681. */
  1682. public function isDeleted(): bool
  1683. {
  1684. return $this->status === self::STATUS_DELETED;
  1685. }
  1686. /**
  1687. * @Serializer\VirtualProperty()
  1688. * @SerializedName ("admin_pending")
  1689. *
  1690. * @return bool
  1691. */
  1692. public function isAdminPending(): bool
  1693. {
  1694. return $this->status === self::STATUS_ADMIN_PENDING;
  1695. }
  1696. /**
  1697. * @return bool
  1698. */
  1699. public function isRegisterPending(): bool
  1700. {
  1701. return $this->status === self::STATUS_REGISTER_PENDING;
  1702. }
  1703. public function getUsers()
  1704. {
  1705. return $this->installers;
  1706. }
  1707. /**
  1708. * @Serializer\VirtualProperty()
  1709. * @SerializedName("count_installers")
  1710. *
  1711. * @Expose()
  1712. * @Groups({
  1713. * "user:count_installers"
  1714. * })
  1715. *
  1716. * @return int
  1717. */
  1718. public function countInstallers(): int
  1719. {
  1720. return count($this->installers);
  1721. }
  1722. /**
  1723. * @Serializer\VirtualProperty()
  1724. * @SerializedName("count_commercials")
  1725. *
  1726. * @Expose()
  1727. * @Groups({
  1728. * "user:count_commercials"
  1729. * })
  1730. *
  1731. * @return int
  1732. */
  1733. public function countCommercials(): int
  1734. {
  1735. $commercials = $this->children;
  1736. if (empty($commercials)) {
  1737. return 0;
  1738. }
  1739. foreach ($commercials as $index => $commercial) {
  1740. if (!in_array('ROLE_COMMERCIAL', $commercial->getRoles())) {
  1741. unset($commercials[ $index ]);
  1742. }
  1743. }
  1744. return count($commercials);
  1745. }
  1746. public function getRoles(): ?array
  1747. {
  1748. return $this->roles;
  1749. }
  1750. public function setRoles(array $roles): User
  1751. {
  1752. $this->roles = $roles;
  1753. return $this;
  1754. }
  1755. /**
  1756. * @Serializer\VirtualProperty
  1757. * @SerializedName("preferredEmail")
  1758. *
  1759. * @Expose()
  1760. * @Groups({"email"})
  1761. *
  1762. * @return string
  1763. */
  1764. public function getPreferredEmail(): string
  1765. {
  1766. if($this->getTransactionalEmail()) return $this->getTransactionalEmail();
  1767. if($this->isFakeUser())
  1768. {
  1769. $secondaryEmails = $this->getSecondaryEmails();
  1770. if(!empty($secondaryEmails)) return array_values($secondaryEmails)[0];
  1771. }
  1772. return $this->email;
  1773. }
  1774. public function getTransactionalEmail(): ?string
  1775. {
  1776. return $this->transactionalEmail;
  1777. }
  1778. public function setTransactionalEmail(?string $transactionalEmail): User
  1779. {
  1780. $this->transactionalEmail = $transactionalEmail;
  1781. return $this;
  1782. }
  1783. /**
  1784. * @Serializer\VirtualProperty()
  1785. * @SerializedName ("roleToString")
  1786. *
  1787. * @Expose()
  1788. * @Groups({"export_user_datatable", "export_admin_datatable", "export_user_citroentf_datatable"})
  1789. *
  1790. * @return string
  1791. */
  1792. public function roleToString(): string
  1793. {
  1794. if ($this->isDemo()) {
  1795. return 'Démo';
  1796. }
  1797. if ($this->isInstaller()) {
  1798. return 'Installateur';
  1799. }
  1800. if ($this->isValidation()) {
  1801. return 'Validation';
  1802. }
  1803. if ($this->isUser()) {
  1804. return 'Utilisateur';
  1805. }
  1806. if ($this->isCommercial()) {
  1807. if ($this->isHeatingCommercial()) {
  1808. return 'Commercial chauffage';
  1809. }
  1810. return 'Commercial';
  1811. }
  1812. if ($this->isAgencyManager()) {
  1813. return "Directeur d'agence";
  1814. }
  1815. if ($this->isDtvLogistique()) {
  1816. return "Logistique";
  1817. }
  1818. if ($this->isDtvCommercial()) {
  1819. return "Commercial";
  1820. }
  1821. if ($this->isDtvCompta()) {
  1822. return "Comptabilité";
  1823. }
  1824. if ($this->isDtvCdp()) {
  1825. return "Chef de projet";
  1826. }
  1827. if ($this->isAdmin()) {
  1828. return 'Administrateur';
  1829. }
  1830. if ($this->isSuperAdmin()) {
  1831. return 'Super Administrateur';
  1832. }
  1833. if ($this->isDeveloper()) {
  1834. return 'Développeur';
  1835. }
  1836. return 'Rôle non défini';
  1837. }
  1838. public function isDemo(): bool
  1839. {
  1840. // return in_array('ROLE_DEMO', $this->getRoles(), TRUE);
  1841. return $this->job === 'demo';
  1842. }
  1843. public function isInstaller(): bool
  1844. {
  1845. // return in_array('ROLE_INSTALLER', $this->getRoles(), TRUE);
  1846. return $this->job === 'installer';
  1847. }
  1848. public function isValidation(): bool
  1849. {
  1850. // return in_array('ROLE_VALIDATION', $this->getRoles(), TRUE);
  1851. return $this->job === 'validation';
  1852. }
  1853. public function isUser(): bool
  1854. {
  1855. return in_array('ROLE_USER', $this->getRoles(), TRUE);
  1856. }
  1857. public function isCommercial(): bool
  1858. {
  1859. // return in_array('ROLE_COMMERCIAL', $this->getRoles(), TRUE);
  1860. return $this->job === 'commercial_agent';
  1861. }
  1862. public function isHeatingCommercial(): bool
  1863. {
  1864. return in_array('ROLE_COMMERCIAL', $this->getRoles(), TRUE) && $this->getChauffage();
  1865. }
  1866. public function getChauffage(): ?bool
  1867. {
  1868. return $this->chauffage;
  1869. }
  1870. public function setChauffage(?bool $chauffage): User
  1871. {
  1872. $this->chauffage = $chauffage;
  1873. return $this;
  1874. }
  1875. public function isAgencyManager(): bool
  1876. {
  1877. return in_array('ROLE_AGENCY_MANAGER', $this->getRoles(), TRUE);
  1878. }
  1879. public function isDtvLogistique(): bool
  1880. {
  1881. return in_array('ROLE_DTV_LOGISTIQUE', $this->getRoles(), TRUE);
  1882. }
  1883. public function isDtvCommercial(): bool
  1884. {
  1885. return in_array('ROLE_DTV_COMMERCIAL', $this->getRoles(), TRUE);
  1886. }
  1887. public function isDtvCompta(): bool
  1888. {
  1889. return in_array('ROLE_DTV_COMPTA', $this->getRoles(), TRUE);
  1890. }
  1891. public function isDtvCdp(): bool
  1892. {
  1893. return in_array('ROLE_DTV_CDP', $this->getRoles(), TRUE);
  1894. }
  1895. public function isAdmin(): bool
  1896. {
  1897. return in_array('ROLE_ADMIN', $this->getRoles(), TRUE);
  1898. }
  1899. public function isSuperAdmin(): bool
  1900. {
  1901. return in_array('ROLE_SUPER_ADMIN', $this->getRoles(), TRUE);
  1902. }
  1903. public function isDeveloper(): bool
  1904. {
  1905. return in_array('ROLE_DEVELOPER', $this->getRoles(), TRUE);
  1906. }
  1907. public function isDeveloperOrSuperAdmin(): bool
  1908. {
  1909. return $this->isDeveloper() || $this->isSuperAdmin();
  1910. }
  1911. public function hasOneOfItsRoles(array $roles): bool
  1912. {
  1913. return count(array_intersect($roles, $this->getRoles())) > 0;
  1914. }
  1915. /**
  1916. * @Serializer\VirtualProperty()
  1917. * @SerializedName ("nbrValidatedPurchases")
  1918. *
  1919. * @Expose()
  1920. * @Groups({
  1921. * "user:nbr_validated_purchases",
  1922. * "export_installer_datatable", "export_commercial_installer_datatable"})
  1923. *
  1924. * @return int
  1925. */
  1926. public function getNbrValidatedPurchases(): int
  1927. {
  1928. $nbr = 0;
  1929. /** @var Purchase $purchase */
  1930. foreach ($this->purchases as $purchase) {
  1931. if ((int)$purchase->getStatus() === Purchase::STATUS_VALIDATED) {
  1932. $nbr++;
  1933. }
  1934. }
  1935. return $nbr;
  1936. }
  1937. public function getStatus(): string
  1938. {
  1939. return $this->status;
  1940. }
  1941. public function setStatus(string $status): User
  1942. {
  1943. $this->status = $status;
  1944. return $this;
  1945. }
  1946. /**
  1947. * @Serializer\VirtualProperty()
  1948. * @SerializedName ("nbrPendingPurchases")
  1949. *
  1950. * @Expose()
  1951. * @Groups({"export_installer_datatable", "export_commercial_installer_datatable"})
  1952. *
  1953. * @return int
  1954. */
  1955. public function getNbrPendingPurchases(): int
  1956. {
  1957. $nbr = 0;
  1958. /** @var Purchase $purchase */
  1959. foreach ($this->purchases as $purchase) {
  1960. if ((int)$purchase->getStatus() === Purchase::STATUS_PENDING) {
  1961. $nbr++;
  1962. }
  1963. }
  1964. return $nbr;
  1965. }
  1966. /**
  1967. * @Serializer\VirtualProperty()
  1968. * @SerializedName ("nbrRejectedPurchases")
  1969. *
  1970. * @Expose()
  1971. * @Groups({
  1972. * "user:nbr_rejected_purchases",
  1973. * "export_installer_datatable", "export_commercial_installer_datatable"})
  1974. *
  1975. * @return int
  1976. */
  1977. public function getNbrRejectedPurchases(): int
  1978. {
  1979. $nbr = 0;
  1980. /** @var Purchase $purchase */
  1981. foreach ($this->purchases as $purchase) {
  1982. if ((int)$purchase->getStatus() === Purchase::STATUS_REJECTED) {
  1983. $nbr++;
  1984. }
  1985. }
  1986. return $nbr;
  1987. }
  1988. /**
  1989. * @Serializer\VirtualProperty()
  1990. * @SerializedName ("nbrReturnedPurchases")
  1991. *
  1992. * @Expose()
  1993. * @Groups({
  1994. * "user:nbr_returned_purchases",
  1995. * "export_installer_datatable", "export_commercial_installer_datatable"})
  1996. *
  1997. * @return int
  1998. */
  1999. public function getNbrReturnedPurchases(): int
  2000. {
  2001. $nbr = 0;
  2002. /** @var Purchase $purchase */
  2003. foreach ($this->purchases as $purchase)
  2004. {
  2005. if ((int)$purchase->getStatus() === Purchase::STATUS_RETURNED) {
  2006. $nbr++;
  2007. }
  2008. }
  2009. return $nbr;
  2010. }
  2011. /**
  2012. * Nombre de commandes de l'utilisateur
  2013. *
  2014. * @Serializer\VirtualProperty()
  2015. * @SerializedName ("nbrOrder")
  2016. *
  2017. * @Expose()
  2018. * @Groups({"export_user_datatable", "export_admin_datatable", "export_installer_datatable", "export_commercial_installer_datatable"})
  2019. *
  2020. * @return int
  2021. */
  2022. public function getNbrOrder(): int
  2023. {
  2024. return count($this->orders);
  2025. }
  2026. /**
  2027. * @Serializer\VirtualProperty()
  2028. * @SerializedName ("nbrPurchases")
  2029. *
  2030. * @Expose()
  2031. * @Groups({
  2032. * "user:nbr_purchases",
  2033. * "export_installer_datatable", "export_commercial_installer_datatable"})
  2034. *
  2035. * @return int
  2036. */
  2037. public function getNbrPurchases(): int
  2038. {
  2039. return count($this->purchases);
  2040. }
  2041. /**
  2042. * @Serializer\VirtualProperty()
  2043. * @SerializedName ("has_heating_commercial")
  2044. * @Groups ({
  2045. * "default",
  2046. * "user:has_heating_commercial",
  2047. * "user"
  2048. * })
  2049. */
  2050. public function hasHeatingCommercial()
  2051. {
  2052. return $this->heatingCommercial instanceof User;
  2053. }
  2054. /**
  2055. * @Serializer\VirtualProperty()
  2056. * @SerializedName ("pointDateExpiration")
  2057. *
  2058. * @Expose()
  2059. * @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
  2060. *
  2061. * @return null|string
  2062. */
  2063. public function getPointDateExpiration(): ?string
  2064. {
  2065. return $this->getExtensionBySlug(\App\Constants\UserExtension::POINT_DATE_EXPIRATION);
  2066. }
  2067. /**
  2068. * Retourne la valeur d'une extension depuis son slug
  2069. *
  2070. * @param string $slug
  2071. *
  2072. * @return string|null
  2073. */
  2074. public function getExtensionBySlug(string $slug): ?string
  2075. {
  2076. if (!empty($this->extensions)) {
  2077. foreach ($this->extensions as $extension) {
  2078. if ($extension->getSlug() === $slug) {
  2079. return $extension->getValue();
  2080. }
  2081. }
  2082. }
  2083. return NULL;
  2084. }
  2085. /**
  2086. * @Serializer\VirtualProperty()
  2087. * @SerializedName ("objCa")
  2088. *
  2089. * @Expose()
  2090. * @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
  2091. *
  2092. * @return int
  2093. */
  2094. public function getObjCa(): int
  2095. {
  2096. $value = $this->getExtensionBySlug(\App\Constants\UserExtension::OBJ_CA);
  2097. if ($value === NULL) {
  2098. return 0;
  2099. }
  2100. return intval($value);
  2101. }
  2102. public function setObjCa(?string $value): User
  2103. {
  2104. if ($value === NULL) {
  2105. return $this;
  2106. }
  2107. $this->addExtension(UserExtensionFactory::setObjCa($this, $value));
  2108. return $this;
  2109. }
  2110. public function addExtension(?UserExtension $extension): User
  2111. {
  2112. if ($extension !== NULL && !$this->extensions->contains($extension)) {
  2113. $this->extensions[] = $extension;
  2114. $extension->setUser($this);
  2115. }
  2116. return $this;
  2117. }
  2118. /**
  2119. * @Serializer\VirtualProperty()
  2120. * @SerializedName ("commitment_level")
  2121. *
  2122. * @Expose()
  2123. * @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
  2124. *
  2125. * @return string
  2126. */
  2127. public function getCommitmentLevel(): string
  2128. {
  2129. $value = $this->getExtensionBySlug(\App\Constants\UserExtension::COMMITMENT_LEVEL);
  2130. if ($value === NULL) {
  2131. return '';
  2132. }
  2133. return $value;
  2134. }
  2135. public function setCommitmentLevel(?string $value): User
  2136. {
  2137. if ($value === NULL) {
  2138. return $this;
  2139. }
  2140. $this->addExtension(UserExtensionFactory::setCommitmentLevel($this, $value));
  2141. return $this;
  2142. }
  2143. /**
  2144. * @Serializer\VirtualProperty()
  2145. * @SerializedName ("objPoint")
  2146. *
  2147. * @Expose()
  2148. * @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
  2149. *
  2150. * @return int
  2151. */
  2152. public function getObjPoint(): int
  2153. {
  2154. $value = $this->getExtensionBySlug(\App\Constants\UserExtension::OBJ_POINT);
  2155. if ($value === NULL) {
  2156. return 0;
  2157. }
  2158. return intval($value);
  2159. }
  2160. public function setObjPoint(?string $value): User
  2161. {
  2162. if ($value === NULL) {
  2163. return $this;
  2164. }
  2165. $this->addExtension(UserExtensionFactory::setObjPoint($this, $value));
  2166. return $this;
  2167. }
  2168. /**
  2169. * @Serializer\VirtualProperty()
  2170. * @SerializedName ("language")
  2171. *
  2172. * @Expose()
  2173. * @Groups({ "user:language", "user:item"})
  2174. *
  2175. * @return string|null
  2176. */
  2177. public function getLanguage(): ?string
  2178. {
  2179. return $this->getExtensionBySlug(\App\Constants\UserExtension::LANGUAGE);
  2180. }
  2181. public function setInternalIdentification1(?string $value): User
  2182. {
  2183. if ($value === NULL) {
  2184. return $this;
  2185. }
  2186. $this->addExtension(UserExtensionFactory::setInternalIdentification1($this, $value));
  2187. return $this;
  2188. }
  2189. /**
  2190. * @Serializer\VirtualProperty()
  2191. * @SerializedName ("internalIdentification2")
  2192. *
  2193. * @Expose()
  2194. * @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable", "export_admin_datatable", "sale_order",
  2195. * "export_order_datatable"})
  2196. *
  2197. * @return string|null
  2198. */
  2199. public function getInternalIdentification2(): ?string
  2200. {
  2201. return $this->getExtensionBySlug(\App\Constants\UserExtension::INTERNAL_IDENTIFICATION_2);
  2202. }
  2203. public function setInternalIdentification2(?string $value): User
  2204. {
  2205. if ($value === NULL) {
  2206. return $this;
  2207. }
  2208. $this->addExtension(UserExtensionFactory::setInternalIdentification2($this, $value));
  2209. return $this;
  2210. }
  2211. /**
  2212. * @Serializer\VirtualProperty()
  2213. * @SerializedName ("internalIdentification3")
  2214. *
  2215. * @Expose()
  2216. * @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
  2217. *
  2218. * @return string|null
  2219. */
  2220. public function getInternalIdentification3(): ?string
  2221. {
  2222. return $this->getExtensionBySlug(\App\Constants\UserExtension::INTERNAL_IDENTIFICATION_3);
  2223. }
  2224. public function setInternalIdentification3(?string $value): User
  2225. {
  2226. if ($value === NULL) {
  2227. return $this;
  2228. }
  2229. $this->addExtension(UserExtensionFactory::setInternalIdentification3($this, $value));
  2230. return $this;
  2231. }
  2232. /**
  2233. * @Serializer\VirtualProperty()
  2234. * @SerializedName ("potentialPoints")
  2235. *
  2236. * @Expose
  2237. * @Groups({
  2238. * "user:potentialPoints",
  2239. * "user:list",
  2240. * "user:item", "user", "get:read", "post:read", "export_user_datatable"})
  2241. *
  2242. * @return int|null
  2243. */
  2244. public function getPotentialPoints(): ?int
  2245. {
  2246. return $this->getExtensionBySlug(\App\Constants\UserExtension::POTENTIAL_POINTS);
  2247. }
  2248. /**
  2249. * @param $value
  2250. *
  2251. * @return $this
  2252. */
  2253. public function setPotentialPoints($value): User
  2254. {
  2255. $this->addExtension(UserExtensionFactory::setPotentialPoints($this, (int)$value));
  2256. return $this;
  2257. }
  2258. /**
  2259. * @param int $step
  2260. *
  2261. * @return string|null
  2262. */
  2263. public function getGoalByStep(int $step): ?string
  2264. {
  2265. $slug = \App\Constants\UserExtension::GOAL . '_' . $step;
  2266. return $this->getExtensionBySlug($slug);
  2267. }
  2268. public function setGoalByStep(string $value, int $step): User
  2269. {
  2270. $this->addExtension(UserExtensionFactory::setGoal($this, $value, $step));
  2271. return $this;
  2272. }
  2273. /**
  2274. * @param int $step
  2275. *
  2276. * @return string|null
  2277. */
  2278. public function getBonusPro(int $step): ?string
  2279. {
  2280. $slug = \App\Constants\UserExtension::BONUS_PRO . '_' . $step;
  2281. return $this->getExtensionBySlug($slug);
  2282. }
  2283. public function setBonusPro(?string $value, int $step): User
  2284. {
  2285. if ($value === NULL) {
  2286. return $this;
  2287. }
  2288. $this->addExtension(UserExtensionFactory::setBonusPro($this, $value, $step));
  2289. return $this;
  2290. }
  2291. public function setGoalPoints(?string $value): User
  2292. {
  2293. if ($value === NULL) {
  2294. return $this;
  2295. }
  2296. $this->addExtension(UserExtensionFactory::setGoalPoints($this, $value));
  2297. return $this;
  2298. }
  2299. /**
  2300. * @Serializer\VirtualProperty()
  2301. * @SerializedName ("parent_lvl_1")
  2302. * @Groups ({"user", "point_of_sale"})
  2303. *
  2304. * @return int
  2305. */
  2306. public function getParentLvl1(): int
  2307. {
  2308. // Boucle sur les commerciaux et retourne le premier
  2309. foreach ($this->parents as $parent) {
  2310. return $parent->getId();
  2311. }
  2312. return -1;
  2313. }
  2314. /**
  2315. * ============================================================================================
  2316. * ============================= FIN FONCTIONS CUSTOM =========================================
  2317. * ============================================================================================
  2318. */
  2319. public function getId(): ?int
  2320. {
  2321. return $this->id;
  2322. }
  2323. /**
  2324. * Le setter est obligatoire pour la partie portail lorsqu'on crée un utilisateur non mappé en bdd
  2325. *
  2326. * @param $id
  2327. *
  2328. * @return $this
  2329. */
  2330. public function setId($id): User
  2331. {
  2332. $this->id = $id;
  2333. return $this;
  2334. }
  2335. /**
  2336. * @Serializer\VirtualProperty()
  2337. * @SerializedName ("parent_lvl_1_code")
  2338. *
  2339. * @Expose()
  2340. * @Groups ({"user", "export_user_datatable", "export_admin_datatable", "sale_order", "export_order_datatable",
  2341. * "export_commercial_datatable"})
  2342. *
  2343. * @return string|null
  2344. */
  2345. public function getParentLvl1Code(): ?string
  2346. {
  2347. // Boucle sur les commerciaux et retourne le premier
  2348. foreach ($this->parents as $parent) {
  2349. return $parent->getInternalIdentification1();
  2350. }
  2351. return NULL;
  2352. }
  2353. /**
  2354. * @Serializer\VirtualProperty()
  2355. * @SerializedName ("internalIdentification1")
  2356. *
  2357. * @Expose()
  2358. * @Groups({
  2359. * "user:internal_identification_1",
  2360. * "user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable", "export_admin_datatable", "sale_order",
  2361. * "export_order_datatable",
  2362. * "export_installer_datatable",
  2363. * "export_commercial_datatable","export_agency_manager_datatable"})
  2364. *
  2365. * @return string|null
  2366. */
  2367. public function getInternalIdentification1(): ?string
  2368. {
  2369. return $this->getExtensionBySlug(\App\Constants\UserExtension::INTERNAL_IDENTIFICATION_1);
  2370. }
  2371. /**
  2372. * @Serializer\VirtualProperty()
  2373. * @SerializedName ("parent_lvl_2")
  2374. * @Groups ({"user", "point_of_sale"})
  2375. *
  2376. * @return int
  2377. */
  2378. public function getParentLvl2(): int
  2379. {
  2380. // Boucle sur les commerciaux
  2381. foreach ($this->parents as $parent) {
  2382. // Boucle sur les chefs d'agence et retourne le premier
  2383. foreach ($parent->getParents() as $grandParent) {
  2384. return $grandParent->getId();
  2385. }
  2386. }
  2387. return -1;
  2388. }
  2389. /**
  2390. * @return Collection<int, User>
  2391. */
  2392. public function getParents(): Collection
  2393. {
  2394. return $this->parents;
  2395. }
  2396. /**
  2397. * @Serializer\VirtualProperty()
  2398. * @SerializedName ("parent_lvl_3")
  2399. * @Groups ({"user", "point_of_sale"})
  2400. *
  2401. * @return int
  2402. */
  2403. public function getParentLvl3(): int
  2404. {
  2405. // Boucle sur les commerciaux
  2406. foreach ($this->parents as $parent) {
  2407. // Boucle sur les chefs d'agence et retourne le premier
  2408. foreach ($parent->getParents() as $grandParent) {
  2409. // Boucle sur les admins et retourne le premier
  2410. foreach ($grandParent->getParents() as $ggparent) {
  2411. return $ggparent->getId();
  2412. }
  2413. }
  2414. }
  2415. return -1;
  2416. }
  2417. /**
  2418. * @Serializer\VirtualProperty()
  2419. * @SerializedName ("pointOfSaleOfClient")
  2420. * @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
  2421. *
  2422. * @return string|null
  2423. */
  2424. public function getPointOfSaleOfClient(): ?string
  2425. {
  2426. // Boucle sur les commerciaux
  2427. if (!empty($this->parents)) {
  2428. foreach ($this->parents as $parent) {
  2429. if ($parent->getPointOfSale() !== NULL) {
  2430. return $parent->getPointOfSale()->getCode();
  2431. } else {
  2432. return NULL;
  2433. }
  2434. }
  2435. }
  2436. return NULL;
  2437. }
  2438. public function getPointOfSale(): ?PointOfSale
  2439. {
  2440. return $this->pointOfSale;
  2441. }
  2442. public function setPointOfSale(?PointOfSale $pointOfSale): User
  2443. {
  2444. $this->pointOfSale = $pointOfSale;
  2445. return $this;
  2446. }
  2447. /**
  2448. * @Serializer\VirtualProperty()
  2449. * @SerializedName ("pointOfSaleOfCommercial")
  2450. * @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
  2451. *
  2452. * @return string|null
  2453. */
  2454. public function getPointOfSaleOfCommercial(): ?string
  2455. {
  2456. // Boucle sur les commerciaux
  2457. if ($this->getPointOfSale() !== NULL) {
  2458. return $this->getPointOfSale()->getCode();
  2459. } else {
  2460. return NULL;
  2461. }
  2462. }
  2463. /**
  2464. * Retourne la date d'adhésion du client s'il en a une
  2465. *
  2466. * @Serializer\VirtualProperty()
  2467. * @SerializedName ("subscribedAt")
  2468. * @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
  2469. *
  2470. * @return string
  2471. */
  2472. public function getSubscribedAt(): string
  2473. {
  2474. if ($this->subscription instanceof UserSubscription) {
  2475. return $this->subscription->getSubscribedAt()->format('d/m/Y');
  2476. }
  2477. return '';
  2478. }
  2479. /**
  2480. * Retourne le label de la catégorie du taux de conversion des points
  2481. *
  2482. * @Serializer\VirtualProperty()
  2483. * @SerializedName ("pointConvertionRateLabel")
  2484. * @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
  2485. *
  2486. * @return string
  2487. */
  2488. public function getPointConvertionRateLabel(): string
  2489. {
  2490. if ($this->pointConversionRate instanceof PointConversionRate) {
  2491. return $this->pointConversionRate->getLabel();
  2492. }
  2493. return '';
  2494. }
  2495. public function getNameCiv(): string
  2496. {
  2497. return trim($this->getCivility() . ' ' . trim($this->lastName . " " . $this->firstName));
  2498. }
  2499. public function getCivility(): ?string
  2500. {
  2501. return $this->civility;
  2502. }
  2503. public function setCivility(?string $civility): User
  2504. {
  2505. $this->civility = $civility;
  2506. return $this;
  2507. }
  2508. /*
  2509. * ============================================================================================
  2510. * ============================== FIN FONCTIONS CUSTOM ========================================
  2511. * ============================================================================================
  2512. */
  2513. public function getCivCode(): int
  2514. {
  2515. if ($this->getCivility() == 'M.') {
  2516. return 0;
  2517. } elseif ($this->getCivility() == 'Mme') {
  2518. return 1;
  2519. } else {
  2520. return 2;
  2521. }
  2522. }
  2523. /**
  2524. * @return void
  2525. * @deprecated
  2526. */
  2527. public function setActive()
  2528. {
  2529. $this->deletedAt = NULL;
  2530. $this->archivedAt = NULL;
  2531. }
  2532. public function isPurchaseAuthorized(): bool
  2533. {
  2534. return in_array('ROLE_INSTALLER', $this->getRoles()) || in_array('ROLE_SUPER_ADMIN', $this->getRoles());
  2535. }
  2536. public function getBillingAddresses()
  2537. {
  2538. return $this->getAddressByType(Address::TYPE_BILLING_ADDRESS);
  2539. }
  2540. /**
  2541. * @param $type
  2542. *
  2543. * @return Collection
  2544. */
  2545. private function getAddressByType($type)
  2546. {
  2547. $shippingAddress = new ArrayCollection();
  2548. foreach ($this->getAddresses() as $address) {
  2549. if ($address->getAddressType() == $type) {
  2550. $shippingAddress->add($address);
  2551. }
  2552. }
  2553. return $shippingAddress;
  2554. }
  2555. /**
  2556. * @return Collection|Address[]
  2557. */
  2558. public function getAddresses(): Collection
  2559. {
  2560. return $this->addresses;
  2561. }
  2562. /**
  2563. * @return DateTimeInterface|null
  2564. * @deprecated
  2565. */
  2566. public function getLevel1UpdatedAt(): ?DateTimeInterface
  2567. {
  2568. return $this->level1UpdatedAt;
  2569. }
  2570. /**
  2571. * @param DateTimeInterface|null $level1UpdatedAt
  2572. *
  2573. * @return $this
  2574. * @deprecated
  2575. */
  2576. public function setLevel1UpdatedAt(?DateTimeInterface $level1UpdatedAt): User
  2577. {
  2578. $this->level1UpdatedAt = $level1UpdatedAt;
  2579. return $this;
  2580. }
  2581. /**
  2582. * @return DateTimeInterface|null
  2583. * @deprecated
  2584. */
  2585. public function getLevel2UpdatedAt(): ?DateTimeInterface
  2586. {
  2587. return $this->level2UpdatedAt;
  2588. }
  2589. /**
  2590. * @param DateTimeInterface|null $level2UpdatedAt
  2591. *
  2592. * @return $this
  2593. * @deprecated
  2594. */
  2595. public function setLevel2UpdatedAt(?DateTimeInterface $level2UpdatedAt): User
  2596. {
  2597. $this->level2UpdatedAt = $level2UpdatedAt;
  2598. return $this;
  2599. }
  2600. /**
  2601. * @Serializer\VirtualProperty
  2602. * @SerializedName("name")
  2603. * @Groups({
  2604. * "user:name",
  2605. * "export_installer_datatable", "export_purchase_declaration_datatable",
  2606. * "export_agency_manager_commercial_datatable",
  2607. * "export_commercial_installer_datatable"})
  2608. *
  2609. * @return string
  2610. */
  2611. public function getName(): string
  2612. {
  2613. return $this->lastName . " " . $this->firstName;
  2614. }
  2615. /**
  2616. * @Serializer\VirtualProperty()
  2617. * @SerializedName("codeDep")
  2618. * @Expose()
  2619. * @Groups({
  2620. * "user:code_dep",
  2621. * "export_installer_datatable", "export_commercial_installer_datatable"})
  2622. *
  2623. * @return false|string|null
  2624. */
  2625. public function getCodeDep()
  2626. {
  2627. return $this->getPostcode() !== NULL ? substr($this->getPostcode(), 0, 2) : NULL;
  2628. }
  2629. public function getPostcode(): ?string
  2630. {
  2631. return $this->postcode;
  2632. }
  2633. public function setPostcode(?string $postcode): User
  2634. {
  2635. $this->postcode = $postcode;
  2636. return $this;
  2637. }
  2638. /**
  2639. * @return Collection|Address[]
  2640. */
  2641. public function getShippingAddresses()
  2642. {
  2643. return $this->getAddressByType(Address::TYPE_SHIPPING_ADDRESS);
  2644. }
  2645. /**
  2646. * @return Address|null
  2647. */
  2648. public function getPreferredShippingAddress(): ?Address
  2649. {
  2650. foreach($this->getShippingAddresses() as $address)
  2651. {
  2652. if($address->getPreferred()) return $address;
  2653. }
  2654. return null;
  2655. }
  2656. /**
  2657. * GARDER POUR LA SSO
  2658. *
  2659. * @return string
  2660. */
  2661. public function getUsername(): string
  2662. {
  2663. return (string)$this->email;
  2664. }
  2665. /**
  2666. * @return string
  2667. */
  2668. public function getRawUsername(): string
  2669. {
  2670. return (string)$this->username;
  2671. }
  2672. /**
  2673. * @param string|null $username
  2674. *
  2675. * @return $this
  2676. * @deprecated
  2677. */
  2678. public function setUsername(?string $username): User
  2679. {
  2680. $this->username = $username;
  2681. return $this;
  2682. }
  2683. /**
  2684. * GARDER POUR LA SSO
  2685. *
  2686. * @return string
  2687. */
  2688. public function getUserIdentifier(): string
  2689. {
  2690. return (string)$this->email;
  2691. }
  2692. public function isDex(): bool
  2693. {
  2694. return TRUE;
  2695. }
  2696. public function getWelcomeEmail(): ?DateTimeInterface
  2697. {
  2698. return $this->welcomeEmail;
  2699. }
  2700. public function setWelcomeEmail(?DateTimeInterface $welcomeEmail): User
  2701. {
  2702. $this->welcomeEmail = $welcomeEmail;
  2703. return $this;
  2704. }
  2705. public function getAccountAddress(): string
  2706. {
  2707. return trim($this->address1 . ' ' . $this->address2) . ' ' . $this->postcode . ' ' . $this->city;
  2708. }
  2709. public function eraseCredentials()
  2710. {
  2711. // If you store any temporary, sensitive data on the user, clear it here
  2712. $this->plainPassword = NULL;
  2713. }
  2714. public function generateAndSetPassword()
  2715. {
  2716. $pwd = substr(str_shuffle('23456789QWERTYUPASDFGHJKLZXCVBNM'), 0, 12);
  2717. $this->setPassword($pwd);
  2718. return $pwd;
  2719. }
  2720. public function getOldEmail(): ?string
  2721. {
  2722. return $this->oldEmail;
  2723. }
  2724. public function setOldEmail(?string $oldEmail): void
  2725. {
  2726. if(is_string($oldEmail)) $oldEmail = trim($oldEmail);
  2727. $this->oldEmail = $oldEmail;
  2728. }
  2729. public function getPassword(): ?string
  2730. {
  2731. return $this->password;
  2732. }
  2733. public function setPassword(string $password): User
  2734. {
  2735. // Chaque fois que le mot de passe est modifié, mettre à jour la date
  2736. // et remettre à 0 le compteur d'essai
  2737. $this->passwordUpdatedAt = new DateTime();
  2738. $this->setFailedAttempts(0);
  2739. $this->password = $password;
  2740. return $this;
  2741. }
  2742. public function getSalt(): ?string
  2743. {
  2744. return $this->salt;
  2745. }
  2746. public function setSalt(?string $salt): User
  2747. {
  2748. $this->salt = $salt;
  2749. return $this;
  2750. }
  2751. public function getPlainPassword(): ?string
  2752. {
  2753. return $this->plainPassword;
  2754. }
  2755. public function setPlainPassword($plainPassword): User
  2756. {
  2757. // Ajout de l'ancien mot de passe dans l'historique
  2758. if ($plainPassword !== NULL) {
  2759. $passwordHistory = new PasswordHistory();
  2760. $passwordHistory->setUser($this);
  2761. $passwordHistory->setHashedPassword(md5($plainPassword));
  2762. $this->passwordHistories[] = $passwordHistory;
  2763. }
  2764. $this->plainPassword = $plainPassword;
  2765. return $this;
  2766. }
  2767. public function getFirstName(): ?string
  2768. {
  2769. return $this->firstName;
  2770. }
  2771. public function setFirstName(?string $firstName): User
  2772. {
  2773. if($firstName) $firstName = ucfirst(strtolower(trim($firstName)));
  2774. $this->firstName = $firstName;
  2775. return $this;
  2776. }
  2777. public function getLastName(): ?string
  2778. {
  2779. return $this->lastName;
  2780. }
  2781. public function setLastName(?string $lastName): User
  2782. {
  2783. if($lastName) $lastName = strtoupper(trim($lastName));
  2784. $this->lastName = $lastName;
  2785. return $this;
  2786. }
  2787. public function getMobile(): ?string
  2788. {
  2789. if(!$this->mobile) return null;
  2790. $mobile = str_replace(['-', '/', '.', ' '], '-', $this->mobile);
  2791. $re = '/^(?:(?:(?:\+|00)33[ ]?(?:\(0\)[ ]?)?)|0){1}[1-9]{1}([ .-]?)(?:\d{2}\1?){3}\d{2}$/m';
  2792. preg_match_all($re, '0' . $mobile, $matches, PREG_SET_ORDER);
  2793. if (!empty($matches)) {
  2794. $mobile = '0' . $mobile;
  2795. }
  2796. return $mobile;
  2797. }
  2798. public function setMobile(?string $mobile): User
  2799. {
  2800. $this->mobile = $mobile;
  2801. return $this;
  2802. }
  2803. public function getPhone(): ?string
  2804. {
  2805. if(!$this->phone) return null;
  2806. $phone = str_replace(['-', '/', '.', ' '], '-', $this->phone);
  2807. $re = '/^(?:(?:(?:\+|00)33[ ]?(?:\(0\)[ ]?)?)|0){1}[1-9]{1}([ .-]?)(?:\d{2}\1?){3}\d{2}$/m';
  2808. preg_match_all($re, '0' . $phone, $matches, PREG_SET_ORDER);
  2809. if (!empty($matches)) {
  2810. $phone = '0' . $phone;
  2811. }
  2812. return $phone;
  2813. }
  2814. public function setPhone(?string $phone): User
  2815. {
  2816. $this->phone = $phone;
  2817. return $this;
  2818. }
  2819. /**
  2820. * @return int|null
  2821. * @deprecated
  2822. */
  2823. public function getAvailablePoint(): ?int
  2824. {
  2825. return $this->availablePoint;
  2826. }
  2827. /**
  2828. * @param int $availablePoint
  2829. *
  2830. * @return $this
  2831. * @deprecated
  2832. */
  2833. public function setAvailablePoint(int $availablePoint): User
  2834. {
  2835. $this->availablePoint = $availablePoint;
  2836. return $this;
  2837. }
  2838. /**
  2839. * @return int|null
  2840. * @deprecated
  2841. */
  2842. public function getPotentialPoint(): ?int
  2843. {
  2844. return $this->potentialPoint;
  2845. }
  2846. /**
  2847. * @param int $potentialPoint
  2848. *
  2849. * @return $this
  2850. * @deprecated
  2851. */
  2852. public function setPotentialPoint(int $potentialPoint): User
  2853. {
  2854. $this->potentialPoint = $potentialPoint;
  2855. return $this;
  2856. }
  2857. /**
  2858. * @return string|null
  2859. * @deprecated
  2860. */
  2861. public function getLocale(): ?string
  2862. {
  2863. return $this->locale;
  2864. }
  2865. /**
  2866. * @param string|null $locale
  2867. *
  2868. * @return $this
  2869. * @deprecated
  2870. */
  2871. public function setLocale(?string $locale): User
  2872. {
  2873. $this->locale = $locale;
  2874. return $this;
  2875. }
  2876. public function getCountry(): ?Country
  2877. {
  2878. return $this->country;
  2879. }
  2880. public function setCountry(?Country $country): User
  2881. {
  2882. $this->country = $country;
  2883. return $this;
  2884. }
  2885. public function getJob(): ?string
  2886. {
  2887. if ($this->job === '') {
  2888. return NULL;
  2889. }
  2890. return $this->job;
  2891. }
  2892. public function setJob(?string $job): User
  2893. {
  2894. $this->job = $job;
  2895. return $this;
  2896. }
  2897. public function getCompany(): ?string
  2898. {
  2899. return $this->company;
  2900. }
  2901. public function setCompany(?string $company): User
  2902. {
  2903. $this->company = $company;
  2904. return $this;
  2905. }
  2906. /**
  2907. * @deprecated
  2908. */
  2909. public function getUserToken(): ?string
  2910. {
  2911. return $this->userToken;
  2912. }
  2913. /**
  2914. * @deprecated
  2915. */
  2916. public function setUserToken(?string $userToken): User
  2917. {
  2918. $this->userToken = $userToken;
  2919. return $this;
  2920. }
  2921. /**
  2922. * @deprecated
  2923. */
  2924. public function getUserTokenValidity(): ?DateTimeInterface
  2925. {
  2926. return $this->userTokenValidity;
  2927. }
  2928. /**
  2929. * @deprecated
  2930. */
  2931. public function setUserTokenValidity(?DateTimeInterface $userTokenValidity): User
  2932. {
  2933. $this->userTokenValidity = $userTokenValidity;
  2934. return $this;
  2935. }
  2936. /**
  2937. * @deprecated
  2938. */
  2939. public function getUserTokenAttempts(): ?int
  2940. {
  2941. return $this->userTokenAttempts;
  2942. }
  2943. /**
  2944. * @deprecated
  2945. */
  2946. public function setUserTokenAttempts(int $userTokenAttempts): User
  2947. {
  2948. $this->userTokenAttempts = $userTokenAttempts;
  2949. return $this;
  2950. }
  2951. public function getAddress1(): ?string
  2952. {
  2953. return $this->address1;
  2954. }
  2955. public function setAddress1(?string $address1): User
  2956. {
  2957. $this->address1 = $address1;
  2958. return $this;
  2959. }
  2960. public function getAddress2(): ?string
  2961. {
  2962. return $this->address2;
  2963. }
  2964. public function setAddress2(?string $address2): User
  2965. {
  2966. $this->address2 = $address2;
  2967. return $this;
  2968. }
  2969. // /**
  2970. // * @Serializer\VirtualProperty()
  2971. // * @SerializedName ("birthDate")
  2972. // * @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
  2973. // *
  2974. // *
  2975. // * @return DateTimeInterface|null
  2976. // */
  2977. // public function getBirthDate(): ?DateTimeInterface
  2978. // {
  2979. // try {
  2980. // return new DateTime( $this->getExtensionBySlug( \App\Constants\UserExtension::BIRTH_DATE ) );
  2981. // }
  2982. // catch ( Exception $e ) {
  2983. // return NULL;
  2984. // }
  2985. // }
  2986. public function getCity(): ?string
  2987. {
  2988. return $this->city;
  2989. }
  2990. public function setCity(?string $city): User
  2991. {
  2992. $this->city = $city;
  2993. return $this;
  2994. }
  2995. public function getCanOrder(): ?bool
  2996. {
  2997. return $this->canOrder;
  2998. }
  2999. public function setCanOrder(?bool $canOrder): User
  3000. {
  3001. $this->canOrder = $canOrder;
  3002. return $this;
  3003. }
  3004. public function getDeletedAt(): ?DateTimeInterface
  3005. {
  3006. return $this->deletedAt;
  3007. }
  3008. public function setDeletedAt(?DateTimeInterface $deletedAt): User
  3009. {
  3010. $this->deletedAt = $deletedAt;
  3011. return $this;
  3012. }
  3013. /**
  3014. * @Serializer\VirtualProperty()
  3015. * @SerializedName ("birthDate")
  3016. * @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
  3017. *
  3018. *
  3019. * @return DateTimeInterface|null
  3020. */
  3021. public function getBirthDate(): ?DateTimeInterface
  3022. {
  3023. try {
  3024. return new DateTime($this->getExtensionBySlug(\App\Constants\UserExtension::BIRTH_DATE));
  3025. } catch (Exception $e) {
  3026. return NULL;
  3027. }
  3028. }
  3029. /**
  3030. * @throws Exception
  3031. */
  3032. public function setBirthDate($value): User
  3033. {
  3034. if ($value === NULL) {
  3035. return $this;
  3036. }
  3037. if ($value instanceof DateTimeInterface) {
  3038. $value = $value->format('Y-m-d');
  3039. }
  3040. $this->addExtension(UserExtensionFactory::setBirthDate($this, $value));
  3041. return $this;
  3042. }
  3043. public function getBirthCity(): ?string
  3044. {
  3045. return $this->getExtensionBySlug(\App\Constants\UserExtension::BIRTH_CITY);
  3046. }
  3047. public function setBirthCity(?string $value): User
  3048. {
  3049. if ($value === NULL) {
  3050. return $this;
  3051. }
  3052. $this->addExtension(UserExtensionFactory::setBirthCity($this, $value));
  3053. return $this;
  3054. }
  3055. public function getSocialSecurityNumber(): ?string
  3056. {
  3057. return $this->getExtensionBySlug(\App\Constants\UserExtension::SOCIAL_SECURITY_NUMBER);
  3058. }
  3059. public function setSocialSecurityNumber(?string $value): User
  3060. {
  3061. if ($value === NULL) {
  3062. return $this;
  3063. }
  3064. $this->addExtension(UserExtensionFactory::setSocialSecurityNbr($this, $value));
  3065. return $this;
  3066. }
  3067. /**
  3068. * @return array
  3069. */
  3070. public function getSecondaryEmails(): array
  3071. {
  3072. $emails = $this->getExtensionBySlug(\App\Constants\UserExtension::SECONDARY_EMAILS);
  3073. if(empty($emails)) return [];
  3074. return json_decode($emails, true);
  3075. }
  3076. /**
  3077. * @param array $emails
  3078. *
  3079. * @return $this
  3080. */
  3081. public function setSecondaryEmails(array $emails): User
  3082. {
  3083. $val = [];
  3084. foreach($emails as $email)
  3085. {
  3086. $email = trim(strtolower($email));
  3087. if(!filter_var($email, FILTER_VALIDATE_EMAIL)) throw new \InvalidArgumentException('email invalide');
  3088. $val[] = $email;
  3089. }
  3090. $this->addExtension(UserExtensionFactory::setSecondaryEmails($this, json_encode($val)));
  3091. return $this;
  3092. }
  3093. /**
  3094. * @param string $email
  3095. *
  3096. * @return $this
  3097. */
  3098. public function addSecondaryEmail(string $email): User
  3099. {
  3100. $email = trim(strtolower($email));
  3101. if(!filter_var($email, FILTER_VALIDATE_EMAIL)) throw new \InvalidArgumentException("email ($email) invalide");
  3102. $emails = $this->getSecondaryEmails();
  3103. if(!in_array($email, $emails))
  3104. {
  3105. $emails[] = $email;
  3106. $this->addExtension(UserExtensionFactory::setSecondaryEmails($this, json_encode($emails)));
  3107. }
  3108. return $this;
  3109. }
  3110. /**
  3111. * @param string $email
  3112. *
  3113. * @return $this
  3114. */
  3115. public function removeSecondaryEmail(string $email): User
  3116. {
  3117. $email = trim(strtolower($email));
  3118. $emails = $this->getSecondaryEmails();
  3119. $key = array_search($email, $emails);
  3120. if($key)
  3121. {
  3122. unset($emails[$key]);
  3123. $this->addExtension(UserExtensionFactory::setSecondaryEmails($this, json_encode($emails)));
  3124. }
  3125. return $this;
  3126. }
  3127. public function getInternalCode(): ?string
  3128. {
  3129. return $this->internalCode;
  3130. }
  3131. public function setInternalCode(?string $internalCode): User
  3132. {
  3133. $this->internalCode = $internalCode;
  3134. return $this;
  3135. }
  3136. public function getCguAt(): ?DateTimeInterface
  3137. {
  3138. return $this->cguAt;
  3139. }
  3140. public function setCguAt(?DateTimeInterface $cguAt): User
  3141. {
  3142. $this->cguAt = $cguAt;
  3143. return $this;
  3144. }
  3145. public function getRegisterAt(): ?DateTimeInterface
  3146. {
  3147. return $this->registerAt;
  3148. }
  3149. public function setRegisterAt(?DateTimeInterface $registerAt): User
  3150. {
  3151. $this->registerAt = $registerAt;
  3152. return $this;
  3153. }
  3154. public function getImportedAt(): ?DateTimeInterface
  3155. {
  3156. return $this->importedAt;
  3157. }
  3158. public function setImportedAt(?DateTimeInterface $importedAt): User
  3159. {
  3160. $this->importedAt = $importedAt;
  3161. return $this;
  3162. }
  3163. public function getCanBeContacted(): ?bool
  3164. {
  3165. return $this->canBeContacted;
  3166. }
  3167. public function setCanBeContacted(bool $canBeContacted): User
  3168. {
  3169. $this->canBeContacted = $canBeContacted;
  3170. return $this;
  3171. }
  3172. /**
  3173. * @deprecated
  3174. */
  3175. public function getCapacity(): ?string
  3176. {
  3177. return $this->capacity;
  3178. }
  3179. /**
  3180. * @deprecated
  3181. */
  3182. public function setCapacity(?string $capacity): User
  3183. {
  3184. $this->capacity = $capacity;
  3185. return $this;
  3186. }
  3187. public function getAddress3(): ?string
  3188. {
  3189. return $this->address3;
  3190. }
  3191. public function setAddress3(?string $address3): User
  3192. {
  3193. $this->address3 = $address3;
  3194. return $this;
  3195. }
  3196. public function getOptinMail(): ?bool
  3197. {
  3198. return $this->optinMail;
  3199. }
  3200. public function setOptinMail(bool $optinMail): User
  3201. {
  3202. $this->optinMail = $optinMail;
  3203. return $this;
  3204. }
  3205. public function getOptinSMS(): ?bool
  3206. {
  3207. return $this->optinSMS;
  3208. }
  3209. public function setOptinSMS(bool $optinSMS): User
  3210. {
  3211. $this->optinSMS = $optinSMS;
  3212. return $this;
  3213. }
  3214. public function getOptinPostal(): ?bool
  3215. {
  3216. return $this->optinPostal;
  3217. }
  3218. public function setOptinPostal(bool $optinPostal): User
  3219. {
  3220. $this->optinPostal = $optinPostal;
  3221. return $this;
  3222. }
  3223. public function getOptinPostalAddress(): ?string
  3224. {
  3225. return $this->optinPostalAddress;
  3226. }
  3227. public function setOptinPostalAddress(?string $optinPostalAddress): User
  3228. {
  3229. $this->optinPostalAddress = $optinPostalAddress;
  3230. return $this;
  3231. }
  3232. public function getSource(): ?string
  3233. {
  3234. return $this->source;
  3235. }
  3236. public function setSource(?string $source): User
  3237. {
  3238. $this->source = $source;
  3239. return $this;
  3240. }
  3241. /**
  3242. * @return int|null
  3243. * @deprecated {@see UserPointService::getLevel()}
  3244. */
  3245. public function getLevel(): ?int
  3246. {
  3247. return $this->level;
  3248. }
  3249. /**
  3250. * @param int $level
  3251. *
  3252. * @return $this
  3253. * @deprecated
  3254. */
  3255. public function setLevel(int $level): User
  3256. {
  3257. $this->level = $level;
  3258. return $this;
  3259. }
  3260. /**
  3261. * @return DateTimeInterface|null
  3262. * @deprecated
  3263. */
  3264. public function getLevel0UpdatedAt(): ?DateTimeInterface
  3265. {
  3266. return $this->level0UpdatedAt;
  3267. }
  3268. /**
  3269. * @param DateTimeInterface|null $level0UpdatedAt
  3270. *
  3271. * @return $this
  3272. * @deprecated
  3273. */
  3274. public function setLevel0UpdatedAt(?DateTimeInterface $level0UpdatedAt): User
  3275. {
  3276. $this->level0UpdatedAt = $level0UpdatedAt;
  3277. return $this;
  3278. }
  3279. public function getLevel3UpdatedAt(): ?DateTimeInterface
  3280. {
  3281. return $this->level3UpdatedAt;
  3282. }
  3283. /**
  3284. * @param DateTimeInterface|null $level3UpdatedAt
  3285. *
  3286. * @return $this
  3287. * @deprecated
  3288. */
  3289. public function setLevel3UpdatedAt(?DateTimeInterface $level3UpdatedAt): User
  3290. {
  3291. $this->level3UpdatedAt = $level3UpdatedAt;
  3292. return $this;
  3293. }
  3294. /**
  3295. * @return DateTimeInterface|null
  3296. * @deprecated
  3297. */
  3298. public function getLevelUpdateSeenAt(): ?DateTimeInterface
  3299. {
  3300. return $this->levelUpdateSeenAt;
  3301. }
  3302. /**
  3303. * @param DateTimeInterface|null $levelUpdateSeenAt
  3304. *
  3305. * @return $this
  3306. * @deprecated
  3307. */
  3308. public function setLevelUpdateSeenAt(?DateTimeInterface $levelUpdateSeenAt): User
  3309. {
  3310. $this->levelUpdateSeenAt = $levelUpdateSeenAt;
  3311. return $this;
  3312. }
  3313. /**
  3314. * @return bool|null
  3315. */
  3316. public function getIsEmailOk(): ?bool
  3317. {
  3318. return $this->isEmailOk;
  3319. }
  3320. /**
  3321. * @param bool $isEmailOk
  3322. *
  3323. * @return $this
  3324. */
  3325. public function setIsEmailOk(bool $isEmailOk): User
  3326. {
  3327. $this->isEmailOk = $isEmailOk;
  3328. return $this;
  3329. }
  3330. /**
  3331. * @return DateTimeInterface|null
  3332. */
  3333. public function getLastEmailCheck(): ?DateTimeInterface
  3334. {
  3335. return $this->lastEmailCheck;
  3336. }
  3337. /**
  3338. * @param DateTimeInterface|null $lastEmailCheck
  3339. *
  3340. * @return $this
  3341. */
  3342. public function setLastEmailCheck(?DateTimeInterface $lastEmailCheck): User
  3343. {
  3344. $this->lastEmailCheck = $lastEmailCheck;
  3345. return $this;
  3346. }
  3347. /**
  3348. * @return string|null
  3349. * @deprecated
  3350. */
  3351. public function getApiToken(): ?string
  3352. {
  3353. return $this->apiToken;
  3354. }
  3355. /**
  3356. * @param string|null $apiToken
  3357. *
  3358. * @return $this
  3359. * @deprecated
  3360. */
  3361. public function setApiToken(?string $apiToken): User
  3362. {
  3363. $this->apiToken = $apiToken;
  3364. return $this;
  3365. }
  3366. public function getSapDistributor(): ?string
  3367. {
  3368. return $this->sapDistributor;
  3369. }
  3370. public function setSapDistributor(?string $sapDistributor): User
  3371. {
  3372. $this->sapDistributor = $sapDistributor;
  3373. return $this;
  3374. }
  3375. public function getDistributor(): ?string
  3376. {
  3377. return $this->distributor;
  3378. }
  3379. public function setDistributor(?string $distributor): User
  3380. {
  3381. $this->distributor = $distributor;
  3382. return $this;
  3383. }
  3384. public function getDistributor2(): ?string
  3385. {
  3386. return $this->distributor2;
  3387. }
  3388. public function setDistributor2(?string $distributor2): User
  3389. {
  3390. $this->distributor2 = $distributor2;
  3391. return $this;
  3392. }
  3393. public function getAggreement(): ?bool
  3394. {
  3395. return $this->aggreement;
  3396. }
  3397. public function setAggreement(?bool $aggreement): User
  3398. {
  3399. $this->aggreement = $aggreement;
  3400. return $this;
  3401. }
  3402. public function getUnsubscribedAt(): ?DateTimeInterface
  3403. {
  3404. return $this->unsubscribedAt;
  3405. }
  3406. public function setUnsubscribedAt(?DateTimeInterface $unsubscribedAt): User
  3407. {
  3408. $this->unsubscribedAt = $unsubscribedAt;
  3409. return $this;
  3410. }
  3411. public function addAddress(Address $address): User
  3412. {
  3413. if (!$this->addresses->contains($address)) {
  3414. $this->addresses->add($address);
  3415. $user = $address->getUser();
  3416. if($user) $user->removeAddress($address);
  3417. $address->setUser($this);
  3418. }
  3419. return $this;
  3420. }
  3421. public function removeAddress(Address $address): User
  3422. {
  3423. if ($this->addresses->removeElement($address)) {
  3424. // set the owning side to null (unless already changed)
  3425. if ($address->getUser() === $this) {
  3426. $address->setUser(NULL);
  3427. }
  3428. }
  3429. return $this;
  3430. }
  3431. public function getCarts(): Collection
  3432. {
  3433. return $this->carts;
  3434. }
  3435. public function addCart(Cart $cart): User
  3436. {
  3437. if (!$this->carts->contains($cart)) {
  3438. $this->carts[] = $cart;
  3439. $cart->setUser($this);
  3440. }
  3441. return $this;
  3442. }
  3443. public function removeCart(Cart $cart): User
  3444. {
  3445. if ($this->carts->removeElement($cart)) {
  3446. // set the owning side to null (unless already changed)
  3447. if ($cart->getUser() === $this) {
  3448. $cart->setUser(NULL);
  3449. }
  3450. }
  3451. return $this;
  3452. }
  3453. public function getSapAccount(): ?string
  3454. {
  3455. return $this->sapAccount;
  3456. }
  3457. public function setSapAccount(?string $sapAccount): User
  3458. {
  3459. $this->sapAccount = $sapAccount;
  3460. return $this;
  3461. }
  3462. /**
  3463. * @return User|null
  3464. */
  3465. public function getMainAccountUser(): ?User
  3466. {
  3467. return $this->mainAccountUser;
  3468. }
  3469. /**
  3470. * @param User|null $mainAccountUser
  3471. *
  3472. * @return $this
  3473. */
  3474. public function setMainAccountUser(?User $mainAccountUser = null, bool $setSubAccountUser = true): User
  3475. {
  3476. if($setSubAccountUser)
  3477. {
  3478. if($mainAccountUser) {
  3479. $mainAccountUser->addSubAccountUser($this, false);
  3480. }
  3481. elseif($this->mainAccountUser) {
  3482. $this->mainAccountUser->removeSubAccountUser($this, false);
  3483. }
  3484. }
  3485. $this->mainAccountUser = $mainAccountUser;
  3486. return $this;
  3487. }
  3488. /**
  3489. * @return Collection|User[]
  3490. */
  3491. public function getSubAccountUsers(): Collection
  3492. {
  3493. $subAccountUsers = clone $this->subAccountUsers;
  3494. $subAccountUsers->removeElement($this);
  3495. return $subAccountUsers;
  3496. }
  3497. /**
  3498. * @param iterable|User[] $subAccountUsers
  3499. *
  3500. * @return User
  3501. */
  3502. public function setSubAccountUsers(iterable $subAccountUsers, bool $setMainAccountUser = true): User
  3503. {
  3504. foreach($this->subAccountUsers as $subAccountUser) {
  3505. $this->removeSubAccountUser($subAccountUser, $setMainAccountUser);
  3506. }
  3507. foreach($subAccountUsers as $subAccountUser) {
  3508. $this->addSubAccountUser($subAccountUser, $setMainAccountUser);
  3509. }
  3510. return $this;
  3511. }
  3512. /**
  3513. * @param User $subAccountUser
  3514. * @param bool $setMainAccountUser
  3515. *
  3516. * @return $this
  3517. */
  3518. public function addSubAccountUser(User $subAccountUser, bool $setMainAccountUser = true): User
  3519. {
  3520. if(!$this->subAccountUsers->contains($subAccountUser))
  3521. {
  3522. $this->subAccountUsers->add($subAccountUser);
  3523. if($setMainAccountUser) $subAccountUser->setMainAccountUser($this, false);
  3524. }
  3525. return $this;
  3526. }
  3527. /**
  3528. * @param User $subAccountUser
  3529. * @param bool $setMainAccountUser
  3530. *
  3531. * @return User
  3532. */
  3533. public function removeSubAccountUser(User $subAccountUser, bool $setMainAccountUser = true): User
  3534. {
  3535. if($this->subAccountUsers->contains($subAccountUser))
  3536. {
  3537. $this->subAccountUsers->removeElement($subAccountUser);
  3538. if($setMainAccountUser) $subAccountUser->setMainAccountUser(null, false);
  3539. }
  3540. return $this;
  3541. }
  3542. public function getDistributors(): Collection
  3543. {
  3544. return $this->distributors;
  3545. }
  3546. public function addDistributor(Distributor $distributor): User
  3547. {
  3548. if (!$this->distributors->contains($distributor)) {
  3549. $this->distributors[] = $distributor;
  3550. }
  3551. return $this;
  3552. }
  3553. public function removeDistributor(Distributor $distributor): User
  3554. {
  3555. $this->distributors->removeElement($distributor);
  3556. return $this;
  3557. }
  3558. public function getPurchases(): Collection
  3559. {
  3560. return $this->purchases;
  3561. }
  3562. public function addPurchase(Purchase $purchase): User
  3563. {
  3564. if (!$this->purchases->contains($purchase)) {
  3565. $this->purchases[] = $purchase;
  3566. $purchase->setValidator($this);
  3567. }
  3568. return $this;
  3569. }
  3570. public function removePurchase(Purchase $purchase): User
  3571. {
  3572. if ($this->purchases->removeElement($purchase)) {
  3573. // set the owning side to null (unless already changed)
  3574. if ($purchase->getValidator() === $this) {
  3575. $purchase->setValidator(NULL);
  3576. }
  3577. }
  3578. return $this;
  3579. }
  3580. public function getPurchasesIHaveProcessed(): Collection
  3581. {
  3582. return $this->purchasesIHaveProcessed;
  3583. }
  3584. public function addPurchaseIHaveProcessed(Purchase $purchasesIHaveProcessed): User
  3585. {
  3586. if (!$this->purchasesIHaveProcessed->contains($purchasesIHaveProcessed)) {
  3587. $this->purchasesIHaveProcessed[] = $purchasesIHaveProcessed;
  3588. $purchasesIHaveProcessed->setValidator($this);
  3589. }
  3590. return $this;
  3591. }
  3592. public function removePurchaseIHaveProcessed(Purchase $purchasesIHaveProcessed): User
  3593. {
  3594. if ($this->purchasesIHaveProcessed->removeElement($purchasesIHaveProcessed)) {
  3595. // set the owning side to null (unless already changed)
  3596. if ($purchasesIHaveProcessed->getValidator() === $this) {
  3597. $purchasesIHaveProcessed->setValidator(NULL);
  3598. }
  3599. }
  3600. return $this;
  3601. }
  3602. /**
  3603. * @param array|null $status
  3604. *
  3605. * @return Collection|SaleOrder[]
  3606. */
  3607. public function getOrders(?array $status = null): Collection
  3608. {
  3609. if(empty($status)) return $this->orders;
  3610. $orders = new ArrayCollection();
  3611. foreach($this->orders as $order)
  3612. {
  3613. if(in_array($order->getStatus(), $status)) $orders->add($order);
  3614. }
  3615. return $orders;
  3616. }
  3617. public function addOrder(SaleOrder $order): User
  3618. {
  3619. if (!$this->orders->contains($order))
  3620. {
  3621. $this->orders->add($order);
  3622. $user = $order->getUser();
  3623. if($user) $user->removeOrder($order);
  3624. $order->setUser($this);
  3625. }
  3626. return $this;
  3627. }
  3628. public function removeOrder(SaleOrder $order): User
  3629. {
  3630. if ($this->orders->removeElement($order)) {
  3631. // set the owning side to null (unless already changed)
  3632. if ($order->getUser() === $this) {
  3633. $order->setUser(NULL);
  3634. }
  3635. }
  3636. return $this;
  3637. }
  3638. /**
  3639. * @return Collection|User[]
  3640. */
  3641. public function getGodchilds(): Collection
  3642. {
  3643. return $this->godchilds;
  3644. }
  3645. /**
  3646. * @param User $godchild
  3647. *
  3648. * @return $this
  3649. */
  3650. public function addGodchild(User $godchild, bool $setGodFather = true): User
  3651. {
  3652. if(!$this->godchilds->contains($godchild))
  3653. {
  3654. $this->godchilds->add($godchild);
  3655. if($setGodFather) $godchild->setGodfather($this, false);
  3656. }
  3657. return $this;
  3658. }
  3659. /**
  3660. * @param User $godchild
  3661. *
  3662. * @return $this
  3663. */
  3664. public function removeGodchild(User $godchild, bool $setGodFather = true): User
  3665. {
  3666. if($this->godchilds->removeElement($godchild) && $setGodFather)
  3667. {
  3668. $godchild->setGodfather(null, false);
  3669. }
  3670. return $this;
  3671. }
  3672. /**
  3673. * @return User
  3674. */
  3675. public function getGodfather(): ?User
  3676. {
  3677. return $this->godfather;
  3678. }
  3679. /**
  3680. * @param User|null $godfather
  3681. *
  3682. * @return $this
  3683. */
  3684. public function setGodfather(?User $godfather = null, bool $updateGodchild = true): User
  3685. {
  3686. if($this->godfather !== $godfather)
  3687. {
  3688. if($updateGodchild && $this->godfather) $this->godfather->removeGodchild($this, false);
  3689. if($updateGodchild && $godfather) $godfather->addGodchild($this, false);
  3690. $this->godfather = $godfather;
  3691. }
  3692. return $this;
  3693. }
  3694. public function isGodFather(): bool
  3695. {
  3696. return !$this->godchilds->isEmpty();
  3697. }
  3698. public function isGodChild(): bool
  3699. {
  3700. return $this->godfather !== null;
  3701. }
  3702. /**
  3703. * @deprecated
  3704. */
  3705. public function getSatisfactions(): Collection
  3706. {
  3707. return $this->satisfactions;
  3708. }
  3709. /**
  3710. * @deprecated
  3711. */
  3712. public function addSatisfaction(Satisfaction $satisfaction): User
  3713. {
  3714. if (!$this->satisfactions->contains($satisfaction)) {
  3715. $this->satisfactions[] = $satisfaction;
  3716. $satisfaction->setUser($this);
  3717. }
  3718. return $this;
  3719. }
  3720. /**
  3721. * @deprecated
  3722. */
  3723. public function removeSatisfaction(Satisfaction $satisfaction): User
  3724. {
  3725. if ($this->satisfactions->removeElement($satisfaction)) {
  3726. // set the owning side to null (unless already changed)
  3727. if ($satisfaction->getUser() === $this) {
  3728. $satisfaction->setUser(NULL);
  3729. }
  3730. }
  3731. return $this;
  3732. }
  3733. public function getRequestProductAvailables(): Collection
  3734. {
  3735. return $this->requestProductAvailables;
  3736. }
  3737. public function addRequestProductAvailable(RequestProductAvailable $requestProductAvailable): User
  3738. {
  3739. if (!$this->requestProductAvailables->contains($requestProductAvailable)) {
  3740. $this->requestProductAvailables[] = $requestProductAvailable;
  3741. $requestProductAvailable->setUser($this);
  3742. }
  3743. return $this;
  3744. }
  3745. public function removeRequestProductAvailable(RequestProductAvailable $requestProductAvailable): User
  3746. {
  3747. if ($this->requestProductAvailables->removeElement($requestProductAvailable)) {
  3748. // set the owning side to null (unless already changed)
  3749. if ($requestProductAvailable->getUser() === $this) {
  3750. $requestProductAvailable->setUser(NULL);
  3751. }
  3752. }
  3753. return $this;
  3754. }
  3755. public function getUserImportHistories(): Collection
  3756. {
  3757. return $this->userImportHistories;
  3758. }
  3759. public function addUserImportHistory(UserImportHistory $userImportHistory): User
  3760. {
  3761. if (!$this->userImportHistories->contains($userImportHistory)) {
  3762. $this->userImportHistories[] = $userImportHistory;
  3763. $userImportHistory->setImporter($this);
  3764. }
  3765. return $this;
  3766. }
  3767. public function removeUserImportHistory(UserImportHistory $userImportHistory): User
  3768. {
  3769. if ($this->userImportHistories->removeElement($userImportHistory)) {
  3770. // set the owning side to null (unless already changed)
  3771. if ($userImportHistory->getImporter() === $this) {
  3772. $userImportHistory->setImporter(NULL);
  3773. }
  3774. }
  3775. return $this;
  3776. }
  3777. public function getContactLists(): Collection
  3778. {
  3779. return $this->contactLists;
  3780. }
  3781. public function addContactList(ContactList $contactList): User
  3782. {
  3783. if (!$this->contactLists->contains($contactList)) {
  3784. $this->contactLists[] = $contactList;
  3785. $contactList->addUser($this);
  3786. }
  3787. return $this;
  3788. }
  3789. public function removeContactList(ContactList $contactList): User
  3790. {
  3791. if ($this->contactLists->removeElement($contactList)) {
  3792. $contactList->removeUser($this);
  3793. }
  3794. return $this;
  3795. }
  3796. /**
  3797. * @deprecated
  3798. */
  3799. public function getUsernameCanonical(): ?string
  3800. {
  3801. return $this->usernameCanonical;
  3802. }
  3803. /**
  3804. * @deprecated
  3805. */
  3806. public function setUsernameCanonical(?string $usernameCanonical): User
  3807. {
  3808. $this->usernameCanonical = $usernameCanonical;
  3809. return $this;
  3810. }
  3811. /**
  3812. * @deprecated
  3813. */
  3814. public function getEmailCanonical(): ?string
  3815. {
  3816. return $this->emailCanonical;
  3817. }
  3818. /**
  3819. * @deprecated
  3820. */
  3821. public function setEmailCanonical(?string $emailCanonical): User
  3822. {
  3823. $this->emailCanonical = $emailCanonical;
  3824. return $this;
  3825. }
  3826. public function getLastLogin(): ?DateTimeInterface
  3827. {
  3828. return $this->lastLogin;
  3829. }
  3830. public function setLastLogin(?DateTimeInterface $lastLogin): User
  3831. {
  3832. $this->lastLogin = $lastLogin;
  3833. return $this;
  3834. }
  3835. public function getConfirmationToken(): ?string
  3836. {
  3837. return $this->confirmationToken;
  3838. }
  3839. public function setConfirmationToken(?string $confirmationToken): User
  3840. {
  3841. $this->confirmationToken = $confirmationToken;
  3842. return $this;
  3843. }
  3844. public function getPasswordRequestedAt(): ?DateTimeInterface
  3845. {
  3846. return $this->passwordRequestedAt;
  3847. }
  3848. public function setPasswordRequestedAt(?DateTimeInterface $passwordRequestedAt): User
  3849. {
  3850. $this->passwordRequestedAt = $passwordRequestedAt;
  3851. return $this;
  3852. }
  3853. public function getCredentialExpired(): ?bool
  3854. {
  3855. return $this->credentialExpired;
  3856. }
  3857. public function setCredentialExpired(?bool $credentialExpired): User
  3858. {
  3859. $this->credentialExpired = $credentialExpired;
  3860. return $this;
  3861. }
  3862. public function getCredentialExpiredAt(): ?DateTimeInterface
  3863. {
  3864. return $this->credentialExpiredAt;
  3865. }
  3866. public function setCredentialExpiredAt(?DateTimeInterface $credentialExpiredAt): User
  3867. {
  3868. $this->credentialExpiredAt = $credentialExpiredAt;
  3869. return $this;
  3870. }
  3871. public function getDevis(): Collection
  3872. {
  3873. return $this->devis;
  3874. }
  3875. public function addDevi(Devis $devi): User
  3876. {
  3877. if (!$this->devis->contains($devi)) {
  3878. $this->devis[] = $devi;
  3879. $devi->setUser($this);
  3880. }
  3881. return $this;
  3882. }
  3883. public function removeDevi(Devis $devi): User
  3884. {
  3885. if ($this->devis->removeElement($devi)) {
  3886. // set the owning side to null (unless already changed)
  3887. if ($devi->getUser() === $this) {
  3888. $devi->setUser(NULL);
  3889. }
  3890. }
  3891. return $this;
  3892. }
  3893. public function __call($name, $arguments)
  3894. {
  3895. // TODO: Implement @method string getUserIdentifier()
  3896. }
  3897. public function getRegateName(): string
  3898. {
  3899. if($this->regate) {
  3900. return $this->regate->getName();
  3901. }
  3902. return "";
  3903. }
  3904. public function getRegateAffectation(): string
  3905. {
  3906. if($this->regate) {
  3907. return $this->regate->getAffectation();
  3908. }
  3909. return "";
  3910. }
  3911. public function getRegate(): ?Regate
  3912. {
  3913. return $this->regate;
  3914. }
  3915. public function setRegate(?Regate $regate): User
  3916. {
  3917. $this->regate = $regate;
  3918. return $this;
  3919. }
  3920. public function getDonneesPersonnelles(): ?bool
  3921. {
  3922. return $this->donneesPersonnelles;
  3923. }
  3924. public function setDonneesPersonnelles(?bool $donneesPersonnelles): User
  3925. {
  3926. $this->donneesPersonnelles = $donneesPersonnelles;
  3927. return $this;
  3928. }
  3929. /**
  3930. * @param PointTransactionType|string|null $type
  3931. * @param bool $sortByExpiration
  3932. *
  3933. * @return Collection|PointTransaction[]
  3934. * @throws Exception
  3935. */
  3936. public function getPointTransactions($type = null, bool $sortByExpiration = false): Collection
  3937. {
  3938. if(!$type && !$sortByExpiration) return $this->pointTransactions;
  3939. $points = clone $this->pointTransactions;
  3940. if($type)
  3941. {
  3942. $points = new ArrayCollection();
  3943. foreach($this->getPointTransactions() as $pointTransaction)
  3944. {
  3945. $pointTransactionType = $pointTransaction->getTransactionType();
  3946. if(!$pointTransactionType) continue;
  3947. if($pointTransactionType === $type || $pointTransactionType->getSlug() === $type) $points->add($pointTransaction);
  3948. }
  3949. }
  3950. if($sortByExpiration)
  3951. {
  3952. $iterator = $points->getIterator();
  3953. $iterator->uasort(function($a, $b) {
  3954. $AexpiredAt = $a->getExpiredAt();
  3955. $BexpiredAt = $b->getExpiredAt();
  3956. if($AexpiredAt && $BexpiredAt) return ($AexpiredAt < $BexpiredAt) ? - 1 : 1;
  3957. if(!$AexpiredAt) return 1;
  3958. return -1;
  3959. });
  3960. $points = new ArrayCollection(iterator_to_array($iterator));
  3961. }
  3962. return $points;
  3963. }
  3964. /**
  3965. * @param PointTransactionType|null $type
  3966. * @return float
  3967. * @throws Exception
  3968. */
  3969. public function getTotalPointTransactions(?PointTransactionType $type = null): float
  3970. {
  3971. $total = 0;
  3972. foreach($this->getPointTransactions($type) as $pointTransaction)
  3973. {
  3974. $total += $pointTransaction->getValue();
  3975. }
  3976. return $total;
  3977. }
  3978. /**
  3979. * @param PointTransaction $pointTransaction
  3980. * @return $this
  3981. */
  3982. public function addPointTransaction(PointTransaction $pointTransaction): User
  3983. {
  3984. if (!$this->pointTransactions->contains($pointTransaction))
  3985. {
  3986. $user = $pointTransaction->getUser();
  3987. if($user) $user->removePointTransaction($pointTransaction);
  3988. $this->pointTransactions->add($pointTransaction);
  3989. $pointTransaction->setUser($this);
  3990. }
  3991. return $this;
  3992. }
  3993. public function removePointTransaction(PointTransaction $pointTransaction): User
  3994. {
  3995. if ($this->pointTransactions->removeElement($pointTransaction)) {
  3996. // set the owning side to null (unless already changed)
  3997. if ($pointTransaction->getUser() === $this) {
  3998. $pointTransaction->setUser(NULL);
  3999. }
  4000. }
  4001. return $this;
  4002. }
  4003. /**
  4004. * @return Collection|User[]
  4005. */
  4006. public function getInstallers(): Collection
  4007. {
  4008. return $this->installers;
  4009. }
  4010. public function addInstaller(User $installer): User
  4011. {
  4012. if (!$this->installers->contains($installer)) {
  4013. $this->installers[] = $installer;
  4014. $installer->setCommercial($this);
  4015. }
  4016. return $this;
  4017. }
  4018. public function removeInstaller(User $installer): User
  4019. {
  4020. if ($this->installers->removeElement($installer)) {
  4021. // set the owning side to null (unless already changed)
  4022. if ($installer->getCommercial() === $this) {
  4023. $installer->setCommercial(NULL);
  4024. }
  4025. }
  4026. return $this;
  4027. }
  4028. public function getCommercial(): ?User
  4029. {
  4030. return $this->commercial;
  4031. }
  4032. public function setCommercial(?User $commercial): User
  4033. {
  4034. $this->commercial = $commercial;
  4035. return $this;
  4036. }
  4037. /**
  4038. * @return Collection|User[]
  4039. */
  4040. public function getHeatingInstallers(): Collection
  4041. {
  4042. return $this->heatingInstallers;
  4043. }
  4044. public function addHeatingInstaller(User $heatingInstaller): User
  4045. {
  4046. if (!$this->heatingInstallers->contains($heatingInstaller)) {
  4047. $this->heatingInstallers[] = $heatingInstaller;
  4048. $heatingInstaller->setHeatingCommercial($this);
  4049. }
  4050. return $this;
  4051. }
  4052. public function removeHeatingInstaller(User $heatingInstaller): User
  4053. {
  4054. if ($this->heatingInstallers->removeElement($heatingInstaller)) {
  4055. // set the owning side to null (unless already changed)
  4056. if ($heatingInstaller->getHeatingCommercial() === $this) {
  4057. $heatingInstaller->setHeatingCommercial(NULL);
  4058. }
  4059. }
  4060. return $this;
  4061. }
  4062. public function getHeatingCommercial(): ?User
  4063. {
  4064. return $this->heatingCommercial;
  4065. }
  4066. public function setHeatingCommercial(?User $heatingCommercial): User
  4067. {
  4068. $this->heatingCommercial = $heatingCommercial;
  4069. return $this;
  4070. }
  4071. public function getAgency(): ?Agence
  4072. {
  4073. return $this->agency;
  4074. }
  4075. public function setAgency(?Agence $agency): User
  4076. {
  4077. $this->agency = $agency;
  4078. return $this;
  4079. }
  4080. public function getArchivedAt(): ?DateTimeInterface
  4081. {
  4082. return $this->archivedAt;
  4083. }
  4084. public function setArchivedAt(?DateTimeInterface $archivedAt): User
  4085. {
  4086. $this->archivedAt = $archivedAt;
  4087. return $this;
  4088. }
  4089. public function getNewsletter(): ?bool
  4090. {
  4091. return $this->newsletter;
  4092. }
  4093. public function setNewsletter(bool $newsletter): User
  4094. {
  4095. $this->newsletter = $newsletter;
  4096. return $this;
  4097. }
  4098. public function getCompanySiret(): ?string
  4099. {
  4100. return $this->companySiret;
  4101. }
  4102. public function setCompanySiret(?string $companySiret): User
  4103. {
  4104. $this->companySiret = $companySiret;
  4105. return $this;
  4106. }
  4107. /**
  4108. * @var bool $getCurrent highlight à null
  4109. * @var bool $getPrevious highlight non null
  4110. * @var bool $sum retourne un integer avec la somme des résultats
  4111. * @var int|null $highlight highlight spécifique
  4112. * @return Collection|UserBusinessResult[]|int
  4113. */
  4114. public function getUserBusinessResults(bool $getCurrent = false, bool $getPrevious = false, bool $sum = false, ?int $highlight = null)
  4115. {
  4116. if(!$getCurrent && !$getPrevious && !$sum && !$highlight) return $this->userBusinessResults;
  4117. $userBusinessResults = $sum ? 0 : new ArrayCollection();
  4118. foreach($this->userBusinessResults as $userBusinessResult)
  4119. {
  4120. if((!$getCurrent && !$getPrevious && !$highlight) || (($getCurrent && $userBusinessResult->getHighlight() === null) || ($getPrevious && $userBusinessResult->getHighlight() !== null) || ($highlight && $userBusinessResult->getHighlight() == $highlight)))
  4121. {
  4122. $sum ? $userBusinessResults += $userBusinessResult->getSale() : $userBusinessResults->add($userBusinessResult);
  4123. }
  4124. }
  4125. return $userBusinessResults;
  4126. }
  4127. public function getTotalUserBusinessResults(): int
  4128. {
  4129. $total = 0;
  4130. foreach($this->userBusinessResults as $userBusinessResult)
  4131. {
  4132. $total += $userBusinessResult->getSale();
  4133. }
  4134. return $total;
  4135. }
  4136. public function addUserBusinessResult(UserBusinessResult $userBusinessResult): User
  4137. {
  4138. if(!$this->userBusinessResults->contains($userBusinessResult))
  4139. {
  4140. $this->userBusinessResults->add($userBusinessResult);
  4141. $user = $userBusinessResult->getUser();
  4142. if($user) $user->removeUserBusinessResult($userBusinessResult);
  4143. $userBusinessResult->setUser($this);
  4144. }
  4145. return $this;
  4146. }
  4147. public function removeUserBusinessResult(UserBusinessResult $userBusinessResult): User
  4148. {
  4149. if ($this->userBusinessResults->removeElement($userBusinessResult)) {
  4150. // set the owning side to null (unless already changed)
  4151. if ($userBusinessResult->getUser() === $this) {
  4152. $userBusinessResult->setUser(NULL);
  4153. }
  4154. }
  4155. return $this;
  4156. }
  4157. public function getExtension1(): ?string
  4158. {
  4159. return $this->extension1;
  4160. }
  4161. public function setExtension1(?string $extension1): User
  4162. {
  4163. $this->extension1 = $extension1;
  4164. return $this;
  4165. }
  4166. public function getExtension2(): ?string
  4167. {
  4168. return $this->extension2;
  4169. }
  4170. public function setExtension2(?string $extension2): User
  4171. {
  4172. $this->extension2 = $extension2;
  4173. return $this;
  4174. }
  4175. public function getWdg(): ?int
  4176. {
  4177. return $this->wdg;
  4178. }
  4179. public function setWdg(?int $wdg): User
  4180. {
  4181. $this->wdg = $wdg;
  4182. return $this;
  4183. }
  4184. public function getGladyUuid(): ?string
  4185. {
  4186. return $this->gladyUuid;
  4187. }
  4188. public function setGladyUuid(?string $gladyUuid): User
  4189. {
  4190. $this->gladyUuid = $gladyUuid;
  4191. return $this;
  4192. }
  4193. public function getCoverageArea(): ?CoverageArea
  4194. {
  4195. return $this->coverageArea;
  4196. }
  4197. public function setCoverageArea(?CoverageArea $coverageArea): User
  4198. {
  4199. $this->coverageArea = $coverageArea;
  4200. $coverageArea->setUser($this);
  4201. return $this;
  4202. }
  4203. /**
  4204. * @return Collection<int, Project>
  4205. */
  4206. public function getProjects(): Collection
  4207. {
  4208. return $this->projects;
  4209. }
  4210. public function addProject(Project $project): User
  4211. {
  4212. if (!$this->projects->contains($project)) {
  4213. $this->projects[] = $project;
  4214. $project->setReferent($this);
  4215. }
  4216. return $this;
  4217. }
  4218. public function removeProject(Project $project): User
  4219. {
  4220. if ($this->projects->removeElement($project)) {
  4221. // set the owning side to null (unless already changed)
  4222. if ($project->getReferent() === $this) {
  4223. $project->setReferent(NULL);
  4224. }
  4225. }
  4226. return $this;
  4227. }
  4228. public function getProgramme(): ?Programme
  4229. {
  4230. return $this->programme;
  4231. }
  4232. public function setProgramme(?Programme $programme): User
  4233. {
  4234. $this->programme = $programme;
  4235. return $this;
  4236. }
  4237. /**
  4238. * @return Collection<int, ServiceUser>
  4239. */
  4240. public function getServiceUsers(): Collection
  4241. {
  4242. return $this->serviceUsers;
  4243. }
  4244. public function addServiceUser(ServiceUser $serviceUser): User
  4245. {
  4246. if (!$this->serviceUsers->contains($serviceUser)) {
  4247. $this->serviceUsers[] = $serviceUser;
  4248. $serviceUser->setUser($this);
  4249. }
  4250. return $this;
  4251. }
  4252. public function removeServiceUser(ServiceUser $serviceUser): User
  4253. {
  4254. if ($this->serviceUsers->removeElement($serviceUser)) {
  4255. // set the owning side to null (unless already changed)
  4256. if ($serviceUser->getUser() === $this) {
  4257. $serviceUser->setUser(NULL);
  4258. }
  4259. }
  4260. return $this;
  4261. }
  4262. public function getSaleOrderValidation(): ?SaleOrderValidation
  4263. {
  4264. return $this->saleOrderValidation;
  4265. }
  4266. public function setSaleOrderValidation(?SaleOrderValidation $saleOrderValidation): User
  4267. {
  4268. $this->saleOrderValidation = $saleOrderValidation;
  4269. return $this;
  4270. }
  4271. /**
  4272. * @return Collection<int, Univers>
  4273. */
  4274. public function getUniverses(): Collection
  4275. {
  4276. return $this->universes;
  4277. }
  4278. public function addUnivers(Univers $univers): User
  4279. {
  4280. if (!$this->universes->contains($univers)) {
  4281. $this->universes[] = $univers;
  4282. $univers->addUser($this);
  4283. }
  4284. return $this;
  4285. }
  4286. public function removeUniverses(Univers $universes): User
  4287. {
  4288. if ($this->universes->removeElement($universes)) {
  4289. $universes->removeUser($this);
  4290. }
  4291. return $this;
  4292. }
  4293. public function getBillingPoint(): ?BillingPoint
  4294. {
  4295. return $this->billingPoint;
  4296. }
  4297. public function setBillingPoint(?BillingPoint $billingPoint): User
  4298. {
  4299. $this->billingPoint = $billingPoint;
  4300. return $this;
  4301. }
  4302. /**
  4303. * @return Collection<int, Score>
  4304. */
  4305. public function getScores(): Collection
  4306. {
  4307. return $this->scores;
  4308. }
  4309. public function addScore(Score $score): User
  4310. {
  4311. if (!$this->scores->contains($score)) {
  4312. $this->scores[] = $score;
  4313. $score->setUser($this);
  4314. }
  4315. return $this;
  4316. }
  4317. public function removeScore(Score $score): User
  4318. {
  4319. if ($this->scores->removeElement($score)) {
  4320. // set the owning side to null (unless already changed)
  4321. if ($score->getUser() === $this) {
  4322. $score->setUser(NULL);
  4323. }
  4324. }
  4325. return $this;
  4326. }
  4327. /**
  4328. * @return Collection<int, ScoreObjective>
  4329. */
  4330. public function getScoreObjectives(): Collection
  4331. {
  4332. return $this->scoreObjectives;
  4333. }
  4334. public function addScoreObjective(ScoreObjective $scoreObjective): User
  4335. {
  4336. if (!$this->scoreObjectives->contains($scoreObjective)) {
  4337. $this->scoreObjectives[] = $scoreObjective;
  4338. $scoreObjective->setUser($this);
  4339. }
  4340. return $this;
  4341. }
  4342. public function removeScoreObjective(ScoreObjective $scoreObjective): User
  4343. {
  4344. if ($this->scoreObjectives->removeElement($scoreObjective)) {
  4345. // set the owning side to null (unless already changed)
  4346. if ($scoreObjective->getUser() === $this) {
  4347. $scoreObjective->setUser(NULL);
  4348. }
  4349. }
  4350. return $this;
  4351. }
  4352. /**
  4353. * @return Collection<int, User>
  4354. */
  4355. public function getChildren(): Collection
  4356. {
  4357. return $this->children;
  4358. }
  4359. /**
  4360. * @param User|null $child
  4361. *
  4362. * @return $this
  4363. */
  4364. public function addChild(?User $child): User
  4365. {
  4366. if ($child && !$this->children->contains($child)) {
  4367. $this->children[] = $child;
  4368. $child->addParent($this);
  4369. }
  4370. return $this;
  4371. }
  4372. /**
  4373. * @param User|null $parent
  4374. *
  4375. * @return $this
  4376. */
  4377. public function addParent(?User $parent): User
  4378. {
  4379. if ($parent && !$this->parents->contains($parent)) {
  4380. $this->parents[] = $parent;
  4381. $parent->addChild($this);
  4382. }
  4383. return $this;
  4384. }
  4385. public function removeParent(User $parent): User
  4386. {
  4387. if ($this->parents->removeElement($parent)) {
  4388. $parent->removeChild($this);
  4389. $this->removeParent($parent);
  4390. }
  4391. return $this;
  4392. }
  4393. public function removeChild(User $child): User
  4394. {
  4395. $this->children->removeElement($child);
  4396. return $this;
  4397. }
  4398. /**
  4399. * @return Collection<int, Message>
  4400. */
  4401. public function getSenderMessages(): Collection
  4402. {
  4403. return $this->senderMessages;
  4404. }
  4405. public function addSenderMessage(Message $senderMessage): User
  4406. {
  4407. if (!$this->senderMessages->contains($senderMessage)) {
  4408. $this->senderMessages[] = $senderMessage;
  4409. $senderMessage->setSender($this);
  4410. }
  4411. return $this;
  4412. }
  4413. public function removeSenderMessage(Message $senderMessage): User
  4414. {
  4415. if ($this->senderMessages->removeElement($senderMessage)) {
  4416. // set the owning side to null (unless already changed)
  4417. if ($senderMessage->getSender() === $this) {
  4418. $senderMessage->setSender(NULL);
  4419. }
  4420. }
  4421. return $this;
  4422. }
  4423. /**
  4424. * @return Collection<int, Message>
  4425. */
  4426. public function getReceiverMessages(): Collection
  4427. {
  4428. return $this->receiverMessages;
  4429. }
  4430. public function addReceiverMessage(Message $receiverMessage): User
  4431. {
  4432. if (!$this->receiverMessages->contains($receiverMessage)) {
  4433. $this->receiverMessages[] = $receiverMessage;
  4434. $receiverMessage->setReceiver($this);
  4435. }
  4436. return $this;
  4437. }
  4438. public function removeReceiverMessage(Message $receiverMessage): User
  4439. {
  4440. if ($this->receiverMessages->removeElement($receiverMessage)) {
  4441. // set the owning side to null (unless already changed)
  4442. if ($receiverMessage->getReceiver() === $this) {
  4443. $receiverMessage->setReceiver(NULL);
  4444. }
  4445. }
  4446. return $this;
  4447. }
  4448. public function getRequestRegistration(): ?RequestRegistration
  4449. {
  4450. return $this->requestRegistration;
  4451. }
  4452. public function setRequestRegistration(RequestRegistration $requestRegistration): User
  4453. {
  4454. // set the owning side of the relation if necessary
  4455. if ($requestRegistration->getUser() !== $this) {
  4456. $requestRegistration->setUser($this);
  4457. }
  4458. $this->requestRegistration = $requestRegistration;
  4459. return $this;
  4460. }
  4461. /**
  4462. * @return Collection<int, RequestRegistration>
  4463. */
  4464. public function getRequestRegistrationsToValidate(): Collection
  4465. {
  4466. return $this->requestRegistrationsToValidate;
  4467. }
  4468. public function addRequestRegistrationsToValidate(RequestRegistration $requestRegistrationsToValidate): User
  4469. {
  4470. if (!$this->requestRegistrationsToValidate->contains($requestRegistrationsToValidate)) {
  4471. $this->requestRegistrationsToValidate[] = $requestRegistrationsToValidate;
  4472. $requestRegistrationsToValidate->setReferent($this);
  4473. }
  4474. return $this;
  4475. }
  4476. public function removeRequestRegistrationsToValidate(RequestRegistration $requestRegistrationsToValidate): User
  4477. {
  4478. if ($this->requestRegistrationsToValidate->removeElement($requestRegistrationsToValidate)) {
  4479. // set the owning side to null (unless already changed)
  4480. if ($requestRegistrationsToValidate->getReferent() === $this) {
  4481. $requestRegistrationsToValidate->setReferent(NULL);
  4482. }
  4483. }
  4484. return $this;
  4485. }
  4486. /**
  4487. * @return Collection<int, CustomProductOrder>
  4488. */
  4489. public function getCustomProductOrders(): Collection
  4490. {
  4491. return $this->customProductOrders;
  4492. }
  4493. public function addCustomProductOrder(CustomProductOrder $customProductOrder): User
  4494. {
  4495. if (!$this->customProductOrders->contains($customProductOrder)) {
  4496. $this->customProductOrders->add($customProductOrder);
  4497. $user = $customProductOrder->getUser();
  4498. if($user) $user->removeCustomProductOrder($customProductOrder);
  4499. $customProductOrder->setUser($this);
  4500. }
  4501. return $this;
  4502. }
  4503. public function removeCustomProductOrder(CustomProductOrder $customProductOrder): User
  4504. {
  4505. if ($this->customProductOrders->removeElement($customProductOrder)) {
  4506. // set the owning side to null (unless already changed)
  4507. if ($customProductOrder->getUser() === $this) {
  4508. $customProductOrder->setUser(NULL);
  4509. }
  4510. }
  4511. return $this;
  4512. }
  4513. public function removeCustomProduct(CustomProduct $customProduct): User
  4514. {
  4515. if ($this->customProducts->removeElement($customProduct)) {
  4516. // set the owning side to null (unless already changed)
  4517. if ($customProduct->getCreatedBy() === $this) {
  4518. $customProduct->setCreatedBy(NULL);
  4519. }
  4520. }
  4521. return $this;
  4522. }
  4523. public function getSubscription()
  4524. {
  4525. return $this->subscription;
  4526. }
  4527. public function setSubscription(UserSubscription $subscription): User
  4528. {
  4529. // set the owning side of the relation if necessary
  4530. if ($subscription->getUser() !== $this) {
  4531. $subscription->setUser($this);
  4532. }
  4533. $this->subscription = $subscription;
  4534. return $this;
  4535. }
  4536. /**
  4537. * @return Collection<int, UserExtension>
  4538. */
  4539. public function getExtensions(): Collection
  4540. {
  4541. return $this->extensions;
  4542. }
  4543. public function removeExtension(UserExtension $extension): User
  4544. {
  4545. if ($this->extensions->removeElement($extension)) {
  4546. // set the owning side to null (unless already changed)
  4547. if ($extension->getUser() === $this) {
  4548. $extension->setUser(NULL);
  4549. }
  4550. }
  4551. return $this;
  4552. }
  4553. /**
  4554. * @return Collection<int, CustomProduct>
  4555. */
  4556. public function getCustomProducts(): Collection
  4557. {
  4558. return $this->customProducts;
  4559. }
  4560. public function addCustomProduct(CustomProduct $customProduct): User
  4561. {
  4562. if (!$this->customProducts->contains($customProduct)) {
  4563. $this->customProducts[] = $customProduct;
  4564. $customProduct->setCreatedBy($this);
  4565. }
  4566. return $this;
  4567. }
  4568. public function getCalculatedPoints(): ?string
  4569. {
  4570. return $this->calculatedPoints;
  4571. }
  4572. public function setCalculatedPoints(?string $calculatedPoints): User
  4573. {
  4574. $this->calculatedPoints = $calculatedPoints;
  4575. return $this;
  4576. }
  4577. public function getAvatar()
  4578. {
  4579. return $this->avatar;
  4580. }
  4581. public function setAvatar($avatar): User
  4582. {
  4583. $this->avatar = $avatar;
  4584. return $this;
  4585. }
  4586. public function getAvatarFile(): ?File
  4587. {
  4588. return $this->avatarFile;
  4589. }
  4590. /**
  4591. * @param File|UploadedFile|null $avatarFile
  4592. */
  4593. public function setAvatarFile(?File $avatarFile = NULL): void
  4594. {
  4595. $this->avatarFile = $avatarFile;
  4596. if (NULL !== $avatarFile) {
  4597. $this->updatedAt = new DateTime();
  4598. }
  4599. }
  4600. public function getLogo()
  4601. {
  4602. return $this->logo;
  4603. }
  4604. public function setLogo($logo): User
  4605. {
  4606. $this->logo = $logo;
  4607. return $this;
  4608. }
  4609. public function getLogoFile(): ?File
  4610. {
  4611. return $this->logoFile;
  4612. }
  4613. public function setLogoFile(?File $logoFile = NULL): User
  4614. {
  4615. $this->logoFile = $logoFile;
  4616. if (NULL !== $logoFile) {
  4617. $this->updatedAt = new DateTime();
  4618. }
  4619. return $this;
  4620. }
  4621. /**
  4622. * @return Collection<int, PointOfSale>
  4623. */
  4624. public function getManagedPointOfSales(): Collection
  4625. {
  4626. return $this->managedPointOfSales;
  4627. }
  4628. public function addManagedPointOfSale(PointOfSale $managedPointOfSale): User
  4629. {
  4630. if (!$this->managedPointOfSales->contains($managedPointOfSale)) {
  4631. $this->managedPointOfSales[] = $managedPointOfSale;
  4632. $managedPointOfSale->addManager($this);
  4633. }
  4634. return $this;
  4635. }
  4636. public function removeManagedPointOfSale(PointOfSale $managedPointOfSale): User
  4637. {
  4638. if ($this->managedPointOfSales->removeElement($managedPointOfSale)) {
  4639. $managedPointOfSale->removeManager($this);
  4640. }
  4641. return $this;
  4642. }
  4643. /**
  4644. * @return Collection<int, Parameter>
  4645. */
  4646. public function getRelatedParameters(): Collection
  4647. {
  4648. return $this->relatedParameters;
  4649. }
  4650. public function addRelatedParameter(Parameter $relatedParameter): User
  4651. {
  4652. if (!$this->relatedParameters->contains($relatedParameter)) {
  4653. $this->relatedParameters[] = $relatedParameter;
  4654. $relatedParameter->setUserRelated($this);
  4655. }
  4656. return $this;
  4657. }
  4658. public function removeRelatedParameter(Parameter $relatedParameter): User
  4659. {
  4660. if ($this->relatedParameters->removeElement($relatedParameter)) {
  4661. // set the owning side to null (unless already changed)
  4662. if ($relatedParameter->getUserRelated() === $this) {
  4663. $relatedParameter->setUserRelated(NULL);
  4664. }
  4665. }
  4666. return $this;
  4667. }
  4668. public function getCompanyLegalStatus(): ?string
  4669. {
  4670. return $this->companyLegalStatus;
  4671. }
  4672. public function setCompanyLegalStatus(?string $companyLegalStatus): User
  4673. {
  4674. $this->companyLegalStatus = $companyLegalStatus;
  4675. return $this;
  4676. }
  4677. /**
  4678. * @return Collection<int, PointOfSale>
  4679. */
  4680. public function getCreatedPointOfSales(): Collection
  4681. {
  4682. return $this->createdPointOfSales;
  4683. }
  4684. public function addCreatedPointOfSale(PointOfSale $createdPointOfSale): User
  4685. {
  4686. if (!$this->createdPointOfSales->contains($createdPointOfSale)) {
  4687. $this->createdPointOfSales[] = $createdPointOfSale;
  4688. $createdPointOfSale->setCreatedBy($this);
  4689. }
  4690. return $this;
  4691. }
  4692. public function removeCreatedPointOfSale(PointOfSale $createdPointOfSale): User
  4693. {
  4694. if ($this->createdPointOfSales->removeElement($createdPointOfSale)) {
  4695. // set the owning side to null (unless already changed)
  4696. if ($createdPointOfSale->getCreatedBy() === $this) {
  4697. $createdPointOfSale->setCreatedBy(NULL);
  4698. }
  4699. }
  4700. return $this;
  4701. }
  4702. /**
  4703. * Serializer\VirtualProperty()
  4704. * @Serializer\SerializedName("count_created_point_of_sales")
  4705. *
  4706. * @return int
  4707. * @Expose()
  4708. * @Groups ({"export_user_datatable", "export_admin_datatable", "user"})
  4709. */
  4710. public function countCreatedPointOfSales(): int
  4711. {
  4712. return $this->createdPointOfSales->count();
  4713. }
  4714. public function getOwnerPointConversionRates(): Collection
  4715. {
  4716. return $this->ownerPointConversionRates;
  4717. }
  4718. public function addOwnerPointConversionRate(PointConversionRate $ownerPointConversionRate): User
  4719. {
  4720. if (!$this->ownerPointConversionRates->contains($ownerPointConversionRate)) {
  4721. $this->ownerPointConversionRates[] = $ownerPointConversionRate;
  4722. $ownerPointConversionRate->setOwner($this);
  4723. }
  4724. return $this;
  4725. }
  4726. public function removeOwnerPointConversionRate(PointConversionRate $ownerPointConversionRate): User
  4727. {
  4728. if ($this->ownerPointConversionRates->removeElement($ownerPointConversionRate)) {
  4729. // set the owning side to null (unless already changed)
  4730. if ($ownerPointConversionRate->getOwner() === $this) {
  4731. $ownerPointConversionRate->setOwner(NULL);
  4732. }
  4733. }
  4734. return $this;
  4735. }
  4736. /**
  4737. * @return PointConversionRate|null
  4738. */
  4739. public function getPointConversionRate()
  4740. {
  4741. return $this->pointConversionRate;
  4742. }
  4743. public function setPointConversionRate($pointConversionRate)
  4744. {
  4745. $this->pointConversionRate = $pointConversionRate;
  4746. return $this;
  4747. }
  4748. public function getFonction(): ?string
  4749. {
  4750. return $this->fonction;
  4751. }
  4752. public function setFonction(?string $fonction): User
  4753. {
  4754. $this->fonction = $fonction;
  4755. return $this;
  4756. }
  4757. public function getResponsableRegate(): ?Regate
  4758. {
  4759. return $this->responsableRegate;
  4760. }
  4761. public function setResponsableRegate(?Regate $responsableRegate): User
  4762. {
  4763. $this->responsableRegate = $responsableRegate;
  4764. return $this;
  4765. }
  4766. public function getRegistrationDocument(): ?string
  4767. {
  4768. return $this->registrationDocument;
  4769. }
  4770. public function setRegistrationDocument(?string $registrationDocument): User
  4771. {
  4772. $this->registrationDocument = $registrationDocument;
  4773. return $this;
  4774. }
  4775. public function getRegistrationDocumentFile(): ?File
  4776. {
  4777. return $this->registrationDocumentFile;
  4778. }
  4779. public function setRegistrationDocumentFile(?File $registrationDocumentFile = NULL): User
  4780. {
  4781. $this->registrationDocumentFile = $registrationDocumentFile;
  4782. if (NULL !== $registrationDocumentFile) {
  4783. $this->updatedAt = new DateTime();
  4784. }
  4785. return $this;
  4786. }
  4787. public function getIdeaBoxAnswers(): ArrayCollection
  4788. {
  4789. return $this->ideaBoxAnswers;
  4790. }
  4791. public function setIdeaBoxAnswers(ArrayCollection $ideaBoxAnswers): void
  4792. {
  4793. $this->ideaBoxAnswers = $ideaBoxAnswers;
  4794. }
  4795. public function getIdeaBoxRatings(): Collection
  4796. {
  4797. return $this->ideaBoxRatings;
  4798. }
  4799. public function addIdeaBoxRating(IdeaBoxRating $ideaBoxRating): User
  4800. {
  4801. if (!$this->ideaBoxRatings->contains($ideaBoxRating)) {
  4802. $this->ideaBoxRatings[] = $ideaBoxRating;
  4803. $ideaBoxRating->setUser($this);
  4804. }
  4805. return $this;
  4806. }
  4807. public function removeIdeaBoxRating(IdeaBoxRating $ideaBoxRating): User
  4808. {
  4809. if ($this->ideaBoxRatings->removeElement($ideaBoxRating)) {
  4810. // set the owning side to null (unless already changed)
  4811. if ($ideaBoxRating->getUser() === $this) {
  4812. $ideaBoxRating->setUser(NULL);
  4813. }
  4814. }
  4815. return $this;
  4816. }
  4817. public function getIdeaBoxRecipients(): Collection
  4818. {
  4819. return $this->ideaBoxRecipients;
  4820. }
  4821. public function addIdeaBoxRecipient(IdeaBoxRecipient $ideaBoxRecipient): User
  4822. {
  4823. if (!$this->ideaBoxRecipients->contains($ideaBoxRecipient)) {
  4824. $this->ideaBoxRecipients[] = $ideaBoxRecipient;
  4825. $ideaBoxRecipient->setUser($this);
  4826. }
  4827. return $this;
  4828. }
  4829. public function removeIdeaBoxRecipient(IdeaBoxRecipient $ideaBoxRecipient): User
  4830. {
  4831. if ($this->ideaBoxRecipients->removeElement($ideaBoxRecipient)) {
  4832. // set the owning side to null (unless already changed)
  4833. if ($ideaBoxRecipient->getUser() === $this) {
  4834. $ideaBoxRecipient->setUser(NULL);
  4835. }
  4836. }
  4837. return $this;
  4838. }
  4839. public function getOldStatus(): ?string
  4840. {
  4841. return $this->oldStatus;
  4842. }
  4843. public function setOldStatus(?string $oldStatus): User
  4844. {
  4845. $this->oldStatus = $oldStatus;
  4846. return $this;
  4847. }
  4848. public function getDisabledAt(): ?DateTimeInterface
  4849. {
  4850. return $this->disabledAt;
  4851. }
  4852. public function setDisabledAt(?DateTimeInterface $disabledAt): User
  4853. {
  4854. $this->disabledAt = $disabledAt;
  4855. return $this;
  4856. }
  4857. public function getArchiveReason(): ?string
  4858. {
  4859. return $this->archiveReason;
  4860. }
  4861. public function setArchiveReason(?string $archiveReason): User
  4862. {
  4863. $this->archiveReason = $archiveReason;
  4864. return $this;
  4865. }
  4866. public function getUnsubscribeReason(): ?string
  4867. {
  4868. return $this->unsubscribeReason;
  4869. }
  4870. public function setUnsubscribeReason(?string $unsubscribeReason): User
  4871. {
  4872. $this->unsubscribeReason = $unsubscribeReason;
  4873. return $this;
  4874. }
  4875. /**
  4876. * @return Collection<int, ActionLog>
  4877. */
  4878. public function getActionLogs(): Collection
  4879. {
  4880. return $this->actionLogs;
  4881. }
  4882. public function addActionLog(ActionLog $ActionLog): User
  4883. {
  4884. if (!$this->actionLogs->contains($ActionLog)) {
  4885. $this->actionLogs[] = $ActionLog;
  4886. $ActionLog->setUser($this);
  4887. }
  4888. return $this;
  4889. }
  4890. public function removeActionLog(ActionLog $ActionLog): User
  4891. {
  4892. if ($this->actionLogs->removeElement($ActionLog)) {
  4893. // set the owning side to null (unless already changed)
  4894. if ($ActionLog->getUser() === $this) {
  4895. $ActionLog->setUser(NULL);
  4896. }
  4897. }
  4898. return $this;
  4899. }
  4900. public function getFailedAttempts(): int
  4901. {
  4902. return $this->failedAttempts;
  4903. }
  4904. public function setFailedAttempts(int $failedAttempts): User
  4905. {
  4906. $this->failedAttempts = $failedAttempts;
  4907. return $this;
  4908. }
  4909. public function getLastFailedAttempt()
  4910. {
  4911. return $this->lastFailedAttempt;
  4912. }
  4913. public function setLastFailedAttempt($lastFailedAttempt): User
  4914. {
  4915. $this->lastFailedAttempt = $lastFailedAttempt;
  4916. return $this;
  4917. }
  4918. public function getPasswordUpdatedAt(): ?DateTimeInterface
  4919. {
  4920. return $this->passwordUpdatedAt;
  4921. }
  4922. public function setPasswordUpdatedAt(?DateTimeInterface $passwordUpdatedAt): User
  4923. {
  4924. $this->passwordUpdatedAt = $passwordUpdatedAt;
  4925. return $this;
  4926. }
  4927. public function getBirthPlace(): ?string
  4928. {
  4929. return $this->birthPlace;
  4930. }
  4931. public function setBirthPlace(?string $birthPlace): User
  4932. {
  4933. $this->birthPlace = $birthPlace;
  4934. return $this;
  4935. }
  4936. public function getQuizUserAnswers()
  4937. {
  4938. return $this->quizUserAnswers;
  4939. }
  4940. public function setQuizUserAnswers($quizUserAnswers): void
  4941. {
  4942. $this->quizUserAnswers = $quizUserAnswers;
  4943. }
  4944. public function getPasswordHistories(): Collection
  4945. {
  4946. return $this->passwordHistories;
  4947. }
  4948. public function addPasswordHistory(PasswordHistory $passwordHistory): User
  4949. {
  4950. if (!$this->passwordHistories->contains($passwordHistory)) {
  4951. $this->passwordHistories[] = $passwordHistory;
  4952. $passwordHistory->setUser($this);
  4953. }
  4954. return $this;
  4955. }
  4956. public function removePasswordHistory(PasswordHistory $passwordHistory): User
  4957. {
  4958. if ($this->passwordHistories->removeElement($passwordHistory)) {
  4959. // set the owning side to null (unless already changed)
  4960. if ($passwordHistory->getUser() === $this) {
  4961. $passwordHistory->setUser(NULL);
  4962. }
  4963. }
  4964. return $this;
  4965. }
  4966. public function getLastActivity(): ?DateTimeInterface
  4967. {
  4968. return $this->lastActivity;
  4969. }
  4970. public function setLastActivity(?DateTimeInterface $lastActivity): User
  4971. {
  4972. $this->lastActivity = $lastActivity;
  4973. return $this;
  4974. }
  4975. public function getUserFavorites(): ArrayCollection
  4976. {
  4977. return $this->userFavorites;
  4978. }
  4979. public function setUserFavorites(ArrayCollection $userFavorites): User
  4980. {
  4981. $this->userFavorites = $userFavorites;
  4982. return $this;
  4983. }
  4984. /**
  4985. * Serializer\VirtualProperty()
  4986. * @SerializedName("count_current_highlight_sale_result")
  4987. *
  4988. * @return int
  4989. * @Expose()
  4990. * @Groups ({
  4991. * "default",
  4992. * "user:count_current_highlight_sale_result",
  4993. * "user:list", "user:item", "user:post", "cdp", "user","email", "user_citroentf",
  4994. * "export_order_datatable",
  4995. * "user_bussiness_result",
  4996. * })
  4997. */
  4998. public function getCurrentHighlightSaleResult(): int
  4999. {
  5000. $ubr = $this->userBusinessResults->filter(function (UserBusinessResult $ubr) {
  5001. return $ubr->getHighlight() === NULL;
  5002. });
  5003. $result = 0;
  5004. /** @var UserBusinessResult $item */
  5005. foreach ($ubr as $item) {
  5006. $result += $item->getSale();
  5007. }
  5008. return $result;
  5009. }
  5010. public function getAccountId(): ?string
  5011. {
  5012. return $this->accountId;
  5013. }
  5014. public function setAccountId(?string $accountId): self
  5015. {
  5016. $this->accountId = $accountId;
  5017. return $this;
  5018. }
  5019. public function getUniqueSlugConstraint(): ?string
  5020. {
  5021. return $this->uniqueSlugConstraint;
  5022. }
  5023. public function setUniqueSlugConstraint(?string $uniqueSlugConstraint): self
  5024. {
  5025. $this->uniqueSlugConstraint = $uniqueSlugConstraint;
  5026. return $this;
  5027. }
  5028. public function isFakeUser(): bool
  5029. {
  5030. return !str_contains($this->getEmail(), '@');
  5031. }
  5032. public function isMainUser(): bool
  5033. {
  5034. return $this === $this->mainAccountUser;
  5035. }
  5036. /**
  5037. * @return Collection<int, BoosterProductResult>
  5038. */
  5039. public function getBoosterProductResults(): Collection
  5040. {
  5041. return $this->boosterProductResults;
  5042. }
  5043. public function addBoosterProductResult(BoosterProductResult $boosterProductResult): self
  5044. {
  5045. if (!$this->boosterProductResults->contains($boosterProductResult)) {
  5046. $this->boosterProductResults[] = $boosterProductResult;
  5047. $boosterProductResult->setUser($this);
  5048. }
  5049. return $this;
  5050. }
  5051. public function removeBoosterProductResult(BoosterProductResult $boosterProductResult): self
  5052. {
  5053. if ($this->boosterProductResults->removeElement($boosterProductResult)) {
  5054. // set the owning side to null (unless already changed)
  5055. if ($boosterProductResult->getUser() === $this) {
  5056. $boosterProductResult->setUser(null);
  5057. }
  5058. }
  5059. return $this;
  5060. }
  5061. /**
  5062. * @return Collection<int, PushSubscription>
  5063. */
  5064. public function getPushSubscriptions(): Collection
  5065. {
  5066. return $this->pushSubscriptions;
  5067. }
  5068. public function addPushSubscription(PushSubscription $pushSubscription): self
  5069. {
  5070. if (!$this->pushSubscriptions->contains($pushSubscription)) {
  5071. $this->pushSubscriptions[] = $pushSubscription;
  5072. $pushSubscription->setUser($this);
  5073. }
  5074. return $this;
  5075. }
  5076. public function removePushSubscription(PushSubscription $pushSubscription): self
  5077. {
  5078. if ($this->pushSubscriptions->removeElement($pushSubscription)) {
  5079. // set the owning side to null (unless already changed)
  5080. if ($pushSubscription->getUser() === $this) {
  5081. $pushSubscription->setUser(null);
  5082. }
  5083. }
  5084. return $this;
  5085. }
  5086. /**
  5087. * @param bool $getLevel
  5088. *
  5089. * @return bool|int
  5090. * @throws \DateInvalidOperationException
  5091. */
  5092. public function isActive(bool $getLevel = false)
  5093. {
  5094. $status = $this->getStatus();
  5095. if(!$getLevel && $this->isFakeUser()) return false;
  5096. $inactiveStatus = [self::STATUS_ARCHIVED, self::STATUS_DELETED, self::STATUS_UNSUBSCRIBED, self::STATUS_REGISTER_PENDING, self::STATUS_DISABLED, self::STATUS_ADMIN_PENDING];
  5097. if(!$getLevel && in_array($status, $inactiveStatus)) return false;
  5098. $twoYears = (new DateTime())->sub(new DateInterval('P2Y'));
  5099. $cguStatus = [self::STATUS_CGU_PENDING, self::STATUS_CGU_DECLINED];
  5100. if(!$getLevel && in_array($status, $cguStatus) && (!$this->lastLogin || $twoYears > $this->lastLogin)) return false;
  5101. if($getLevel)
  5102. {
  5103. $oneYear = (new DateTime())->sub(new DateInterval('P1Y'));
  5104. $sixMonths = (new DateTime())->sub(new DateInterval('P6M'));
  5105. $lvl = 15;
  5106. if($this->isFakeUser())
  5107. {
  5108. $lvl = 0;
  5109. }
  5110. // si l'utilisateur possède un email, son score sera au moins de 1
  5111. else
  5112. {
  5113. switch ($status)
  5114. {
  5115. case self::STATUS_DELETED:
  5116. $lvl -= 11;
  5117. break;
  5118. case self::STATUS_ARCHIVED:
  5119. $lvl -= 10;
  5120. break;
  5121. case self::STATUS_DISABLED:
  5122. case self::STATUS_UNSUBSCRIBED:
  5123. $lvl -= 9;
  5124. break;
  5125. case self::STATUS_REGISTER_PENDING:
  5126. $lvl -= 8;
  5127. break;
  5128. case self::STATUS_CGU_DECLINED:
  5129. $lvl -= 7;
  5130. break;
  5131. case self::STATUS_CGU_PENDING:
  5132. $lvl -= 6;
  5133. break;
  5134. case self::STATUS_ENABLED:
  5135. break;
  5136. default:
  5137. $lvl -= 5;
  5138. }
  5139. if(!$this->lastLogin || $twoYears > $this->lastLogin) {
  5140. $lvl -= 3;
  5141. }
  5142. elseif($oneYear > $this->lastLogin) {
  5143. $lvl -= 2;
  5144. }
  5145. elseif($sixMonths > $this->lastLogin) {
  5146. $lvl -= 1;
  5147. }
  5148. }
  5149. return $lvl;
  5150. }
  5151. return true;
  5152. }
  5153. public function getAzureId(): ?string
  5154. {
  5155. return $this->azureId;
  5156. }
  5157. public function setAzureId(?string $azureId): self
  5158. {
  5159. $this->azureId = $azureId;
  5160. return $this;
  5161. }
  5162. /**
  5163. * @return Collection<int, AzureGroup>
  5164. */
  5165. public function getAzureGroups(): Collection
  5166. {
  5167. return $this->azureGroups;
  5168. }
  5169. public function addAzureGroup(AzureGroup $azureGroup): self
  5170. {
  5171. if (!$this->azureGroups->contains($azureGroup)) {
  5172. $this->azureGroups[] = $azureGroup;
  5173. $azureGroup->addMember($this);
  5174. }
  5175. return $this;
  5176. }
  5177. public function removeAzureGroup(AzureGroup $azureGroup): self
  5178. {
  5179. if ($this->azureGroups->removeElement($azureGroup)) {
  5180. $azureGroup->removeMember($this);
  5181. }
  5182. return $this;
  5183. }
  5184. public function getActivatedBy(): ?self
  5185. {
  5186. return $this->activatedBy;
  5187. }
  5188. public function setActivatedBy(?self $activatedBy): self
  5189. {
  5190. $this->activatedBy = $activatedBy;
  5191. return $this;
  5192. }
  5193. /**
  5194. * @return Collection<int, QuotaProductUser>
  5195. */
  5196. public function getQuotaProductUsers(): Collection
  5197. {
  5198. return $this->quotaProductUsers;
  5199. }
  5200. public function addQuotaProductUser(QuotaProductUser $quotaProductUser): self
  5201. {
  5202. if (!$this->quotaProductUsers->contains($quotaProductUser)) {
  5203. $this->quotaProductUsers[] = $quotaProductUser;
  5204. $quotaProductUser->setUser($this);
  5205. }
  5206. return $this;
  5207. }
  5208. public function removeQuotaProductUser(QuotaProductUser $quotaProductUser): self
  5209. {
  5210. if ($this->quotaProductUsers->removeElement($quotaProductUser)) {
  5211. // set the owning side to null (unless already changed)
  5212. if ($quotaProductUser->getUser() === $this) {
  5213. $quotaProductUser->setUser(null);
  5214. }
  5215. }
  5216. return $this;
  5217. }
  5218. /**
  5219. * @return Collection<int, RankingScore>
  5220. */
  5221. public function getRankingScores(): Collection
  5222. {
  5223. return $this->rankingScores;
  5224. }
  5225. public function addRankingScore(RankingScore $rankingScore): self
  5226. {
  5227. if (!$this->rankingScores->contains($rankingScore)) {
  5228. $this->rankingScores->add($rankingScore);
  5229. $user = $rankingScore->getUser();
  5230. if($user) $user->removeRankingScore($rankingScore);
  5231. $rankingScore->setUser($this);
  5232. }
  5233. return $this;
  5234. }
  5235. public function removeRankingScore(RankingScore $rankingScore): self
  5236. {
  5237. if ($this->rankingScores->removeElement($rankingScore)) {
  5238. // set the owning side to null (unless already changed)
  5239. if ($rankingScore->getUser() === $this) {
  5240. $rankingScore->setUser(null);
  5241. }
  5242. }
  5243. return $this;
  5244. }
  5245. public function getEmailUnsubscribeReason(): ?string
  5246. {
  5247. return $this->emailUnsubscribeReason;
  5248. }
  5249. public function setEmailUnsubscribeReason(?string $emailUnsubscribeReason): User
  5250. {
  5251. $this->emailUnsubscribeReason = $emailUnsubscribeReason;
  5252. return $this;
  5253. }
  5254. public function getEmailUnsubscribedAt(): ?DateTimeInterface
  5255. {
  5256. return $this->emailUnsubscribedAt;
  5257. }
  5258. public function setEmailUnsubscribedAt(?DateTimeInterface $emailUnsubscribedAt): User
  5259. {
  5260. $this->emailUnsubscribedAt = $emailUnsubscribedAt;
  5261. return $this;
  5262. }
  5263. public function hasOrder(): bool
  5264. {
  5265. return $this->getPointTransactions(PointTransactionType::ORDER)->count() > 0;
  5266. }
  5267. }