<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass="App\Repository\CompanyLocationRepository")
*/
class CompanyLocation
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=20)
*/
private $civicNumber;
/**
* @ORM\Column(type="string", length=255)
*/
private $streetName;
/**
* @ORM\Column(type="string", length=255)
* @Groups({"searchable"})
*/
private $city;
/**
* @ORM\Column(type="string", length=10)
*/
private $zipCode;
/**
* @ORM\Column(type="string", length=255)
*/
private $province='QC';
/**
* @ORM\Column(type="string", length=255)
*/
private $country='CA';
/**
* @ORM\Column(type="string", length=20)
*/
private $phone;
/**
* @ORM\Column(type="string", length=10, nullable=true)
*/
private $phoneExtension;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $email;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Company", inversedBy="otherLocations")
* @ORM\JoinColumn(onDelete="CASCADE")
*/
private $company;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $mobilePhone;
/**
* @ORM\Column(type="string", length=255, nullable=true)
* @Groups({"searchable"})
*/
private $name;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $notesForBuyer;
/**
* @ORM\Column(type="boolean")
*/
//@Note if false it mean it's a real building company
private $pickUp=true;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Product", mappedBy="locations")
*/
private $products;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Region", inversedBy="companyLocations")
* @Groups({"searchable"})
*/
private $region;
/**
* @ORM\Column(type="boolean")
*/
private $showPublic=true;
public function __construct()
{
$this->products = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getFullAddress(): ?string
{
return $this->civicNumber.' '.$this->streetName.', '.$this->city.' '.$this->province.' '.$this->zipCode;
}
public function getFullAddressWithName(): ?string
{
//In theory only the Main address should be empty
if(empty($this->name))
$name = 'Bureau principal';
else
$name = $this->name;
return $name.' - '.$this->civicNumber.' '.$this->streetName.', '.$this->city.' '.$this->province.' '.$this->zipCode;
}
public function getStreetAddress(): ?string
{
return $this->civicNumber.' '.$this->streetName;
}
public function getCivicNumber(): ?string
{
return $this->civicNumber;
}
public function setCivicNumber(string $civicNumber): self
{
$this->civicNumber = $civicNumber;
return $this;
}
public function getStreetName(): ?string
{
return $this->streetName;
}
public function setStreetName(string $streetName): self
{
$this->streetName = $streetName;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(string $city): self
{
$this->city = $city;
return $this;
}
public function getZipCode(): ?string
{
return $this->zipCode;
}
public function setZipCode(string $zipCode): self
{
$this->zipCode = $zipCode;
return $this;
}
public function getProvince(): ?string
{
return $this->province;
}
public function setProvince(string $province): self
{
$this->province = $province;
return $this;
}
public function getCountry(): ?string
{
return $this->country;
}
public function setCountry(string $country): self
{
$this->country = $country;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(string $phone): self
{
$this->phone = $phone;
return $this;
}
public function getPhoneExtension(): ?string
{
return $this->phoneExtension;
}
public function setPhoneExtension(?string $phoneExtension): self
{
$this->phoneExtension = $phoneExtension;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = $email;
return $this;
}
public function getCompany(): ?Company
{
return $this->company;
}
public function setCompany(?Company $company): self
{
$this->company = $company;
return $this;
}
public function getMobilePhone(): ?string
{
return $this->mobilePhone;
}
public function setMobilePhone(?string $mobilePhone): self
{
$this->mobilePhone = $mobilePhone;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getNotesForBuyer(): ?string
{
return $this->notesForBuyer;
}
public function setNotesForBuyer(?string $notesForBuyer): self
{
$this->notesForBuyer = $notesForBuyer;
return $this;
}
public function getPickUp(): ?bool
{
return $this->pickUp;
}
public function setPickUp(bool $pickUp): self
{
$this->pickUp = $pickUp;
return $this;
}
/**
* @return Collection|Product[]
*/
public function getProducts(): Collection
{
return $this->products;
}
public function addProduct(Product $product): self
{
if (!$this->products->contains($product)) {
$this->products[] = $product;
$product->addLocation($this);
}
return $this;
}
public function removeProduct(Product $product): self
{
if ($this->products->contains($product)) {
$this->products->removeElement($product);
$product->removeLocation($this);
}
return $this;
}
public function getRegion(): ?Region
{
return $this->region;
}
public function setRegion(?Region $region): self
{
$this->region = $region;
return $this;
}
public function getShowPublic(): ?bool
{
return $this->showPublic;
}
public function setShowPublic(bool $showPublic): self
{
$this->showPublic = $showPublic;
return $this;
}
public function __toString()
{
return $this->getFullAddressWithName();
}
}