<?php
namespace App\Model\Customer;
use App\Enum\LanguageEnum;
use App\Model\CustomerFile\CustomerFile;
use App\Model\Module\Module;
use App\Model\Security\UserInfo;
use App\Model\Traits\ImportableObjectTrait;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
/**
* Class Customer.
*/
class Customer
{
use ImportableObjectTrait;
/**
* @var string|null
* @Groups({
* "read", "list", "write"
* })
*/
private $id;
/**
* @var string|null
* @Assert\NotBlank(message="Le nom de l'entreprise est obligatoire")
* @Groups({"read", "list", "write"})
*/
private $name;
/**
* @var DateTime|null
* @Groups({"read", "list", "write"})
*/
private $expiredAt;
/**
* @var bool|null
* @Groups({"read", "list", "write"})
*/
private $isActive = true;
/**
* @var bool|null
* @Groups({"read", "list", "write"})
*/
private $isLiveo = false;
/**
* @var bool|null
* @Groups({"read", "list", "write"})
*/
private $hasIntranet = false;
/**
* @var string|null
* @Groups({"read", "list", "write"})
*/
private $phone;
/**
* @var string|null
* @Groups({"read", "list", "write"})
*/
private $fax;
/**
* @var int|null
* @Groups({"read"})
*/
private $activeUsersNumber;
/**
* @var string|null
* @Groups({"read", "list", "write"})
*/
private $email;
/**
* @var string|null
* @Groups({"read", "list", "write"})
*/
private $website;
/**
* @var string|null
* @Groups({"read", "list", "write"})
*/
private $address;
/**
* @var string|null
* @Groups({"read", "list", "write"})
*/
private $postalCode;
/**
* @var string|null
* @Groups({"read", "list", "write"})
*/
private $city;
/**
* @var float|null
*/
private $lat;
/**
* @var float|null
*/
private $lng;
/**
* @var bool|null
*/
private $isGeolocated = false;
/**
* @var string|null
* @Groups({"read", "list", "write"})
*/
private $externalId;
/**
* @var string|null
* @Groups({"read", "list", "write"})
*/
private $mailingId;
/**
* @var string|null
* @Groups({"read", "list"})
*/
private $logoUrl;
/**
* @var int|null
* @Groups({"read", "list", "write"})
*/
private $licenseNumber;
/**
* @var DateTime|null
* @Groups({"read", "list", "write"})
*/
private $buyingAt;
/**
* @var UserInfo[]|Collection
* @Groups({"read", "list"})
*/
private $users;
/**
* @var CustomerFile[]|Collection
* @Groups({"read", "list"})
*/
private $customerFiles;
/**
* @var string
* @Groups({"read", "list", "write"})
*/
private $language = LanguageEnum::LANGUAGE_FRENCH;
/**
* @var Module[]|Collection
* @Groups({"customer:write:modules"})
*/
private $modules;
/**
* @var string
* @Groups({"read", "list", "write"})
*/
private $alternativeTranslations;
/**
* @var string|null
* @Groups({"read", "list", "write"})
*/
private $mailingHost;
/**
* Customer constructor.
*/
public function __construct()
{
$this->users = new ArrayCollection();
$this->customerFiles = new ArrayCollection();
$this->modules = new ArrayCollection();
}
/**
* @param string $moduleRole
*
* @return bool
*/
public function hasCustomerModule(string $moduleRole): bool
{
foreach ($this->getModules() as $module) {
if ($module->getRole() === $moduleRole) {
return true;
}
}
return false;
}
/**
* @return string|null
*/
public function getId(): ?string
{
return $this->id;
}
/**
* @param string|null $id
*
* @return Customer
*/
public function setId(?string $id): Customer
{
$this->id = $id;
return $this;
}
/**
* @return string|null
*/
public function getName(): ?string
{
return $this->name;
}
/**
* @param string|null $name
*
* @return Customer
*/
public function setName(?string $name): Customer
{
$this->name = $name;
return $this;
}
/**
* @return DateTime|null
*/
public function getExpiredAt(): ?DateTime
{
return $this->expiredAt;
}
/**
* @param DateTime|null $expiredAt
*
* @return Customer
*/
public function setExpiredAt(?DateTime $expiredAt): Customer
{
$this->expiredAt = $expiredAt;
return $this;
}
/**
* @return bool|null
*/
public function getIsActive(): ?bool
{
return $this->isActive;
}
/**
* @param bool|null $isActive
*
* @return Customer
*/
public function setIsActive(?bool $isActive): Customer
{
$this->isActive = $isActive;
return $this;
}
/**
* @return string|null
*/
public function getPhone(): ?string
{
return $this->phone;
}
/**
* @param string|null $phone
*
* @return Customer
*/
public function setPhone(?string $phone): Customer
{
$this->phone = $phone;
return $this;
}
/**
* @return string|null
*/
public function getFax(): ?string
{
return $this->fax;
}
/**
* @param string|null $fax
*
* @return Customer
*/
public function setFax(?string $fax): Customer
{
$this->fax = $fax;
return $this;
}
/**
* @return string|null
*/
public function getEmail(): ?string
{
return $this->email;
}
/**
* @param string|null $email
*
* @return Customer
*/
public function setEmail(?string $email): Customer
{
$this->email = $email;
return $this;
}
/**
* @return string|null
*/
public function getWebsite(): ?string
{
return $this->website;
}
/**
* @param string|null $website
*
* @return Customer
*/
public function setWebsite(?string $website): Customer
{
$this->website = $website;
return $this;
}
/**
* @return string|null
*/
public function getAddress(): ?string
{
return $this->address;
}
/**
* @param string|null $address
*
* @return Customer
*/
public function setAddress(?string $address): Customer
{
$this->address = $address;
return $this;
}
/**
* @return string|null
*/
public function getPostalCode(): ?string
{
return $this->postalCode;
}
/**
* @param string|null $postalCode
*
* @return Customer
*/
public function setPostalCode(?string $postalCode): Customer
{
$this->postalCode = $postalCode;
return $this;
}
/**
* @return string|null
*/
public function getCity(): ?string
{
return $this->city;
}
/**
* @param string|null $city
*
* @return Customer
*/
public function setCity(?string $city): Customer
{
$this->city = $city;
return $this;
}
/**
* @return float|null
*/
public function getLat(): ?float
{
return $this->lat;
}
/**
* @param float|null $lat
*
* @return Customer
*/
public function setLat(?float $lat): Customer
{
$this->lat = $lat;
return $this;
}
/**
* @return float|null
*/
public function getLng(): ?float
{
return $this->lng;
}
/**
* @param float|null $lng
*
* @return Customer
*/
public function setLng(?float $lng): Customer
{
$this->lng = $lng;
return $this;
}
/**
* @return bool|null
*/
public function getIsGeolocated(): ?bool
{
return $this->isGeolocated;
}
/**
* @param bool|null $isGeolocated
*
* @return Customer
*/
public function setIsGeolocated(?bool $isGeolocated): Customer
{
$this->isGeolocated = $isGeolocated;
return $this;
}
/**
* @return string|null
*/
public function getExternalId(): ?string
{
return $this->externalId;
}
/**
* @param string|null $externalId
*
* @return Customer
*/
public function setExternalId(?string $externalId): Customer
{
$this->externalId = $externalId;
return $this;
}
/**
* @return int|null
*/
public function getLicenseNumber(): ?int
{
return $this->licenseNumber;
}
/**
* @param int|null $licenseNumber
*
* @return Customer
*/
public function setLicenseNumber(?int $licenseNumber): Customer
{
$this->licenseNumber = $licenseNumber;
return $this;
}
/**
* @return DateTime|null
*/
public function getBuyingAt(): ?DateTime
{
return $this->buyingAt;
}
/**
* @param DateTime|null $buyingAt
*
* @return Customer
*/
public function setBuyingAt(?DateTime $buyingAt): Customer
{
$this->buyingAt = $buyingAt;
return $this;
}
/**
* @return UserInfo[]|Collection
*/
public function getUsers(): Collection
{
return $this->users;
}
/**
* @param Collection $users
*
* @return Customer
*/
public function setUsersFromForm(Collection $users): self
{
$this->users = $users;
return $this;
}
/**
* @param UserInfo $userInfo
*
* @return $this
*/
public function addUser(UserInfo $userInfo): self
{
if (!$this->users->contains($userInfo)) {
$userInfo->setCustomer($this);
$this->users->add($userInfo);
}
return $this;
}
/**
* @param UserInfo $userInfo
*
* @return $this
*/
public function removeUser(UserInfo $userInfo): self
{
if ($this->users->contains($userInfo)) {
$userInfo->setCustomer(null);
$this->users->removeElement($userInfo);
}
return $this;
}
/**
* @return int|null
*/
public function getActiveUsersNumber(): ?int
{
return $this->activeUsersNumber;
}
/**
* @param int|null $activeUsersNumber
*
* @return Customer
*/
public function setActiveUsersNumber(?int $activeUsersNumber): Customer
{
$this->activeUsersNumber = $activeUsersNumber;
return $this;
}
/**
* @return CustomerFile[]|Collection
*/
public function getCustomerFiles(): Collection
{
return $this->customerFiles;
}
/**
* @param CustomerFile[]|Collection $customerFiles
*
* @return Customer
*/
public function setCustomerFiles($customerFiles): Customer
{
$this->customerFiles = $customerFiles;
return $this;
}
/**
* @return string|null
*/
public function getLogoUrl(): ?string
{
return $this->logoUrl;
}
/**
* @param string|null $logoUrl
*
* @return Customer
*/
public function setLogoUrl(?string $logoUrl): Customer
{
$this->logoUrl = $logoUrl;
return $this;
}
/**
* @return bool|null
*/
public function getIsLiveo(): ?bool
{
return $this->isLiveo;
}
/**
* @param bool|null $isLiveo
*
* @return Customer
*/
public function setIsLiveo(?bool $isLiveo): Customer
{
$this->isLiveo = $isLiveo;
return $this;
}
/**
* @return string|null
*/
public function getMailingId(): ?string
{
return $this->mailingId;
}
/**
* @param string|null $mailingId
*
* @return Customer
*/
public function setMailingId(?string $mailingId): Customer
{
$this->mailingId = $mailingId;
return $this;
}
/**
* @return bool|null
*/
public function getHasIntranet(): ?bool
{
return $this->hasIntranet;
}
/**
* @param bool|null $hasIntranet
*
* @return Customer
*/
public function setHasIntranet(?bool $hasIntranet): Customer
{
$this->hasIntranet = $hasIntranet;
return $this;
}
/**
* @return string
*/
public function getLanguage(): string
{
return $this->language;
}
/**
* @param string $language
*
* @return Customer
*/
public function setLanguage(string $language): self
{
$this->language = $language;
return $this;
}
/**
* @return Module[]|Collection
*/
public function getModules(): Collection
{
return $this->modules;
}
/**
* @param Module[]|Collection $modules
*
* @return Customer
*/
public function setModules(Collection $modules): self
{
$this->modules = $modules;
return $this;
}
/**
* @param Module|null $module
*
* @return $this
*/
public function addModule(?Module $module): self
{
if ($module && !$this->modules->contains($module)) {
$this->modules->add($module);
}
return $this;
}
/**
* @param Module|null $module
*
* @return $this
*/
public function removeModule(?Module $module): self
{
if ($module && $this->modules->contains($module)) {
$this->modules->removeElement($module);
return $this;
}
if ($module) {
foreach ($this->getModules() as $customerModule) {
if ($customerModule->getRole() === $module->getRole()) {
$this->modules->removeElement($customerModule);
}
}
}
return $this;
}
public function getAlternativeTranslations(): ?string
{
return $this->alternativeTranslations;
}
public function setAlternativeTranslations(?string $alternativeTranslations): Customer
{
$this->alternativeTranslations = $alternativeTranslations;
return $this;
}
public function getMailingHost(): ?string
{
return $this->mailingHost;
}
public function setMailingHost(?string $mailingHost): self
{
$this->mailingHost = $mailingHost;
return $this;
}
}