<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="fs_agency")
* @ORM\Entity(repositoryClass="App\Repository\AgencyRepository")
*/
class Agency
{
public function __toString(){
return $this->name;
}
public function displayInfo(){
return $this->name. " - ".$this->mainAddress()." - Tel: ".$this->getPhone()." - ".$this->getEmail();
}
public function canReserve(){
if($this->getGroup() == null) return false;
if($this->getIban() == null) return false;
if($this->getSwift() == null) return false;
return true;
}
public function canDelete(){
return true;
}
public function getIsActive()
{
if($this->adminActive)
return true;
return false;
}
public function languagesNoApi()
{
$array = array();
foreach($this->languages as $language)
if($language->getSign() != 'api')
array_push($array, $language);
return $array;
}
public function mainAddress()
{
foreach($this->addresses as $address){
return $address;
}
}
public function getReserveAsByDealer($dealerId){
foreach($this->dealers as $jt){
if($jt->getDealer()->getId() == $dealerId)
return $jt->getReserveAs();
}
return null;
}
/**
* @ORM\Column(name="id", type="bigint")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(name="name", type="string", length=191)
*/
protected $name;
/**
* @ORM\Column(name="email", type="string", length=191)
*/
protected $email;
/**
* @ORM\Column(name="phone", type="string", length=191)
*/
protected $phone;
/**
* @ORM\Column(name="fiscal_code", type="string", length=191)
*/
protected $fiscalCode;
/**
* @ORM\Column(name="vat", type="string", length=191)
*/
protected $vat;
/**
* @ORM\Column(name="vat_country", type="string", length=191)
*/
protected $vatCountry;
/**
* @ORM\Column(name="sdi", type="string", length=191)
*/
protected $sdi;
/**
* @ORM\Column(name="directory_path", type="string", length=191)
*/
protected $directoryPath;
/**
* @ORM\Column(name="logo_path", type="string", length=191, nullable=true)
*/
protected $logoPath;
/**
* @ORM\Column(name="admin_access", type="boolean")
*/
protected $adminAccess = false;
/**
* @ORM\Column(name="admin_active", type="boolean")
*/
protected $adminActive = true;
/**
* @ORM\Column(name="is_first_access", type="boolean")
*/
protected $firstAccess = true;
/**
* @ORM\Column(name="iban", type="string", length=191, nullable=true)
*/
protected $iban;
/**
* @ORM\Column(name="swift", type="string", length=191, nullable=true)
*/
protected $swift;
// ONE TO MANY
/**
* @ORM\OneToMany(targetEntity="App\Entity\JoinTableDealerAgency", mappedBy="agency")
*/
private $dealers;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Address", mappedBy="agency")
*/
private $addresses;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Contact", mappedBy="agency")
*/
private $contacts;
/**
* @ORM\OneToMany(targetEntity="App\Entity\JoinTableAgencyUser", mappedBy="agency")
*/
private $users;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Reservation", mappedBy="agency")
*/
private $reservations;
/**
* @ORM\OneToMany(targetEntity="App\Entity\ReservationFreeCabins", mappedBy="agency")
*/
private $reservationFreeCabins;
//
// MANY TO ONE
/**
* @ORM\ManyToOne(targetEntity="App\Entity\AgencyGroup", inversedBy="agencies")
* @ORM\JoinColumn(name="group_id", referencedColumnName="id")
*/
private $group;
public function __construct()
{
$this->dealers = new ArrayCollection();
$this->addresses = new ArrayCollection();
$this->contacts = new ArrayCollection();
$this->users = new ArrayCollection();
$this->reservations = new ArrayCollection();
$this->reservationFreeCabins = new ArrayCollection();
$this->suppliers = new ArrayCollection();
$this->licenses = new ArrayCollection();
$this->orders = new ArrayCollection();
$this->signalerForOrders = new ArrayCollection();
$this->investorForFeatures = new ArrayCollection();
}
//
public function getId(): ?string
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email): static
{
$this->email = $email;
return $this;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(string $phone): static
{
$this->phone = $phone;
return $this;
}
public function getFiscalCode(): ?string
{
return $this->fiscalCode;
}
public function setFiscalCode(string $fiscalCode): static
{
$this->fiscalCode = $fiscalCode;
return $this;
}
public function getVat(): ?string
{
return $this->vat;
}
public function setVat(string $vat): static
{
$this->vat = $vat;
return $this;
}
public function getVatCountry(): ?string
{
return $this->vatCountry;
}
public function setVatCountry(string $vatCountry): static
{
$this->vatCountry = $vatCountry;
return $this;
}
public function getSdi(): ?string
{
return $this->sdi;
}
public function setSdi(string $sdi): static
{
$this->sdi = $sdi;
return $this;
}
public function getDirectoryPath(): ?string
{
return $this->directoryPath;
}
public function setDirectoryPath(string $directoryPath): static
{
$this->directoryPath = $directoryPath;
return $this;
}
public function getLogoPath(): ?string
{
return $this->logoPath;
}
public function setLogoPath(?string $logoPath): static
{
$this->logoPath = $logoPath;
return $this;
}
public function isAdminAccess(): ?bool
{
return $this->adminAccess;
}
public function setAdminAccess(bool $adminAccess): static
{
$this->adminAccess = $adminAccess;
return $this;
}
public function isAdminActive(): ?bool
{
return $this->adminActive;
}
public function setAdminActive(bool $adminActive): static
{
$this->adminActive = $adminActive;
return $this;
}
public function isFirstAccess(): ?bool
{
return $this->firstAccess;
}
public function setFirstAccess(bool $firstAccess): static
{
$this->firstAccess = $firstAccess;
return $this;
}
/**
* @return Collection<int, JoinTableDealerAgency>
*/
public function getDealers(): Collection
{
return $this->dealers;
}
public function addDealer(JoinTableDealerAgency $dealer): static
{
if (!$this->dealers->contains($dealer)) {
$this->dealers->add($dealer);
$dealer->setAgency($this);
}
return $this;
}
public function removeDealer(JoinTableDealerAgency $dealer): static
{
if ($this->dealers->removeElement($dealer)) {
// set the owning side to null (unless already changed)
if ($dealer->getAgency() === $this) {
$dealer->setAgency(null);
}
}
return $this;
}
/**
* @return Collection<int, Address>
*/
public function getAddresses(): Collection
{
return $this->addresses;
}
public function addAddress(Address $address): static
{
if (!$this->addresses->contains($address)) {
$this->addresses->add($address);
$address->setAgency($this);
}
return $this;
}
public function removeAddress(Address $address): static
{
if ($this->addresses->removeElement($address)) {
// set the owning side to null (unless already changed)
if ($address->getAgency() === $this) {
$address->setAgency(null);
}
}
return $this;
}
/**
* @return Collection<int, Contact>
*/
public function getContacts(): Collection
{
return $this->contacts;
}
public function addContact(Contact $contact): static
{
if (!$this->contacts->contains($contact)) {
$this->contacts->add($contact);
$contact->setAgency($this);
}
return $this;
}
public function removeContact(Contact $contact): static
{
if ($this->contacts->removeElement($contact)) {
// set the owning side to null (unless already changed)
if ($contact->getAgency() === $this) {
$contact->setAgency(null);
}
}
return $this;
}
/**
* @return Collection<int, JoinTableAgencyUser>
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(JoinTableAgencyUser $user): static
{
if (!$this->users->contains($user)) {
$this->users->add($user);
$user->setAgency($this);
}
return $this;
}
public function removeUser(JoinTableAgencyUser $user): static
{
if ($this->users->removeElement($user)) {
// set the owning side to null (unless already changed)
if ($user->getAgency() === $this) {
$user->setAgency(null);
}
}
return $this;
}
/**
* @return Collection<int, Reservation>
*/
public function getReservations(): Collection
{
return $this->reservations;
}
public function addReservation(Reservation $reservation): static
{
if (!$this->reservations->contains($reservation)) {
$this->reservations->add($reservation);
$reservation->setAgency($this);
}
return $this;
}
public function removeReservation(Reservation $reservation): static
{
if ($this->reservations->removeElement($reservation)) {
// set the owning side to null (unless already changed)
if ($reservation->getAgency() === $this) {
$reservation->setAgency(null);
}
}
return $this;
}
/**
* @return Collection<int, ReservationFreeCabins>
*/
public function getReservationFreeCabins(): Collection
{
return $this->reservationFreeCabins;
}
public function addReservationFreeCabin(ReservationFreeCabins $reservationFreeCabin): static
{
if (!$this->reservationFreeCabins->contains($reservationFreeCabin)) {
$this->reservationFreeCabins->add($reservationFreeCabin);
$reservationFreeCabin->setAgency($this);
}
return $this;
}
public function removeReservationFreeCabin(ReservationFreeCabins $reservationFreeCabin): static
{
if ($this->reservationFreeCabins->removeElement($reservationFreeCabin)) {
// set the owning side to null (unless already changed)
if ($reservationFreeCabin->getAgency() === $this) {
$reservationFreeCabin->setAgency(null);
}
}
return $this;
}
public function getGroup(): ?AgencyGroup
{
return $this->group;
}
public function setGroup(?AgencyGroup $group): static
{
$this->group = $group;
return $this;
}
public function getIban(): ?string
{
return $this->iban;
}
public function setIban(?string $iban): static
{
$this->iban = $iban;
return $this;
}
public function getSwift(): ?string
{
return $this->swift;
}
public function setSwift(?string $swift): static
{
$this->swift = $swift;
return $this;
}
}