src/Entity/User.php line 43

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