src/Entity/User.php line 46

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