src/Entity/User.php line 45

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