src/Entity/User.php line 46

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