src/Entity/User.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Model\Uploadable;
  4. use App\Service\KiboardToolsService;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  10. use Symfony\Component\Security\Core\User\UserInterface;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  13. /**
  14. * User
  15. *
  16. * @ORM\Table(name="user")
  17. * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
  18. * @ORM\HasLifecycleCallbacks
  19. * @UniqueEntity(fields="email", message="Cet email existe déjà")
  20. */
  21. class User extends Uploadable implements UserInterface, PasswordAuthenticatedUserInterface, \Serializable
  22. {
  23. use TraitEntityAddons;
  24. const DIRPATH = '../../data/';
  25. const DIRNAME = 'pictures';
  26. /**
  27. * Civilities
  28. */
  29. const CIV_MISTER = 1;
  30. const CIV_MISS = 2;
  31. const CIV_CONF = [
  32. self::CIV_MISTER => [
  33. 'label' => 'M.',
  34. 'detail' => 'Monsieur',
  35. 'class' => 'dark',
  36. 'icon' => 'build/icon_men.png',
  37. ],
  38. self::CIV_MISS => [
  39. 'label' => 'Mme',
  40. 'detail' => 'Madame',
  41. 'class' => 'dark',
  42. 'icon' => 'build/icon_women.png',
  43. ],
  44. ];
  45. /**
  46. * Types
  47. */
  48. const TYPE_SALARIED = 1;
  49. const TYPE_FREELANCE = 2;
  50. const TYPE_CONF = [
  51. self::TYPE_SALARIED => [
  52. 'label' => 'Salarié(e)',
  53. 'icon' => 'fa-building',
  54. 'class' => 'dark',
  55. ],
  56. self::TYPE_FREELANCE => [
  57. 'label' => 'Indépendant(e)',
  58. 'icon' => 'fa-home',
  59. 'class' => 'info',
  60. ],
  61. ];
  62. /**
  63. * Roles
  64. */
  65. const ROLE_SUPER_ADMIN = 'ROLE_SUPER_ADMIN';
  66. const ROLE_ADMIN = 'ROLE_ADMIN';
  67. const ROLE_MANAGER = 'ROLE_MANAGER';
  68. const ROLE_USER = 'ROLE_USER';
  69. const ROLE_TELEMARKETING_MNG = 'ROLE_TELEMARKETING_MNG';
  70. const ROLE_TELEMARKETING_USR = 'ROLE_TELEMARKETING_USR';
  71. const ROLE_BIENPRETER_ADM = 'ROLE_BIENPRETER_ADM';
  72. const ROLE_BIENPRETER_MNG = 'ROLE_BIENPRETER_MNG';
  73. const ROLE_BIENPRETER_USR = 'ROLE_BIENPRETER_USR';
  74. const ROLE_CONSULTING_ADM = 'ROLE_CONSULTING_ADM';
  75. const ROLE_CONSULTING_MNG = 'ROLE_CONSULTING_MNG';
  76. const ROLE_CONSULTING_USR = 'ROLE_CONSULTING_USR';
  77. const ROLE_ADMINISTRATIVE_ADM = 'ROLE_ADMINISTRATIVE_ADM';
  78. const ROLE_ADMINISTRATIVE_MNG = 'ROLE_ADMINISTRATIVE_MNG';
  79. const ROLE_ADMINISTRATIVE_USR = 'ROLE_ADMINISTRATIVE_USR';
  80. const ROLE_CONTRACT_PHOTOGRAPHER = 'ROLE_CONTRACT_PHOTOGRAPHER';
  81. const ROLE_CONTRACT_WRITER = 'ROLE_CONTRACT_WRITER';
  82. const ROLE_CONTRACT_LINKER = 'ROLE_CONTRACT_LINKER';
  83. const ROLE_SPECIAL_HUMAN_RESOURCES = 'ROLE_SPECIAL_HUMAN_RESOURCES';
  84. const ROLE_SPECIAL_ACCOUNTING = 'ROLE_SPECIAL_ACCOUNTING';
  85. const ROLE_SPECIAL_LOGISTICS = 'ROLE_SPECIAL_LOGISTICS';
  86. const ROLE_SPECIAL_DESIGNER = 'ROLE_SPECIAL_DESIGNER';
  87. const ROLE_SPECIAL_LEGAL = 'ROLE_SPECIAL_LEGAL';
  88. const ROLE_SPECIAL_SWISS_KNIFE = 'ROLE_SPECIAL_SWISS_KNIFE';
  89. const ROLE_CONF = [
  90. self::ROLE_SUPER_ADMIN => [
  91. 'label' => 'Super-Admin',
  92. 'class' => 'info',
  93. ],
  94. self::ROLE_ADMIN => [
  95. 'label' => 'Administrateur',
  96. 'class' => 'info',
  97. ],
  98. self::ROLE_MANAGER => [
  99. 'label' => 'Superviseur',
  100. 'class' => 'dark',
  101. ],
  102. self::ROLE_USER => [
  103. 'label' => 'Utilisateur simple',
  104. 'class' => 'dark',
  105. ],
  106. self::ROLE_TELEMARKETING_MNG => [
  107. 'label' => 'Téléprospection - Superviseur',
  108. 'class' => 'dark',
  109. ],
  110. self::ROLE_TELEMARKETING_USR => [
  111. 'label' => 'Téléprospection',
  112. 'class' => 'light',
  113. ],
  114. self::ROLE_BIENPRETER_ADM => [
  115. 'label' => 'Bienprêter - Superviseur',
  116. 'class' => 'dark',
  117. ],
  118. self::ROLE_BIENPRETER_MNG => [
  119. 'label' => 'Bienprêter - Chargé d\'affaires',
  120. 'class' => 'dark',
  121. ],
  122. self::ROLE_BIENPRETER_USR => [
  123. 'label' => 'Bienprêter',
  124. 'class' => 'dark',
  125. ],
  126. self::ROLE_CONSULTING_ADM => [
  127. 'label' => 'Commercial - Directeur',
  128. 'class' => 'info',
  129. ],
  130. self::ROLE_CONSULTING_MNG => [
  131. 'label' => 'Commercial - Superviseur',
  132. 'class' => 'dark',
  133. ],
  134. self::ROLE_CONSULTING_USR => [
  135. 'label' => 'Commercial',
  136. 'class' => 'light',
  137. ],
  138. self::ROLE_ADMINISTRATIVE_ADM => [
  139. 'label' => 'Administratif - Directeur',
  140. 'class' => 'info',
  141. ],
  142. self::ROLE_ADMINISTRATIVE_MNG => [
  143. 'label' => 'Administratif - Superviseur',
  144. 'class' => 'dark',
  145. ],
  146. self::ROLE_ADMINISTRATIVE_USR => [
  147. 'label' => 'Administratif - Suivi client',
  148. 'class' => 'light',
  149. ],
  150. self::ROLE_CONTRACT_PHOTOGRAPHER => [
  151. 'label' => 'Contrat - Photographe',
  152. 'class' => 'dark',
  153. ],
  154. self::ROLE_CONTRACT_WRITER => [
  155. 'label' => 'Contrat - Rédacteur',
  156. 'class' => 'dark',
  157. ],
  158. self::ROLE_CONTRACT_LINKER => [
  159. 'label' => 'Contrat - Gestion des liens de diffusion',
  160. 'class' => 'dark',
  161. ],
  162. self::ROLE_SPECIAL_HUMAN_RESOURCES => [
  163. 'label' => 'Ressources Humaines',
  164. 'class' => 'dark',
  165. ],
  166. self::ROLE_SPECIAL_ACCOUNTING => [
  167. 'label' => 'Comptabilité',
  168. 'class' => 'dark',
  169. ],
  170. self::ROLE_SPECIAL_LOGISTICS => [
  171. 'label' => 'Responsable Logistique',
  172. 'class' => 'dark',
  173. ],
  174. self::ROLE_SPECIAL_DESIGNER => [
  175. 'label' => 'Graphiste / Gestion Front',
  176. 'class' => 'dark',
  177. ],
  178. self::ROLE_SPECIAL_LEGAL => [
  179. 'label' => 'Juridique',
  180. 'class' => 'dark',
  181. ],
  182. self::ROLE_SPECIAL_SWISS_KNIFE => [
  183. 'label' => 'Couteau suisse',
  184. 'class' => 'dark',
  185. ],
  186. ];
  187. const EXTRA_ROLE_TELEMARKETING = 'EXTRA_ROLE_TELEMARKETING';
  188. const EXTRA_ROLE_CONTRACT_VALIDATE = 'EXTRA_ROLE_CONTRACT_VALIDATE';
  189. const EXTRA_ROLE_CONTRACT_CANCEL = 'EXTRA_ROLE_CONTRACT_CANCEL';
  190. const EXTRA_ROLE_CONTRACT_PRICE = 'EXTRA_ROLE_CONTRACT_PRICE';
  191. const EXTRA_ROLE_CONTRACT_YOUSIGN = 'EXTRA_ROLE_CONTRACT_YOUSIGN';
  192. const EXTRA_ROLE_CONTRACT_ARCHIVED = 'EXTRA_ROLE_CONTRACT_ARCHIVED';
  193. const EXTRA_ROLE_CONTRACT_NETTY = 'EXTRA_ROLE_CONTRACT_NETTY';
  194. const EXTRA_ROLE_CONTRACT_PROMUP = 'EXTRA_ROLE_CONTRACT_PROMUP';
  195. const EXTRA_ROLE_CONTRACT_KIMPLI = 'EXTRA_ROLE_CONTRACT_KIMPLI';
  196. const EXTRA_ROLE_CONF = [
  197. self::EXTRA_ROLE_TELEMARKETING => [
  198. 'label' => 'Téléprospection',
  199. 'class' => 'info',
  200. ],
  201. self::EXTRA_ROLE_CONTRACT_VALIDATE => [
  202. 'label' => 'Validation des contrats',
  203. 'class' => 'info',
  204. ],
  205. self::EXTRA_ROLE_CONTRACT_CANCEL => [
  206. 'label' => 'Annulation des contrats',
  207. 'class' => 'info',
  208. ],
  209. self::EXTRA_ROLE_CONTRACT_PRICE => [
  210. 'label' => 'Modification du prix des contrats',
  211. 'class' => 'info',
  212. ],
  213. self::EXTRA_ROLE_CONTRACT_YOUSIGN => [
  214. 'label' => 'Signature Yousign',
  215. 'class' => 'info',
  216. ],
  217. self::EXTRA_ROLE_CONTRACT_ARCHIVED => [
  218. 'label' => 'Gestion des contrats archivés',
  219. 'class' => 'info',
  220. ],
  221. self::EXTRA_ROLE_CONTRACT_NETTY => [
  222. 'label' => 'Gestion de la synchro Netty',
  223. 'class' => 'info',
  224. ],
  225. self::EXTRA_ROLE_CONTRACT_PROMUP => [
  226. 'label' => 'Gestion de l\'interface Promup',
  227. 'class' => 'info',
  228. ],
  229. self::EXTRA_ROLE_CONTRACT_KIMPLI => [
  230. 'label' => 'Gestion de l\'interface Kimpli',
  231. 'class' => 'info',
  232. ],
  233. ];
  234. const UNIVERSE_BIENPRETER = 'UNIVERSE_BIENPRETER';
  235. const UNIVERSE_PROMUP = 'UNIVERSE_PROMUP';
  236. const UNIVERSE_KIMPLI = 'UNIVERSE_KIMPLI';
  237. const UNIVERSE_CONF = [
  238. self::UNIVERSE_BIENPRETER => [
  239. 'label' => 'Bienprêter',
  240. 'code' => 'bienpreter',
  241. 'class' => 'primary',
  242. 'logo' => 'build/logo_bienpreter.png',
  243. 'url_prod' => 'https://www.bienpreter.com',
  244. 'url_path' => '/connected',
  245. 'auto_login' => false,
  246. 'sync_users' => false,
  247. ],
  248. self::UNIVERSE_PROMUP => [
  249. 'label' => 'Promup',
  250. 'code' => 'promup',
  251. 'class' => 'primary',
  252. 'logo' => 'build/logo_promup.png',
  253. 'url_prod' => 'https://www.promup.com',
  254. 'url_path' => KiboardToolsService::URL_AUTH,
  255. 'auto_login' => true,
  256. 'sync_users' => true,
  257. ],
  258. self::UNIVERSE_KIMPLI => [
  259. 'label' => 'Kimpli',
  260. 'code' => 'kimpli',
  261. 'class' => 'primary',
  262. 'logo' => 'build/logo_kimpli.png',
  263. 'url_prod' => 'https://www.kimpli.com',
  264. 'url_path' => KiboardToolsService::URL_AUTH,
  265. 'auto_login' => true,
  266. 'sync_users' => true,
  267. ],
  268. ];
  269. /**
  270. * @var int|null
  271. *
  272. * @ORM\Column(name="id", type="integer")
  273. * @ORM\Id
  274. * @ORM\GeneratedValue(strategy="AUTO")
  275. */
  276. private ?int $id = null;
  277. /**
  278. * @var RefDepartment
  279. *
  280. * @ORM\OneToOne(targetEntity="RefDepartment", inversedBy="userConsulting", cascade={"persist"})
  281. */
  282. private $exclusiveDepartment;
  283. /**
  284. * @var RefDepartment[]
  285. *
  286. * @ORM\OneToMany(targetEntity="RefDepartment", mappedBy="userCustomerService", cascade={"persist", "remove"})
  287. */
  288. private $exclusiveDepartments;
  289. /**
  290. * @var Contract[]
  291. * @ORM\OneToMany(targetEntity="Contract", mappedBy="userConsulting")
  292. */
  293. private $contracts;
  294. /**
  295. * @var CustomerMessage[]
  296. * @ORM\OneToMany(targetEntity="CustomerMessage", mappedBy="userCustomerService")
  297. */
  298. private $messages;
  299. /**
  300. * @var UserActivity[]
  301. * @ORM\OneToMany(targetEntity="UserActivity", mappedBy="user", cascade={"persist", "remove"})
  302. */
  303. private $activities;
  304. /**
  305. * @var string
  306. *
  307. * @ORM\Column(name="filename", type="string", length=150, nullable=true, unique=true)
  308. */
  309. protected $filename;
  310. /**
  311. * @var string
  312. *
  313. * @ORM\Column(name="address", type="text", nullable=true)
  314. */
  315. private $address;
  316. /**
  317. * @var string
  318. *
  319. * @ORM\Column(name="email", type="string", length=150, unique=true)
  320. * @Assert\Email()
  321. */
  322. private $email;
  323. /**
  324. * @var string
  325. *
  326. * @ORM\Column(name="password", type="string", length=255)
  327. */
  328. private $password;
  329. /**
  330. * @var string
  331. *
  332. * @ORM\Column(name="slack_id", type="string", length=100, nullable=true)
  333. */
  334. private $slackId;
  335. /**
  336. * @var string
  337. *
  338. * @ORM\Column(name="civility", type="integer", length=1)
  339. */
  340. private $civility;
  341. /**
  342. * @var string
  343. *
  344. * @ORM\Column(name="first_name", type="string", length=100)
  345. */
  346. private $firstName;
  347. /**
  348. * @var string
  349. *
  350. * @ORM\Column(name="last_name", type="string", length=100)
  351. */
  352. private $lastName;
  353. /**
  354. * @var string
  355. *
  356. * @ORM\Column(name="email_home", type="string", length=150)
  357. * @Assert\Email()
  358. */
  359. private $emailHome;
  360. /**
  361. * @var string
  362. *
  363. * @ORM\Column(name="phone_home", type="string", nullable=true, length=50)
  364. */
  365. private $phoneHome;
  366. /**
  367. * @var string
  368. *
  369. * @ORM\Column(name="phone_work", type="string", nullable=true, length=50)
  370. */
  371. private $phoneWork;
  372. /**
  373. * @var int
  374. *
  375. * @ORM\Column(name="type", type="integer")
  376. */
  377. private $type;
  378. /**
  379. * @var array
  380. *
  381. * @ORM\Column(name="roles", type="array")
  382. */
  383. private $roles;
  384. /**
  385. * @var array
  386. *
  387. * @ORM\Column(name="extra_roles", type="array")
  388. */
  389. private $extraRoles;
  390. /**
  391. * @var array
  392. *
  393. * @ORM\Column(name="universes", type="array")
  394. */
  395. private $universes;
  396. /**
  397. * @var bool
  398. *
  399. * @ORM\Column(name="is_locked", type="boolean", options={"default": 0})
  400. */
  401. private $isLocked;
  402. /**
  403. * @var array
  404. *
  405. * @ORM\Column(name="logs", type="array")
  406. */
  407. private $logs;
  408. /**
  409. * @var \DateTime
  410. *
  411. * @ORM\Column(name="connected_at", type="datetime", nullable=true)
  412. */
  413. private $connectedAt;
  414. /**
  415. * @param bool $bShowOnlyPublic
  416. *
  417. * @return array
  418. */
  419. public function toArray(bool $bShowOnlyPublic = true): array
  420. {
  421. $aData = $this->buildArray([
  422. 'id', 'logs', 'activities', 'messages', 'password',
  423. 'contracts', 'documents', 'connectedAt', 'exclusiveDepartment', 'exclusiveDepartments',
  424. ]);
  425. $aData['phone'] = $bShowOnlyPublic ? $this->phoneWork : $this->getPhone();
  426. $aData['fullName'] = $this->getFullName();
  427. $aData['halfName'] = $this->getHalfName();
  428. if ($bShowOnlyPublic) {
  429. $aAllowedFields = ['fullName', 'halfName', 'email', 'phone', 'civility'];
  430. foreach ($aData as $sKey => $sField) {
  431. if (!in_array($sKey, $aAllowedFields)) {
  432. unset($aData[$sKey]);
  433. }
  434. }
  435. }
  436. return $aData;
  437. }
  438. /**
  439. * @param User $oUser
  440. * @param string $sMessage
  441. * @param null $oDate
  442. *
  443. * @return self
  444. * @throws \Exception
  445. */
  446. public function addLog(User $oUser, string $sMessage, $oDate = null): User
  447. {
  448. $oDate = $oDate ?? new \DateTime();
  449. $this->logs[] = implode(' ', ['['.$oDate->format('d/m/Y H:i').']', '['.$oUser->getHalfName().']', $sMessage]);
  450. return $this;
  451. }
  452. /**
  453. * @return string
  454. */
  455. public function getExclusiveDepartmentsList(): string
  456. {
  457. $aCodes = [];
  458. foreach ($this->exclusiveDepartments as $oDep) {
  459. $aCodes[] = $oDep->getCode();
  460. }
  461. return implode(' - ', $aCodes);
  462. }
  463. public function getUser(): User
  464. {
  465. return $this;
  466. }
  467. public function getRole()
  468. {
  469. return $this->roles ? $this->roles[0] : null;
  470. }
  471. public function setRole($role): self
  472. {
  473. $this->roles = [$role];
  474. return $this;
  475. }
  476. /**
  477. * @return string
  478. */
  479. public function getUsername(): ?string
  480. {
  481. return $this->getUserIdentifier();
  482. }
  483. /**
  484. * @return string
  485. */
  486. public function getUserIdentifier(): ?string
  487. {
  488. return $this->getEmail();
  489. }
  490. /**
  491. * @return string
  492. */
  493. public function getPassword(): ?string
  494. {
  495. return $this->password;
  496. }
  497. public function getSalt()
  498. {
  499. // you *may* need a real salt depending on your encoder
  500. // see section on salt below
  501. return null;
  502. }
  503. /**
  504. * Get the user roles
  505. *
  506. * @return array
  507. */
  508. public function getRoles(): array
  509. {
  510. return $this->roles;
  511. }
  512. public function eraseCredentials()
  513. {
  514. }
  515. /**
  516. * Constructor
  517. */
  518. public function __construct()
  519. {
  520. $this->civility = self::CIV_MISTER;
  521. $this->isLocked = false;
  522. $this->logs = [];
  523. $this->roles = $this->extraRoles = $this->universes = [];
  524. $this->documents = new ArrayCollection();
  525. $this->contracts = new ArrayCollection();
  526. $this->messages = new ArrayCollection();
  527. $this->exclusiveDepartments = new ArrayCollection();
  528. $this->activities = new ArrayCollection();
  529. }
  530. /**
  531. * @inheritDoc
  532. */
  533. public function serialize()
  534. {
  535. return serialize(array(
  536. $this->id,
  537. $this->email,
  538. $this->password
  539. ));
  540. }
  541. /**
  542. * @inheritDoc
  543. */
  544. public function unserialize($serialized)
  545. {
  546. [
  547. $this->id,
  548. $this->email,
  549. $this->password,
  550. ] = unserialize($serialized);
  551. }
  552. /**
  553. * @return string
  554. */
  555. public function getName(): string
  556. {
  557. return $this->getFullName();
  558. }
  559. /**
  560. * @return string|null
  561. */
  562. public function getPhone(): ?string
  563. {
  564. return $this->phoneWork ? $this->phoneWork : $this->phoneHome;
  565. }
  566. /**
  567. * @return string
  568. */
  569. public function __toString(): string
  570. {
  571. return $this->getFullName();
  572. }
  573. /**
  574. * @return string
  575. */
  576. public function getHalfName(): string
  577. {
  578. return ucfirst($this->firstName) .' '. ($this->lastName ? mb_strtoupper($this->lastName[0]) : '') . '.';
  579. }
  580. /**
  581. * @return string
  582. */
  583. public function getFullName(): string
  584. {
  585. return ucfirst($this->firstName) .' '. mb_strtoupper($this->lastName);
  586. }
  587. /**
  588. * @return string
  589. */
  590. public function getReverseFullName(): string
  591. {
  592. return mb_strtoupper($this->lastName) .' '. ucfirst($this->firstName);
  593. }
  594. /**
  595. * @return string
  596. */
  597. public function getExtraFullName(): string
  598. {
  599. return $this->id . ' - ' . ucfirst($this->firstName) .' '. mb_strtoupper($this->lastName);
  600. }
  601. public function getId(): ?int
  602. {
  603. return $this->id;
  604. }
  605. public function setId(int $id): self
  606. {
  607. $this->id = $id;
  608. return $this;
  609. }
  610. public function getEmail(): ?string
  611. {
  612. return $this->email;
  613. }
  614. public function setEmail(string $email): self
  615. {
  616. $this->email = $email;
  617. return $this;
  618. }
  619. public function setPassword(?string $password): self
  620. {
  621. $this->password = $password;
  622. return $this;
  623. }
  624. public function setRoles($roles): self
  625. {
  626. $this->roles = is_array($roles) ? $roles : [$roles];
  627. return $this;
  628. }
  629. public function getIsLocked(): ?bool
  630. {
  631. return $this->isLocked;
  632. }
  633. public function setIsLocked(bool $isLocked): self
  634. {
  635. $this->isLocked = $isLocked;
  636. return $this;
  637. }
  638. public function getCreatedAt(): ?\DateTimeInterface
  639. {
  640. return $this->createdAt;
  641. }
  642. public function setCreatedAt(\DateTimeInterface $createdAt): self
  643. {
  644. $this->createdAt = $createdAt;
  645. return $this;
  646. }
  647. public function getUpdatedAt(): ?\DateTimeInterface
  648. {
  649. return $this->updatedAt;
  650. }
  651. public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  652. {
  653. $this->updatedAt = $updatedAt;
  654. return $this;
  655. }
  656. public function getConnectedAt(): ?\DateTimeInterface
  657. {
  658. return $this->connectedAt;
  659. }
  660. public function setConnectedAt(\DateTimeInterface $connectedAt): self
  661. {
  662. $this->connectedAt = $connectedAt;
  663. return $this;
  664. }
  665. public function getFirstName(): ?string
  666. {
  667. return $this->firstName;
  668. }
  669. public function setFirstName(string $firstName): self
  670. {
  671. $this->firstName = $firstName;
  672. return $this;
  673. }
  674. public function getLastName(): ?string
  675. {
  676. return $this->lastName;
  677. }
  678. public function setLastName(string $lastName): self
  679. {
  680. $this->lastName = $lastName;
  681. return $this;
  682. }
  683. public function getAddress(): ?string
  684. {
  685. return $this->address;
  686. }
  687. public function setAddress(?string $address): self
  688. {
  689. $this->address = $address;
  690. return $this;
  691. }
  692. public function getCivility(): ?int
  693. {
  694. return $this->civility;
  695. }
  696. public function setCivility(int $civility): self
  697. {
  698. $this->civility = $civility;
  699. return $this;
  700. }
  701. public function getPhoneHome(): ?string
  702. {
  703. return $this->phoneHome;
  704. }
  705. public function setPhoneHome(?string $phoneHome): self
  706. {
  707. $this->phoneHome = str_replace(['+33', ' '], ['0', ''], $phoneHome);
  708. return $this;
  709. }
  710. public function getPhoneWork(): ?string
  711. {
  712. return $this->phoneWork;
  713. }
  714. public function setPhoneWork(?string $phoneWork): self
  715. {
  716. $this->phoneWork = str_replace(['+33', ' '], ['0', ''], $phoneWork);
  717. return $this;
  718. }
  719. public function getType(): ?int
  720. {
  721. return $this->type;
  722. }
  723. public function setType(int $type): self
  724. {
  725. $this->type = $type;
  726. return $this;
  727. }
  728. public function getEmailHome(): ?string
  729. {
  730. return $this->emailHome;
  731. }
  732. public function setEmailHome(string $emailHome): self
  733. {
  734. $this->emailHome = $emailHome;
  735. return $this;
  736. }
  737. public function getFilename(): ?string
  738. {
  739. return $this->filename;
  740. }
  741. public function setFilename(?string $filename): self
  742. {
  743. $this->filename = $filename;
  744. return $this;
  745. }
  746. /**
  747. * @return Collection|Contract[]
  748. */
  749. public function getContracts(): Collection
  750. {
  751. return $this->contracts;
  752. }
  753. public function addContract(Contract $contract): self
  754. {
  755. if (!$this->contracts->contains($contract)) {
  756. $this->contracts[] = $contract;
  757. $contract->setUserConsulting($this);
  758. }
  759. return $this;
  760. }
  761. public function removeContract(Contract $contract): self
  762. {
  763. if ($this->contracts->contains($contract)) {
  764. $this->contracts->removeElement($contract);
  765. // set the owning side to null (unless already changed)
  766. if ($contract->getUserConsulting() === $this) {
  767. $contract->setUserConsulting(null);
  768. }
  769. }
  770. return $this;
  771. }
  772. public function getExclusiveDepartment(): ?RefDepartment
  773. {
  774. return $this->exclusiveDepartment;
  775. }
  776. public function setExclusiveDepartment(?RefDepartment $exclusiveDepartment): self
  777. {
  778. $this->exclusiveDepartment = $exclusiveDepartment;
  779. return $this;
  780. }
  781. public function getLogs(): ?array
  782. {
  783. return $this->logs;
  784. }
  785. public function setLogs(array $logs): self
  786. {
  787. $this->logs = $logs;
  788. return $this;
  789. }
  790. /**
  791. * @return Collection|CustomerMessage[]
  792. */
  793. public function getMessages(): Collection
  794. {
  795. return $this->messages;
  796. }
  797. public function addMessage(CustomerMessage $message): self
  798. {
  799. if (!$this->messages->contains($message)) {
  800. $this->messages[] = $message;
  801. $message->setUserCustomerService($this);
  802. }
  803. return $this;
  804. }
  805. public function removeMessage(CustomerMessage $message): self
  806. {
  807. if ($this->messages->removeElement($message)) {
  808. // set the owning side to null (unless already changed)
  809. if ($message->getUserCustomerService() === $this) {
  810. $message->setUserCustomerService(null);
  811. }
  812. }
  813. return $this;
  814. }
  815. public function getExtraRoles(): ?array
  816. {
  817. return $this->extraRoles;
  818. }
  819. public function setExtraRoles(array $extraRoles): self
  820. {
  821. $this->extraRoles = $extraRoles;
  822. return $this;
  823. }
  824. /**
  825. * @return Collection|RefDepartment[]
  826. */
  827. public function getExclusiveDepartments(): Collection
  828. {
  829. return $this->exclusiveDepartments;
  830. }
  831. public function syncExclusiveDepartments(array $aOldDeps): self
  832. {
  833. foreach ($aOldDeps as $oDep) {
  834. if (!$this->exclusiveDepartments->contains($oDep) && ($oDep->getUserCustomerService() === $this)) {
  835. $oDep->setUserCustomerService(null);
  836. }
  837. }
  838. foreach ($this->exclusiveDepartments->toArray() as $oDep) {
  839. $oDep->setUserCustomerService($this);
  840. }
  841. return $this;
  842. }
  843. public function addExclusiveDepartment(RefDepartment $exclusiveDepartment): self
  844. {
  845. if (!$this->exclusiveDepartments->contains($exclusiveDepartment)) {
  846. $this->exclusiveDepartments[] = $exclusiveDepartment;
  847. $exclusiveDepartment->setUserCustomerService($this);
  848. }
  849. return $this;
  850. }
  851. public function removeExclusiveDepartment(RefDepartment $exclusiveDepartment): self
  852. {
  853. if ($this->exclusiveDepartments->removeElement($exclusiveDepartment)) {
  854. // set the owning side to null (unless already changed)
  855. if ($exclusiveDepartment->getUserCustomerService() === $this) {
  856. $exclusiveDepartment->setUserCustomerService(null);
  857. }
  858. }
  859. return $this;
  860. }
  861. public function getSlackId(): ?string
  862. {
  863. return $this->slackId;
  864. }
  865. public function setSlackId(?string $slackId): self
  866. {
  867. $this->slackId = $slackId;
  868. return $this;
  869. }
  870. public function getUniverses(): ?array
  871. {
  872. return $this->universes;
  873. }
  874. public function setUniverses(array $universes): self
  875. {
  876. $this->universes = $universes;
  877. return $this;
  878. }
  879. public function isIsLocked(): ?bool
  880. {
  881. return $this->isLocked;
  882. }
  883. /**
  884. * @return Collection<int, UserActivity>
  885. */
  886. public function getActivities(): Collection
  887. {
  888. return $this->activities;
  889. }
  890. public function addActivity(UserActivity $activity): self
  891. {
  892. if (!$this->activities->contains($activity)) {
  893. $this->activities[] = $activity;
  894. $activity->setUser($this);
  895. }
  896. return $this;
  897. }
  898. public function removeActivity(UserActivity $activity): self
  899. {
  900. if ($this->activities->removeElement($activity)) {
  901. // set the owning side to null (unless already changed)
  902. if ($activity->getUser() === $this) {
  903. $activity->setUser(null);
  904. }
  905. }
  906. return $this;
  907. }
  908. }