src/Entity/User.php line 45

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