src/Entity/Agency.php line 191

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