src/Entity/Agency.php line 181

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Table(name="fs_agency")
  9.  * @ORM\Entity(repositoryClass="App\Repository\AgencyRepository")
  10.  */
  11. class Agency
  12. {
  13.     public function __toString(){
  14.         return $this->name;
  15.     }
  16.     public function displayInfo(){
  17.        return $this->name" - ".$this->mainAddress()." - Tel: ".$this->getPhone()." - ".$this->getEmail();
  18.     }
  19.     public function canReserve(){
  20.         if($this->getGroup() == null)
  21.             return false;
  22.         return true;
  23.     }
  24.     public function canDelete(){
  25.         return true;
  26.     }
  27.     public function getIsActive()
  28.     {
  29.         if($this->isAdminActive)
  30.             return true;
  31.         return false;
  32.     }
  33.     
  34.     public function languagesNoApi()
  35.     {
  36.         $array = array();
  37.         foreach($this->languages as $language)
  38.             if($language->getSign() != 'api')
  39.                 array_push($array$language);
  40.         return $array;
  41.     }
  42.     
  43.     public function mainAddress()
  44.     {
  45.         foreach($this->addresses as $address){
  46.             return $address;
  47.         }
  48.     }
  49.     public function getReserveAsByDealer($dealerId){
  50.         foreach($this->dealers as $jt){
  51.             if($jt->getDealer()->getId() == $dealerId)
  52.                 return $jt->getReserveAs();
  53.         }
  54.         return null;
  55.     }
  56.     /**
  57.      * @ORM\Column(name="id", type="bigint")
  58.      * @ORM\Id
  59.      * @ORM\GeneratedValue(strategy="AUTO")
  60.      */
  61.     protected $id;
  62.         
  63.     /**
  64.      * @ORM\Column(name="name", type="string", length=191)
  65.      */
  66.     protected $name;
  67.     
  68.     /**
  69.      * @ORM\Column(name="email", type="string", length=191)
  70.      */
  71.     protected $email;
  72.     /**
  73.      * @ORM\Column(name="phone", type="string", length=191)
  74.      */
  75.     protected $phone;
  76.     /**
  77.      * @ORM\Column(name="fiscal_code", type="string", length=191)
  78.      */
  79.     protected $fiscalCode;
  80.     /**
  81.      * @ORM\Column(name="vat", type="string", length=191)
  82.      */
  83.     protected $vat;
  84.     
  85.     /**
  86.      * @ORM\Column(name="vat_country", type="string", length=191)
  87.      */
  88.     protected $vatCountry;
  89.     
  90.     /**
  91.      * @ORM\Column(name="sdi", type="string", length=191)
  92.      */
  93.     protected $sdi;
  94.     
  95.     /**
  96.      * @ORM\Column(name="directory_path", type="string", length=191)
  97.      */
  98.     protected $directoryPath;
  99.     /**
  100.      * @ORM\Column(name="logo_path", type="string", length=191, nullable=true)
  101.      */
  102.     protected $logoPath;
  103.     
  104.     /**
  105.      * @ORM\Column(name="admin_access", type="boolean")
  106.      */
  107.     protected $adminAccess false;
  108.     
  109.     /**
  110.      * @ORM\Column(name="admin_active", type="boolean")
  111.      */
  112.     protected $adminActive true;
  113.     
  114.     /**
  115.      * @ORM\Column(name="is_first_access", type="boolean")
  116.      */
  117.     protected $firstAccess true;
  118.     // ONE TO MANY
  119.         /**
  120.          * @ORM\OneToMany(targetEntity="App\Entity\JoinTableDealerAgency", mappedBy="agency")
  121.          */
  122.         private $dealers;
  123.         
  124.         /**
  125.          * @ORM\OneToMany(targetEntity="App\Entity\Address", mappedBy="agency")
  126.          */
  127.         private $addresses;
  128.         
  129.         /**
  130.          * @ORM\OneToMany(targetEntity="App\Entity\Contact", mappedBy="agency")
  131.          */
  132.         private $contacts;
  133.         /**
  134.          * @ORM\OneToMany(targetEntity="App\Entity\JoinTableAgencyUser", mappedBy="agency")
  135.          */
  136.         private $users;
  137.                 
  138.         /**
  139.          * @ORM\OneToMany(targetEntity="App\Entity\Reservation", mappedBy="agency")
  140.          */
  141.         private $reservations;
  142.         /**
  143.          * @ORM\OneToMany(targetEntity="App\Entity\ReservationFreeCabins", mappedBy="agency")
  144.          */
  145.         private $reservationFreeCabins;
  146.     //
  147.     // MANY TO ONE
  148.         /**
  149.          * @ORM\ManyToOne(targetEntity="App\Entity\AgencyGroup", inversedBy="agencies")
  150.          * @ORM\JoinColumn(name="group_id", referencedColumnName="id")
  151.          */
  152.         private $group;
  153.         public function __construct()
  154.         {
  155.             $this->dealers = new ArrayCollection();
  156.             $this->addresses = new ArrayCollection();
  157.             $this->contacts = new ArrayCollection();
  158.             $this->users = new ArrayCollection();
  159.             $this->reservations = new ArrayCollection();
  160.             $this->reservationFreeCabins = new ArrayCollection();
  161.             $this->suppliers = new ArrayCollection();
  162.             $this->licenses = new ArrayCollection();
  163.             $this->orders = new ArrayCollection();
  164.             $this->signalerForOrders = new ArrayCollection();
  165.             $this->investorForFeatures = new ArrayCollection();
  166.         }
  167.     //
  168.     public function getId(): ?string
  169.     {
  170.         return $this->id;
  171.     }
  172.     public function getName(): ?string
  173.     {
  174.         return $this->name;
  175.     }
  176.     public function setName(string $name): static
  177.     {
  178.         $this->name $name;
  179.         return $this;
  180.     }
  181.     public function getEmail(): ?string
  182.     {
  183.         return $this->email;
  184.     }
  185.     public function setEmail(string $email): static
  186.     {
  187.         $this->email $email;
  188.         return $this;
  189.     }
  190.     public function getPhone(): ?string
  191.     {
  192.         return $this->phone;
  193.     }
  194.     public function setPhone(string $phone): static
  195.     {
  196.         $this->phone $phone;
  197.         return $this;
  198.     }
  199.     public function getFiscalCode(): ?string
  200.     {
  201.         return $this->fiscalCode;
  202.     }
  203.     public function setFiscalCode(string $fiscalCode): static
  204.     {
  205.         $this->fiscalCode $fiscalCode;
  206.         return $this;
  207.     }
  208.     public function getVat(): ?string
  209.     {
  210.         return $this->vat;
  211.     }
  212.     public function setVat(string $vat): static
  213.     {
  214.         $this->vat $vat;
  215.         return $this;
  216.     }
  217.     public function getVatCountry(): ?string
  218.     {
  219.         return $this->vatCountry;
  220.     }
  221.     public function setVatCountry(string $vatCountry): static
  222.     {
  223.         $this->vatCountry $vatCountry;
  224.         return $this;
  225.     }
  226.     public function getSdi(): ?string
  227.     {
  228.         return $this->sdi;
  229.     }
  230.     public function setSdi(string $sdi): static
  231.     {
  232.         $this->sdi $sdi;
  233.         return $this;
  234.     }
  235.     public function getDirectoryPath(): ?string
  236.     {
  237.         return $this->directoryPath;
  238.     }
  239.     public function setDirectoryPath(string $directoryPath): static
  240.     {
  241.         $this->directoryPath $directoryPath;
  242.         return $this;
  243.     }
  244.     public function getLogoPath(): ?string
  245.     {
  246.         return $this->logoPath;
  247.     }
  248.     public function setLogoPath(?string $logoPath): static
  249.     {
  250.         $this->logoPath $logoPath;
  251.         return $this;
  252.     }
  253.     public function isAdminAccess(): ?bool
  254.     {
  255.         return $this->adminAccess;
  256.     }
  257.     public function setAdminAccess(bool $adminAccess): static
  258.     {
  259.         $this->adminAccess $adminAccess;
  260.         return $this;
  261.     }
  262.     public function isAdminActive(): ?bool
  263.     {
  264.         return $this->adminActive;
  265.     }
  266.     public function setAdminActive(bool $adminActive): static
  267.     {
  268.         $this->adminActive $adminActive;
  269.         return $this;
  270.     }
  271.     public function isFirstAccess(): ?bool
  272.     {
  273.         return $this->firstAccess;
  274.     }
  275.     public function setFirstAccess(bool $firstAccess): static
  276.     {
  277.         $this->firstAccess $firstAccess;
  278.         return $this;
  279.     }
  280.     /**
  281.      * @return Collection<int, JoinTableDealerAgency>
  282.      */
  283.     public function getDealers(): Collection
  284.     {
  285.         return $this->dealers;
  286.     }
  287.     public function addDealer(JoinTableDealerAgency $dealer): static
  288.     {
  289.         if (!$this->dealers->contains($dealer)) {
  290.             $this->dealers->add($dealer);
  291.             $dealer->setAgency($this);
  292.         }
  293.         return $this;
  294.     }
  295.     public function removeDealer(JoinTableDealerAgency $dealer): static
  296.     {
  297.         if ($this->dealers->removeElement($dealer)) {
  298.             // set the owning side to null (unless already changed)
  299.             if ($dealer->getAgency() === $this) {
  300.                 $dealer->setAgency(null);
  301.             }
  302.         }
  303.         return $this;
  304.     }
  305.     /**
  306.      * @return Collection<int, Address>
  307.      */
  308.     public function getAddresses(): Collection
  309.     {
  310.         return $this->addresses;
  311.     }
  312.     public function addAddress(Address $address): static
  313.     {
  314.         if (!$this->addresses->contains($address)) {
  315.             $this->addresses->add($address);
  316.             $address->setAgency($this);
  317.         }
  318.         return $this;
  319.     }
  320.     public function removeAddress(Address $address): static
  321.     {
  322.         if ($this->addresses->removeElement($address)) {
  323.             // set the owning side to null (unless already changed)
  324.             if ($address->getAgency() === $this) {
  325.                 $address->setAgency(null);
  326.             }
  327.         }
  328.         return $this;
  329.     }
  330.     /**
  331.      * @return Collection<int, Contact>
  332.      */
  333.     public function getContacts(): Collection
  334.     {
  335.         return $this->contacts;
  336.     }
  337.     public function addContact(Contact $contact): static
  338.     {
  339.         if (!$this->contacts->contains($contact)) {
  340.             $this->contacts->add($contact);
  341.             $contact->setAgency($this);
  342.         }
  343.         return $this;
  344.     }
  345.     public function removeContact(Contact $contact): static
  346.     {
  347.         if ($this->contacts->removeElement($contact)) {
  348.             // set the owning side to null (unless already changed)
  349.             if ($contact->getAgency() === $this) {
  350.                 $contact->setAgency(null);
  351.             }
  352.         }
  353.         return $this;
  354.     }
  355.     /**
  356.      * @return Collection<int, JoinTableAgencyUser>
  357.      */
  358.     public function getUsers(): Collection
  359.     {
  360.         return $this->users;
  361.     }
  362.     public function addUser(JoinTableAgencyUser $user): static
  363.     {
  364.         if (!$this->users->contains($user)) {
  365.             $this->users->add($user);
  366.             $user->setAgency($this);
  367.         }
  368.         return $this;
  369.     }
  370.     public function removeUser(JoinTableAgencyUser $user): static
  371.     {
  372.         if ($this->users->removeElement($user)) {
  373.             // set the owning side to null (unless already changed)
  374.             if ($user->getAgency() === $this) {
  375.                 $user->setAgency(null);
  376.             }
  377.         }
  378.         return $this;
  379.     }
  380.     /**
  381.      * @return Collection<int, Reservation>
  382.      */
  383.     public function getReservations(): Collection
  384.     {
  385.         return $this->reservations;
  386.     }
  387.     public function addReservation(Reservation $reservation): static
  388.     {
  389.         if (!$this->reservations->contains($reservation)) {
  390.             $this->reservations->add($reservation);
  391.             $reservation->setAgency($this);
  392.         }
  393.         return $this;
  394.     }
  395.     public function removeReservation(Reservation $reservation): static
  396.     {
  397.         if ($this->reservations->removeElement($reservation)) {
  398.             // set the owning side to null (unless already changed)
  399.             if ($reservation->getAgency() === $this) {
  400.                 $reservation->setAgency(null);
  401.             }
  402.         }
  403.         return $this;
  404.     }
  405.     /**
  406.      * @return Collection<int, ReservationFreeCabins>
  407.      */
  408.     public function getReservationFreeCabins(): Collection
  409.     {
  410.         return $this->reservationFreeCabins;
  411.     }
  412.     public function addReservationFreeCabin(ReservationFreeCabins $reservationFreeCabin): static
  413.     {
  414.         if (!$this->reservationFreeCabins->contains($reservationFreeCabin)) {
  415.             $this->reservationFreeCabins->add($reservationFreeCabin);
  416.             $reservationFreeCabin->setAgency($this);
  417.         }
  418.         return $this;
  419.     }
  420.     public function removeReservationFreeCabin(ReservationFreeCabins $reservationFreeCabin): static
  421.     {
  422.         if ($this->reservationFreeCabins->removeElement($reservationFreeCabin)) {
  423.             // set the owning side to null (unless already changed)
  424.             if ($reservationFreeCabin->getAgency() === $this) {
  425.                 $reservationFreeCabin->setAgency(null);
  426.             }
  427.         }
  428.         return $this;
  429.     }
  430.     public function getGroup(): ?AgencyGroup
  431.     {
  432.         return $this->group;
  433.     }
  434.     public function setGroup(?AgencyGroup $group): static
  435.     {
  436.         $this->group $group;
  437.         return $this;
  438.     }
  439. }