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", "objective_target_score", "objective_target", "upload_communication_export"
  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", "objective_target", "upload_communication_export"
  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", "objective_target", "upload_communication_export"
  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", "objective_target_score", "objective_target"})
  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=ObjectiveTarget::class, mappedBy="owner", orphanRemoval=true)
  1183. *
  1184. * @Exportable()
  1185. */
  1186. private Collection $ownerObjectiveTargets;
  1187. /**
  1188. * @ORM\ManyToMany(targetEntity=ObjectiveTarget::class, inversedBy="users")
  1189. * @ORM\JoinTable(name="objective_target_user")
  1190. *
  1191. * @Expose()
  1192. * @Groups({"objective_target"})
  1193. */
  1194. private Collection $objectiveTargets;
  1195. /**
  1196. * @ORM\Column(type="string", length=255, nullable=true)
  1197. *
  1198. * @Exportable()
  1199. */
  1200. private ?string $fonction = null;
  1201. /**
  1202. * @ORM\OneToOne(targetEntity=Regate::class, inversedBy="responsable", cascade={"persist", "remove"}, fetch="EXTRA_LAZY")
  1203. *
  1204. * @Expose()
  1205. * @Groups({"user", "export_user_datatable"})
  1206. *
  1207. * @Exportable()
  1208. */
  1209. private ?Regate $responsableRegate = null;
  1210. /**
  1211. * @ORM\Column(type="string", length=255, nullable=true)
  1212. *
  1213. * @Exportable()
  1214. */
  1215. private ?string $registrationDocument = null;
  1216. /**
  1217. * @Vich\UploadableField(mapping="user_registration_document", fileNameProperty="registrationDocument")
  1218. * @var File
  1219. */
  1220. private $registrationDocumentFile;
  1221. /**
  1222. * @ORM\OneToOne(targetEntity=CoverageArea::class, inversedBy="user", cascade={"persist", "remove"})
  1223. * @ORM\JoinColumn(nullable=true)
  1224. *
  1225. * @Exportable()
  1226. */
  1227. private $coverageArea;
  1228. /**
  1229. * @ORM\OneToMany(targetEntity=QuizUserAnswer::class, mappedBy="user")
  1230. *
  1231. * @Exportable()
  1232. */
  1233. private $quizUserAnswers;
  1234. /**
  1235. * @ORM\OneToMany(targetEntity=IdeaBoxAnswer::class, mappedBy="user")
  1236. *
  1237. * @Expose
  1238. * @Groups({
  1239. * "user:idea_box_answers",
  1240. * "idea_box_list", "idea_box_stats", "export_idea_box_datatable"
  1241. * })
  1242. *
  1243. * @Exportable()
  1244. */
  1245. private Collection $ideaBoxAnswers;
  1246. /**
  1247. * @ORM\OneToMany(targetEntity=IdeaBoxRating::class, mappedBy="user")
  1248. *
  1249. * @Expose
  1250. * @Groups({
  1251. * "user:idea_box_ratings",
  1252. * "idea_box_list", "idea_box_stats", "export_idea_box_datatable"
  1253. * })
  1254. *
  1255. * @Exportable()
  1256. */
  1257. private Collection $ideaBoxRatings;
  1258. /**
  1259. * @ORM\OneToMany(targetEntity=IdeaBoxRecipient::class, mappedBy="user")
  1260. *
  1261. * @Expose
  1262. * @Groups({
  1263. * "user:idea_box_recipients",
  1264. * "idea_box_list", "idea_box_stats", "export_idea_box_datatable"
  1265. * })
  1266. *
  1267. * @Exportable()
  1268. */
  1269. private Collection $ideaBoxRecipients;
  1270. /**
  1271. * @ORM\Column(type="string", length=128, nullable=true)
  1272. */
  1273. private ?string $oldStatus = null;
  1274. /**
  1275. * @ORM\Column(type="datetime", nullable=true)
  1276. */
  1277. private ?DateTimeInterface $disabledAt = null;
  1278. /**
  1279. * @ORM\Column(type="string", length=255, nullable=true)
  1280. *
  1281. * @Exportable()
  1282. */
  1283. private ?string $archiveReason = null;
  1284. /**
  1285. * @ORM\Column(type="string", length=255, nullable=true)
  1286. *
  1287. * @Exportable()
  1288. */
  1289. private ?string $unsubscribeReason = null;
  1290. /**
  1291. * @ORM\OneToMany(targetEntity=ActionLog::class, mappedBy="user")
  1292. *
  1293. * @Expose()
  1294. * @Groups({
  1295. * "user:actionLog",
  1296. * "actionLog"
  1297. * })
  1298. *
  1299. * @Exportable()
  1300. */
  1301. private Collection $actionLogs;
  1302. /**
  1303. * @ORM\Column(type="integer")
  1304. *
  1305. * @Exportable()
  1306. */
  1307. private int $failedAttempts = 0;
  1308. /**
  1309. * @ORM\Column(type="datetime", nullable=true)
  1310. *
  1311. * @Exportable()
  1312. */
  1313. private ?DateTimeInterface $lastFailedAttempt = null;
  1314. /**
  1315. * @ORM\Column(type="datetime", nullable=true)
  1316. *
  1317. * @Exportable()
  1318. */
  1319. private ?DateTimeInterface $passwordUpdatedAt = null;
  1320. /**
  1321. * @ORM\OneToMany(targetEntity=PasswordHistory::class, mappedBy="user", orphanRemoval=true, cascade={"persist"})
  1322. */
  1323. private Collection $passwordHistories;
  1324. /**
  1325. * @ORM\OneToMany(targetEntity=UserFavorites::class, mappedBy="user")
  1326. *
  1327. * @Exportable()
  1328. */
  1329. private Collection $userFavorites;
  1330. /**
  1331. * @ORM\Column(type="datetime", nullable=true)
  1332. *
  1333. * @Exportable()
  1334. */
  1335. private ?DateTimeInterface $lastActivity = null;
  1336. /**
  1337. * Variables pour stocker la valeur avant modification
  1338. * @Expose()
  1339. * @Groups ({"user:post"})
  1340. */
  1341. private ?string $oldEmail = null;
  1342. /**
  1343. * @ORM\Column(type="string", length=255, nullable=true)
  1344. *
  1345. * @Expose()
  1346. * @Groups({
  1347. * "default",
  1348. * "user:accountId",
  1349. * "user:post", "user:list","user:item", "cdp", "user",
  1350. * "user_bussiness_result", "user_bussiness_result:user",
  1351. * "export_user_datatable"
  1352. * })
  1353. */
  1354. private ?string $accountId = null;
  1355. /**
  1356. * @ORM\Column(type="string", nullable=true, unique=true)
  1357. */
  1358. private ?string $uniqueSlugConstraint = null;
  1359. /**
  1360. * @ORM\OneToMany(targetEntity=BoosterProductResult::class, mappedBy="user", orphanRemoval=true)
  1361. */
  1362. private Collection $boosterProductResults;
  1363. /**
  1364. * @ORM\OneToMany(targetEntity=PushSubscription::class, mappedBy="user")
  1365. */
  1366. private Collection $pushSubscriptions;
  1367. /**
  1368. * @ORM\Column(type="string", length=50, nullable=true)
  1369. */
  1370. private ?string $azureId = null;
  1371. /**
  1372. * @ORM\ManyToMany(targetEntity=AzureGroup::class, mappedBy="members")
  1373. */
  1374. private Collection $azureGroups;
  1375. /**
  1376. * @ORM\ManyToOne(targetEntity=User::class)
  1377. */
  1378. private ?User $activatedBy = null;
  1379. /**
  1380. * @ORM\OneToMany(targetEntity=QuotaProductUser::class, mappedBy="user", orphanRemoval=true)
  1381. */
  1382. private Collection $quotaProductUsers;
  1383. /**
  1384. * @ORM\OneToMany(targetEntity=RankingScore::class, mappedBy="user")
  1385. */
  1386. private Collection $rankingScores;
  1387. /**
  1388. * @ORM\OneToMany(targetEntity=ObjectiveTargetScore::class, mappedBy="user")
  1389. */
  1390. private Collection $objectiveTargetScores;
  1391. /**
  1392. * @ORM\Column(type="text", length=255, nullable=true)
  1393. *
  1394. * @Exportable()
  1395. */
  1396. private ?string $emailUnsubscribeReason = null;
  1397. /**
  1398. * @ORM\Column(type="datetime", nullable=true)
  1399. */
  1400. private ?DateTimeInterface $emailUnsubscribedAt = null;
  1401. public function __construct()
  1402. {
  1403. $this->addresses = new ArrayCollection();
  1404. $this->subAccountUsers = new ArrayCollection();
  1405. $this->carts = new ArrayCollection();
  1406. $this->distributors = new ArrayCollection();
  1407. $this->purchases = new ArrayCollection();
  1408. $this->orders = new ArrayCollection();
  1409. $this->godchilds = new ArrayCollection();
  1410. $this->requestProductAvailables = new ArrayCollection();
  1411. $this->userImportHistories = new ArrayCollection();
  1412. $this->contactLists = new ArrayCollection();
  1413. $this->devis = new ArrayCollection();
  1414. $this->pointTransactions = new ArrayCollection();
  1415. $this->installers = new ArrayCollection();
  1416. $this->heatingInstallers = new ArrayCollection();
  1417. $this->userBusinessResults = new ArrayCollection();
  1418. $this->projects = new ArrayCollection();
  1419. $this->serviceUsers = new ArrayCollection();
  1420. $this->universes = new ArrayCollection();
  1421. $this->scores = new ArrayCollection();
  1422. $this->scoreObjectives = new ArrayCollection();
  1423. $this->children = new ArrayCollection();
  1424. $this->parents = new ArrayCollection();
  1425. $this->requestRegistrationsToValidate = new ArrayCollection();
  1426. $this->customProductOrders = new ArrayCollection();
  1427. $this->extensions = new ArrayCollection();
  1428. $this->managedPointOfSales = new ArrayCollection();
  1429. $this->relatedParameters = new ArrayCollection();
  1430. $this->createdPointOfSales = new ArrayCollection();
  1431. $this->status = self::STATUS_CGU_PENDING;
  1432. $this->ideaBoxAnswers = new ArrayCollection();
  1433. $this->ideaBoxRatings = new ArrayCollection();
  1434. $this->ideaBoxRecipients = new ArrayCollection();
  1435. $this->actionLogs = new ArrayCollection();
  1436. $this->passwordHistories = new ArrayCollection();
  1437. $this->userFavorites = new ArrayCollection();
  1438. $this->boosterProductResults = new ArrayCollection();
  1439. $this->pushSubscriptions = new ArrayCollection();
  1440. $this->azureGroups = new ArrayCollection();
  1441. $this->quotaProductUsers = new ArrayCollection();
  1442. $this->rankingScores = new ArrayCollection();
  1443. $this->objectiveTargets = new ArrayCollection();
  1444. $this->objectiveTargetScores = new ArrayCollection();
  1445. }
  1446. private function generateSlug(): void
  1447. {
  1448. $parts = [$this->email, $this->accountId, $this->extension1, $this->extension2];
  1449. $parts = array_filter($parts);
  1450. $this->uniqueSlugConstraint = implode('-', $parts);
  1451. }
  1452. /**
  1453. * @ORM\PreUpdate()
  1454. */
  1455. public function preUpdate(PreUpdateEventArgs $eventArgs): void
  1456. {
  1457. if ($eventArgs->getObject() instanceof User) {
  1458. if ($eventArgs->hasChangedField('email') || $eventArgs->hasChangedField(
  1459. 'extension1'
  1460. ) || $eventArgs->hasChangedField('extension2') || $eventArgs->hasChangedField('accountId')) {
  1461. $this->generateSlug();
  1462. }
  1463. }
  1464. }
  1465. // Typed property App\Entity\User::$email must not be accessed before initialization
  1466. // Modif prePersist() vers postPersist()
  1467. /**
  1468. * @ORM\PostPersist()
  1469. */
  1470. public function postPersist(): void
  1471. {
  1472. $this->generateSlug();
  1473. }
  1474. /**
  1475. * @ORM\PostUpdate()
  1476. */
  1477. public function postUpdate(): void
  1478. {
  1479. $this->oldEmail = null;
  1480. }
  1481. public function __toString(): string
  1482. {
  1483. return $this->getFullName();
  1484. }
  1485. /**
  1486. * @Serializer\VirtualProperty
  1487. * @SerializedName("fullName")
  1488. *
  1489. * @Expose()
  1490. * @Groups({"user:full_name","email", "export_order_datatable", "purchase", "service_user",
  1491. * "univers","customProductOrder:list"})
  1492. *
  1493. * @return string
  1494. *
  1495. * @ExportableMethod()
  1496. */
  1497. public function getFullName(): string
  1498. {
  1499. $fullName = trim($this->firstName . ' ' . $this->lastName);
  1500. if (empty($fullName)) {
  1501. return $this->getEmail();
  1502. }
  1503. return $fullName;
  1504. }
  1505. public function getEmail(): ?string
  1506. {
  1507. return $this->email;
  1508. }
  1509. public function setEmail(string $email): User
  1510. {
  1511. $email = trim($email);
  1512. if (isset($this->email)) {
  1513. $this->setOldEmail($this->email);
  1514. } else {
  1515. $this->setOldEmail($email);
  1516. }
  1517. $this->email = $email;
  1518. return $this;
  1519. }
  1520. public function __toArray(): array
  1521. {
  1522. return get_object_vars($this);
  1523. }
  1524. /**
  1525. * ============================================================================================
  1526. * =============================== FONCTIONS CUSTOM ===========================================
  1527. * ============================================================================================
  1528. */
  1529. public function serialize(): string
  1530. {
  1531. return serialize([
  1532. $this->id,
  1533. ],);
  1534. }
  1535. public function __serialize(): array
  1536. {
  1537. return [
  1538. 'id' => $this->id,
  1539. 'email' => $this->email,
  1540. 'password' => $this->password,
  1541. 'salt' => $this->salt,
  1542. ];
  1543. }
  1544. public function __unserialize($serialized): void
  1545. {
  1546. $this->id = $serialized['id'];
  1547. $this->email = $serialized['email'];
  1548. $this->password = $serialized['password'];
  1549. $this->salt = $serialized['salt'];
  1550. }
  1551. /**
  1552. * @Serializer\VirtualProperty()
  1553. * @SerializedName ("unsubscribed")
  1554. *
  1555. * @Expose()
  1556. * @Groups({
  1557. * "user:unsubscribed",
  1558. * "default",
  1559. * "unsubscribed",
  1560. * "user:list", "user:item", "cdp", "user", "export_user_citroentf_datatable", "user_citroentf",
  1561. * "export_user_citroentf_datatable",
  1562. * "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
  1563. * "export_commercial_installer_datatable",
  1564. * "export_commercial_datatable", "export_user_datatable", "export_admin_datatable", "export_installer_datatable"
  1565. * })
  1566. *
  1567. * @return bool
  1568. */
  1569. public function isUnsubscribed(): bool
  1570. {
  1571. return $this->status === self::STATUS_UNSUBSCRIBED;
  1572. }
  1573. /**
  1574. * @Serializer\VirtualProperty()
  1575. * @SerializedName ("enabled")
  1576. *
  1577. * @Expose()
  1578. * @Groups({
  1579. * "user:enabled",
  1580. * "default",
  1581. * "enabled",
  1582. * "user:list", "user:item", "cdp", "user", "export_user_citroentf_datatable", "user_citroentf",
  1583. * "export_user_citroentf_datatable",
  1584. * "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
  1585. * "export_commercial_installer_datatable",
  1586. * "export_commercial_datatable", "export_user_datatable", "export_admin_datatable", "export_installer_datatable"
  1587. * })
  1588. *
  1589. * @return bool
  1590. */
  1591. public function isEnabled(): bool
  1592. {
  1593. return $this->status === self::STATUS_ENABLED;
  1594. }
  1595. /**
  1596. * @Serializer\VirtualProperty()
  1597. * @SerializedName ("disabled")
  1598. *
  1599. * @Expose()
  1600. * @Groups({
  1601. * "user:disabled",
  1602. * "user:list", "user:item", "cdp", "user", "export_user_citroentf_datatable", "user_citroentf",
  1603. * "export_user_citroentf_datatable",
  1604. * "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
  1605. * "export_commercial_installer_datatable",
  1606. * "export_commercial_datatable", "export_user_datatable", "export_admin_datatable", "export_installer_datatable"})
  1607. *
  1608. * @return bool
  1609. */
  1610. public function isDisabled(): bool
  1611. {
  1612. return $this->status === self::STATUS_DISABLED;
  1613. }
  1614. /**
  1615. * @Serializer\VirtualProperty()
  1616. * @SerializedName ("cgu_pending")
  1617. *
  1618. * @Expose()
  1619. * @Groups({
  1620. * "user:cgu_pending",
  1621. * "cgu_pending",
  1622. * "user:list", "user:item", "cdp", "user", "export_user_citroentf_datatable", "user_citroentf",
  1623. * "export_user_citroentf_datatable",
  1624. * "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
  1625. * "export_commercial_installer_datatable",
  1626. * "export_commercial_datatable", "export_user_datatable", "export_admin_datatable", "export_installer_datatable"})
  1627. *
  1628. * @return bool
  1629. */
  1630. public function isCguPending(): bool
  1631. {
  1632. return $this->status === self::STATUS_CGU_PENDING;
  1633. }
  1634. /**
  1635. * @Serializer\VirtualProperty()
  1636. * @SerializedName ("cgu_declined")
  1637. *
  1638. * @Expose()
  1639. * @Groups({
  1640. * "user:cgu_declined",
  1641. * "cgu_declined",
  1642. * "user:list", "user:item", "cdp", "user", "export_user_citroentf_datatable", "user_citroentf",
  1643. * "export_user_citroentf_datatable",
  1644. * "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
  1645. * "export_commercial_installer_datatable",
  1646. * "export_commercial_datatable", "export_user_datatable", "export_admin_datatable", "export_installer_datatable"})
  1647. *
  1648. * @return bool
  1649. */
  1650. public function isCguDeclined(): bool
  1651. {
  1652. return $this->status === self::STATUS_CGU_DECLINED;
  1653. }
  1654. /**
  1655. * @Serializer\VirtualProperty()
  1656. * @SerializedName ("archived")
  1657. *
  1658. * @Expose()
  1659. * @Groups({
  1660. * "user:archived",
  1661. * "default",
  1662. * "is_archived",
  1663. * "user:list", "user:item", "cdp", "user", "export_user_citroentf_datatable", "user_citroentf",
  1664. * "export_user_citroentf_datatable",
  1665. * "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
  1666. * "export_commercial_installer_datatable",
  1667. * "export_commercial_datatable", "export_user_datatable", "export_admin_datatable", "export_installer_datatable"
  1668. * })
  1669. *
  1670. * @return bool
  1671. */
  1672. public function isArchived(): bool
  1673. {
  1674. return $this->status === self::STATUS_ARCHIVED;
  1675. }
  1676. /**
  1677. * @Serializer\VirtualProperty()
  1678. * @SerializedName ("deleted")
  1679. *
  1680. * @Expose()
  1681. * @Groups({
  1682. * "user:deleted",
  1683. * "user:list", "user:item", "cdp", "user", "export_user_citroentf_datatable", "user_citroentf",
  1684. * "export_user_citroentf_datatable",
  1685. * "export_agency_manager_commercial_datatable", "export_agency_manager_datatable",
  1686. * "export_commercial_installer_datatable",
  1687. * "export_commercial_datatable", "export_user_datatable", "export_admin_datatable", "export_installer_datatable"})
  1688. *
  1689. * @return bool
  1690. */
  1691. public function isDeleted(): bool
  1692. {
  1693. return $this->status === self::STATUS_DELETED;
  1694. }
  1695. /**
  1696. * @Serializer\VirtualProperty()
  1697. * @SerializedName ("admin_pending")
  1698. *
  1699. * @return bool
  1700. */
  1701. public function isAdminPending(): bool
  1702. {
  1703. return $this->status === self::STATUS_ADMIN_PENDING;
  1704. }
  1705. /**
  1706. * @return bool
  1707. */
  1708. public function isRegisterPending(): bool
  1709. {
  1710. return $this->status === self::STATUS_REGISTER_PENDING;
  1711. }
  1712. public function getUsers()
  1713. {
  1714. return $this->installers;
  1715. }
  1716. /**
  1717. * @Serializer\VirtualProperty()
  1718. * @SerializedName("count_installers")
  1719. *
  1720. * @Expose()
  1721. * @Groups({
  1722. * "user:count_installers"
  1723. * })
  1724. *
  1725. * @return int
  1726. */
  1727. public function countInstallers(): int
  1728. {
  1729. return count($this->installers);
  1730. }
  1731. /**
  1732. * @Serializer\VirtualProperty()
  1733. * @SerializedName("count_commercials")
  1734. *
  1735. * @Expose()
  1736. * @Groups({
  1737. * "user:count_commercials"
  1738. * })
  1739. *
  1740. * @return int
  1741. */
  1742. public function countCommercials(): int
  1743. {
  1744. $commercials = $this->children;
  1745. if (empty($commercials)) {
  1746. return 0;
  1747. }
  1748. foreach ($commercials as $index => $commercial) {
  1749. if (!in_array('ROLE_COMMERCIAL', $commercial->getRoles())) {
  1750. unset($commercials[$index]);
  1751. }
  1752. }
  1753. return count($commercials);
  1754. }
  1755. public function getRoles(): ?array
  1756. {
  1757. return $this->roles;
  1758. }
  1759. public function setRoles(array $roles): User
  1760. {
  1761. $this->roles = $roles;
  1762. return $this;
  1763. }
  1764. /**
  1765. * @Serializer\VirtualProperty
  1766. * @SerializedName("preferredEmail")
  1767. *
  1768. * @Expose()
  1769. * @Groups({"email"})
  1770. *
  1771. * @return string
  1772. */
  1773. public function getPreferredEmail(): string
  1774. {
  1775. if ($this->getTransactionalEmail()) {
  1776. return $this->getTransactionalEmail();
  1777. }
  1778. if ($this->isFakeUser()) {
  1779. $secondaryEmails = $this->getSecondaryEmails();
  1780. if (!empty($secondaryEmails)) {
  1781. return array_values($secondaryEmails)[0];
  1782. }
  1783. }
  1784. return $this->email;
  1785. }
  1786. public function getTransactionalEmail(): ?string
  1787. {
  1788. return $this->transactionalEmail;
  1789. }
  1790. public function setTransactionalEmail(?string $transactionalEmail): User
  1791. {
  1792. $this->transactionalEmail = $transactionalEmail;
  1793. return $this;
  1794. }
  1795. /**
  1796. * @Serializer\VirtualProperty()
  1797. * @SerializedName ("roleToString")
  1798. *
  1799. * @Expose()
  1800. * @Groups({"export_user_datatable", "export_admin_datatable", "export_user_citroentf_datatable"})
  1801. *
  1802. * @return string
  1803. */
  1804. public function roleToString(): string
  1805. {
  1806. if ($this->isDemo()) {
  1807. return 'Démo';
  1808. }
  1809. if ($this->isInstaller()) {
  1810. return 'Installateur';
  1811. }
  1812. if ($this->isValidation()) {
  1813. return 'Validation';
  1814. }
  1815. if ($this->isUser()) {
  1816. return 'Utilisateur';
  1817. }
  1818. if ($this->isCommercial()) {
  1819. if ($this->isHeatingCommercial()) {
  1820. return 'Commercial chauffage';
  1821. }
  1822. return 'Commercial';
  1823. }
  1824. if ($this->isAgencyManager()) {
  1825. return "Directeur d'agence";
  1826. }
  1827. if ($this->isDtvLogistique()) {
  1828. return "Logistique";
  1829. }
  1830. if ($this->isDtvCommercial()) {
  1831. return "Commercial";
  1832. }
  1833. if ($this->isDtvCompta()) {
  1834. return "Comptabilité";
  1835. }
  1836. if ($this->isDtvCdp()) {
  1837. return "Chef de projet";
  1838. }
  1839. if ($this->isAdmin()) {
  1840. return 'Administrateur';
  1841. }
  1842. if ($this->isSuperAdmin()) {
  1843. return 'Super Administrateur';
  1844. }
  1845. if ($this->isDeveloper()) {
  1846. return 'Développeur';
  1847. }
  1848. return 'Rôle non défini';
  1849. }
  1850. public function isDemo(): bool
  1851. {
  1852. // return in_array('ROLE_DEMO', $this->getRoles(), TRUE);
  1853. return $this->job === 'demo';
  1854. }
  1855. public function isInstaller(): bool
  1856. {
  1857. // return in_array('ROLE_INSTALLER', $this->getRoles(), TRUE);
  1858. return $this->job === 'installer';
  1859. }
  1860. public function isValidation(): bool
  1861. {
  1862. // return in_array('ROLE_VALIDATION', $this->getRoles(), TRUE);
  1863. return $this->job === 'validation';
  1864. }
  1865. public function isUser(): bool
  1866. {
  1867. return in_array('ROLE_USER', $this->getRoles(), true);
  1868. }
  1869. public function isCommercial(): bool
  1870. {
  1871. // return in_array('ROLE_COMMERCIAL', $this->getRoles(), TRUE);
  1872. return $this->job === 'commercial_agent';
  1873. }
  1874. public function isHeatingCommercial(): bool
  1875. {
  1876. return in_array('ROLE_COMMERCIAL', $this->getRoles(), true) && $this->getChauffage();
  1877. }
  1878. public function getChauffage(): ?bool
  1879. {
  1880. return $this->chauffage;
  1881. }
  1882. public function setChauffage(?bool $chauffage): User
  1883. {
  1884. $this->chauffage = $chauffage;
  1885. return $this;
  1886. }
  1887. public function isAgencyManager(): bool
  1888. {
  1889. return in_array('ROLE_AGENCY_MANAGER', $this->getRoles(), true);
  1890. }
  1891. public function isDtvLogistique(): bool
  1892. {
  1893. return in_array('ROLE_DTV_LOGISTIQUE', $this->getRoles(), true);
  1894. }
  1895. public function isDtvCommercial(): bool
  1896. {
  1897. return in_array('ROLE_DTV_COMMERCIAL', $this->getRoles(), true);
  1898. }
  1899. public function isDtvCompta(): bool
  1900. {
  1901. return in_array('ROLE_DTV_COMPTA', $this->getRoles(), true);
  1902. }
  1903. public function isDtvCdp(): bool
  1904. {
  1905. return in_array('ROLE_DTV_CDP', $this->getRoles(), true);
  1906. }
  1907. public function isAdmin(): bool
  1908. {
  1909. return in_array('ROLE_ADMIN', $this->getRoles(), true);
  1910. }
  1911. public function isSuperAdmin(): bool
  1912. {
  1913. return in_array('ROLE_SUPER_ADMIN', $this->getRoles(), true);
  1914. }
  1915. public function isDeveloper(): bool
  1916. {
  1917. return in_array('ROLE_DEVELOPER', $this->getRoles(), true);
  1918. }
  1919. public function isDeveloperOrSuperAdmin(): bool
  1920. {
  1921. return $this->isDeveloper() || $this->isSuperAdmin();
  1922. }
  1923. public function hasOneOfItsRoles(array $roles): bool
  1924. {
  1925. return count(array_intersect($roles, $this->getRoles())) > 0;
  1926. }
  1927. /**
  1928. * @Serializer\VirtualProperty()
  1929. * @SerializedName ("nbrValidatedPurchases")
  1930. *
  1931. * @Expose()
  1932. * @Groups({
  1933. * "user:nbr_validated_purchases",
  1934. * "export_installer_datatable", "export_commercial_installer_datatable"})
  1935. *
  1936. * @return int
  1937. */
  1938. public function getNbrValidatedPurchases(): int
  1939. {
  1940. $nbr = 0;
  1941. /** @var Purchase $purchase */
  1942. foreach ($this->purchases as $purchase) {
  1943. if ((int)$purchase->getStatus() === Purchase::STATUS_VALIDATED) {
  1944. $nbr++;
  1945. }
  1946. }
  1947. return $nbr;
  1948. }
  1949. public function getStatus(): string
  1950. {
  1951. return $this->status;
  1952. }
  1953. public function setStatus(string $status): User
  1954. {
  1955. $this->status = $status;
  1956. return $this;
  1957. }
  1958. /**
  1959. * @Serializer\VirtualProperty()
  1960. * @SerializedName ("nbrPendingPurchases")
  1961. *
  1962. * @Expose()
  1963. * @Groups({"export_installer_datatable", "export_commercial_installer_datatable"})
  1964. *
  1965. * @return int
  1966. */
  1967. public function getNbrPendingPurchases(): int
  1968. {
  1969. $nbr = 0;
  1970. /** @var Purchase $purchase */
  1971. foreach ($this->purchases as $purchase) {
  1972. if ((int)$purchase->getStatus() === Purchase::STATUS_PENDING) {
  1973. $nbr++;
  1974. }
  1975. }
  1976. return $nbr;
  1977. }
  1978. /**
  1979. * @Serializer\VirtualProperty()
  1980. * @SerializedName ("nbrRejectedPurchases")
  1981. *
  1982. * @Expose()
  1983. * @Groups({
  1984. * "user:nbr_rejected_purchases",
  1985. * "export_installer_datatable", "export_commercial_installer_datatable"})
  1986. *
  1987. * @return int
  1988. */
  1989. public function getNbrRejectedPurchases(): int
  1990. {
  1991. $nbr = 0;
  1992. /** @var Purchase $purchase */
  1993. foreach ($this->purchases as $purchase) {
  1994. if ((int)$purchase->getStatus() === Purchase::STATUS_REJECTED) {
  1995. $nbr++;
  1996. }
  1997. }
  1998. return $nbr;
  1999. }
  2000. /**
  2001. * @Serializer\VirtualProperty()
  2002. * @SerializedName ("nbrReturnedPurchases")
  2003. *
  2004. * @Expose()
  2005. * @Groups({
  2006. * "user:nbr_returned_purchases",
  2007. * "export_installer_datatable", "export_commercial_installer_datatable"})
  2008. *
  2009. * @return int
  2010. */
  2011. public function getNbrReturnedPurchases(): int
  2012. {
  2013. $nbr = 0;
  2014. /** @var Purchase $purchase */
  2015. foreach ($this->purchases as $purchase) {
  2016. if ((int)$purchase->getStatus() === Purchase::STATUS_RETURNED) {
  2017. $nbr++;
  2018. }
  2019. }
  2020. return $nbr;
  2021. }
  2022. /**
  2023. * Nombre de commandes de l'utilisateur
  2024. *
  2025. * @Serializer\VirtualProperty()
  2026. * @SerializedName ("nbrOrder")
  2027. *
  2028. * @Expose()
  2029. * @Groups({"export_user_datatable", "export_admin_datatable", "export_installer_datatable", "export_commercial_installer_datatable"})
  2030. *
  2031. * @return int
  2032. */
  2033. public function getNbrOrder(): int
  2034. {
  2035. return count($this->orders);
  2036. }
  2037. /**
  2038. * @Serializer\VirtualProperty()
  2039. * @SerializedName ("nbrPurchases")
  2040. *
  2041. * @Expose()
  2042. * @Groups({
  2043. * "user:nbr_purchases",
  2044. * "export_installer_datatable", "export_commercial_installer_datatable"})
  2045. *
  2046. * @return int
  2047. */
  2048. public function getNbrPurchases(): int
  2049. {
  2050. return count($this->purchases);
  2051. }
  2052. /**
  2053. * @Serializer\VirtualProperty()
  2054. * @SerializedName ("has_heating_commercial")
  2055. * @Groups ({
  2056. * "default",
  2057. * "user:has_heating_commercial",
  2058. * "user"
  2059. * })
  2060. */
  2061. public function hasHeatingCommercial()
  2062. {
  2063. return $this->heatingCommercial instanceof User;
  2064. }
  2065. /**
  2066. * @Serializer\VirtualProperty()
  2067. * @SerializedName ("pointDateExpiration")
  2068. *
  2069. * @Expose()
  2070. * @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
  2071. *
  2072. * @return null|string
  2073. */
  2074. public function getPointDateExpiration(): ?string
  2075. {
  2076. return $this->getExtensionBySlug(\App\Constants\UserExtension::POINT_DATE_EXPIRATION);
  2077. }
  2078. /**
  2079. * Retourne la valeur d'une extension depuis son slug
  2080. *
  2081. * @param string $slug
  2082. *
  2083. * @return string|null
  2084. */
  2085. public function getExtensionBySlug(string $slug): ?string
  2086. {
  2087. if (!empty($this->extensions)) {
  2088. foreach ($this->extensions as $extension) {
  2089. if ($extension->getSlug() === $slug) {
  2090. return $extension->getValue();
  2091. }
  2092. }
  2093. }
  2094. return null;
  2095. }
  2096. /**
  2097. * @Serializer\VirtualProperty()
  2098. * @SerializedName ("objCa")
  2099. *
  2100. * @Expose()
  2101. * @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
  2102. *
  2103. * @return int
  2104. */
  2105. public function getObjCa(): int
  2106. {
  2107. $value = $this->getExtensionBySlug(\App\Constants\UserExtension::OBJ_CA);
  2108. if ($value === null) {
  2109. return 0;
  2110. }
  2111. return intval($value);
  2112. }
  2113. public function setObjCa(?string $value): User
  2114. {
  2115. if ($value === null) {
  2116. return $this;
  2117. }
  2118. $this->addExtension(UserExtensionFactory::setObjCa($this, $value));
  2119. return $this;
  2120. }
  2121. public function addExtension(?UserExtension $extension): User
  2122. {
  2123. if ($extension !== null && !$this->extensions->contains($extension)) {
  2124. $this->extensions[] = $extension;
  2125. $extension->setUser($this);
  2126. }
  2127. return $this;
  2128. }
  2129. /**
  2130. * @Serializer\VirtualProperty()
  2131. * @SerializedName ("commitment_level")
  2132. *
  2133. * @Expose()
  2134. * @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
  2135. *
  2136. * @return string
  2137. */
  2138. public function getCommitmentLevel(): string
  2139. {
  2140. $value = $this->getExtensionBySlug(\App\Constants\UserExtension::COMMITMENT_LEVEL);
  2141. if ($value === null) {
  2142. return '';
  2143. }
  2144. return $value;
  2145. }
  2146. public function setCommitmentLevel(?string $value): User
  2147. {
  2148. if ($value === null) {
  2149. return $this;
  2150. }
  2151. $this->addExtension(UserExtensionFactory::setCommitmentLevel($this, $value));
  2152. return $this;
  2153. }
  2154. /**
  2155. * @Serializer\VirtualProperty()
  2156. * @SerializedName ("objPoint")
  2157. *
  2158. * @Expose()
  2159. * @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
  2160. *
  2161. * @return int
  2162. */
  2163. public function getObjPoint(): int
  2164. {
  2165. $value = $this->getExtensionBySlug(\App\Constants\UserExtension::OBJ_POINT);
  2166. if ($value === null) {
  2167. return 0;
  2168. }
  2169. return intval($value);
  2170. }
  2171. public function setObjPoint(?string $value): User
  2172. {
  2173. if ($value === null) {
  2174. return $this;
  2175. }
  2176. $this->addExtension(UserExtensionFactory::setObjPoint($this, $value));
  2177. return $this;
  2178. }
  2179. /**
  2180. * @Serializer\VirtualProperty()
  2181. * @SerializedName ("language")
  2182. *
  2183. * @Expose()
  2184. * @Groups({ "user:language", "user:item"})
  2185. *
  2186. * @return string|null
  2187. */
  2188. public function getLanguage(): ?string
  2189. {
  2190. return $this->getExtensionBySlug(\App\Constants\UserExtension::LANGUAGE);
  2191. }
  2192. public function setInternalIdentification1(?string $value): User
  2193. {
  2194. if ($value === null) {
  2195. return $this;
  2196. }
  2197. $this->addExtension(UserExtensionFactory::setInternalIdentification1($this, $value));
  2198. return $this;
  2199. }
  2200. /**
  2201. * @Serializer\VirtualProperty()
  2202. * @SerializedName ("internalIdentification2")
  2203. *
  2204. * @Expose()
  2205. * @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable", "export_admin_datatable", "sale_order",
  2206. * "export_order_datatable"})
  2207. *
  2208. * @return string|null
  2209. */
  2210. public function getInternalIdentification2(): ?string
  2211. {
  2212. return $this->getExtensionBySlug(\App\Constants\UserExtension::INTERNAL_IDENTIFICATION_2);
  2213. }
  2214. public function setInternalIdentification2(?string $value): User
  2215. {
  2216. if ($value === null) {
  2217. return $this;
  2218. }
  2219. $this->addExtension(UserExtensionFactory::setInternalIdentification2($this, $value));
  2220. return $this;
  2221. }
  2222. /**
  2223. * @Serializer\VirtualProperty()
  2224. * @SerializedName ("internalIdentification3")
  2225. *
  2226. * @Expose()
  2227. * @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
  2228. *
  2229. * @return string|null
  2230. */
  2231. public function getInternalIdentification3(): ?string
  2232. {
  2233. return $this->getExtensionBySlug(\App\Constants\UserExtension::INTERNAL_IDENTIFICATION_3);
  2234. }
  2235. public function setInternalIdentification3(?string $value): User
  2236. {
  2237. if ($value === null) {
  2238. return $this;
  2239. }
  2240. $this->addExtension(UserExtensionFactory::setInternalIdentification3($this, $value));
  2241. return $this;
  2242. }
  2243. /**
  2244. * @Serializer\VirtualProperty()
  2245. * @SerializedName ("potentialPoints")
  2246. *
  2247. * @Expose
  2248. * @Groups({
  2249. * "user:potentialPoints",
  2250. * "user:list",
  2251. * "user:item", "user", "get:read", "post:read", "export_user_datatable"})
  2252. *
  2253. * @return int|null
  2254. */
  2255. public function getPotentialPoints(): ?int
  2256. {
  2257. return $this->getExtensionBySlug(\App\Constants\UserExtension::POTENTIAL_POINTS);
  2258. }
  2259. /**
  2260. * @param $value
  2261. *
  2262. * @return $this
  2263. */
  2264. public function setPotentialPoints($value): User
  2265. {
  2266. $this->addExtension(UserExtensionFactory::setPotentialPoints($this, (int)$value));
  2267. return $this;
  2268. }
  2269. /**
  2270. * @param int $step
  2271. *
  2272. * @return string|null
  2273. */
  2274. public function getGoalByStep(int $step): ?string
  2275. {
  2276. $slug = \App\Constants\UserExtension::GOAL . '_' . $step;
  2277. return $this->getExtensionBySlug($slug);
  2278. }
  2279. public function setGoalByStep(string $value, int $step): User
  2280. {
  2281. $this->addExtension(UserExtensionFactory::setGoal($this, $value, $step));
  2282. return $this;
  2283. }
  2284. /**
  2285. * @param int $step
  2286. *
  2287. * @return string|null
  2288. */
  2289. public function getBonusPro(int $step): ?string
  2290. {
  2291. $slug = \App\Constants\UserExtension::BONUS_PRO . '_' . $step;
  2292. return $this->getExtensionBySlug($slug);
  2293. }
  2294. public function setBonusPro(?string $value, int $step): User
  2295. {
  2296. if ($value === null) {
  2297. return $this;
  2298. }
  2299. $this->addExtension(UserExtensionFactory::setBonusPro($this, $value, $step));
  2300. return $this;
  2301. }
  2302. public function setGoalPoints(?string $value): User
  2303. {
  2304. if ($value === null) {
  2305. return $this;
  2306. }
  2307. $this->addExtension(UserExtensionFactory::setGoalPoints($this, $value));
  2308. return $this;
  2309. }
  2310. /**
  2311. * @Serializer\VirtualProperty()
  2312. * @SerializedName ("parent_lvl_1")
  2313. * @Groups ({"user", "point_of_sale"})
  2314. *
  2315. * @return int
  2316. */
  2317. public function getParentLvl1(): int
  2318. {
  2319. // Boucle sur les commerciaux et retourne le premier
  2320. foreach ($this->parents as $parent) {
  2321. return $parent->getId();
  2322. }
  2323. return -1;
  2324. }
  2325. /**
  2326. * ============================================================================================
  2327. * ============================= FIN FONCTIONS CUSTOM =========================================
  2328. * ============================================================================================
  2329. */
  2330. public function getId(): ?int
  2331. {
  2332. return $this->id;
  2333. }
  2334. /**
  2335. * Le setter est obligatoire pour la partie portail lorsqu'on crée un utilisateur non mappé en bdd
  2336. *
  2337. * @param $id
  2338. *
  2339. * @return $this
  2340. */
  2341. public function setId($id): User
  2342. {
  2343. $this->id = $id;
  2344. return $this;
  2345. }
  2346. /**
  2347. * @Serializer\VirtualProperty()
  2348. * @SerializedName ("parent_lvl_1_code")
  2349. *
  2350. * @Expose()
  2351. * @Groups ({"user", "export_user_datatable", "export_admin_datatable", "sale_order", "export_order_datatable",
  2352. * "export_commercial_datatable"})
  2353. *
  2354. * @return string|null
  2355. */
  2356. public function getParentLvl1Code(): ?string
  2357. {
  2358. // Boucle sur les commerciaux et retourne le premier
  2359. foreach ($this->parents as $parent) {
  2360. return $parent->getInternalIdentification1();
  2361. }
  2362. return null;
  2363. }
  2364. /**
  2365. * @Serializer\VirtualProperty()
  2366. * @SerializedName ("internalIdentification1")
  2367. *
  2368. * @Expose()
  2369. * @Groups({
  2370. * "user:internal_identification_1",
  2371. * "user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable", "export_admin_datatable", "sale_order",
  2372. * "export_order_datatable",
  2373. * "export_installer_datatable",
  2374. * "export_commercial_datatable","export_agency_manager_datatable"})
  2375. *
  2376. * @return string|null
  2377. */
  2378. public function getInternalIdentification1(): ?string
  2379. {
  2380. return $this->getExtensionBySlug(\App\Constants\UserExtension::INTERNAL_IDENTIFICATION_1);
  2381. }
  2382. /**
  2383. * @Serializer\VirtualProperty()
  2384. * @SerializedName ("parent_lvl_2")
  2385. * @Groups ({"user", "point_of_sale"})
  2386. *
  2387. * @return int
  2388. */
  2389. public function getParentLvl2(): int
  2390. {
  2391. // Boucle sur les commerciaux
  2392. foreach ($this->parents as $parent) {
  2393. // Boucle sur les chefs d'agence et retourne le premier
  2394. foreach ($parent->getParents() as $grandParent) {
  2395. return $grandParent->getId();
  2396. }
  2397. }
  2398. return -1;
  2399. }
  2400. /**
  2401. * @return Collection<int, User>
  2402. */
  2403. public function getParents(): Collection
  2404. {
  2405. return $this->parents;
  2406. }
  2407. /**
  2408. * @Serializer\VirtualProperty()
  2409. * @SerializedName ("parent_lvl_3")
  2410. * @Groups ({"user", "point_of_sale"})
  2411. *
  2412. * @return int
  2413. */
  2414. public function getParentLvl3(): int
  2415. {
  2416. // Boucle sur les commerciaux
  2417. foreach ($this->parents as $parent) {
  2418. // Boucle sur les chefs d'agence et retourne le premier
  2419. foreach ($parent->getParents() as $grandParent) {
  2420. // Boucle sur les admins et retourne le premier
  2421. foreach ($grandParent->getParents() as $ggparent) {
  2422. return $ggparent->getId();
  2423. }
  2424. }
  2425. }
  2426. return -1;
  2427. }
  2428. /**
  2429. * @Serializer\VirtualProperty()
  2430. * @SerializedName ("pointOfSaleOfClient")
  2431. * @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
  2432. *
  2433. * @return string|null
  2434. */
  2435. public function getPointOfSaleOfClient(): ?string
  2436. {
  2437. // Boucle sur les commerciaux
  2438. if (!empty($this->parents)) {
  2439. foreach ($this->parents as $parent) {
  2440. if ($parent->getPointOfSale() !== null) {
  2441. return $parent->getPointOfSale()->getCode();
  2442. } else {
  2443. return null;
  2444. }
  2445. }
  2446. }
  2447. return null;
  2448. }
  2449. public function getPointOfSale(): ?PointOfSale
  2450. {
  2451. return $this->pointOfSale;
  2452. }
  2453. public function setPointOfSale(?PointOfSale $pointOfSale): User
  2454. {
  2455. $this->pointOfSale = $pointOfSale;
  2456. return $this;
  2457. }
  2458. /**
  2459. * @Serializer\VirtualProperty()
  2460. * @SerializedName ("pointOfSaleOfCommercial")
  2461. * @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
  2462. *
  2463. * @return string|null
  2464. */
  2465. public function getPointOfSaleOfCommercial(): ?string
  2466. {
  2467. // Boucle sur les commerciaux
  2468. if ($this->getPointOfSale() !== null) {
  2469. return $this->getPointOfSale()->getCode();
  2470. } else {
  2471. return null;
  2472. }
  2473. }
  2474. /**
  2475. * Retourne la date d'adhésion du client s'il en a une
  2476. *
  2477. * @Serializer\VirtualProperty()
  2478. * @SerializedName ("subscribedAt")
  2479. * @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
  2480. *
  2481. * @return string
  2482. */
  2483. public function getSubscribedAt(): string
  2484. {
  2485. if ($this->subscription instanceof UserSubscription) {
  2486. return $this->subscription->getSubscribedAt()->format('d/m/Y');
  2487. }
  2488. return '';
  2489. }
  2490. public function getNameCiv(): string
  2491. {
  2492. return trim($this->getCivility() . ' ' . trim($this->lastName . " " . $this->firstName));
  2493. }
  2494. public function getCivility(): ?string
  2495. {
  2496. return $this->civility;
  2497. }
  2498. public function setCivility(?string $civility): User
  2499. {
  2500. $this->civility = $civility;
  2501. return $this;
  2502. }
  2503. /*
  2504. * ============================================================================================
  2505. * ============================== FIN FONCTIONS CUSTOM ========================================
  2506. * ============================================================================================
  2507. */
  2508. public function getCivCode(): int
  2509. {
  2510. if ($this->getCivility() == 'M.') {
  2511. return 0;
  2512. } elseif ($this->getCivility() == 'Mme') {
  2513. return 1;
  2514. } else {
  2515. return 2;
  2516. }
  2517. }
  2518. /**
  2519. * @return void
  2520. * @deprecated
  2521. */
  2522. public function setActive()
  2523. {
  2524. $this->deletedAt = null;
  2525. $this->archivedAt = null;
  2526. }
  2527. public function isPurchaseAuthorized(): bool
  2528. {
  2529. return in_array('ROLE_INSTALLER', $this->getRoles()) || in_array('ROLE_SUPER_ADMIN', $this->getRoles());
  2530. }
  2531. public function getBillingAddresses()
  2532. {
  2533. return $this->getAddressByType(Address::TYPE_BILLING_ADDRESS);
  2534. }
  2535. /**
  2536. * @param $type
  2537. *
  2538. * @return Collection
  2539. */
  2540. private function getAddressByType($type)
  2541. {
  2542. $shippingAddress = new ArrayCollection();
  2543. foreach ($this->getAddresses() as $address) {
  2544. if ($address->getAddressType() == $type) {
  2545. $shippingAddress->add($address);
  2546. }
  2547. }
  2548. return $shippingAddress;
  2549. }
  2550. /**
  2551. * @return Collection|Address[]
  2552. */
  2553. public function getAddresses(): Collection
  2554. {
  2555. return $this->addresses;
  2556. }
  2557. /**
  2558. * @return DateTimeInterface|null
  2559. * @deprecated
  2560. */
  2561. public function getLevel1UpdatedAt(): ?DateTimeInterface
  2562. {
  2563. return $this->level1UpdatedAt;
  2564. }
  2565. /**
  2566. * @param DateTimeInterface|null $level1UpdatedAt
  2567. *
  2568. * @return $this
  2569. * @deprecated
  2570. */
  2571. public function setLevel1UpdatedAt(?DateTimeInterface $level1UpdatedAt): User
  2572. {
  2573. $this->level1UpdatedAt = $level1UpdatedAt;
  2574. return $this;
  2575. }
  2576. /**
  2577. * @return DateTimeInterface|null
  2578. * @deprecated
  2579. */
  2580. public function getLevel2UpdatedAt(): ?DateTimeInterface
  2581. {
  2582. return $this->level2UpdatedAt;
  2583. }
  2584. /**
  2585. * @param DateTimeInterface|null $level2UpdatedAt
  2586. *
  2587. * @return $this
  2588. * @deprecated
  2589. */
  2590. public function setLevel2UpdatedAt(?DateTimeInterface $level2UpdatedAt): User
  2591. {
  2592. $this->level2UpdatedAt = $level2UpdatedAt;
  2593. return $this;
  2594. }
  2595. /**
  2596. * @Serializer\VirtualProperty
  2597. * @SerializedName("name")
  2598. * @Groups({
  2599. * "user:name",
  2600. * "export_installer_datatable", "export_purchase_declaration_datatable",
  2601. * "export_agency_manager_commercial_datatable",
  2602. * "export_commercial_installer_datatable"})
  2603. *
  2604. * @return string
  2605. */
  2606. public function getName(): string
  2607. {
  2608. return $this->lastName . " " . $this->firstName;
  2609. }
  2610. /**
  2611. * @Serializer\VirtualProperty()
  2612. * @SerializedName("codeDep")
  2613. * @Expose()
  2614. * @Groups({
  2615. * "user:code_dep",
  2616. * "export_installer_datatable", "export_commercial_installer_datatable"})
  2617. *
  2618. * @return false|string|null
  2619. */
  2620. public function getCodeDep()
  2621. {
  2622. return $this->getPostcode() !== null ? substr($this->getPostcode(), 0, 2) : null;
  2623. }
  2624. public function getPostcode(): ?string
  2625. {
  2626. return $this->postcode;
  2627. }
  2628. public function setPostcode(?string $postcode): User
  2629. {
  2630. $this->postcode = $postcode;
  2631. return $this;
  2632. }
  2633. /**
  2634. * @return Collection|Address[]
  2635. */
  2636. public function getShippingAddresses()
  2637. {
  2638. return $this->getAddressByType(Address::TYPE_SHIPPING_ADDRESS);
  2639. }
  2640. /**
  2641. * @return Address|null
  2642. */
  2643. public function getPreferredShippingAddress(): ?Address
  2644. {
  2645. foreach ($this->getShippingAddresses() as $address) {
  2646. if ($address->getPreferred()) {
  2647. return $address;
  2648. }
  2649. }
  2650. return null;
  2651. }
  2652. /**
  2653. * GARDER POUR LA SSO
  2654. *
  2655. * @return string
  2656. */
  2657. public function getUsername(): string
  2658. {
  2659. return (string)$this->email;
  2660. }
  2661. /**
  2662. * @return string
  2663. */
  2664. public function getRawUsername(): string
  2665. {
  2666. return (string)$this->username;
  2667. }
  2668. /**
  2669. * @param string|null $username
  2670. *
  2671. * @return $this
  2672. * @deprecated
  2673. */
  2674. public function setUsername(?string $username): User
  2675. {
  2676. $this->username = $username;
  2677. return $this;
  2678. }
  2679. /**
  2680. * GARDER POUR LA SSO
  2681. *
  2682. * @return string
  2683. */
  2684. public function getUserIdentifier(): string
  2685. {
  2686. return (string)$this->email;
  2687. }
  2688. public function isDex(): bool
  2689. {
  2690. return true;
  2691. }
  2692. public function getWelcomeEmail(): ?DateTimeInterface
  2693. {
  2694. return $this->welcomeEmail;
  2695. }
  2696. public function setWelcomeEmail(?DateTimeInterface $welcomeEmail): User
  2697. {
  2698. $this->welcomeEmail = $welcomeEmail;
  2699. return $this;
  2700. }
  2701. public function getAccountAddress(): string
  2702. {
  2703. return trim($this->address1 . ' ' . $this->address2) . ' ' . $this->postcode . ' ' . $this->city;
  2704. }
  2705. public function eraseCredentials()
  2706. {
  2707. // If you store any temporary, sensitive data on the user, clear it here
  2708. $this->plainPassword = null;
  2709. }
  2710. public function generateAndSetPassword()
  2711. {
  2712. $pwd = substr(str_shuffle('23456789QWERTYUPASDFGHJKLZXCVBNM'), 0, 12);
  2713. $this->setPassword($pwd);
  2714. return $pwd;
  2715. }
  2716. public function getOldEmail(): ?string
  2717. {
  2718. return $this->oldEmail;
  2719. }
  2720. public function setOldEmail(?string $oldEmail): void
  2721. {
  2722. if (is_string($oldEmail)) {
  2723. $oldEmail = trim($oldEmail);
  2724. }
  2725. $this->oldEmail = $oldEmail;
  2726. }
  2727. public function getPassword(): ?string
  2728. {
  2729. return $this->password;
  2730. }
  2731. public function setPassword(string $password): User
  2732. {
  2733. // Chaque fois que le mot de passe est modifié, mettre à jour la date
  2734. // et remettre à 0 le compteur d'essai
  2735. $this->passwordUpdatedAt = new DateTime();
  2736. $this->setFailedAttempts(0);
  2737. $this->password = $password;
  2738. return $this;
  2739. }
  2740. public function getSalt(): ?string
  2741. {
  2742. return $this->salt;
  2743. }
  2744. public function setSalt(?string $salt): User
  2745. {
  2746. $this->salt = $salt;
  2747. return $this;
  2748. }
  2749. public function getPlainPassword(): ?string
  2750. {
  2751. return $this->plainPassword;
  2752. }
  2753. public function setPlainPassword($plainPassword): User
  2754. {
  2755. // Ajout de l'ancien mot de passe dans l'historique
  2756. if ($plainPassword !== null) {
  2757. $passwordHistory = new PasswordHistory();
  2758. $passwordHistory->setUser($this);
  2759. $passwordHistory->setHashedPassword(md5($plainPassword));
  2760. $this->passwordHistories[] = $passwordHistory;
  2761. }
  2762. $this->plainPassword = $plainPassword;
  2763. return $this;
  2764. }
  2765. public function getFirstName(): ?string
  2766. {
  2767. return $this->firstName;
  2768. }
  2769. public function setFirstName(?string $firstName): User
  2770. {
  2771. if ($firstName) {
  2772. $firstName = ucfirst(strtolower(trim($firstName)));
  2773. }
  2774. $this->firstName = $firstName;
  2775. return $this;
  2776. }
  2777. public function getLastName(): ?string
  2778. {
  2779. return $this->lastName;
  2780. }
  2781. public function setLastName(?string $lastName): User
  2782. {
  2783. if ($lastName) {
  2784. $lastName = strtoupper(trim($lastName));
  2785. }
  2786. $this->lastName = $lastName;
  2787. return $this;
  2788. }
  2789. public function getMobile(): ?string
  2790. {
  2791. if (!$this->mobile) {
  2792. return null;
  2793. }
  2794. $mobile = str_replace(['-', '/', '.', ' '], '-', $this->mobile);
  2795. $re = '/^(?:(?:(?:\+|00)33[ ]?(?:\(0\)[ ]?)?)|0){1}[1-9]{1}([ .-]?)(?:\d{2}\1?){3}\d{2}$/m';
  2796. preg_match_all($re, '0' . $mobile, $matches, PREG_SET_ORDER);
  2797. if (!empty($matches)) {
  2798. $mobile = '0' . $mobile;
  2799. }
  2800. return $mobile;
  2801. }
  2802. public function setMobile(?string $mobile): User
  2803. {
  2804. $this->mobile = $mobile;
  2805. return $this;
  2806. }
  2807. public function getPhone(): ?string
  2808. {
  2809. if (!$this->phone) {
  2810. return null;
  2811. }
  2812. $phone = str_replace(['-', '/', '.', ' '], '-', $this->phone);
  2813. $re = '/^(?:(?:(?:\+|00)33[ ]?(?:\(0\)[ ]?)?)|0){1}[1-9]{1}([ .-]?)(?:\d{2}\1?){3}\d{2}$/m';
  2814. preg_match_all($re, '0' . $phone, $matches, PREG_SET_ORDER);
  2815. if (!empty($matches)) {
  2816. $phone = '0' . $phone;
  2817. }
  2818. return $phone;
  2819. }
  2820. public function setPhone(?string $phone): User
  2821. {
  2822. $this->phone = $phone;
  2823. return $this;
  2824. }
  2825. /**
  2826. * @return int|null
  2827. * @deprecated
  2828. */
  2829. public function getAvailablePoint(): ?int
  2830. {
  2831. return $this->availablePoint;
  2832. }
  2833. /**
  2834. * @param int $availablePoint
  2835. *
  2836. * @return $this
  2837. * @deprecated
  2838. */
  2839. public function setAvailablePoint(int $availablePoint): User
  2840. {
  2841. $this->availablePoint = $availablePoint;
  2842. return $this;
  2843. }
  2844. /**
  2845. * @return int|null
  2846. * @deprecated
  2847. */
  2848. public function getPotentialPoint(): ?int
  2849. {
  2850. return $this->potentialPoint;
  2851. }
  2852. /**
  2853. * @param int $potentialPoint
  2854. *
  2855. * @return $this
  2856. * @deprecated
  2857. */
  2858. public function setPotentialPoint(int $potentialPoint): User
  2859. {
  2860. $this->potentialPoint = $potentialPoint;
  2861. return $this;
  2862. }
  2863. /**
  2864. * @return string|null
  2865. * @deprecated
  2866. */
  2867. public function getLocale(): ?string
  2868. {
  2869. return $this->locale;
  2870. }
  2871. /**
  2872. * @param string|null $locale
  2873. *
  2874. * @return $this
  2875. * @deprecated
  2876. */
  2877. public function setLocale(?string $locale): User
  2878. {
  2879. $this->locale = $locale;
  2880. return $this;
  2881. }
  2882. public function getCountry(): ?Country
  2883. {
  2884. return $this->country;
  2885. }
  2886. public function setCountry(?Country $country): User
  2887. {
  2888. $this->country = $country;
  2889. return $this;
  2890. }
  2891. public function getJob(): ?string
  2892. {
  2893. if ($this->job === '') {
  2894. return null;
  2895. }
  2896. return $this->job;
  2897. }
  2898. public function setJob(?string $job): User
  2899. {
  2900. $this->job = $job;
  2901. return $this;
  2902. }
  2903. public function getCompany(): ?string
  2904. {
  2905. return $this->company;
  2906. }
  2907. public function setCompany(?string $company): User
  2908. {
  2909. $this->company = $company;
  2910. return $this;
  2911. }
  2912. /**
  2913. * @deprecated
  2914. */
  2915. public function getUserToken(): ?string
  2916. {
  2917. return $this->userToken;
  2918. }
  2919. /**
  2920. * @deprecated
  2921. */
  2922. public function setUserToken(?string $userToken): User
  2923. {
  2924. $this->userToken = $userToken;
  2925. return $this;
  2926. }
  2927. /**
  2928. * @deprecated
  2929. */
  2930. public function getUserTokenValidity(): ?DateTimeInterface
  2931. {
  2932. return $this->userTokenValidity;
  2933. }
  2934. /**
  2935. * @deprecated
  2936. */
  2937. public function setUserTokenValidity(?DateTimeInterface $userTokenValidity): User
  2938. {
  2939. $this->userTokenValidity = $userTokenValidity;
  2940. return $this;
  2941. }
  2942. /**
  2943. * @deprecated
  2944. */
  2945. public function getUserTokenAttempts(): ?int
  2946. {
  2947. return $this->userTokenAttempts;
  2948. }
  2949. /**
  2950. * @deprecated
  2951. */
  2952. public function setUserTokenAttempts(int $userTokenAttempts): User
  2953. {
  2954. $this->userTokenAttempts = $userTokenAttempts;
  2955. return $this;
  2956. }
  2957. public function getAddress1(): ?string
  2958. {
  2959. return $this->address1;
  2960. }
  2961. public function setAddress1(?string $address1): User
  2962. {
  2963. $this->address1 = $address1;
  2964. return $this;
  2965. }
  2966. public function getAddress2(): ?string
  2967. {
  2968. return $this->address2;
  2969. }
  2970. public function setAddress2(?string $address2): User
  2971. {
  2972. $this->address2 = $address2;
  2973. return $this;
  2974. }
  2975. // /**
  2976. // * @Serializer\VirtualProperty()
  2977. // * @SerializedName ("birthDate")
  2978. // * @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
  2979. // *
  2980. // *
  2981. // * @return DateTimeInterface|null
  2982. // */
  2983. // public function getBirthDate(): ?DateTimeInterface
  2984. // {
  2985. // try {
  2986. // return new DateTime( $this->getExtensionBySlug( \App\Constants\UserExtension::BIRTH_DATE ) );
  2987. // }
  2988. // catch ( Exception $e ) {
  2989. // return null;
  2990. // }
  2991. // }
  2992. public function getCity(): ?string
  2993. {
  2994. return $this->city;
  2995. }
  2996. public function setCity(?string $city): User
  2997. {
  2998. $this->city = $city;
  2999. return $this;
  3000. }
  3001. public function getCanOrder(): ?bool
  3002. {
  3003. return $this->canOrder;
  3004. }
  3005. public function setCanOrder(?bool $canOrder): User
  3006. {
  3007. $this->canOrder = $canOrder;
  3008. return $this;
  3009. }
  3010. public function getDeletedAt(): ?DateTimeInterface
  3011. {
  3012. return $this->deletedAt;
  3013. }
  3014. public function setDeletedAt(?DateTimeInterface $deletedAt): User
  3015. {
  3016. $this->deletedAt = $deletedAt;
  3017. return $this;
  3018. }
  3019. /**
  3020. * @Serializer\VirtualProperty()
  3021. * @SerializedName ("birthDate")
  3022. * @Groups({"user:list", "user:item", "user", "get:read", "post:read", "export_user_datatable"})
  3023. *
  3024. *
  3025. * @return DateTimeInterface|null
  3026. */
  3027. public function getBirthDate(): ?DateTimeInterface
  3028. {
  3029. try {
  3030. return new DateTime($this->getExtensionBySlug(\App\Constants\UserExtension::BIRTH_DATE));
  3031. } catch (Exception $e) {
  3032. return null;
  3033. }
  3034. }
  3035. /**
  3036. * @throws Exception
  3037. */
  3038. public function setBirthDate($value): User
  3039. {
  3040. if ($value === null) {
  3041. return $this;
  3042. }
  3043. if ($value instanceof DateTimeInterface) {
  3044. $value = $value->format('Y-m-d');
  3045. }
  3046. $this->addExtension(UserExtensionFactory::setBirthDate($this, $value));
  3047. return $this;
  3048. }
  3049. public function getBirthCity(): ?string
  3050. {
  3051. return $this->getExtensionBySlug(\App\Constants\UserExtension::BIRTH_CITY);
  3052. }
  3053. public function setBirthCity(?string $value): User
  3054. {
  3055. if ($value === null) {
  3056. return $this;
  3057. }
  3058. $this->addExtension(UserExtensionFactory::setBirthCity($this, $value));
  3059. return $this;
  3060. }
  3061. public function getSocialSecurityNumber(): ?string
  3062. {
  3063. return $this->getExtensionBySlug(\App\Constants\UserExtension::SOCIAL_SECURITY_NUMBER);
  3064. }
  3065. public function setSocialSecurityNumber(?string $value): User
  3066. {
  3067. if ($value === null) {
  3068. return $this;
  3069. }
  3070. $this->addExtension(UserExtensionFactory::setSocialSecurityNbr($this, $value));
  3071. return $this;
  3072. }
  3073. /**
  3074. * @return array
  3075. */
  3076. public function getSecondaryEmails(): array
  3077. {
  3078. $emails = $this->getExtensionBySlug(\App\Constants\UserExtension::SECONDARY_EMAILS);
  3079. if (empty($emails)) {
  3080. return [];
  3081. }
  3082. return json_decode($emails, true);
  3083. }
  3084. /**
  3085. * @param array $emails
  3086. *
  3087. * @return $this
  3088. */
  3089. public function setSecondaryEmails(array $emails): User
  3090. {
  3091. $val = [];
  3092. foreach ($emails as $email) {
  3093. $email = trim(strtolower($email));
  3094. if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
  3095. throw new InvalidArgumentException('email invalide');
  3096. }
  3097. $val[] = $email;
  3098. }
  3099. $this->addExtension(UserExtensionFactory::setSecondaryEmails($this, json_encode($val)));
  3100. return $this;
  3101. }
  3102. /**
  3103. * @param string $email
  3104. *
  3105. * @return $this
  3106. */
  3107. public function addSecondaryEmail(string $email): User
  3108. {
  3109. $email = trim(strtolower($email));
  3110. if (!filter_var($email, FILTER_VALIDATE_EMAIL)) {
  3111. throw new InvalidArgumentException("email ($email) invalide");
  3112. }
  3113. $emails = $this->getSecondaryEmails();
  3114. if (!in_array($email, $emails)) {
  3115. $emails[] = $email;
  3116. $this->addExtension(UserExtensionFactory::setSecondaryEmails($this, json_encode($emails)));
  3117. }
  3118. return $this;
  3119. }
  3120. /**
  3121. * @param string $email
  3122. *
  3123. * @return $this
  3124. */
  3125. public function removeSecondaryEmail(string $email): User
  3126. {
  3127. $email = trim(strtolower($email));
  3128. $emails = $this->getSecondaryEmails();
  3129. $key = array_search($email, $emails);
  3130. if ($key) {
  3131. unset($emails[$key]);
  3132. $this->addExtension(UserExtensionFactory::setSecondaryEmails($this, json_encode($emails)));
  3133. }
  3134. return $this;
  3135. }
  3136. public function getInternalCode(): ?string
  3137. {
  3138. return $this->internalCode;
  3139. }
  3140. public function setInternalCode(?string $internalCode): User
  3141. {
  3142. $this->internalCode = $internalCode;
  3143. return $this;
  3144. }
  3145. public function getCguAt(): ?DateTimeInterface
  3146. {
  3147. return $this->cguAt;
  3148. }
  3149. public function setCguAt(?DateTimeInterface $cguAt): User
  3150. {
  3151. $this->cguAt = $cguAt;
  3152. return $this;
  3153. }
  3154. public function getRegisterAt(): ?DateTimeInterface
  3155. {
  3156. return $this->registerAt;
  3157. }
  3158. public function setRegisterAt(?DateTimeInterface $registerAt): User
  3159. {
  3160. $this->registerAt = $registerAt;
  3161. return $this;
  3162. }
  3163. public function getImportedAt(): ?DateTimeInterface
  3164. {
  3165. return $this->importedAt;
  3166. }
  3167. public function setImportedAt(?DateTimeInterface $importedAt): User
  3168. {
  3169. $this->importedAt = $importedAt;
  3170. return $this;
  3171. }
  3172. public function getCanBeContacted(): ?bool
  3173. {
  3174. return $this->canBeContacted;
  3175. }
  3176. public function setCanBeContacted(bool $canBeContacted): User
  3177. {
  3178. $this->canBeContacted = $canBeContacted;
  3179. return $this;
  3180. }
  3181. /**
  3182. * @deprecated
  3183. */
  3184. public function getCapacity(): ?string
  3185. {
  3186. return $this->capacity;
  3187. }
  3188. /**
  3189. * @deprecated
  3190. */
  3191. public function setCapacity(?string $capacity): User
  3192. {
  3193. $this->capacity = $capacity;
  3194. return $this;
  3195. }
  3196. public function getAddress3(): ?string
  3197. {
  3198. return $this->address3;
  3199. }
  3200. public function setAddress3(?string $address3): User
  3201. {
  3202. $this->address3 = $address3;
  3203. return $this;
  3204. }
  3205. public function getOptinMail(): ?bool
  3206. {
  3207. return $this->optinMail;
  3208. }
  3209. public function setOptinMail(bool $optinMail): User
  3210. {
  3211. $this->optinMail = $optinMail;
  3212. return $this;
  3213. }
  3214. public function getOptinSMS(): ?bool
  3215. {
  3216. return $this->optinSMS;
  3217. }
  3218. public function setOptinSMS(bool $optinSMS): User
  3219. {
  3220. $this->optinSMS = $optinSMS;
  3221. return $this;
  3222. }
  3223. public function getOptinPostal(): ?bool
  3224. {
  3225. return $this->optinPostal;
  3226. }
  3227. public function setOptinPostal(bool $optinPostal): User
  3228. {
  3229. $this->optinPostal = $optinPostal;
  3230. return $this;
  3231. }
  3232. public function getOptinPostalAddress(): ?string
  3233. {
  3234. return $this->optinPostalAddress;
  3235. }
  3236. public function setOptinPostalAddress(?string $optinPostalAddress): User
  3237. {
  3238. $this->optinPostalAddress = $optinPostalAddress;
  3239. return $this;
  3240. }
  3241. public function getSource(): ?string
  3242. {
  3243. return $this->source;
  3244. }
  3245. public function setSource(?string $source): User
  3246. {
  3247. $this->source = $source;
  3248. return $this;
  3249. }
  3250. /**
  3251. * @return int|null
  3252. * @deprecated {@see UserPointService::getLevel()}
  3253. */
  3254. public function getLevel(): ?int
  3255. {
  3256. return $this->level;
  3257. }
  3258. /**
  3259. * @param int $level
  3260. *
  3261. * @return $this
  3262. * @deprecated
  3263. */
  3264. public function setLevel(int $level): User
  3265. {
  3266. $this->level = $level;
  3267. return $this;
  3268. }
  3269. /**
  3270. * @return DateTimeInterface|null
  3271. * @deprecated
  3272. */
  3273. public function getLevel0UpdatedAt(): ?DateTimeInterface
  3274. {
  3275. return $this->level0UpdatedAt;
  3276. }
  3277. /**
  3278. * @param DateTimeInterface|null $level0UpdatedAt
  3279. *
  3280. * @return $this
  3281. * @deprecated
  3282. */
  3283. public function setLevel0UpdatedAt(?DateTimeInterface $level0UpdatedAt): User
  3284. {
  3285. $this->level0UpdatedAt = $level0UpdatedAt;
  3286. return $this;
  3287. }
  3288. public function getLevel3UpdatedAt(): ?DateTimeInterface
  3289. {
  3290. return $this->level3UpdatedAt;
  3291. }
  3292. /**
  3293. * @param DateTimeInterface|null $level3UpdatedAt
  3294. *
  3295. * @return $this
  3296. * @deprecated
  3297. */
  3298. public function setLevel3UpdatedAt(?DateTimeInterface $level3UpdatedAt): User
  3299. {
  3300. $this->level3UpdatedAt = $level3UpdatedAt;
  3301. return $this;
  3302. }
  3303. /**
  3304. * @return DateTimeInterface|null
  3305. * @deprecated
  3306. */
  3307. public function getLevelUpdateSeenAt(): ?DateTimeInterface
  3308. {
  3309. return $this->levelUpdateSeenAt;
  3310. }
  3311. /**
  3312. * @param DateTimeInterface|null $levelUpdateSeenAt
  3313. *
  3314. * @return $this
  3315. * @deprecated
  3316. */
  3317. public function setLevelUpdateSeenAt(?DateTimeInterface $levelUpdateSeenAt): User
  3318. {
  3319. $this->levelUpdateSeenAt = $levelUpdateSeenAt;
  3320. return $this;
  3321. }
  3322. /**
  3323. * @return bool|null
  3324. */
  3325. public function getIsEmailOk(): ?bool
  3326. {
  3327. return $this->isEmailOk;
  3328. }
  3329. /**
  3330. * @param bool $isEmailOk
  3331. *
  3332. * @return $this
  3333. */
  3334. public function setIsEmailOk(bool $isEmailOk): User
  3335. {
  3336. $this->isEmailOk = $isEmailOk;
  3337. return $this;
  3338. }
  3339. /**
  3340. * @return DateTimeInterface|null
  3341. */
  3342. public function getLastEmailCheck(): ?DateTimeInterface
  3343. {
  3344. return $this->lastEmailCheck;
  3345. }
  3346. /**
  3347. * @param DateTimeInterface|null $lastEmailCheck
  3348. *
  3349. * @return $this
  3350. */
  3351. public function setLastEmailCheck(?DateTimeInterface $lastEmailCheck): User
  3352. {
  3353. $this->lastEmailCheck = $lastEmailCheck;
  3354. return $this;
  3355. }
  3356. /**
  3357. * @return string|null
  3358. * @deprecated
  3359. */
  3360. public function getApiToken(): ?string
  3361. {
  3362. return $this->apiToken;
  3363. }
  3364. /**
  3365. * @param string|null $apiToken
  3366. *
  3367. * @return $this
  3368. * @deprecated
  3369. */
  3370. public function setApiToken(?string $apiToken): User
  3371. {
  3372. $this->apiToken = $apiToken;
  3373. return $this;
  3374. }
  3375. public function getSapDistributor(): ?string
  3376. {
  3377. return $this->sapDistributor;
  3378. }
  3379. public function setSapDistributor(?string $sapDistributor): User
  3380. {
  3381. $this->sapDistributor = $sapDistributor;
  3382. return $this;
  3383. }
  3384. public function getDistributor(): ?string
  3385. {
  3386. return $this->distributor;
  3387. }
  3388. public function setDistributor(?string $distributor): User
  3389. {
  3390. $this->distributor = $distributor;
  3391. return $this;
  3392. }
  3393. public function getDistributor2(): ?string
  3394. {
  3395. return $this->distributor2;
  3396. }
  3397. public function setDistributor2(?string $distributor2): User
  3398. {
  3399. $this->distributor2 = $distributor2;
  3400. return $this;
  3401. }
  3402. public function getAggreement(): ?bool
  3403. {
  3404. return $this->aggreement;
  3405. }
  3406. public function setAggreement(?bool $aggreement): User
  3407. {
  3408. $this->aggreement = $aggreement;
  3409. return $this;
  3410. }
  3411. public function getUnsubscribedAt(): ?DateTimeInterface
  3412. {
  3413. return $this->unsubscribedAt;
  3414. }
  3415. public function setUnsubscribedAt(?DateTimeInterface $unsubscribedAt): User
  3416. {
  3417. $this->unsubscribedAt = $unsubscribedAt;
  3418. return $this;
  3419. }
  3420. public function addAddress(Address $address): User
  3421. {
  3422. if (!$this->addresses->contains($address)) {
  3423. $this->addresses->add($address);
  3424. $user = $address->getUser();
  3425. if ($user) {
  3426. $user->removeAddress($address);
  3427. }
  3428. $address->setUser($this);
  3429. }
  3430. return $this;
  3431. }
  3432. public function removeAddress(Address $address): User
  3433. {
  3434. if ($this->addresses->removeElement($address)) {
  3435. // set the owning side to null (unless already changed)
  3436. if ($address->getUser() === $this) {
  3437. $address->setUser(null);
  3438. }
  3439. }
  3440. return $this;
  3441. }
  3442. public function getCarts(): Collection
  3443. {
  3444. return $this->carts;
  3445. }
  3446. public function addCart(Cart $cart): User
  3447. {
  3448. if (!$this->carts->contains($cart)) {
  3449. $this->carts[] = $cart;
  3450. $cart->setUser($this);
  3451. }
  3452. return $this;
  3453. }
  3454. public function removeCart(Cart $cart): User
  3455. {
  3456. if ($this->carts->removeElement($cart)) {
  3457. // set the owning side to null (unless already changed)
  3458. if ($cart->getUser() === $this) {
  3459. $cart->setUser(null);
  3460. }
  3461. }
  3462. return $this;
  3463. }
  3464. public function getSapAccount(): ?string
  3465. {
  3466. return $this->sapAccount;
  3467. }
  3468. public function setSapAccount(?string $sapAccount): User
  3469. {
  3470. $this->sapAccount = $sapAccount;
  3471. return $this;
  3472. }
  3473. /**
  3474. * @return User|null
  3475. */
  3476. public function getMainAccountUser(): ?User
  3477. {
  3478. return $this->mainAccountUser;
  3479. }
  3480. /**
  3481. * @param User|null $mainAccountUser
  3482. *
  3483. * @return $this
  3484. */
  3485. public function setMainAccountUser(?User $mainAccountUser = null, bool $setSubAccountUser = true): User
  3486. {
  3487. if ($setSubAccountUser) {
  3488. if ($mainAccountUser) {
  3489. $mainAccountUser->addSubAccountUser($this, false);
  3490. } elseif ($this->mainAccountUser) {
  3491. $this->mainAccountUser->removeSubAccountUser($this, false);
  3492. }
  3493. }
  3494. $this->mainAccountUser = $mainAccountUser;
  3495. return $this;
  3496. }
  3497. /**
  3498. * @return Collection|User[]
  3499. */
  3500. public function getSubAccountUsers(): Collection
  3501. {
  3502. $subAccountUsers = clone $this->subAccountUsers;
  3503. $subAccountUsers->removeElement($this);
  3504. return $subAccountUsers;
  3505. }
  3506. /**
  3507. * @param iterable|User[] $subAccountUsers
  3508. *
  3509. * @return User
  3510. */
  3511. public function setSubAccountUsers(iterable $subAccountUsers, bool $setMainAccountUser = true): User
  3512. {
  3513. foreach ($this->subAccountUsers as $subAccountUser) {
  3514. $this->removeSubAccountUser($subAccountUser, $setMainAccountUser);
  3515. }
  3516. foreach ($subAccountUsers as $subAccountUser) {
  3517. $this->addSubAccountUser($subAccountUser, $setMainAccountUser);
  3518. }
  3519. return $this;
  3520. }
  3521. /**
  3522. * @param User $subAccountUser
  3523. * @param bool $setMainAccountUser
  3524. *
  3525. * @return $this
  3526. */
  3527. public function addSubAccountUser(User $subAccountUser, bool $setMainAccountUser = true): User
  3528. {
  3529. if (!$this->subAccountUsers->contains($subAccountUser)) {
  3530. $this->subAccountUsers->add($subAccountUser);
  3531. if ($setMainAccountUser) {
  3532. $subAccountUser->setMainAccountUser($this, false);
  3533. }
  3534. }
  3535. return $this;
  3536. }
  3537. /**
  3538. * @param User $subAccountUser
  3539. * @param bool $setMainAccountUser
  3540. *
  3541. * @return User
  3542. */
  3543. public function removeSubAccountUser(User $subAccountUser, bool $setMainAccountUser = true): User
  3544. {
  3545. if ($this->subAccountUsers->contains($subAccountUser)) {
  3546. $this->subAccountUsers->removeElement($subAccountUser);
  3547. if ($setMainAccountUser) {
  3548. $subAccountUser->setMainAccountUser(null, false);
  3549. }
  3550. }
  3551. return $this;
  3552. }
  3553. public function getDistributors(): Collection
  3554. {
  3555. return $this->distributors;
  3556. }
  3557. public function addDistributor(Distributor $distributor): User
  3558. {
  3559. if (!$this->distributors->contains($distributor)) {
  3560. $this->distributors[] = $distributor;
  3561. }
  3562. return $this;
  3563. }
  3564. public function removeDistributor(Distributor $distributor): User
  3565. {
  3566. $this->distributors->removeElement($distributor);
  3567. return $this;
  3568. }
  3569. public function getPurchases(): Collection
  3570. {
  3571. return $this->purchases;
  3572. }
  3573. public function addPurchase(Purchase $purchase): User
  3574. {
  3575. if (!$this->purchases->contains($purchase)) {
  3576. $this->purchases[] = $purchase;
  3577. $purchase->setValidator($this);
  3578. }
  3579. return $this;
  3580. }
  3581. public function removePurchase(Purchase $purchase): User
  3582. {
  3583. if ($this->purchases->removeElement($purchase)) {
  3584. // set the owning side to null (unless already changed)
  3585. if ($purchase->getValidator() === $this) {
  3586. $purchase->setValidator(null);
  3587. }
  3588. }
  3589. return $this;
  3590. }
  3591. public function getPurchasesIHaveProcessed(): Collection
  3592. {
  3593. return $this->purchasesIHaveProcessed;
  3594. }
  3595. public function addPurchaseIHaveProcessed(Purchase $purchasesIHaveProcessed): User
  3596. {
  3597. if (!$this->purchasesIHaveProcessed->contains($purchasesIHaveProcessed)) {
  3598. $this->purchasesIHaveProcessed[] = $purchasesIHaveProcessed;
  3599. $purchasesIHaveProcessed->setValidator($this);
  3600. }
  3601. return $this;
  3602. }
  3603. public function removePurchaseIHaveProcessed(Purchase $purchasesIHaveProcessed): User
  3604. {
  3605. if ($this->purchasesIHaveProcessed->removeElement($purchasesIHaveProcessed)) {
  3606. // set the owning side to null (unless already changed)
  3607. if ($purchasesIHaveProcessed->getValidator() === $this) {
  3608. $purchasesIHaveProcessed->setValidator(null);
  3609. }
  3610. }
  3611. return $this;
  3612. }
  3613. /**
  3614. * @param array|null $status
  3615. *
  3616. * @return Collection|SaleOrder[]
  3617. */
  3618. public function getOrders(?array $status = null): Collection
  3619. {
  3620. if (empty($status)) {
  3621. return $this->orders;
  3622. }
  3623. $orders = new ArrayCollection();
  3624. foreach ($this->orders as $order) {
  3625. if (in_array($order->getStatus(), $status)) {
  3626. $orders->add($order);
  3627. }
  3628. }
  3629. return $orders;
  3630. }
  3631. public function addOrder(SaleOrder $order): User
  3632. {
  3633. if (!$this->orders->contains($order)) {
  3634. $this->orders->add($order);
  3635. $user = $order->getUser();
  3636. if ($user) {
  3637. $user->removeOrder($order);
  3638. }
  3639. $order->setUser($this);
  3640. }
  3641. return $this;
  3642. }
  3643. public function removeOrder(SaleOrder $order): User
  3644. {
  3645. if ($this->orders->removeElement($order)) {
  3646. // set the owning side to null (unless already changed)
  3647. if ($order->getUser() === $this) {
  3648. $order->setUser(null);
  3649. }
  3650. }
  3651. return $this;
  3652. }
  3653. /**
  3654. * @return Collection|User[]
  3655. */
  3656. public function getGodchilds(): Collection
  3657. {
  3658. return $this->godchilds;
  3659. }
  3660. /**
  3661. * @param User $godchild
  3662. *
  3663. * @return $this
  3664. */
  3665. public function addGodchild(User $godchild, bool $setGodFather = true): User
  3666. {
  3667. if (!$this->godchilds->contains($godchild)) {
  3668. $this->godchilds->add($godchild);
  3669. if ($setGodFather) {
  3670. $godchild->setGodfather($this, false);
  3671. }
  3672. }
  3673. return $this;
  3674. }
  3675. /**
  3676. * @param User $godchild
  3677. *
  3678. * @return $this
  3679. */
  3680. public function removeGodchild(User $godchild, bool $setGodFather = true): User
  3681. {
  3682. if ($this->godchilds->removeElement($godchild) && $setGodFather) {
  3683. $godchild->setGodfather(null, false);
  3684. }
  3685. return $this;
  3686. }
  3687. /**
  3688. * @return User
  3689. */
  3690. public function getGodfather(): ?User
  3691. {
  3692. return $this->godfather;
  3693. }
  3694. /**
  3695. * @param User|null $godfather
  3696. *
  3697. * @return $this
  3698. */
  3699. public function setGodfather(?User $godfather = null, bool $updateGodchild = true): User
  3700. {
  3701. if ($this->godfather !== $godfather) {
  3702. if ($updateGodchild && $this->godfather) {
  3703. $this->godfather->removeGodchild($this, false);
  3704. }
  3705. if ($updateGodchild && $godfather) {
  3706. $godfather->addGodchild($this, false);
  3707. }
  3708. $this->godfather = $godfather;
  3709. }
  3710. return $this;
  3711. }
  3712. public function isGodFather(): bool
  3713. {
  3714. return !$this->godchilds->isEmpty();
  3715. }
  3716. public function isGodChild(): bool
  3717. {
  3718. return $this->godfather !== null;
  3719. }
  3720. /**
  3721. * @deprecated
  3722. */
  3723. public function getSatisfactions(): Collection
  3724. {
  3725. return $this->satisfactions;
  3726. }
  3727. /**
  3728. * @deprecated
  3729. */
  3730. public function addSatisfaction(Satisfaction $satisfaction): User
  3731. {
  3732. if (!$this->satisfactions->contains($satisfaction)) {
  3733. $this->satisfactions[] = $satisfaction;
  3734. $satisfaction->setUser($this);
  3735. }
  3736. return $this;
  3737. }
  3738. /**
  3739. * @deprecated
  3740. */
  3741. public function removeSatisfaction(Satisfaction $satisfaction): User
  3742. {
  3743. if ($this->satisfactions->removeElement($satisfaction)) {
  3744. // set the owning side to null (unless already changed)
  3745. if ($satisfaction->getUser() === $this) {
  3746. $satisfaction->setUser(null);
  3747. }
  3748. }
  3749. return $this;
  3750. }
  3751. public function getRequestProductAvailables(): Collection
  3752. {
  3753. return $this->requestProductAvailables;
  3754. }
  3755. public function addRequestProductAvailable(RequestProductAvailable $requestProductAvailable): User
  3756. {
  3757. if (!$this->requestProductAvailables->contains($requestProductAvailable)) {
  3758. $this->requestProductAvailables[] = $requestProductAvailable;
  3759. $requestProductAvailable->setUser($this);
  3760. }
  3761. return $this;
  3762. }
  3763. public function removeRequestProductAvailable(RequestProductAvailable $requestProductAvailable): User
  3764. {
  3765. if ($this->requestProductAvailables->removeElement($requestProductAvailable)) {
  3766. // set the owning side to null (unless already changed)
  3767. if ($requestProductAvailable->getUser() === $this) {
  3768. $requestProductAvailable->setUser(null);
  3769. }
  3770. }
  3771. return $this;
  3772. }
  3773. public function getUserImportHistories(): Collection
  3774. {
  3775. return $this->userImportHistories;
  3776. }
  3777. public function addUserImportHistory(UserImportHistory $userImportHistory): User
  3778. {
  3779. if (!$this->userImportHistories->contains($userImportHistory)) {
  3780. $this->userImportHistories[] = $userImportHistory;
  3781. $userImportHistory->setImporter($this);
  3782. }
  3783. return $this;
  3784. }
  3785. public function removeUserImportHistory(UserImportHistory $userImportHistory): User
  3786. {
  3787. if ($this->userImportHistories->removeElement($userImportHistory)) {
  3788. // set the owning side to null (unless already changed)
  3789. if ($userImportHistory->getImporter() === $this) {
  3790. $userImportHistory->setImporter(null);
  3791. }
  3792. }
  3793. return $this;
  3794. }
  3795. public function getContactLists(): Collection
  3796. {
  3797. return $this->contactLists;
  3798. }
  3799. public function addContactList(ContactList $contactList): User
  3800. {
  3801. if (!$this->contactLists->contains($contactList)) {
  3802. $this->contactLists[] = $contactList;
  3803. $contactList->addUser($this);
  3804. }
  3805. return $this;
  3806. }
  3807. public function removeContactList(ContactList $contactList): User
  3808. {
  3809. if ($this->contactLists->removeElement($contactList)) {
  3810. $contactList->removeUser($this);
  3811. }
  3812. return $this;
  3813. }
  3814. /**
  3815. * @deprecated
  3816. */
  3817. public function getUsernameCanonical(): ?string
  3818. {
  3819. return $this->usernameCanonical;
  3820. }
  3821. /**
  3822. * @deprecated
  3823. */
  3824. public function setUsernameCanonical(?string $usernameCanonical): User
  3825. {
  3826. $this->usernameCanonical = $usernameCanonical;
  3827. return $this;
  3828. }
  3829. /**
  3830. * @deprecated
  3831. */
  3832. public function getEmailCanonical(): ?string
  3833. {
  3834. return $this->emailCanonical;
  3835. }
  3836. /**
  3837. * @deprecated
  3838. */
  3839. public function setEmailCanonical(?string $emailCanonical): User
  3840. {
  3841. $this->emailCanonical = $emailCanonical;
  3842. return $this;
  3843. }
  3844. public function getLastLogin(): ?DateTimeInterface
  3845. {
  3846. return $this->lastLogin;
  3847. }
  3848. public function setLastLogin(?DateTimeInterface $lastLogin): User
  3849. {
  3850. $this->lastLogin = $lastLogin;
  3851. return $this;
  3852. }
  3853. public function getConfirmationToken(): ?string
  3854. {
  3855. return $this->confirmationToken;
  3856. }
  3857. public function setConfirmationToken(?string $confirmationToken): User
  3858. {
  3859. $this->confirmationToken = $confirmationToken;
  3860. return $this;
  3861. }
  3862. public function getPasswordRequestedAt(): ?DateTimeInterface
  3863. {
  3864. return $this->passwordRequestedAt;
  3865. }
  3866. public function setPasswordRequestedAt(?DateTimeInterface $passwordRequestedAt): User
  3867. {
  3868. $this->passwordRequestedAt = $passwordRequestedAt;
  3869. return $this;
  3870. }
  3871. public function getCredentialExpired(): ?bool
  3872. {
  3873. return $this->credentialExpired;
  3874. }
  3875. public function setCredentialExpired(?bool $credentialExpired): User
  3876. {
  3877. $this->credentialExpired = $credentialExpired;
  3878. return $this;
  3879. }
  3880. public function getCredentialExpiredAt(): ?DateTimeInterface
  3881. {
  3882. return $this->credentialExpiredAt;
  3883. }
  3884. public function setCredentialExpiredAt(?DateTimeInterface $credentialExpiredAt): User
  3885. {
  3886. $this->credentialExpiredAt = $credentialExpiredAt;
  3887. return $this;
  3888. }
  3889. public function getDevis(): Collection
  3890. {
  3891. return $this->devis;
  3892. }
  3893. public function addDevi(Devis $devi): User
  3894. {
  3895. if (!$this->devis->contains($devi)) {
  3896. $this->devis[] = $devi;
  3897. $devi->setUser($this);
  3898. }
  3899. return $this;
  3900. }
  3901. public function removeDevi(Devis $devi): User
  3902. {
  3903. if ($this->devis->removeElement($devi)) {
  3904. // set the owning side to null (unless already changed)
  3905. if ($devi->getUser() === $this) {
  3906. $devi->setUser(null);
  3907. }
  3908. }
  3909. return $this;
  3910. }
  3911. public function __call($name, $arguments)
  3912. {
  3913. // TODO: Implement @method string getUserIdentifier()
  3914. }
  3915. public function getRegateName(): string
  3916. {
  3917. if ($this->regate) {
  3918. return $this->regate->getName();
  3919. }
  3920. return "";
  3921. }
  3922. public function getRegateAffectation(): string
  3923. {
  3924. if ($this->regate) {
  3925. return $this->regate->getAffectation();
  3926. }
  3927. return "";
  3928. }
  3929. public function getRegate(): ?Regate
  3930. {
  3931. return $this->regate;
  3932. }
  3933. public function setRegate(?Regate $regate): User
  3934. {
  3935. $this->regate = $regate;
  3936. return $this;
  3937. }
  3938. public function getDonneesPersonnelles(): ?bool
  3939. {
  3940. return $this->donneesPersonnelles;
  3941. }
  3942. public function setDonneesPersonnelles(?bool $donneesPersonnelles): User
  3943. {
  3944. $this->donneesPersonnelles = $donneesPersonnelles;
  3945. return $this;
  3946. }
  3947. /**
  3948. * @param PointTransactionType|string|null $type
  3949. * @param bool $sortByExpiration
  3950. *
  3951. * @return Collection|PointTransaction[]
  3952. * @throws Exception
  3953. */
  3954. public function getPointTransactions($type = null, bool $sortByExpiration = false): Collection
  3955. {
  3956. if (!$type && !$sortByExpiration) {
  3957. return $this->pointTransactions;
  3958. }
  3959. $points = clone $this->pointTransactions;
  3960. if ($type) {
  3961. $points = new ArrayCollection();
  3962. foreach ($this->getPointTransactions() as $pointTransaction) {
  3963. $pointTransactionType = $pointTransaction->getTransactionType();
  3964. if (!$pointTransactionType) {
  3965. continue;
  3966. }
  3967. if ($pointTransactionType === $type || $pointTransactionType->getSlug() === $type) {
  3968. $points->add($pointTransaction);
  3969. }
  3970. }
  3971. }
  3972. if ($sortByExpiration) {
  3973. $iterator = $points->getIterator();
  3974. $iterator->uasort(function ($a, $b) {
  3975. $AexpiredAt = $a->getExpiredAt();
  3976. $BexpiredAt = $b->getExpiredAt();
  3977. if ($AexpiredAt && $BexpiredAt) {
  3978. return ($AexpiredAt < $BexpiredAt) ? -1 : 1;
  3979. }
  3980. if (!$AexpiredAt) {
  3981. return 1;
  3982. }
  3983. return -1;
  3984. });
  3985. $points = new ArrayCollection(iterator_to_array($iterator));
  3986. }
  3987. return $points;
  3988. }
  3989. /**
  3990. * @param PointTransactionType|null $type
  3991. * @return float
  3992. * @throws Exception
  3993. */
  3994. public function getTotalPointTransactions(?PointTransactionType $type = null): float
  3995. {
  3996. $total = 0;
  3997. foreach ($this->getPointTransactions($type) as $pointTransaction) {
  3998. $total += $pointTransaction->getValue();
  3999. }
  4000. return $total;
  4001. }
  4002. /**
  4003. * @param PointTransaction $pointTransaction
  4004. * @return $this
  4005. */
  4006. public function addPointTransaction(PointTransaction $pointTransaction): User
  4007. {
  4008. if (!$this->pointTransactions->contains($pointTransaction)) {
  4009. $user = $pointTransaction->getUser();
  4010. if ($user) {
  4011. $user->removePointTransaction($pointTransaction);
  4012. }
  4013. $this->pointTransactions->add($pointTransaction);
  4014. $pointTransaction->setUser($this);
  4015. }
  4016. return $this;
  4017. }
  4018. public function removePointTransaction(PointTransaction $pointTransaction): User
  4019. {
  4020. if ($this->pointTransactions->removeElement($pointTransaction)) {
  4021. // set the owning side to null (unless already changed)
  4022. if ($pointTransaction->getUser() === $this) {
  4023. $pointTransaction->setUser(null);
  4024. }
  4025. }
  4026. return $this;
  4027. }
  4028. /**
  4029. * @return Collection|User[]
  4030. */
  4031. public function getInstallers(): Collection
  4032. {
  4033. return $this->installers;
  4034. }
  4035. public function addInstaller(User $installer): User
  4036. {
  4037. if (!$this->installers->contains($installer)) {
  4038. $this->installers[] = $installer;
  4039. $installer->setCommercial($this);
  4040. }
  4041. return $this;
  4042. }
  4043. public function removeInstaller(User $installer): User
  4044. {
  4045. if ($this->installers->removeElement($installer)) {
  4046. // set the owning side to null (unless already changed)
  4047. if ($installer->getCommercial() === $this) {
  4048. $installer->setCommercial(null);
  4049. }
  4050. }
  4051. return $this;
  4052. }
  4053. public function getCommercial(): ?User
  4054. {
  4055. return $this->commercial;
  4056. }
  4057. public function setCommercial(?User $commercial): User
  4058. {
  4059. $this->commercial = $commercial;
  4060. return $this;
  4061. }
  4062. /**
  4063. * @return Collection|User[]
  4064. */
  4065. public function getHeatingInstallers(): Collection
  4066. {
  4067. return $this->heatingInstallers;
  4068. }
  4069. public function addHeatingInstaller(User $heatingInstaller): User
  4070. {
  4071. if (!$this->heatingInstallers->contains($heatingInstaller)) {
  4072. $this->heatingInstallers[] = $heatingInstaller;
  4073. $heatingInstaller->setHeatingCommercial($this);
  4074. }
  4075. return $this;
  4076. }
  4077. public function removeHeatingInstaller(User $heatingInstaller): User
  4078. {
  4079. if ($this->heatingInstallers->removeElement($heatingInstaller)) {
  4080. // set the owning side to null (unless already changed)
  4081. if ($heatingInstaller->getHeatingCommercial() === $this) {
  4082. $heatingInstaller->setHeatingCommercial(null);
  4083. }
  4084. }
  4085. return $this;
  4086. }
  4087. public function getHeatingCommercial(): ?User
  4088. {
  4089. return $this->heatingCommercial;
  4090. }
  4091. public function setHeatingCommercial(?User $heatingCommercial): User
  4092. {
  4093. $this->heatingCommercial = $heatingCommercial;
  4094. return $this;
  4095. }
  4096. public function getAgency(): ?Agence
  4097. {
  4098. return $this->agency;
  4099. }
  4100. public function setAgency(?Agence $agency): User
  4101. {
  4102. $this->agency = $agency;
  4103. return $this;
  4104. }
  4105. public function getArchivedAt(): ?DateTimeInterface
  4106. {
  4107. return $this->archivedAt;
  4108. }
  4109. public function setArchivedAt(?DateTimeInterface $archivedAt): User
  4110. {
  4111. $this->archivedAt = $archivedAt;
  4112. return $this;
  4113. }
  4114. public function getNewsletter(): ?bool
  4115. {
  4116. return $this->newsletter;
  4117. }
  4118. public function setNewsletter(bool $newsletter): User
  4119. {
  4120. $this->newsletter = $newsletter;
  4121. return $this;
  4122. }
  4123. public function getCompanySiret(): ?string
  4124. {
  4125. return $this->companySiret;
  4126. }
  4127. public function setCompanySiret(?string $companySiret): User
  4128. {
  4129. $this->companySiret = $companySiret;
  4130. return $this;
  4131. }
  4132. /**
  4133. * @return Collection|UserBusinessResult[]|int
  4134. * @var bool $getPrevious highlight non null
  4135. * @var bool $sum retourne un integer avec la somme des résultats
  4136. * @var int|null $highlight highlight spécifique
  4137. * @var bool $getCurrent highlight à null
  4138. */
  4139. public function getUserBusinessResults(
  4140. bool $getCurrent = false,
  4141. bool $getPrevious = false,
  4142. bool $sum = false,
  4143. ?int $highlight = null
  4144. ) {
  4145. if (!$getCurrent && !$getPrevious && !$sum && !$highlight) {
  4146. return $this->userBusinessResults;
  4147. }
  4148. $userBusinessResults = $sum ? 0 : new ArrayCollection();
  4149. foreach ($this->userBusinessResults as $userBusinessResult) {
  4150. if ((!$getCurrent && !$getPrevious && !$highlight) || (($getCurrent && $userBusinessResult->getHighlight(
  4151. ) === null) || ($getPrevious && $userBusinessResult->getHighlight(
  4152. ) !== null) || ($highlight && $userBusinessResult->getHighlight() == $highlight))) {
  4153. $sum ? $userBusinessResults += $userBusinessResult->getSale() : $userBusinessResults->add(
  4154. $userBusinessResult
  4155. );
  4156. }
  4157. }
  4158. return $userBusinessResults;
  4159. }
  4160. public function getTotalUserBusinessResults(): int
  4161. {
  4162. $total = 0;
  4163. foreach ($this->userBusinessResults as $userBusinessResult) {
  4164. $total += $userBusinessResult->getSale();
  4165. }
  4166. return $total;
  4167. }
  4168. public function addUserBusinessResult(UserBusinessResult $userBusinessResult): User
  4169. {
  4170. if (!$this->userBusinessResults->contains($userBusinessResult)) {
  4171. $this->userBusinessResults->add($userBusinessResult);
  4172. $user = $userBusinessResult->getUser();
  4173. if ($user) {
  4174. $user->removeUserBusinessResult($userBusinessResult);
  4175. }
  4176. $userBusinessResult->setUser($this);
  4177. }
  4178. return $this;
  4179. }
  4180. public function removeUserBusinessResult(UserBusinessResult $userBusinessResult): User
  4181. {
  4182. if ($this->userBusinessResults->removeElement($userBusinessResult)) {
  4183. // set the owning side to null (unless already changed)
  4184. if ($userBusinessResult->getUser() === $this) {
  4185. $userBusinessResult->setUser(null);
  4186. }
  4187. }
  4188. return $this;
  4189. }
  4190. public function getExtension1(): ?string
  4191. {
  4192. return $this->extension1;
  4193. }
  4194. public function setExtension1(?string $extension1): User
  4195. {
  4196. $this->extension1 = $extension1;
  4197. return $this;
  4198. }
  4199. public function getExtension2(): ?string
  4200. {
  4201. return $this->extension2;
  4202. }
  4203. public function setExtension2(?string $extension2): User
  4204. {
  4205. $this->extension2 = $extension2;
  4206. return $this;
  4207. }
  4208. public function getWdg(): ?int
  4209. {
  4210. return $this->wdg;
  4211. }
  4212. public function setWdg(?int $wdg): User
  4213. {
  4214. $this->wdg = $wdg;
  4215. return $this;
  4216. }
  4217. public function getGladyUuid(): ?string
  4218. {
  4219. return $this->gladyUuid;
  4220. }
  4221. public function setGladyUuid(?string $gladyUuid): User
  4222. {
  4223. $this->gladyUuid = $gladyUuid;
  4224. return $this;
  4225. }
  4226. public function getCoverageArea(): ?CoverageArea
  4227. {
  4228. return $this->coverageArea;
  4229. }
  4230. public function setCoverageArea(?CoverageArea $coverageArea): User
  4231. {
  4232. $this->coverageArea = $coverageArea;
  4233. $coverageArea->setUser($this);
  4234. return $this;
  4235. }
  4236. /**
  4237. * @return Collection<int, Project>
  4238. */
  4239. public function getProjects(): Collection
  4240. {
  4241. return $this->projects;
  4242. }
  4243. public function addProject(Project $project): User
  4244. {
  4245. if (!$this->projects->contains($project)) {
  4246. $this->projects[] = $project;
  4247. $project->setReferent($this);
  4248. }
  4249. return $this;
  4250. }
  4251. public function removeProject(Project $project): User
  4252. {
  4253. if ($this->projects->removeElement($project)) {
  4254. // set the owning side to null (unless already changed)
  4255. if ($project->getReferent() === $this) {
  4256. $project->setReferent(null);
  4257. }
  4258. }
  4259. return $this;
  4260. }
  4261. public function getProgramme(): ?Programme
  4262. {
  4263. return $this->programme;
  4264. }
  4265. public function setProgramme(?Programme $programme): User
  4266. {
  4267. $this->programme = $programme;
  4268. return $this;
  4269. }
  4270. /**
  4271. * @return Collection<int, ServiceUser>
  4272. */
  4273. public function getServiceUsers(): Collection
  4274. {
  4275. return $this->serviceUsers;
  4276. }
  4277. public function addServiceUser(ServiceUser $serviceUser): User
  4278. {
  4279. if (!$this->serviceUsers->contains($serviceUser)) {
  4280. $this->serviceUsers[] = $serviceUser;
  4281. $serviceUser->setUser($this);
  4282. }
  4283. return $this;
  4284. }
  4285. public function removeServiceUser(ServiceUser $serviceUser): User
  4286. {
  4287. if ($this->serviceUsers->removeElement($serviceUser)) {
  4288. // set the owning side to null (unless already changed)
  4289. if ($serviceUser->getUser() === $this) {
  4290. $serviceUser->setUser(null);
  4291. }
  4292. }
  4293. return $this;
  4294. }
  4295. public function getSaleOrderValidation(): ?SaleOrderValidation
  4296. {
  4297. return $this->saleOrderValidation;
  4298. }
  4299. public function setSaleOrderValidation(?SaleOrderValidation $saleOrderValidation): User
  4300. {
  4301. $this->saleOrderValidation = $saleOrderValidation;
  4302. return $this;
  4303. }
  4304. /**
  4305. * @return Collection<int, Univers>
  4306. */
  4307. public function getUniverses(): Collection
  4308. {
  4309. return $this->universes;
  4310. }
  4311. public function addUnivers(Univers $univers): User
  4312. {
  4313. if (!$this->universes->contains($univers)) {
  4314. $this->universes[] = $univers;
  4315. $univers->addUser($this);
  4316. }
  4317. return $this;
  4318. }
  4319. public function removeUniverses(Univers $universes): User
  4320. {
  4321. if ($this->universes->removeElement($universes)) {
  4322. $universes->removeUser($this);
  4323. }
  4324. return $this;
  4325. }
  4326. public function getBillingPoint(): ?BillingPoint
  4327. {
  4328. return $this->billingPoint;
  4329. }
  4330. public function setBillingPoint(?BillingPoint $billingPoint): User
  4331. {
  4332. $this->billingPoint = $billingPoint;
  4333. return $this;
  4334. }
  4335. /**
  4336. * @return Collection<int, Score>
  4337. */
  4338. public function getScores(): Collection
  4339. {
  4340. return $this->scores;
  4341. }
  4342. public function addScore(Score $score): User
  4343. {
  4344. if (!$this->scores->contains($score)) {
  4345. $this->scores[] = $score;
  4346. $score->setUser($this);
  4347. }
  4348. return $this;
  4349. }
  4350. public function removeScore(Score $score): User
  4351. {
  4352. if ($this->scores->removeElement($score)) {
  4353. // set the owning side to null (unless already changed)
  4354. if ($score->getUser() === $this) {
  4355. $score->setUser(null);
  4356. }
  4357. }
  4358. return $this;
  4359. }
  4360. /**
  4361. * @return Collection<int, ScoreObjective>
  4362. */
  4363. public function getScoreObjectives(): Collection
  4364. {
  4365. return $this->scoreObjectives;
  4366. }
  4367. public function addScoreObjective(ScoreObjective $scoreObjective): User
  4368. {
  4369. if (!$this->scoreObjectives->contains($scoreObjective)) {
  4370. $this->scoreObjectives[] = $scoreObjective;
  4371. $scoreObjective->setUser($this);
  4372. }
  4373. return $this;
  4374. }
  4375. public function removeScoreObjective(ScoreObjective $scoreObjective): User
  4376. {
  4377. if ($this->scoreObjectives->removeElement($scoreObjective)) {
  4378. // set the owning side to null (unless already changed)
  4379. if ($scoreObjective->getUser() === $this) {
  4380. $scoreObjective->setUser(null);
  4381. }
  4382. }
  4383. return $this;
  4384. }
  4385. /**
  4386. * @return Collection<int, User>
  4387. */
  4388. public function getChildren(): Collection
  4389. {
  4390. return $this->children;
  4391. }
  4392. /**
  4393. * @param User|null $child
  4394. *
  4395. * @return $this
  4396. */
  4397. public function addChild(?User $child): User
  4398. {
  4399. if ($child && !$this->children->contains($child)) {
  4400. $this->children[] = $child;
  4401. $child->addParent($this);
  4402. }
  4403. return $this;
  4404. }
  4405. /**
  4406. * @param User|null $parent
  4407. *
  4408. * @return $this
  4409. */
  4410. public function addParent(?User $parent): User
  4411. {
  4412. if ($parent && !$this->parents->contains($parent)) {
  4413. $this->parents[] = $parent;
  4414. $parent->addChild($this);
  4415. }
  4416. return $this;
  4417. }
  4418. public function removeParent(User $parent): User
  4419. {
  4420. if ($this->parents->removeElement($parent)) {
  4421. $parent->removeChild($this);
  4422. $this->removeParent($parent);
  4423. }
  4424. return $this;
  4425. }
  4426. public function removeChild(User $child): User
  4427. {
  4428. $this->children->removeElement($child);
  4429. return $this;
  4430. }
  4431. /**
  4432. * @return Collection<int, Message>
  4433. */
  4434. public function getSenderMessages(): Collection
  4435. {
  4436. return $this->senderMessages;
  4437. }
  4438. public function addSenderMessage(Message $senderMessage): User
  4439. {
  4440. if (!$this->senderMessages->contains($senderMessage)) {
  4441. $this->senderMessages[] = $senderMessage;
  4442. $senderMessage->setSender($this);
  4443. }
  4444. return $this;
  4445. }
  4446. public function removeSenderMessage(Message $senderMessage): User
  4447. {
  4448. if ($this->senderMessages->removeElement($senderMessage)) {
  4449. // set the owning side to null (unless already changed)
  4450. if ($senderMessage->getSender() === $this) {
  4451. $senderMessage->setSender(null);
  4452. }
  4453. }
  4454. return $this;
  4455. }
  4456. /**
  4457. * @return Collection<int, Message>
  4458. */
  4459. public function getReceiverMessages(): Collection
  4460. {
  4461. return $this->receiverMessages;
  4462. }
  4463. public function addReceiverMessage(Message $receiverMessage): User
  4464. {
  4465. if (!$this->receiverMessages->contains($receiverMessage)) {
  4466. $this->receiverMessages[] = $receiverMessage;
  4467. $receiverMessage->setReceiver($this);
  4468. }
  4469. return $this;
  4470. }
  4471. public function removeReceiverMessage(Message $receiverMessage): User
  4472. {
  4473. if ($this->receiverMessages->removeElement($receiverMessage)) {
  4474. // set the owning side to null (unless already changed)
  4475. if ($receiverMessage->getReceiver() === $this) {
  4476. $receiverMessage->setReceiver(null);
  4477. }
  4478. }
  4479. return $this;
  4480. }
  4481. public function getRequestRegistration(): ?RequestRegistration
  4482. {
  4483. return $this->requestRegistration;
  4484. }
  4485. public function setRequestRegistration(RequestRegistration $requestRegistration): User
  4486. {
  4487. // set the owning side of the relation if necessary
  4488. if ($requestRegistration->getUser() !== $this) {
  4489. $requestRegistration->setUser($this);
  4490. }
  4491. $this->requestRegistration = $requestRegistration;
  4492. return $this;
  4493. }
  4494. /**
  4495. * @return Collection<int, RequestRegistration>
  4496. */
  4497. public function getRequestRegistrationsToValidate(): Collection
  4498. {
  4499. return $this->requestRegistrationsToValidate;
  4500. }
  4501. public function addRequestRegistrationsToValidate(RequestRegistration $requestRegistrationsToValidate): User
  4502. {
  4503. if (!$this->requestRegistrationsToValidate->contains($requestRegistrationsToValidate)) {
  4504. $this->requestRegistrationsToValidate[] = $requestRegistrationsToValidate;
  4505. $requestRegistrationsToValidate->setReferent($this);
  4506. }
  4507. return $this;
  4508. }
  4509. public function removeRequestRegistrationsToValidate(RequestRegistration $requestRegistrationsToValidate): User
  4510. {
  4511. if ($this->requestRegistrationsToValidate->removeElement($requestRegistrationsToValidate)) {
  4512. // set the owning side to null (unless already changed)
  4513. if ($requestRegistrationsToValidate->getReferent() === $this) {
  4514. $requestRegistrationsToValidate->setReferent(null);
  4515. }
  4516. }
  4517. return $this;
  4518. }
  4519. /**
  4520. * @return Collection<int, CustomProductOrder>
  4521. */
  4522. public function getCustomProductOrders(): Collection
  4523. {
  4524. return $this->customProductOrders;
  4525. }
  4526. public function addCustomProductOrder(CustomProductOrder $customProductOrder): User
  4527. {
  4528. if (!$this->customProductOrders->contains($customProductOrder)) {
  4529. $this->customProductOrders->add($customProductOrder);
  4530. $user = $customProductOrder->getUser();
  4531. if ($user) {
  4532. $user->removeCustomProductOrder($customProductOrder);
  4533. }
  4534. $customProductOrder->setUser($this);
  4535. }
  4536. return $this;
  4537. }
  4538. public function removeCustomProductOrder(CustomProductOrder $customProductOrder): User
  4539. {
  4540. if ($this->customProductOrders->removeElement($customProductOrder)) {
  4541. // set the owning side to null (unless already changed)
  4542. if ($customProductOrder->getUser() === $this) {
  4543. $customProductOrder->setUser(null);
  4544. }
  4545. }
  4546. return $this;
  4547. }
  4548. public function removeCustomProduct(CustomProduct $customProduct): User
  4549. {
  4550. if ($this->customProducts->removeElement($customProduct)) {
  4551. // set the owning side to null (unless already changed)
  4552. if ($customProduct->getCreatedBy() === $this) {
  4553. $customProduct->setCreatedBy(null);
  4554. }
  4555. }
  4556. return $this;
  4557. }
  4558. public function getSubscription()
  4559. {
  4560. return $this->subscription;
  4561. }
  4562. public function setSubscription(UserSubscription $subscription): User
  4563. {
  4564. // set the owning side of the relation if necessary
  4565. if ($subscription->getUser() !== $this) {
  4566. $subscription->setUser($this);
  4567. }
  4568. $this->subscription = $subscription;
  4569. return $this;
  4570. }
  4571. /**
  4572. * @return Collection<int, UserExtension>
  4573. */
  4574. public function getExtensions(): Collection
  4575. {
  4576. return $this->extensions;
  4577. }
  4578. public function removeExtension(UserExtension $extension): User
  4579. {
  4580. if ($this->extensions->removeElement($extension)) {
  4581. // set the owning side to null (unless already changed)
  4582. if ($extension->getUser() === $this) {
  4583. $extension->setUser(null);
  4584. }
  4585. }
  4586. return $this;
  4587. }
  4588. /**
  4589. * @return Collection<int, CustomProduct>
  4590. */
  4591. public function getCustomProducts(): Collection
  4592. {
  4593. return $this->customProducts;
  4594. }
  4595. public function addCustomProduct(CustomProduct $customProduct): User
  4596. {
  4597. if (!$this->customProducts->contains($customProduct)) {
  4598. $this->customProducts[] = $customProduct;
  4599. $customProduct->setCreatedBy($this);
  4600. }
  4601. return $this;
  4602. }
  4603. public function getCalculatedPoints(): ?string
  4604. {
  4605. return $this->calculatedPoints;
  4606. }
  4607. public function setCalculatedPoints(?string $calculatedPoints): User
  4608. {
  4609. $this->calculatedPoints = $calculatedPoints;
  4610. return $this;
  4611. }
  4612. public function getAvatar()
  4613. {
  4614. return $this->avatar;
  4615. }
  4616. public function setAvatar($avatar): User
  4617. {
  4618. $this->avatar = $avatar;
  4619. return $this;
  4620. }
  4621. public function getAvatarFile(): ?File
  4622. {
  4623. return $this->avatarFile;
  4624. }
  4625. /**
  4626. * @param File|UploadedFile|null $avatarFile
  4627. */
  4628. public function setAvatarFile(?File $avatarFile = null): void
  4629. {
  4630. $this->avatarFile = $avatarFile;
  4631. if (null !== $avatarFile) {
  4632. $this->updatedAt = new DateTime();
  4633. }
  4634. }
  4635. public function getLogo()
  4636. {
  4637. return $this->logo;
  4638. }
  4639. public function setLogo($logo): User
  4640. {
  4641. $this->logo = $logo;
  4642. return $this;
  4643. }
  4644. public function getLogoFile(): ?File
  4645. {
  4646. return $this->logoFile;
  4647. }
  4648. public function setLogoFile(?File $logoFile = null): User
  4649. {
  4650. $this->logoFile = $logoFile;
  4651. if (null !== $logoFile) {
  4652. $this->updatedAt = new DateTime();
  4653. }
  4654. return $this;
  4655. }
  4656. /**
  4657. * @return Collection<int, PointOfSale>
  4658. */
  4659. public function getManagedPointOfSales(): Collection
  4660. {
  4661. return $this->managedPointOfSales;
  4662. }
  4663. public function addManagedPointOfSale(PointOfSale $managedPointOfSale): User
  4664. {
  4665. if (!$this->managedPointOfSales->contains($managedPointOfSale)) {
  4666. $this->managedPointOfSales[] = $managedPointOfSale;
  4667. $managedPointOfSale->addManager($this);
  4668. }
  4669. return $this;
  4670. }
  4671. public function removeManagedPointOfSale(PointOfSale $managedPointOfSale): User
  4672. {
  4673. if ($this->managedPointOfSales->removeElement($managedPointOfSale)) {
  4674. $managedPointOfSale->removeManager($this);
  4675. }
  4676. return $this;
  4677. }
  4678. public function isManagerOfPointOfSale(?PointOfSale $pointOfSale = null): bool
  4679. {
  4680. if ($pointOfSale) {
  4681. return $this->managedPointOfSales->contains($pointOfSale);
  4682. }
  4683. return !$this->managedPointOfSales->isEmpty();
  4684. }
  4685. /**
  4686. * @return Collection<int, Parameter>
  4687. */
  4688. public function getRelatedParameters(): Collection
  4689. {
  4690. return $this->relatedParameters;
  4691. }
  4692. public function addRelatedParameter(Parameter $relatedParameter): User
  4693. {
  4694. if (!$this->relatedParameters->contains($relatedParameter)) {
  4695. $this->relatedParameters[] = $relatedParameter;
  4696. $relatedParameter->setUserRelated($this);
  4697. }
  4698. return $this;
  4699. }
  4700. public function removeRelatedParameter(Parameter $relatedParameter): User
  4701. {
  4702. if ($this->relatedParameters->removeElement($relatedParameter)) {
  4703. // set the owning side to null (unless already changed)
  4704. if ($relatedParameter->getUserRelated() === $this) {
  4705. $relatedParameter->setUserRelated(null);
  4706. }
  4707. }
  4708. return $this;
  4709. }
  4710. public function getCompanyLegalStatus(): ?string
  4711. {
  4712. return $this->companyLegalStatus;
  4713. }
  4714. public function setCompanyLegalStatus(?string $companyLegalStatus): User
  4715. {
  4716. $this->companyLegalStatus = $companyLegalStatus;
  4717. return $this;
  4718. }
  4719. /**
  4720. * @return Collection<int, PointOfSale>
  4721. */
  4722. public function getCreatedPointOfSales(): Collection
  4723. {
  4724. return $this->createdPointOfSales;
  4725. }
  4726. public function addCreatedPointOfSale(PointOfSale $createdPointOfSale): User
  4727. {
  4728. if (!$this->createdPointOfSales->contains($createdPointOfSale)) {
  4729. $this->createdPointOfSales[] = $createdPointOfSale;
  4730. $createdPointOfSale->setCreatedBy($this);
  4731. }
  4732. return $this;
  4733. }
  4734. public function removeCreatedPointOfSale(PointOfSale $createdPointOfSale): User
  4735. {
  4736. if ($this->createdPointOfSales->removeElement($createdPointOfSale)) {
  4737. // set the owning side to null (unless already changed)
  4738. if ($createdPointOfSale->getCreatedBy() === $this) {
  4739. $createdPointOfSale->setCreatedBy(null);
  4740. }
  4741. }
  4742. return $this;
  4743. }
  4744. /**
  4745. * Serializer\VirtualProperty()
  4746. * @Serializer\SerializedName("count_created_point_of_sales")
  4747. *
  4748. * @return int
  4749. * @Expose()
  4750. * @Groups ({"export_user_datatable", "export_admin_datatable", "user"})
  4751. */
  4752. public function countCreatedPointOfSales(): int
  4753. {
  4754. return $this->createdPointOfSales->count();
  4755. }
  4756. public function getOwnerObjectiveTargets(): Collection
  4757. {
  4758. return $this->ownerObjectiveTargets;
  4759. }
  4760. public function addOwnerObjectiveTarget(ObjectiveTarget $ownerObjectiveTarget): User
  4761. {
  4762. if (!$this->ownerObjectiveTargets->contains($ownerObjectiveTarget)) {
  4763. $this->ownerObjectiveTargets[] = $ownerObjectiveTarget;
  4764. $ownerObjectiveTarget->setOwner($this);
  4765. }
  4766. return $this;
  4767. }
  4768. public function removeOwnerObjectiveTarget(ObjectiveTarget $ownerObjectiveTarget): User
  4769. {
  4770. if ($this->ownerObjectiveTargets->removeElement($ownerObjectiveTarget)) {
  4771. // set the owning side to null (unless already changed)
  4772. if ($ownerObjectiveTarget->getOwner() === $this) {
  4773. $ownerObjectiveTarget->setOwner(null);
  4774. }
  4775. }
  4776. return $this;
  4777. }
  4778. /**
  4779. * @return Collection<int, ObjectiveTarget>
  4780. */
  4781. public function getObjectiveTargets(): Collection
  4782. {
  4783. return $this->objectiveTargets;
  4784. }
  4785. public function addObjectiveTarget(ObjectiveTarget $objectiveTarget): self
  4786. {
  4787. if (!$this->objectiveTargets->contains($objectiveTarget)) {
  4788. $this->objectiveTargets[] = $objectiveTarget;
  4789. }
  4790. return $this;
  4791. }
  4792. public function removeObjectiveTarget(ObjectiveTarget $objectiveTarget): self
  4793. {
  4794. $this->objectiveTargets->removeElement($objectiveTarget);
  4795. return $this;
  4796. }
  4797. public function getFonction(): ?string
  4798. {
  4799. return $this->fonction;
  4800. }
  4801. public function setFonction(?string $fonction): User
  4802. {
  4803. $this->fonction = $fonction;
  4804. return $this;
  4805. }
  4806. public function getResponsableRegate(): ?Regate
  4807. {
  4808. return $this->responsableRegate;
  4809. }
  4810. public function setResponsableRegate(?Regate $responsableRegate): User
  4811. {
  4812. $this->responsableRegate = $responsableRegate;
  4813. return $this;
  4814. }
  4815. public function getRegistrationDocument(): ?string
  4816. {
  4817. return $this->registrationDocument;
  4818. }
  4819. public function setRegistrationDocument(?string $registrationDocument): User
  4820. {
  4821. $this->registrationDocument = $registrationDocument;
  4822. return $this;
  4823. }
  4824. public function getRegistrationDocumentFile(): ?File
  4825. {
  4826. return $this->registrationDocumentFile;
  4827. }
  4828. public function setRegistrationDocumentFile(?File $registrationDocumentFile = null): User
  4829. {
  4830. $this->registrationDocumentFile = $registrationDocumentFile;
  4831. if (null !== $registrationDocumentFile) {
  4832. $this->updatedAt = new DateTime();
  4833. }
  4834. return $this;
  4835. }
  4836. public function getIdeaBoxAnswers(): ArrayCollection
  4837. {
  4838. return $this->ideaBoxAnswers;
  4839. }
  4840. public function setIdeaBoxAnswers(ArrayCollection $ideaBoxAnswers): void
  4841. {
  4842. $this->ideaBoxAnswers = $ideaBoxAnswers;
  4843. }
  4844. public function getIdeaBoxRatings(): Collection
  4845. {
  4846. return $this->ideaBoxRatings;
  4847. }
  4848. public function addIdeaBoxRating(IdeaBoxRating $ideaBoxRating): User
  4849. {
  4850. if (!$this->ideaBoxRatings->contains($ideaBoxRating)) {
  4851. $this->ideaBoxRatings[] = $ideaBoxRating;
  4852. $ideaBoxRating->setUser($this);
  4853. }
  4854. return $this;
  4855. }
  4856. public function removeIdeaBoxRating(IdeaBoxRating $ideaBoxRating): User
  4857. {
  4858. if ($this->ideaBoxRatings->removeElement($ideaBoxRating)) {
  4859. // set the owning side to null (unless already changed)
  4860. if ($ideaBoxRating->getUser() === $this) {
  4861. $ideaBoxRating->setUser(null);
  4862. }
  4863. }
  4864. return $this;
  4865. }
  4866. public function getIdeaBoxRecipients(): Collection
  4867. {
  4868. return $this->ideaBoxRecipients;
  4869. }
  4870. public function addIdeaBoxRecipient(IdeaBoxRecipient $ideaBoxRecipient): User
  4871. {
  4872. if (!$this->ideaBoxRecipients->contains($ideaBoxRecipient)) {
  4873. $this->ideaBoxRecipients[] = $ideaBoxRecipient;
  4874. $ideaBoxRecipient->setUser($this);
  4875. }
  4876. return $this;
  4877. }
  4878. public function removeIdeaBoxRecipient(IdeaBoxRecipient $ideaBoxRecipient): User
  4879. {
  4880. if ($this->ideaBoxRecipients->removeElement($ideaBoxRecipient)) {
  4881. // set the owning side to null (unless already changed)
  4882. if ($ideaBoxRecipient->getUser() === $this) {
  4883. $ideaBoxRecipient->setUser(null);
  4884. }
  4885. }
  4886. return $this;
  4887. }
  4888. public function getOldStatus(): ?string
  4889. {
  4890. return $this->oldStatus;
  4891. }
  4892. public function setOldStatus(?string $oldStatus): User
  4893. {
  4894. $this->oldStatus = $oldStatus;
  4895. return $this;
  4896. }
  4897. public function getDisabledAt(): ?DateTimeInterface
  4898. {
  4899. return $this->disabledAt;
  4900. }
  4901. public function setDisabledAt(?DateTimeInterface $disabledAt): User
  4902. {
  4903. $this->disabledAt = $disabledAt;
  4904. return $this;
  4905. }
  4906. public function getArchiveReason(): ?string
  4907. {
  4908. return $this->archiveReason;
  4909. }
  4910. public function setArchiveReason(?string $archiveReason): User
  4911. {
  4912. $this->archiveReason = $archiveReason;
  4913. return $this;
  4914. }
  4915. public function getUnsubscribeReason(): ?string
  4916. {
  4917. return $this->unsubscribeReason;
  4918. }
  4919. public function setUnsubscribeReason(?string $unsubscribeReason): User
  4920. {
  4921. $this->unsubscribeReason = $unsubscribeReason;
  4922. return $this;
  4923. }
  4924. /**
  4925. * @return Collection<int, ActionLog>
  4926. */
  4927. public function getActionLogs(): Collection
  4928. {
  4929. return $this->actionLogs;
  4930. }
  4931. public function addActionLog(ActionLog $ActionLog): User
  4932. {
  4933. if (!$this->actionLogs->contains($ActionLog)) {
  4934. $this->actionLogs[] = $ActionLog;
  4935. $ActionLog->setUser($this);
  4936. }
  4937. return $this;
  4938. }
  4939. public function removeActionLog(ActionLog $ActionLog): User
  4940. {
  4941. if ($this->actionLogs->removeElement($ActionLog)) {
  4942. // set the owning side to null (unless already changed)
  4943. if ($ActionLog->getUser() === $this) {
  4944. $ActionLog->setUser(null);
  4945. }
  4946. }
  4947. return $this;
  4948. }
  4949. public function getFailedAttempts(): int
  4950. {
  4951. return $this->failedAttempts;
  4952. }
  4953. public function setFailedAttempts(int $failedAttempts): User
  4954. {
  4955. $this->failedAttempts = $failedAttempts;
  4956. return $this;
  4957. }
  4958. public function getLastFailedAttempt()
  4959. {
  4960. return $this->lastFailedAttempt;
  4961. }
  4962. public function setLastFailedAttempt($lastFailedAttempt): User
  4963. {
  4964. $this->lastFailedAttempt = $lastFailedAttempt;
  4965. return $this;
  4966. }
  4967. public function getPasswordUpdatedAt(): ?DateTimeInterface
  4968. {
  4969. return $this->passwordUpdatedAt;
  4970. }
  4971. public function setPasswordUpdatedAt(?DateTimeInterface $passwordUpdatedAt): User
  4972. {
  4973. $this->passwordUpdatedAt = $passwordUpdatedAt;
  4974. return $this;
  4975. }
  4976. public function getBirthPlace(): ?string
  4977. {
  4978. return $this->birthPlace;
  4979. }
  4980. public function setBirthPlace(?string $birthPlace): User
  4981. {
  4982. $this->birthPlace = $birthPlace;
  4983. return $this;
  4984. }
  4985. public function getQuizUserAnswers()
  4986. {
  4987. return $this->quizUserAnswers;
  4988. }
  4989. public function setQuizUserAnswers($quizUserAnswers): void
  4990. {
  4991. $this->quizUserAnswers = $quizUserAnswers;
  4992. }
  4993. public function getPasswordHistories(): Collection
  4994. {
  4995. return $this->passwordHistories;
  4996. }
  4997. public function addPasswordHistory(PasswordHistory $passwordHistory): User
  4998. {
  4999. if (!$this->passwordHistories->contains($passwordHistory)) {
  5000. $this->passwordHistories[] = $passwordHistory;
  5001. $passwordHistory->setUser($this);
  5002. }
  5003. return $this;
  5004. }
  5005. public function removePasswordHistory(PasswordHistory $passwordHistory): User
  5006. {
  5007. if ($this->passwordHistories->removeElement($passwordHistory)) {
  5008. // set the owning side to null (unless already changed)
  5009. if ($passwordHistory->getUser() === $this) {
  5010. $passwordHistory->setUser(null);
  5011. }
  5012. }
  5013. return $this;
  5014. }
  5015. public function getLastActivity(): ?DateTimeInterface
  5016. {
  5017. return $this->lastActivity;
  5018. }
  5019. public function setLastActivity(?DateTimeInterface $lastActivity): User
  5020. {
  5021. $this->lastActivity = $lastActivity;
  5022. return $this;
  5023. }
  5024. public function getUserFavorites(): ArrayCollection
  5025. {
  5026. return $this->userFavorites;
  5027. }
  5028. public function setUserFavorites(ArrayCollection $userFavorites): User
  5029. {
  5030. $this->userFavorites = $userFavorites;
  5031. return $this;
  5032. }
  5033. /**
  5034. * Serializer\VirtualProperty()
  5035. * @SerializedName("count_current_highlight_sale_result")
  5036. *
  5037. * @return int
  5038. * @Expose()
  5039. * @Groups ({
  5040. * "default",
  5041. * "user:count_current_highlight_sale_result",
  5042. * "user:list", "user:item", "user:post", "cdp", "user","email", "user_citroentf",
  5043. * "export_order_datatable",
  5044. * "user_bussiness_result",
  5045. * })
  5046. */
  5047. public function getCurrentHighlightSaleResult(): int
  5048. {
  5049. $ubr = $this->userBusinessResults->filter(function (UserBusinessResult $ubr) {
  5050. return $ubr->getHighlight() === null;
  5051. });
  5052. $result = 0;
  5053. /** @var UserBusinessResult $item */
  5054. foreach ($ubr as $item) {
  5055. $result += $item->getSale();
  5056. }
  5057. return $result;
  5058. }
  5059. public function getAccountId(): ?string
  5060. {
  5061. return $this->accountId;
  5062. }
  5063. public function setAccountId(?string $accountId): self
  5064. {
  5065. $this->accountId = $accountId;
  5066. return $this;
  5067. }
  5068. public function getUniqueSlugConstraint(): ?string
  5069. {
  5070. return $this->uniqueSlugConstraint;
  5071. }
  5072. public function setUniqueSlugConstraint(?string $uniqueSlugConstraint): self
  5073. {
  5074. $this->uniqueSlugConstraint = $uniqueSlugConstraint;
  5075. return $this;
  5076. }
  5077. public function isFakeUser(): bool
  5078. {
  5079. return !str_contains($this->getEmail(), '@');
  5080. }
  5081. public function isMainUser(): bool
  5082. {
  5083. return $this === $this->mainAccountUser;
  5084. }
  5085. /**
  5086. * @return Collection<int, BoosterProductResult>
  5087. */
  5088. public function getBoosterProductResults(): Collection
  5089. {
  5090. return $this->boosterProductResults;
  5091. }
  5092. public function addBoosterProductResult(BoosterProductResult $boosterProductResult): self
  5093. {
  5094. if (!$this->boosterProductResults->contains($boosterProductResult)) {
  5095. $this->boosterProductResults[] = $boosterProductResult;
  5096. $boosterProductResult->setUser($this);
  5097. }
  5098. return $this;
  5099. }
  5100. public function removeBoosterProductResult(BoosterProductResult $boosterProductResult): self
  5101. {
  5102. if ($this->boosterProductResults->removeElement($boosterProductResult)) {
  5103. // set the owning side to null (unless already changed)
  5104. if ($boosterProductResult->getUser() === $this) {
  5105. $boosterProductResult->setUser(null);
  5106. }
  5107. }
  5108. return $this;
  5109. }
  5110. /**
  5111. * @return Collection<int, PushSubscription>
  5112. */
  5113. public function getPushSubscriptions(): Collection
  5114. {
  5115. return $this->pushSubscriptions;
  5116. }
  5117. public function addPushSubscription(PushSubscription $pushSubscription): self
  5118. {
  5119. if (!$this->pushSubscriptions->contains($pushSubscription)) {
  5120. $this->pushSubscriptions[] = $pushSubscription;
  5121. $pushSubscription->setUser($this);
  5122. }
  5123. return $this;
  5124. }
  5125. public function removePushSubscription(PushSubscription $pushSubscription): self
  5126. {
  5127. if ($this->pushSubscriptions->removeElement($pushSubscription)) {
  5128. // set the owning side to null (unless already changed)
  5129. if ($pushSubscription->getUser() === $this) {
  5130. $pushSubscription->setUser(null);
  5131. }
  5132. }
  5133. return $this;
  5134. }
  5135. /**
  5136. * @param bool $getLevel
  5137. *
  5138. * @return bool|int
  5139. * @throws DateInvalidOperationException
  5140. */
  5141. public function isActive(bool $getLevel = false)
  5142. {
  5143. $status = $this->getStatus();
  5144. if (!$getLevel && $this->isFakeUser()) {
  5145. return false;
  5146. }
  5147. $inactiveStatus = [
  5148. self::STATUS_ARCHIVED,
  5149. self::STATUS_DELETED,
  5150. self::STATUS_UNSUBSCRIBED,
  5151. self::STATUS_REGISTER_PENDING,
  5152. self::STATUS_DISABLED,
  5153. self::STATUS_ADMIN_PENDING
  5154. ];
  5155. if (!$getLevel && in_array($status, $inactiveStatus)) {
  5156. return false;
  5157. }
  5158. $twoYears = (new DateTime())->sub(new DateInterval('P2Y'));
  5159. $cguStatus = [self::STATUS_CGU_PENDING, self::STATUS_CGU_DECLINED];
  5160. if (!$getLevel && in_array($status, $cguStatus) && (!$this->lastLogin || $twoYears > $this->lastLogin)) {
  5161. return false;
  5162. }
  5163. if ($getLevel) {
  5164. $oneYear = (new DateTime())->sub(new DateInterval('P1Y'));
  5165. $sixMonths = (new DateTime())->sub(new DateInterval('P6M'));
  5166. $lvl = 15;
  5167. if ($this->isFakeUser()) {
  5168. $lvl = 0;
  5169. } // si l'utilisateur possède un email, son score sera au moins de 1
  5170. else {
  5171. switch ($status) {
  5172. case self::STATUS_DELETED:
  5173. $lvl -= 11;
  5174. break;
  5175. case self::STATUS_ARCHIVED:
  5176. $lvl -= 10;
  5177. break;
  5178. case self::STATUS_DISABLED:
  5179. case self::STATUS_UNSUBSCRIBED:
  5180. $lvl -= 9;
  5181. break;
  5182. case self::STATUS_REGISTER_PENDING:
  5183. $lvl -= 8;
  5184. break;
  5185. case self::STATUS_CGU_DECLINED:
  5186. $lvl -= 7;
  5187. break;
  5188. case self::STATUS_CGU_PENDING:
  5189. $lvl -= 6;
  5190. break;
  5191. case self::STATUS_ENABLED:
  5192. break;
  5193. default:
  5194. $lvl -= 5;
  5195. }
  5196. if (!$this->lastLogin || $twoYears > $this->lastLogin) {
  5197. $lvl -= 3;
  5198. } elseif ($oneYear > $this->lastLogin) {
  5199. $lvl -= 2;
  5200. } elseif ($sixMonths > $this->lastLogin) {
  5201. $lvl -= 1;
  5202. }
  5203. }
  5204. return $lvl;
  5205. }
  5206. return true;
  5207. }
  5208. public function getAzureId(): ?string
  5209. {
  5210. return $this->azureId;
  5211. }
  5212. public function setAzureId(?string $azureId): self
  5213. {
  5214. $this->azureId = $azureId;
  5215. return $this;
  5216. }
  5217. /**
  5218. * @return Collection<int, AzureGroup>
  5219. */
  5220. public function getAzureGroups(): Collection
  5221. {
  5222. return $this->azureGroups;
  5223. }
  5224. public function addAzureGroup(AzureGroup $azureGroup): self
  5225. {
  5226. if (!$this->azureGroups->contains($azureGroup)) {
  5227. $this->azureGroups[] = $azureGroup;
  5228. $azureGroup->addMember($this);
  5229. }
  5230. return $this;
  5231. }
  5232. public function removeAzureGroup(AzureGroup $azureGroup): self
  5233. {
  5234. if ($this->azureGroups->removeElement($azureGroup)) {
  5235. $azureGroup->removeMember($this);
  5236. }
  5237. return $this;
  5238. }
  5239. public function getActivatedBy(): ?self
  5240. {
  5241. return $this->activatedBy;
  5242. }
  5243. public function setActivatedBy(?self $activatedBy): self
  5244. {
  5245. $this->activatedBy = $activatedBy;
  5246. return $this;
  5247. }
  5248. /**
  5249. * @return Collection<int, QuotaProductUser>
  5250. */
  5251. public function getQuotaProductUsers(): Collection
  5252. {
  5253. return $this->quotaProductUsers;
  5254. }
  5255. public function addQuotaProductUser(QuotaProductUser $quotaProductUser): self
  5256. {
  5257. if (!$this->quotaProductUsers->contains($quotaProductUser)) {
  5258. $this->quotaProductUsers[] = $quotaProductUser;
  5259. $quotaProductUser->setUser($this);
  5260. }
  5261. return $this;
  5262. }
  5263. public function removeQuotaProductUser(QuotaProductUser $quotaProductUser): self
  5264. {
  5265. if ($this->quotaProductUsers->removeElement($quotaProductUser)) {
  5266. // set the owning side to null (unless already changed)
  5267. if ($quotaProductUser->getUser() === $this) {
  5268. $quotaProductUser->setUser(null);
  5269. }
  5270. }
  5271. return $this;
  5272. }
  5273. /**
  5274. * @return Collection<int, RankingScore>
  5275. */
  5276. public function getRankingScores(): Collection
  5277. {
  5278. return $this->rankingScores;
  5279. }
  5280. public function addRankingScore(RankingScore $rankingScore): self
  5281. {
  5282. if (!$this->rankingScores->contains($rankingScore)) {
  5283. $this->rankingScores->add($rankingScore);
  5284. $user = $rankingScore->getUser();
  5285. if ($user) {
  5286. $user->removeRankingScore($rankingScore);
  5287. }
  5288. $rankingScore->setUser($this);
  5289. }
  5290. return $this;
  5291. }
  5292. public function removeRankingScore(RankingScore $rankingScore): self
  5293. {
  5294. if ($this->rankingScores->removeElement($rankingScore)) {
  5295. // set the owning side to null (unless already changed)
  5296. if ($rankingScore->getUser() === $this) {
  5297. $rankingScore->setUser(null);
  5298. }
  5299. }
  5300. return $this;
  5301. }
  5302. /**
  5303. * @return Collection<int, ObjectiveTargetScore>
  5304. */
  5305. public function getObjectiveTargetScores(): Collection
  5306. {
  5307. return $this->objectiveTargetScores;
  5308. }
  5309. public function addObjectiveTargetScore(ObjectiveTargetScore $objectiveTargetScore): self
  5310. {
  5311. if (!$this->objectiveTargetScores->contains($objectiveTargetScore)) {
  5312. $this->objectiveTargetScores->add($objectiveTargetScore);
  5313. $objectiveTargetScore->setUser($this);
  5314. }
  5315. return $this;
  5316. }
  5317. public function removeObjectiveTargetScore(ObjectiveTargetScore $objectiveTargetScore): self
  5318. {
  5319. if ($this->objectiveTargetScores->removeElement($objectiveTargetScore)) {
  5320. // set the owning side to null (unless already changed)
  5321. if ($objectiveTargetScore->getUser() === $this) {
  5322. $objectiveTargetScore->setUser(null);
  5323. }
  5324. }
  5325. return $this;
  5326. }
  5327. public function getEmailUnsubscribeReason(): ?string
  5328. {
  5329. return $this->emailUnsubscribeReason;
  5330. }
  5331. public function setEmailUnsubscribeReason(?string $emailUnsubscribeReason): User
  5332. {
  5333. $this->emailUnsubscribeReason = $emailUnsubscribeReason;
  5334. return $this;
  5335. }
  5336. public function getEmailUnsubscribedAt(): ?DateTimeInterface
  5337. {
  5338. return $this->emailUnsubscribedAt;
  5339. }
  5340. public function setEmailUnsubscribedAt(?DateTimeInterface $emailUnsubscribedAt): User
  5341. {
  5342. $this->emailUnsubscribedAt = $emailUnsubscribedAt;
  5343. return $this;
  5344. }
  5345. /**
  5346. * @throws Exception
  5347. */
  5348. public function hasOrder(): bool
  5349. {
  5350. return $this->getPointTransactions(PointTransactionType::ORDER)->count() > 0;
  5351. }
  5352. public static function createFromArray(array $data): self
  5353. {
  5354. $user = new self();
  5355. $user->setEmail($data['email'] ?? null);
  5356. $user->setCivility($data['civility'] ?? null);
  5357. $user->setFirstName($data['firstName'] ?? null);
  5358. $user->setLastName($data['lastName'] ?? null);
  5359. $user->setPhone($data['phone'] ?? null);
  5360. $user->setMobile($data['mobile'] ?? null);
  5361. $user->setCreatedAt(new DateTime());
  5362. $user->setPassword(password_hash($data['password'] ?? '', PASSWORD_DEFAULT));
  5363. $user->setRoles($data['password'] ?? ['ROLE_USER']);
  5364. return $user;
  5365. }
  5366. }