src/Entity/Customer.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Model\Uploadable;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Symfony\Component\HttpFoundation\File\UploadedFile;
  10. use Symfony\Component\Security\Core\User\PasswordAuthenticatedUserInterface;
  11. use Symfony\Component\Security\Core\User\UserInterface;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. /**
  14. * @ORM\Table()
  15. * @ORM\Entity(repositoryClass="App\Repository\CustomerRepository")
  16. * @ORM\HasLifecycleCallbacks
  17. */
  18. class Customer implements UserInterface, PasswordAuthenticatedUserInterface, \Serializable
  19. {
  20. use TraitEntityAddons;
  21. /**
  22. * Types
  23. */
  24. const TYPE_INDIVIDUAL = 1;
  25. const TYPE_SOCIETY = 2;
  26. const TYPE_JOINT = 3;
  27. const TYPE_CONF = [
  28. self::TYPE_INDIVIDUAL => [
  29. 'label' => 'Particulier',
  30. 'class' => 'dark',
  31. 'icon' => 'build/icon_individual.png',
  32. ],
  33. self::TYPE_SOCIETY => [
  34. 'label' => 'Société',
  35. 'class' => 'dark',
  36. 'icon' => 'build/icon_society.png',
  37. ],
  38. self::TYPE_JOINT => [
  39. 'label' => 'Indivision',
  40. 'class' => 'dark',
  41. 'icon' => 'build/icon_joint.png',
  42. ],
  43. ];
  44. /**
  45. * Family's situation
  46. */
  47. const FAMILY_SITUATION_SINGLE = 1;
  48. const FAMILY_SITUATION_PACS = 2;
  49. const FAMILY_SITUATION_MARRIED = 3;
  50. const FAMILY_SITUATION_CONCUBINAGE = 4;
  51. const FAMILY_SITUATION_WIDOWED = 5;
  52. const FAMILY_SITUATION_DIVORCED = 6;
  53. const FAMILY_SITUATION_CONF = [
  54. self::FAMILY_SITUATION_SINGLE => [
  55. 'label' => 'Célibataire',
  56. ],
  57. self::FAMILY_SITUATION_PACS => [
  58. 'label' => 'Pacs',
  59. ],
  60. self::FAMILY_SITUATION_MARRIED => [
  61. 'label' => 'Marié',
  62. ],
  63. self::FAMILY_SITUATION_CONCUBINAGE => [
  64. 'label' => 'Concubinage',
  65. ],
  66. self::FAMILY_SITUATION_WIDOWED => [
  67. 'label' => 'Veuf(ve)',
  68. ],
  69. self::FAMILY_SITUATION_DIVORCED => [
  70. 'label' => 'Divorcé(e)',
  71. ],
  72. ];
  73. /**
  74. * Typologies
  75. */
  76. const TYPOLOGY_NONE = 0;
  77. const TYPOLOGY_NO_ACTION_TAKEN = 1;
  78. const TYPOLOGY_FUNDING_OBTAINED = 2;
  79. const TYPOLOGY_NO_FINANCING = 3;
  80. const TYPOLOGY_SEEKING_FUNDING = 4;
  81. const TYPOLOGY_FUNDING_REFUSED = 5;
  82. const TYPOLOGY_CONF = [
  83. self::TYPOLOGY_NONE => [
  84. 'label' => 'Aucun projet d\'acquisition prévu',
  85. 'class' => 'light',
  86. ],
  87. self::TYPOLOGY_NO_ACTION_TAKEN => [
  88. 'label' => 'Aucune démarche effectuée',
  89. 'class' => 'dark',
  90. ],
  91. self::TYPOLOGY_FUNDING_OBTAINED => [
  92. 'label' => 'Financement obtenu',
  93. 'class' => 'success',
  94. ],
  95. self::TYPOLOGY_NO_FINANCING => [
  96. 'label' => 'Achat sans financement',
  97. 'class' => 'dark',
  98. ],
  99. self::TYPOLOGY_SEEKING_FUNDING => [
  100. 'label' => 'A la recherche d’un financement',
  101. 'class' => 'dark',
  102. ],
  103. self::TYPOLOGY_FUNDING_REFUSED => [
  104. 'label' => 'Financement refusé',
  105. 'class' => 'danger',
  106. ],
  107. ];
  108. /**
  109. * Statuses
  110. */
  111. const STATUS_DRAFT = 1;
  112. const STATUS_VALIDATED = 2;
  113. const STATUS_CONF = [
  114. self::STATUS_DRAFT => [
  115. 'label' => 'En cours de saisie',
  116. 'class' => 'light',
  117. ],
  118. self::STATUS_VALIDATED => [
  119. 'label' => 'Validé',
  120. 'class' => 'success',
  121. ],
  122. ];
  123. /**
  124. * Moods
  125. */
  126. const MOOD_ANGRY = 1;
  127. const MOOD_ANXIOUS = 2;
  128. const MOOD_PLEASED = 3;
  129. const MOOD_CHEERFUL = 4;
  130. const MOOD_LOVER = 5;
  131. const MOOD_CONF = [
  132. self::MOOD_ANGRY => [
  133. 'label' => 'Client énervé',
  134. 'class' => 'danger',
  135. 'icon' => 'angry',
  136. ],
  137. self::MOOD_ANXIOUS => [
  138. 'label' => 'Client inquiet',
  139. 'class' => 'warning',
  140. 'icon' => 'meh',
  141. ],
  142. self::MOOD_PLEASED => [
  143. 'label' => 'Client content',
  144. 'class' => 'primary',
  145. 'icon' => 'smile',
  146. ],
  147. self::MOOD_CHEERFUL => [
  148. 'label' => 'Client reconnaissant',
  149. 'class' => 'info',
  150. 'icon' => 'grin',
  151. ],
  152. self::MOOD_LOVER => [
  153. 'label' => 'Client heureux',
  154. 'class' => 'success',
  155. 'icon' => 'grin-hearts',
  156. ],
  157. ];
  158. /**
  159. * Roles
  160. */
  161. const ROLE_CUSTOMER = 'ROLE_CUSTOMER';
  162. const ROLE_CONF = [
  163. self::ROLE_CUSTOMER => [
  164. 'label' => 'Client(e)',
  165. 'class' => 'info',
  166. ],
  167. ];
  168. /**
  169. * @var int
  170. *
  171. * @ORM\Column(name="id", type="integer")
  172. * @ORM\Id
  173. * @ORM\GeneratedValue(strategy="AUTO")
  174. */
  175. private $id;
  176. /**
  177. * @var CustomerDocument[]
  178. *
  179. * @ORM\OneToMany(targetEntity="CustomerDocument", mappedBy="customer", cascade={"persist", "remove"})
  180. */
  181. private $documents;
  182. /**
  183. * @var Person[]
  184. *
  185. * @ORM\ManyToMany(targetEntity="Person", cascade={"persist", "remove"}, orphanRemoval=true)
  186. * @ORM\JoinTable(name="customer_persons",
  187. * joinColumns={@ORM\JoinColumn(name="customer_id", referencedColumnName="id")},
  188. * inverseJoinColumns={@ORM\JoinColumn(name="person_id", referencedColumnName="id")}
  189. * )
  190. */
  191. private $persons;
  192. /**
  193. * @var Contract[]
  194. * @ORM\OneToMany(targetEntity="Contract", mappedBy="customer", cascade={"persist", "remove"})
  195. */
  196. private $contracts;
  197. /**
  198. * @var ContractAppointment[]
  199. * @ORM\OneToMany(targetEntity="ContractAppointment", mappedBy="customer", cascade={"persist", "remove"})
  200. */
  201. private $appointments;
  202. /**
  203. * @var Sponsorship[]
  204. * @ORM\OneToMany(targetEntity="Sponsorship", mappedBy="customer", cascade={"persist", "remove"})
  205. */
  206. private $sponsorships;
  207. /**
  208. * @var CustomerMessage[]
  209. * @ORM\OneToMany(targetEntity="CustomerMessage", mappedBy="customer", cascade={"persist", "remove"})
  210. */
  211. private $messages;
  212. /**
  213. * @var CustomerNotification[]
  214. * @ORM\OneToMany(targetEntity="CustomerNotification", mappedBy="customer", cascade={"persist", "remove"})
  215. */
  216. private $notifications;
  217. /**
  218. * @var User
  219. *
  220. * @ORM\ManyToOne(targetEntity="User")
  221. * @ORM\JoinColumn(name="user_customer_service_id", referencedColumnName="id")
  222. */
  223. private $userCustomerService;
  224. /**
  225. * @var CustomerSearch
  226. *
  227. * @ORM\OneToOne(targetEntity="CustomerSearch", mappedBy="customer", cascade={"persist", "remove"})
  228. */
  229. private $search;
  230. /**
  231. * @var Address
  232. *
  233. * @ORM\OneToOne(targetEntity="Address", cascade={"persist", "remove"})
  234. */
  235. private $address;
  236. /**
  237. * @var int
  238. *
  239. * @ORM\Column(name="netty_id", type="integer", nullable=true)
  240. */
  241. private $nettyId;
  242. /**
  243. * @var int
  244. *
  245. * @ORM\Column(name="type", type="integer")
  246. */
  247. private $type;
  248. /**
  249. * @var string
  250. *
  251. * @ORM\Column(name="society_name", type="string", length=100, nullable=true)
  252. */
  253. private $societyName;
  254. /**
  255. * @var string
  256. *
  257. * @ORM\Column(name="society_address", type="text", nullable=true)
  258. */
  259. private $societyAddress;
  260. /**
  261. * @var string
  262. *
  263. * @ORM\Column(name="society_siret", type="text", nullable=true)
  264. */
  265. private $societySiret;
  266. /**
  267. * @var string
  268. *
  269. * @ORM\Column(name="remarks", type="text", nullable=true)
  270. */
  271. private $remarks;
  272. /**
  273. * @var string
  274. *
  275. * @ORM\Column(name="password", type="string", length=255, nullable=true)
  276. */
  277. private $password;
  278. /**
  279. * @var string
  280. *
  281. * @ORM\Column(name="email1", type="string", length=150, nullable=true)
  282. * @Assert\Email()
  283. */
  284. private $email1;
  285. /**
  286. * @var string
  287. *
  288. * @ORM\Column(name="email2", type="string", length=150, nullable=true)
  289. * @Assert\Email()
  290. */
  291. private $email2;
  292. /**
  293. * @var string
  294. *
  295. * @ORM\Column(name="phone1", type="string", length=50, nullable=true)
  296. */
  297. private $phone1;
  298. /**
  299. * @var string
  300. *
  301. * @ORM\Column(name="phone2", type="string", length=50, nullable=true)
  302. */
  303. private $phone2;
  304. /**
  305. * @var string
  306. *
  307. * @ORM\Column(name="phone3", type="string", length=50, nullable=true)
  308. */
  309. private $phone3;
  310. /**
  311. * @var array
  312. *
  313. * @ORM\Column(name="roles", type="array")
  314. */
  315. private $roles;
  316. /**
  317. * @var int
  318. *
  319. * @ORM\Column(name="family_situation", type="integer", nullable=true)
  320. */
  321. private $familySituation;
  322. /**
  323. * @var int
  324. *
  325. * @ORM\Column(name="mood", type="integer", nullable=true)
  326. */
  327. private $mood;
  328. /**
  329. * @var int
  330. *
  331. * @ORM\Column(name="status", type="integer")
  332. */
  333. private $status;
  334. /**
  335. * @var string
  336. *
  337. * @ORM\Column(name="comment", type="text", nullable=true)
  338. */
  339. private $comment;
  340. /**
  341. * @var string
  342. *
  343. * @ORM\Column(name="source", type="string", length=100, nullable=true)
  344. */
  345. private $source;
  346. /**
  347. * @var int
  348. *
  349. * @ORM\Column(name="typology", type="integer")
  350. */
  351. private $typology;
  352. /**
  353. * @var string
  354. *
  355. * @ORM\Column(name="forgot_password_token", type="string", length=100, nullable=true)
  356. */
  357. private $forgotPasswordToken;
  358. /**
  359. * @var \DateTime
  360. *
  361. * @ORM\Column(name="forgot_password_token_expire_at", type="datetime", nullable=true)
  362. */
  363. private $forgotPasswordTokenExpireAt;
  364. /**
  365. * @var array
  366. *
  367. * @ORM\Column(name="logs", type="array")
  368. */
  369. private $logs;
  370. /**
  371. * @var \DateTime
  372. *
  373. * @ORM\Column(name="created_at", type="datetime")
  374. */
  375. private $createdAt;
  376. /**
  377. * @var \DateTime
  378. *
  379. * @ORM\Column(name="updated_at", type="datetime")
  380. */
  381. private $updatedAt;
  382. /**
  383. * @var \DateTime
  384. *
  385. * @ORM\Column(name="connected_at", type="datetime", nullable=true)
  386. */
  387. private $connectedAt;
  388. /**
  389. * @var \DateTime
  390. *
  391. * @ORM\Column(name="last_call_at", type="datetime", nullable=true)
  392. */
  393. private $lastCallAt;
  394. /**
  395. * @var \DateTime
  396. *
  397. * @ORM\Column(name="last_successful_call_at", type="datetime", nullable=true)
  398. */
  399. private $lastSuccessfulCallAt;
  400. /**
  401. * @var \DateTime
  402. *
  403. * @ORM\Column(name="recall_at", type="datetime", nullable=true)
  404. */
  405. private $recallAt;
  406. /**
  407. * @var \DateTime
  408. *
  409. * @ORM\Column(name="unreachable_at", type="datetime", nullable=true)
  410. */
  411. private $unreachableAt;
  412. /**
  413. * @var bool
  414. *
  415. * @ORM\Column(name="not_duplicate", type="boolean", nullable=true)
  416. */
  417. private $notDuplicate;
  418. /**
  419. * @var UploadedFile[]
  420. */
  421. private $documentFiles;
  422. /**
  423. * @param User $oUser
  424. * @param string $sMessage
  425. * @param null $oDate
  426. *
  427. * @return Customer
  428. * @throws \Exception
  429. */
  430. public function addLog(User $oUser, string $sMessage, $oDate = null): Customer
  431. {
  432. $oDate = $oDate ?? new \DateTime();
  433. $this->logs[] = implode(' ', ['['.$oDate->format('d/m/Y H:i').']', '['.$oUser->getHalfName().']', $sMessage]);
  434. return $this;
  435. }
  436. /**
  437. * @return bool
  438. */
  439. public function isValid() : bool
  440. {
  441. return array_key_exists($this->type, self::TYPE_CONF) && (count($this->persons) > 0) && !empty($this->phone1)
  442. && !empty($this->email1) && !empty($this->address) && !empty($this->address->isValid());
  443. }
  444. /**
  445. * @return bool
  446. */
  447. public function isValidLight() : bool
  448. {
  449. return array_key_exists($this->type, self::TYPE_CONF) && (count($this->persons) > 0) && !empty($this->phone1)
  450. && !empty($this->email1);
  451. }
  452. /**
  453. * @return bool
  454. */
  455. public function hasLitigation(): bool
  456. {
  457. foreach ($this->contracts as $oContract) {
  458. if ($oContract->isLitigation()) {
  459. return true;
  460. }
  461. }
  462. return false;
  463. }
  464. /**
  465. * @return \DateTime
  466. */
  467. public function needToBeRecallAt(): \DateTime
  468. {
  469. return $this->getLastCallAt() ? (clone $this->getLastCallAt())->add(new \DateInterval('P30D')) : new \DateTime();
  470. }
  471. /**
  472. * @return bool
  473. */
  474. public function needToBeRecallSoon(): bool
  475. {
  476. return empty($this->getLastCallAt()) || $this->getLastCallAt() <= (new \DateTime())->sub(new \DateInterval('P30D'));
  477. }
  478. /**
  479. * @return bool
  480. */
  481. public function needToBeRecallVerySoon(): bool
  482. {
  483. return empty($this->getLastCallAt()) || $this->getLastCallAt() <= (new \DateTime())->sub(new \DateInterval('P35D'));
  484. }
  485. /**
  486. * @return string
  487. */
  488. public function getExtraFullName(): string
  489. {
  490. $sText = $this->getId() . ' - ' . $this->getLabel() . ' - ' . $this->getEmail1();
  491. if (!empty($this->getAddress())) {
  492. $sText .= ' - ' . $this->getAddress();
  493. }
  494. $sText .= ' (' . count($this->getContracts()) . ' biens)';
  495. return $sText;
  496. }
  497. /**
  498. * @param bool $bShowOnlyPublic
  499. *
  500. * @return array
  501. */
  502. public function toArray(bool $bShowOnlyPublic = true): array
  503. {
  504. $aData = $this->buildArray(['id', 'documents', 'contracts', 'appointments', 'createdAt', 'updatedAt', 'connectedAt', 'documentFiles', 'logs']);
  505. foreach ($aData['persons'] as $iIdx => $oPerson) {
  506. $aData['persons'][$iIdx] = $oPerson->toArray();
  507. }
  508. $aData['userCustomerService'] = $aData['userCustomerService'] ? $aData['userCustomerService']->toArray($bShowOnlyPublic) : $aData['userCustomerService'];
  509. $aData['address'] = $aData['address'] ? $aData['address']->toArray(true) : $aData['address'];
  510. $aData['search'] = $aData['search'] ? $aData['search']->toArray() : $aData['search'];
  511. if ($bShowOnlyPublic) {
  512. $aAllowedFields = ['phone1', 'userCustomerService'];
  513. foreach ($aData as $sKey => $sField) {
  514. if (!in_array($sKey, $aAllowedFields)) {
  515. unset($aData[$sKey]);
  516. }
  517. }
  518. }
  519. return $aData;
  520. }
  521. /**
  522. * @ORM\PrePersist
  523. */
  524. public function prePersist()
  525. {
  526. $this->createdAt = $this->updatedAt = new \DateTime();
  527. }
  528. /**
  529. * @ORM\PreUpdate()
  530. */
  531. public function preUpdate()
  532. {
  533. $this->updatedAt = new \DateTime();
  534. }
  535. /**
  536. * @param User $oUser
  537. *
  538. * @return bool
  539. */
  540. public function isUserUpdateAllowed(User $oUser): bool
  541. {
  542. foreach ($this->getContracts() as $oContract) {
  543. if ($oContract->getUserConsulting() === $oUser) {
  544. return true;
  545. }
  546. }
  547. return false;
  548. }
  549. /**
  550. * @ORM\PreFlush()
  551. */
  552. public function uploadFiles()
  553. {
  554. foreach ($this->documentFiles as $oFile) {
  555. if ($oFile instanceof UploadedFile) {
  556. $oDocument = (new CustomerDocument())
  557. ->upload($oFile, Uploadable::NAME_RANDOM, $this->getId())
  558. ->setCustomer($this)
  559. ;
  560. $this->addDocument($oDocument);
  561. }
  562. }
  563. $this->documentFiles = [];
  564. }
  565. /**
  566. * @ORM\PostLoad()
  567. */
  568. public function retrieveFiles()
  569. {
  570. $this->documentFiles = [];
  571. foreach ($this->documents as $oDocument) {
  572. $this->documentFiles[] = new File($oDocument->getAbsolutePath(), false);
  573. }
  574. }
  575. /**
  576. * @param UploadedFile $oFile
  577. *
  578. * @return $this
  579. */
  580. public function addDocumentFile(UploadedFile $oFile): self
  581. {
  582. $this->documentFiles[] = $oFile;
  583. return $this;
  584. }
  585. /**
  586. * @return string
  587. */
  588. public function getName(): string
  589. {
  590. return $this->getLabel();
  591. }
  592. /**
  593. * @return string
  594. */
  595. public function getLabel(): string
  596. {
  597. $aNames = [];
  598. foreach ($this->getPersons()->toArray() as $oPerson) {
  599. $aNames[] = mb_strtoupper($oPerson->getLastName());
  600. }
  601. return (!empty($this->getSocietyName()) ? $this->getSocietyName() . ' - ' : '') . implode(' - ', array_unique($aNames));
  602. }
  603. /**
  604. * @return string
  605. */
  606. public function getFullName(): string
  607. {
  608. $sText = !empty($this->getSocietyName()) ? $this->getSocietyName() . ' - ' : '';
  609. $sText .= count($this->getPersons()) > 0 ? ucfirst($this->getFirstName()) .' '. mb_strtoupper($this->getLastName()) : '';
  610. return $sText;
  611. }
  612. /**
  613. * @return string
  614. */
  615. public function getFirstName(): string
  616. {
  617. return count($this->getPersons()) > 0 ? $this->getPersons()[0]->getFirstName() : '';
  618. }
  619. /**
  620. * @return string
  621. */
  622. public function getLastName(): string
  623. {
  624. return count($this->getPersons()) > 0 ? $this->getPersons()[0]->getLastName() : '';
  625. }
  626. public function __construct()
  627. {
  628. $this->documentFiles = $this->logs = [];
  629. $this->type = self::TYPE_INDIVIDUAL;
  630. $this->status = self::STATUS_DRAFT;
  631. $this->typology = self::TYPOLOGY_NONE;
  632. $this->address = new Address();
  633. $this->contracts = new ArrayCollection();
  634. $this->appointments = new ArrayCollection();
  635. $this->documents = new ArrayCollection();
  636. $this->persons = new ArrayCollection();
  637. $this->sponsorships = new ArrayCollection();
  638. $this->messages = new ArrayCollection();
  639. $this->notifications = new ArrayCollection();
  640. }
  641. /**
  642. * @param string $sLastName
  643. *
  644. * @return string
  645. */
  646. public function setLastName(string $sLastName): self
  647. {
  648. if (count($this->getPersons()) > 0) {
  649. $this->getPersons()[0]->setLastName($sLastName);
  650. } else {
  651. $this->addPerson((new Person())->setFirstName('XX')->setLastName($sLastName));
  652. }
  653. return $this;
  654. }
  655. /**
  656. * @param string $sFirstName
  657. *
  658. * @return string
  659. */
  660. public function setFirstName(string $sFirstName): self
  661. {
  662. if (count($this->getPersons()) > 0) {
  663. $this->getPersons()[0]->setFirstName($sFirstName);
  664. } else {
  665. $this->addPerson((new Person())->setFirstName($sFirstName)->setLastName('XX'));
  666. }
  667. return $this;
  668. }
  669. /**
  670. * @param int $iCivility
  671. *
  672. * @return string
  673. */
  674. public function setCivility(int $iCivility): self
  675. {
  676. if (count($this->getPersons()) > 0) {
  677. $this->getPersons()[0]->setCivility($iCivility);
  678. } else {
  679. $this->addPerson((new Person())->setCivility($iCivility)->setFirstName('XX')->setLastName('XX'));
  680. }
  681. return $this;
  682. }
  683. /**
  684. * @return array
  685. */
  686. public function getConversations(): array
  687. {
  688. $aCustMessages = $this->getMessages()->toArray();
  689. usort($aCustMessages, function (CustomerMessage $a, CustomerMessage $b) {
  690. return ($b->getCreatedAt()->format('U') <=> $a->getCreatedAt()->format('U'));
  691. });
  692. $aConversations = [];
  693. foreach ($aCustMessages as $oMessage) {
  694. $sKey = implode('_', [$oMessage->getCategory(), $oMessage->getContract() ? $oMessage->getContract()->getRefNetty() : '']);
  695. $aConversations[ $sKey ][] = $oMessage;
  696. }
  697. return $aConversations;
  698. }
  699. /**
  700. * @return array
  701. */
  702. public function getMobilePhones(): array
  703. {
  704. $aPhones = [];
  705. foreach ([$this->phone1, $this->phone2, $this->phone3] as $sPhone) {
  706. if (strpos($sPhone, '+336') === 0 || strpos($sPhone, '06') === 0) {
  707. $aPhones[] = $sPhone;
  708. }
  709. }
  710. return $aPhones;
  711. }
  712. /**
  713. * @return string|null
  714. */
  715. public function getEmail(): ?string
  716. {
  717. return $this->email1;
  718. }
  719. /**
  720. * @return string|null
  721. */
  722. public function getPhone(): ?string
  723. {
  724. return $this->phone1;
  725. }
  726. public function setEmail(string $sEmail): self
  727. {
  728. if (empty($sEmail)) {
  729. $sEmail = uniqid() . '@nospam.fr';
  730. }
  731. $this->email1 = $sEmail;
  732. return $this;
  733. }
  734. public function getId(): ?int
  735. {
  736. return $this->id;
  737. }
  738. public function getEmail1(): ?string
  739. {
  740. return $this->email1;
  741. }
  742. public function setEmail1(?string $email1): self
  743. {
  744. $this->email1 = $email1;
  745. return $this;
  746. }
  747. /**
  748. * @return Collection|Contract[]
  749. */
  750. public function getContracts(): Collection
  751. {
  752. return $this->contracts;
  753. }
  754. public function addContract(Contract $contract): self
  755. {
  756. if (!$this->contracts->contains($contract)) {
  757. $this->contracts[] = $contract;
  758. $contract->setCustomer($this);
  759. }
  760. return $this;
  761. }
  762. public function removeContract(Contract $contract): self
  763. {
  764. if ($this->contracts->contains($contract)) {
  765. $this->contracts->removeElement($contract);
  766. // set the owning side to null (unless already changed)
  767. if ($contract->getCustomer() === $this) {
  768. $contract->setCustomer(null);
  769. }
  770. }
  771. return $this;
  772. }
  773. public function getUserCustomerService(): ?User
  774. {
  775. return $this->userCustomerService;
  776. }
  777. public function setUserCustomerService(?User $userCustomerService): self
  778. {
  779. $this->userCustomerService = $userCustomerService;
  780. return $this;
  781. }
  782. public function getStatus(): ?int
  783. {
  784. return $this->status;
  785. }
  786. public function setStatus(int $status): self
  787. {
  788. $this->status = $status;
  789. return $this;
  790. }
  791. public function getCreatedAt(): ?\DateTimeInterface
  792. {
  793. return $this->createdAt;
  794. }
  795. public function setCreatedAt(\DateTimeInterface $createdAt): self
  796. {
  797. $this->createdAt = $createdAt;
  798. return $this;
  799. }
  800. public function getUpdatedAt(): ?\DateTimeInterface
  801. {
  802. return $this->updatedAt;
  803. }
  804. public function setUpdatedAt(\DateTimeInterface $updatedAt): self
  805. {
  806. $this->updatedAt = $updatedAt;
  807. return $this;
  808. }
  809. /**
  810. * @return Collection|CustomerDocument[]
  811. */
  812. public function getDocuments(): Collection
  813. {
  814. return $this->documents;
  815. }
  816. public function addDocument(CustomerDocument $document): self
  817. {
  818. if (!$this->documents->contains($document)) {
  819. $this->documents[] = $document;
  820. $document->setCustomer($this);
  821. }
  822. return $this;
  823. }
  824. public function removeDocument(CustomerDocument $document): self
  825. {
  826. if ($this->documents->contains($document)) {
  827. $this->documents->removeElement($document);
  828. // set the owning side to null (unless already changed)
  829. if ($document->getCustomer() === $this) {
  830. $document->setCustomer(null);
  831. }
  832. }
  833. return $this;
  834. }
  835. public function getAddress(): ?Address
  836. {
  837. return $this->address;
  838. }
  839. public function setAddress(?Address $address): self
  840. {
  841. $this->address = $address;
  842. return $this;
  843. }
  844. public function getPhone1(): ?string
  845. {
  846. return $this->phone1;
  847. }
  848. public function setPhone1(?string $phone1): self
  849. {
  850. $this->phone1 = str_replace(['+33', ' '], ['0', ''], $phone1);
  851. return $this;
  852. }
  853. public function getPhone2(): ?string
  854. {
  855. return $this->phone2;
  856. }
  857. public function setPhone2(?string $phone2): self
  858. {
  859. $this->phone2 = str_replace(['+33', ' '], ['0', ''], $phone2);
  860. return $this;
  861. }
  862. public function getPhone3(): ?string
  863. {
  864. return $this->phone3;
  865. }
  866. public function setPhone3(?string $phone3): self
  867. {
  868. $this->phone3 = str_replace(['+33', ' '], ['0', ''], $phone3);
  869. return $this;
  870. }
  871. public function getLogs(): ?array
  872. {
  873. return $this->logs;
  874. }
  875. public function setLogs(array $logs): self
  876. {
  877. $this->logs = $logs;
  878. return $this;
  879. }
  880. public function getType(): ?int
  881. {
  882. return $this->type;
  883. }
  884. public function setType(int $type): self
  885. {
  886. $this->type = $type;
  887. return $this;
  888. }
  889. public function getSocietyName(): ?string
  890. {
  891. return $this->societyName;
  892. }
  893. public function setSocietyName(?string $societyName): self
  894. {
  895. $this->societyName = $societyName;
  896. return $this;
  897. }
  898. public function getSocietyAddress(): ?string
  899. {
  900. return $this->societyAddress;
  901. }
  902. public function setSocietyAddress(?string $societyAddress): self
  903. {
  904. $this->societyAddress = $societyAddress;
  905. return $this;
  906. }
  907. public function getRemarks(): ?string
  908. {
  909. return $this->remarks;
  910. }
  911. public function setRemarks(?string $remarks): self
  912. {
  913. $this->remarks = $remarks;
  914. return $this;
  915. }
  916. /**
  917. * @return Collection|Person[]
  918. */
  919. public function getPersons(): Collection
  920. {
  921. return $this->persons;
  922. }
  923. public function getComment(): ?string
  924. {
  925. return $this->comment;
  926. }
  927. public function setComment(?string $comment): self
  928. {
  929. $this->comment = $comment;
  930. return $this;
  931. }
  932. public function addPerson(Person $oPerson): self
  933. {
  934. if (!$this->persons->contains($oPerson)) {
  935. $this->persons[] = $oPerson;
  936. }
  937. return $this;
  938. }
  939. public function removePerson(Person $person): self
  940. {
  941. if ($this->persons->contains($person)) {
  942. $this->persons->removeElement($person);
  943. }
  944. return $this;
  945. }
  946. public function getLastCallAt(): ?\DateTimeInterface
  947. {
  948. return $this->lastCallAt;
  949. }
  950. public function setLastCallAt(?\DateTimeInterface $lastCallAt): self
  951. {
  952. $this->lastCallAt = $lastCallAt;
  953. return $this;
  954. }
  955. public function getRecallAt(): ?\DateTimeInterface
  956. {
  957. return $this->recallAt;
  958. }
  959. public function setRecallAt(?\DateTimeInterface $recallAt): self
  960. {
  961. $this->recallAt = $recallAt;
  962. return $this;
  963. }
  964. public function getEmail2(): ?string
  965. {
  966. return $this->email2;
  967. }
  968. public function setEmail2(?string $email2): self
  969. {
  970. $this->email2 = $email2;
  971. return $this;
  972. }
  973. public function getNotDuplicate(): ?bool
  974. {
  975. return $this->notDuplicate;
  976. }
  977. public function setNotDuplicate(?bool $notDuplicate): self
  978. {
  979. $this->notDuplicate = $notDuplicate;
  980. return $this;
  981. }
  982. public function getSource(): ?string
  983. {
  984. return $this->source;
  985. }
  986. public function setSource(?string $source): self
  987. {
  988. $this->source = $source;
  989. return $this;
  990. }
  991. public function getTypology(): ?int
  992. {
  993. return $this->typology;
  994. }
  995. public function setTypology(int $typology): self
  996. {
  997. $this->typology = $typology;
  998. return $this;
  999. }
  1000. /**
  1001. * @return Collection|ContractAppointment[]
  1002. */
  1003. public function getAppointments(): Collection
  1004. {
  1005. return $this->appointments;
  1006. }
  1007. public function addAppointment(ContractAppointment $appointment): self
  1008. {
  1009. if (!$this->appointments->contains($appointment)) {
  1010. $this->appointments[] = $appointment;
  1011. $appointment->setCustomer($this);
  1012. }
  1013. return $this;
  1014. }
  1015. public function removeAppointment(ContractAppointment $appointment): self
  1016. {
  1017. if ($this->appointments->removeElement($appointment)) {
  1018. // set the owning side to null (unless already changed)
  1019. if ($appointment->getCustomer() === $this) {
  1020. $appointment->setCustomer(null);
  1021. }
  1022. }
  1023. return $this;
  1024. }
  1025. public function getSearch(): ?CustomerSearch
  1026. {
  1027. return $this->search;
  1028. }
  1029. public function setSearch(?CustomerSearch $search): self
  1030. {
  1031. $this->search = $search;
  1032. return $this;
  1033. }
  1034. /**
  1035. * @inheritDoc
  1036. */
  1037. public function serialize()
  1038. {
  1039. return serialize(array(
  1040. $this->id,
  1041. $this->email1,
  1042. $this->password
  1043. ));
  1044. }
  1045. /**
  1046. * @inheritDoc
  1047. */
  1048. public function unserialize($serialized)
  1049. {
  1050. [
  1051. $this->id,
  1052. $this->email1,
  1053. $this->password,
  1054. ] = unserialize($serialized);
  1055. }
  1056. public function getRoles(): array
  1057. {
  1058. return $this->roles;
  1059. }
  1060. public function getPassword(): ?string
  1061. {
  1062. return $this->password;
  1063. }
  1064. public function getSalt(): ?string
  1065. {
  1066. // you *may* need a real salt depending on your encoder
  1067. // see section on salt below
  1068. return null;
  1069. }
  1070. /**
  1071. * @return string
  1072. */
  1073. public function getUsername(): ?string
  1074. {
  1075. return $this->getUserIdentifier();
  1076. }
  1077. /**
  1078. * @return string
  1079. */
  1080. public function getUserIdentifier(): ?string
  1081. {
  1082. return $this->email1;
  1083. }
  1084. public function eraseCredentials()
  1085. {
  1086. // TODO: Implement eraseCredentials() method.
  1087. }
  1088. public function setPassword(?string $password): self
  1089. {
  1090. $this->password = $password;
  1091. return $this;
  1092. }
  1093. public function setRoles(array $roles): self
  1094. {
  1095. $this->roles = $roles;
  1096. return $this;
  1097. }
  1098. public function getForgotPasswordToken(): ?string
  1099. {
  1100. return $this->forgotPasswordToken;
  1101. }
  1102. public function setForgotPasswordToken(?string $forgotPasswordToken): self
  1103. {
  1104. $this->forgotPasswordToken = $forgotPasswordToken;
  1105. return $this;
  1106. }
  1107. public function getForgotPasswordTokenExpireAt(): ?\DateTimeInterface
  1108. {
  1109. return $this->forgotPasswordTokenExpireAt;
  1110. }
  1111. public function setForgotPasswordTokenExpireAt(?\DateTimeInterface $forgotPasswordTokenExpireAt): self
  1112. {
  1113. $this->forgotPasswordTokenExpireAt = $forgotPasswordTokenExpireAt;
  1114. return $this;
  1115. }
  1116. /**
  1117. * @return Collection|Sponsorship[]
  1118. */
  1119. public function getSponsorships(): Collection
  1120. {
  1121. return $this->sponsorships;
  1122. }
  1123. public function addSponsorship(Sponsorship $sponsorship): self
  1124. {
  1125. if (!$this->sponsorships->contains($sponsorship)) {
  1126. $this->sponsorships[] = $sponsorship;
  1127. $sponsorship->setCustomer($this);
  1128. }
  1129. return $this;
  1130. }
  1131. public function removeSponsorship(Sponsorship $sponsorship): self
  1132. {
  1133. if ($this->sponsorships->removeElement($sponsorship)) {
  1134. // set the owning side to null (unless already changed)
  1135. if ($sponsorship->getCustomer() === $this) {
  1136. $sponsorship->setCustomer(null);
  1137. }
  1138. }
  1139. return $this;
  1140. }
  1141. /**
  1142. * @return Collection|CustomerMessage[]
  1143. */
  1144. public function getMessages(): Collection
  1145. {
  1146. return $this->messages;
  1147. }
  1148. public function addMessage(CustomerMessage $message): self
  1149. {
  1150. if (!$this->messages->contains($message)) {
  1151. $this->messages[] = $message;
  1152. $message->setCustomer($this);
  1153. }
  1154. return $this;
  1155. }
  1156. public function removeMessage(CustomerMessage $message): self
  1157. {
  1158. if ($this->messages->removeElement($message)) {
  1159. // set the owning side to null (unless already changed)
  1160. if ($message->getCustomer() === $this) {
  1161. $message->setCustomer(null);
  1162. }
  1163. }
  1164. return $this;
  1165. }
  1166. public function getUnreachableAt(): ?\DateTimeInterface
  1167. {
  1168. return $this->unreachableAt;
  1169. }
  1170. public function setUnreachableAt(?\DateTimeInterface $unreachableAt): self
  1171. {
  1172. $this->unreachableAt = $unreachableAt;
  1173. return $this;
  1174. }
  1175. public function getConnectedAt(): ?\DateTimeInterface
  1176. {
  1177. return $this->connectedAt;
  1178. }
  1179. public function setConnectedAt(?\DateTimeInterface $connectedAt): self
  1180. {
  1181. $this->connectedAt = $connectedAt;
  1182. return $this;
  1183. }
  1184. /**
  1185. * @return Collection|CustomerNotification[]
  1186. */
  1187. public function getNotifications(): Collection
  1188. {
  1189. return $this->notifications;
  1190. }
  1191. public function addNotification(CustomerNotification $notification): self
  1192. {
  1193. if (!$this->notifications->contains($notification)) {
  1194. $this->notifications[] = $notification;
  1195. $notification->setCustomer($this);
  1196. }
  1197. return $this;
  1198. }
  1199. public function removeNotification(CustomerNotification $notification): self
  1200. {
  1201. if ($this->notifications->removeElement($notification)) {
  1202. // set the owning side to null (unless already changed)
  1203. if ($notification->getCustomer() === $this) {
  1204. $notification->setCustomer(null);
  1205. }
  1206. }
  1207. return $this;
  1208. }
  1209. public function getNettyId(): ?int
  1210. {
  1211. return $this->nettyId;
  1212. }
  1213. public function setNettyId(?int $nettyId): self
  1214. {
  1215. $this->nettyId = $nettyId;
  1216. return $this;
  1217. }
  1218. public function getSocietySiret(): ?string
  1219. {
  1220. return $this->societySiret;
  1221. }
  1222. public function setSocietySiret(?string $societySiret): self
  1223. {
  1224. $this->societySiret = $societySiret;
  1225. return $this;
  1226. }
  1227. public function getFamilySituation(): ?int
  1228. {
  1229. return $this->familySituation;
  1230. }
  1231. public function setFamilySituation(?int $familySituation): self
  1232. {
  1233. $this->familySituation = $familySituation;
  1234. return $this;
  1235. }
  1236. public function isNotDuplicate(): ?bool
  1237. {
  1238. return $this->notDuplicate;
  1239. }
  1240. public function getMood(): ?int
  1241. {
  1242. return $this->mood;
  1243. }
  1244. public function setMood(?int $mood): self
  1245. {
  1246. $this->mood = $mood;
  1247. return $this;
  1248. }
  1249. public function getLastSuccessfulCallAt(): ?\DateTimeInterface
  1250. {
  1251. return $this->lastSuccessfulCallAt;
  1252. }
  1253. public function setLastSuccessfulCallAt(?\DateTimeInterface $lastSuccessfulCallAt): self
  1254. {
  1255. $this->lastSuccessfulCallAt = $lastSuccessfulCallAt;
  1256. return $this;
  1257. }
  1258. }