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