src/Model/Customer/Customer.php line 20

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