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