src/Model/Customer/Customer.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Model\Customer;
  3. use App\Enum\LanguageEnum;
  4. use App\Model\CustomerFile\CustomerFile;
  5. use App\Model\Module\Module;
  6. use App\Model\Security\UserInfo;
  7. use App\Model\Traits\ImportableObjectTrait;
  8. use DateTime;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. use Symfony\Component\Serializer\Annotation\Groups;
  12. use Symfony\Component\Validator\Constraints as Assert;
  13. /**
  14.  * Class Customer.
  15.  */
  16. class Customer
  17. {
  18.     use ImportableObjectTrait;
  19.     /**
  20.      * @var string|null
  21.      * @Groups({
  22.      *     "read", "list", "write"
  23.      * })
  24.      */
  25.     private $id;
  26.     /**
  27.      * @var string|null
  28.      * @Assert\NotBlank(message="Le nom de l'entreprise est obligatoire")
  29.      * @Groups({"read", "list", "write"})
  30.      */
  31.     private $name;
  32.     /**
  33.      * @var DateTime|null
  34.      * @Groups({"read", "list", "write"})
  35.      */
  36.     private $expiredAt;
  37.     /**
  38.      * @var bool|null
  39.      * @Groups({"read", "list", "write"})
  40.      */
  41.     private $isActive true;
  42.     /**
  43.      * @var bool|null
  44.      * @Groups({"read", "list", "write"})
  45.      */
  46.     private $isLiveo false;
  47.     /**
  48.      * @var bool|null
  49.      * @Groups({"read", "list", "write"})
  50.      */
  51.     private $hasIntranet false;
  52.     /**
  53.      * @var string|null
  54.      * @Groups({"read", "list", "write"})
  55.      */
  56.     private $phone;
  57.     /**
  58.      * @var string|null
  59.      * @Groups({"read", "list", "write"})
  60.      */
  61.     private $fax;
  62.     /**
  63.      * @var int|null
  64.      * @Groups({"read"})
  65.      */
  66.     private $activeUsersNumber;
  67.     /**
  68.      * @var string|null
  69.      * @Groups({"read", "list", "write"})
  70.      */
  71.     private $email;
  72.     /**
  73.      * @var string|null
  74.      * @Groups({"read", "list", "write"})
  75.      */
  76.     private $website;
  77.     /**
  78.      * @var string|null
  79.      * @Groups({"read", "list", "write"})
  80.      */
  81.     private $address;
  82.     /**
  83.      * @var string|null
  84.      * @Groups({"read", "list", "write"})
  85.      */
  86.     private $postalCode;
  87.     /**
  88.      * @var string|null
  89.      * @Groups({"read", "list", "write"})
  90.      */
  91.     private $city;
  92.     /**
  93.      * @var float|null
  94.      */
  95.     private $lat;
  96.     /**
  97.      * @var float|null
  98.      */
  99.     private $lng;
  100.     /**
  101.      * @var bool|null
  102.      */
  103.     private $isGeolocated false;
  104.     /**
  105.      * @var string|null
  106.      * @Groups({"read", "list", "write"})
  107.      */
  108.     private $externalId;
  109.     /**
  110.      * @var string|null
  111.      * @Groups({"read", "list", "write"})
  112.      */
  113.     private $mailingId;
  114.     /**
  115.      * @var string|null
  116.      * @Groups({"read", "list"})
  117.      */
  118.     private $logoUrl;
  119.     /**
  120.      * @var int|null
  121.      * @Groups({"read", "list", "write"})
  122.      */
  123.     private $licenseNumber;
  124.     /**
  125.      * @var DateTime|null
  126.      * @Groups({"read", "list", "write"})
  127.      */
  128.     private $buyingAt;
  129.     /**
  130.      * @var UserInfo[]|Collection
  131.      * @Groups({"read", "list"})
  132.      */
  133.     private $users;
  134.     /**
  135.      * @var CustomerFile[]|Collection
  136.      * @Groups({"read", "list"})
  137.      */
  138.     private $customerFiles;
  139.     /**
  140.      * @var string
  141.      * @Groups({"read", "list", "write"})
  142.      */
  143.     private $language LanguageEnum::LANGUAGE_FRENCH;
  144.     /**
  145.      * @var Module[]|Collection
  146.      * @Groups({"customer:write:modules"})
  147.      */
  148.     private $modules;
  149.     /**
  150.      * @var string
  151.      * @Groups({"read", "list", "write"})
  152.      */
  153.     private $alternativeTranslations;
  154.     /**
  155.      * @var string|null
  156.      * @Groups({"read", "list", "write"})
  157.      */
  158.     private $mailingHost;
  159.     /**
  160.      * Customer constructor.
  161.      */
  162.     public function __construct()
  163.     {
  164.         $this->users = new ArrayCollection();
  165.         $this->customerFiles = new ArrayCollection();
  166.         $this->modules = new ArrayCollection();
  167.     }
  168.     /**
  169.      * @param string $moduleRole
  170.      *
  171.      * @return bool
  172.      */
  173.     public function hasCustomerModule(string $moduleRole): bool
  174.     {
  175.         foreach ($this->getModules() as $module) {
  176.             if ($module->getRole() === $moduleRole) {
  177.                 return true;
  178.             }
  179.         }
  180.         return false;
  181.     }
  182.     /**
  183.      * @return string|null
  184.      */
  185.     public function getId(): ?string
  186.     {
  187.         return $this->id;
  188.     }
  189.     /**
  190.      * @param string|null $id
  191.      *
  192.      * @return Customer
  193.      */
  194.     public function setId(?string $id): Customer
  195.     {
  196.         $this->id $id;
  197.         return $this;
  198.     }
  199.     /**
  200.      * @return string|null
  201.      */
  202.     public function getName(): ?string
  203.     {
  204.         return $this->name;
  205.     }
  206.     /**
  207.      * @param string|null $name
  208.      *
  209.      * @return Customer
  210.      */
  211.     public function setName(?string $name): Customer
  212.     {
  213.         $this->name $name;
  214.         return $this;
  215.     }
  216.     /**
  217.      * @return DateTime|null
  218.      */
  219.     public function getExpiredAt(): ?DateTime
  220.     {
  221.         return $this->expiredAt;
  222.     }
  223.     /**
  224.      * @param DateTime|null $expiredAt
  225.      *
  226.      * @return Customer
  227.      */
  228.     public function setExpiredAt(?DateTime $expiredAt): Customer
  229.     {
  230.         $this->expiredAt $expiredAt;
  231.         return $this;
  232.     }
  233.     /**
  234.      * @return bool|null
  235.      */
  236.     public function getIsActive(): ?bool
  237.     {
  238.         return $this->isActive;
  239.     }
  240.     /**
  241.      * @param bool|null $isActive
  242.      *
  243.      * @return Customer
  244.      */
  245.     public function setIsActive(?bool $isActive): Customer
  246.     {
  247.         $this->isActive $isActive;
  248.         return $this;
  249.     }
  250.     /**
  251.      * @return string|null
  252.      */
  253.     public function getPhone(): ?string
  254.     {
  255.         return $this->phone;
  256.     }
  257.     /**
  258.      * @param string|null $phone
  259.      *
  260.      * @return Customer
  261.      */
  262.     public function setPhone(?string $phone): Customer
  263.     {
  264.         $this->phone $phone;
  265.         return $this;
  266.     }
  267.     /**
  268.      * @return string|null
  269.      */
  270.     public function getFax(): ?string
  271.     {
  272.         return $this->fax;
  273.     }
  274.     /**
  275.      * @param string|null $fax
  276.      *
  277.      * @return Customer
  278.      */
  279.     public function setFax(?string $fax): Customer
  280.     {
  281.         $this->fax $fax;
  282.         return $this;
  283.     }
  284.     /**
  285.      * @return string|null
  286.      */
  287.     public function getEmail(): ?string
  288.     {
  289.         return $this->email;
  290.     }
  291.     /**
  292.      * @param string|null $email
  293.      *
  294.      * @return Customer
  295.      */
  296.     public function setEmail(?string $email): Customer
  297.     {
  298.         $this->email $email;
  299.         return $this;
  300.     }
  301.     /**
  302.      * @return string|null
  303.      */
  304.     public function getWebsite(): ?string
  305.     {
  306.         return $this->website;
  307.     }
  308.     /**
  309.      * @param string|null $website
  310.      *
  311.      * @return Customer
  312.      */
  313.     public function setWebsite(?string $website): Customer
  314.     {
  315.         $this->website $website;
  316.         return $this;
  317.     }
  318.     /**
  319.      * @return string|null
  320.      */
  321.     public function getAddress(): ?string
  322.     {
  323.         return $this->address;
  324.     }
  325.     /**
  326.      * @param string|null $address
  327.      *
  328.      * @return Customer
  329.      */
  330.     public function setAddress(?string $address): Customer
  331.     {
  332.         $this->address $address;
  333.         return $this;
  334.     }
  335.     /**
  336.      * @return string|null
  337.      */
  338.     public function getPostalCode(): ?string
  339.     {
  340.         return $this->postalCode;
  341.     }
  342.     /**
  343.      * @param string|null $postalCode
  344.      *
  345.      * @return Customer
  346.      */
  347.     public function setPostalCode(?string $postalCode): Customer
  348.     {
  349.         $this->postalCode $postalCode;
  350.         return $this;
  351.     }
  352.     /**
  353.      * @return string|null
  354.      */
  355.     public function getCity(): ?string
  356.     {
  357.         return $this->city;
  358.     }
  359.     /**
  360.      * @param string|null $city
  361.      *
  362.      * @return Customer
  363.      */
  364.     public function setCity(?string $city): Customer
  365.     {
  366.         $this->city $city;
  367.         return $this;
  368.     }
  369.     /**
  370.      * @return float|null
  371.      */
  372.     public function getLat(): ?float
  373.     {
  374.         return $this->lat;
  375.     }
  376.     /**
  377.      * @param float|null $lat
  378.      *
  379.      * @return Customer
  380.      */
  381.     public function setLat(?float $lat): Customer
  382.     {
  383.         $this->lat $lat;
  384.         return $this;
  385.     }
  386.     /**
  387.      * @return float|null
  388.      */
  389.     public function getLng(): ?float
  390.     {
  391.         return $this->lng;
  392.     }
  393.     /**
  394.      * @param float|null $lng
  395.      *
  396.      * @return Customer
  397.      */
  398.     public function setLng(?float $lng): Customer
  399.     {
  400.         $this->lng $lng;
  401.         return $this;
  402.     }
  403.     /**
  404.      * @return bool|null
  405.      */
  406.     public function getIsGeolocated(): ?bool
  407.     {
  408.         return $this->isGeolocated;
  409.     }
  410.     /**
  411.      * @param bool|null $isGeolocated
  412.      *
  413.      * @return Customer
  414.      */
  415.     public function setIsGeolocated(?bool $isGeolocated): Customer
  416.     {
  417.         $this->isGeolocated $isGeolocated;
  418.         return $this;
  419.     }
  420.     /**
  421.      * @return string|null
  422.      */
  423.     public function getExternalId(): ?string
  424.     {
  425.         return $this->externalId;
  426.     }
  427.     /**
  428.      * @param string|null $externalId
  429.      *
  430.      * @return Customer
  431.      */
  432.     public function setExternalId(?string $externalId): Customer
  433.     {
  434.         $this->externalId $externalId;
  435.         return $this;
  436.     }
  437.     /**
  438.      * @return int|null
  439.      */
  440.     public function getLicenseNumber(): ?int
  441.     {
  442.         return $this->licenseNumber;
  443.     }
  444.     /**
  445.      * @param int|null $licenseNumber
  446.      *
  447.      * @return Customer
  448.      */
  449.     public function setLicenseNumber(?int $licenseNumber): Customer
  450.     {
  451.         $this->licenseNumber $licenseNumber;
  452.         return $this;
  453.     }
  454.     /**
  455.      * @return DateTime|null
  456.      */
  457.     public function getBuyingAt(): ?DateTime
  458.     {
  459.         return $this->buyingAt;
  460.     }
  461.     /**
  462.      * @param DateTime|null $buyingAt
  463.      *
  464.      * @return Customer
  465.      */
  466.     public function setBuyingAt(?DateTime $buyingAt): Customer
  467.     {
  468.         $this->buyingAt $buyingAt;
  469.         return $this;
  470.     }
  471.     /**
  472.      * @return UserInfo[]|Collection
  473.      */
  474.     public function getUsers(): Collection
  475.     {
  476.         return $this->users;
  477.     }
  478.     /**
  479.      * @param Collection $users
  480.      *
  481.      * @return Customer
  482.      */
  483.     public function setUsersFromForm(Collection $users): self
  484.     {
  485.         $this->users $users;
  486.         return $this;
  487.     }
  488.     /**
  489.      * @param UserInfo $userInfo
  490.      *
  491.      * @return $this
  492.      */
  493.     public function addUser(UserInfo $userInfo): self
  494.     {
  495.         if (!$this->users->contains($userInfo)) {
  496.             $userInfo->setCustomer($this);
  497.             $this->users->add($userInfo);
  498.         }
  499.         return $this;
  500.     }
  501.     /**
  502.      * @param UserInfo $userInfo
  503.      *
  504.      * @return $this
  505.      */
  506.     public function removeUser(UserInfo $userInfo): self
  507.     {
  508.         if ($this->users->contains($userInfo)) {
  509.             $userInfo->setCustomer(null);
  510.             $this->users->removeElement($userInfo);
  511.         }
  512.         return $this;
  513.     }
  514.     /**
  515.      * @return int|null
  516.      */
  517.     public function getActiveUsersNumber(): ?int
  518.     {
  519.         return $this->activeUsersNumber;
  520.     }
  521.     /**
  522.      * @param int|null $activeUsersNumber
  523.      *
  524.      * @return Customer
  525.      */
  526.     public function setActiveUsersNumber(?int $activeUsersNumber): Customer
  527.     {
  528.         $this->activeUsersNumber $activeUsersNumber;
  529.         return $this;
  530.     }
  531.     /**
  532.      * @return CustomerFile[]|Collection
  533.      */
  534.     public function getCustomerFiles(): Collection
  535.     {
  536.         return $this->customerFiles;
  537.     }
  538.     /**
  539.      * @param CustomerFile[]|Collection $customerFiles
  540.      *
  541.      * @return Customer
  542.      */
  543.     public function setCustomerFiles($customerFiles): Customer
  544.     {
  545.         $this->customerFiles $customerFiles;
  546.         return $this;
  547.     }
  548.     /**
  549.      * @return string|null
  550.      */
  551.     public function getLogoUrl(): ?string
  552.     {
  553.         return $this->logoUrl;
  554.     }
  555.     /**
  556.      * @param string|null $logoUrl
  557.      *
  558.      * @return Customer
  559.      */
  560.     public function setLogoUrl(?string $logoUrl): Customer
  561.     {
  562.         $this->logoUrl $logoUrl;
  563.         return $this;
  564.     }
  565.     /**
  566.      * @return bool|null
  567.      */
  568.     public function getIsLiveo(): ?bool
  569.     {
  570.         return $this->isLiveo;
  571.     }
  572.     /**
  573.      * @param bool|null $isLiveo
  574.      *
  575.      * @return Customer
  576.      */
  577.     public function setIsLiveo(?bool $isLiveo): Customer
  578.     {
  579.         $this->isLiveo $isLiveo;
  580.         return $this;
  581.     }
  582.     /**
  583.      * @return string|null
  584.      */
  585.     public function getMailingId(): ?string
  586.     {
  587.         return $this->mailingId;
  588.     }
  589.     /**
  590.      * @param string|null $mailingId
  591.      *
  592.      * @return Customer
  593.      */
  594.     public function setMailingId(?string $mailingId): Customer
  595.     {
  596.         $this->mailingId $mailingId;
  597.         return $this;
  598.     }
  599.     /**
  600.      * @return bool|null
  601.      */
  602.     public function getHasIntranet(): ?bool
  603.     {
  604.         return $this->hasIntranet;
  605.     }
  606.     /**
  607.      * @param bool|null $hasIntranet
  608.      *
  609.      * @return Customer
  610.      */
  611.     public function setHasIntranet(?bool $hasIntranet): Customer
  612.     {
  613.         $this->hasIntranet $hasIntranet;
  614.         return $this;
  615.     }
  616.     /**
  617.      * @return string
  618.      */
  619.     public function getLanguage(): string
  620.     {
  621.         return $this->language;
  622.     }
  623.     /**
  624.      * @param string $language
  625.      *
  626.      * @return Customer
  627.      */
  628.     public function setLanguage(string $language): self
  629.     {
  630.         $this->language $language;
  631.         return $this;
  632.     }
  633.     /**
  634.      * @return Module[]|Collection
  635.      */
  636.     public function getModules(): Collection
  637.     {
  638.         return $this->modules;
  639.     }
  640.     /**
  641.      * @param Module[]|Collection $modules
  642.      *
  643.      * @return Customer
  644.      */
  645.     public function setModules(Collection $modules): self
  646.     {
  647.         $this->modules $modules;
  648.         return $this;
  649.     }
  650.     /**
  651.      * @param Module|null $module
  652.      *
  653.      * @return $this
  654.      */
  655.     public function addModule(?Module $module): self
  656.     {
  657.         if ($module && !$this->modules->contains($module)) {
  658.             $this->modules->add($module);
  659.         }
  660.         return $this;
  661.     }
  662.     /**
  663.      * @param Module|null $module
  664.      *
  665.      * @return $this
  666.      */
  667.     public function removeModule(?Module $module): self
  668.     {
  669.         if ($module && $this->modules->contains($module)) {
  670.             $this->modules->removeElement($module);
  671.             return $this;
  672.         }
  673.         if ($module) {
  674.             foreach ($this->getModules() as $customerModule) {
  675.                 if ($customerModule->getRole() === $module->getRole()) {
  676.                     $this->modules->removeElement($customerModule);
  677.                 }
  678.             }
  679.         }
  680.         return $this;
  681.     }
  682.     public function getAlternativeTranslations(): ?string
  683.     {
  684.         return $this->alternativeTranslations;
  685.     }
  686.     public function setAlternativeTranslations(?string $alternativeTranslations): Customer
  687.     {
  688.         $this->alternativeTranslations $alternativeTranslations;
  689.         return $this;
  690.     }
  691.     public function getMailingHost(): ?string
  692.     {
  693.         return $this->mailingHost;
  694.     }
  695.     public function setMailingHost(?string $mailingHost): self
  696.     {
  697.         $this->mailingHost $mailingHost;
  698.         return $this;
  699.     }
  700. }