src/Entity/Slave/Client.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Slave;
  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="eposm_s_client")
  9.  * @ORM\Entity(repositoryClass="App\Repository\Slave\ClientRepository")
  10.  */
  11. class Client
  12. {        
  13.     public function __toString()
  14.     {
  15.         if($this->getName() != null)
  16.             return $this->getName();
  17.         elseif($this->getNickname() != null)
  18.             return $this->getNickname();
  19.         else
  20.             return $this->getCode();
  21.     }
  22.     public function canDelete(){
  23.         if(sizeof($this->getTickets()) > 0) return false;
  24.         if($this->getWarehouse() != null && !$this->getWarehouse()->canDelete()) return false;
  25.         return true;
  26.     }
  27.     public function getPhoneByName($name)
  28.     {
  29.         foreach($this->getPhones() as $phone)
  30.             if($phone->getName() == $name && $phone->getNumber() != '' && $phone->getNumber() != '-' && $phone->getNumber() != '.' && $phone->getNumber() != '*' && $phone->getNumber() != '//' && $phone->getNumber() != 'non disp.')
  31.                 return $phone->getNumber();
  32.         return '';
  33.     }
  34.     public function displayPhones()
  35.     {
  36.         $res "";
  37.         foreach($this->getPhones() as $phone){
  38.             if($phone->getNumber() != '' && $phone->getNumber() != '-' && $phone->getNumber() != '.' && $phone->getNumber() != '*' && $phone->getNumber() != '//' && $phone->getNumber() != 'non disp.')
  39.                 $res.= $phone->getName().': '.$phone->getNumber().'<br>';
  40.         }
  41.         return $res;
  42.     }
  43.     public function displayTermids($type)
  44.     {
  45.         $html '';
  46.         switch($type){
  47.             case 'table':
  48.                 $html '<table class="table table_no_padding b_none m_b_none">';
  49.                 foreach($this->getTermids() as $termid){
  50.                     $html.= '<tr><td>'.$termid->getCode().'</td></tr>';
  51.                 }
  52.                 $html.= '</table>';
  53.                 break;
  54.             case 'string':
  55.                 $first true;
  56.                 foreach($this->getTermids() as $termid){
  57.                     if($first$first false; else $html.= ', ';
  58.                     $html.= $termid->getCode();
  59.                 }
  60.                 break;
  61.             default: break;
  62.         }
  63.         return $html;
  64.     }
  65.     /**
  66.      * @ORM\Column(name="id", type="bigint")
  67.      * @ORM\Id
  68.      * @ORM\GeneratedValue(strategy="AUTO")
  69.      */
  70.     protected $id;
  71.     
  72.     /**
  73.      * @ORM\Column(name="code", type="string", length=191, nullable=true)
  74.      */
  75.     protected $code;
  76.     
  77.     /**
  78.      * @ORM\Column(name="name", type="string", length=191, nullable=true)
  79.      */
  80.     protected $name;
  81.     
  82.     /**
  83.      * @ORM\Column(name="nickname", type="string", length=191, nullable=true)
  84.      */
  85.     protected $nickname;
  86.     
  87.     /**
  88.      * @ORM\Column(name="referent", type="string", length=191, nullable=true)
  89.      */
  90.     protected $referent;
  91.     
  92.     /**
  93.      * @ORM\Column(name="fiscal_code", type="string", length=191, nullable=true)
  94.      */
  95.     protected $fiscalCode;
  96.     
  97.     /**
  98.      * @ORM\Column(name="vat", type="string", length=191, nullable=true)
  99.      */
  100.     protected $vat;
  101.     
  102.     /**
  103.      * @ORM\Column(name="sdi", type="string", length=191, nullable=true)
  104.      */
  105.     protected $sdi;
  106.     
  107.     /**
  108.      * @ORM\Column(name="address", type="string", length=191, nullable=true)
  109.      */
  110.     protected $address;
  111.     
  112.     /**
  113.      * @ORM\Column(name="locality", type="string", length=191, nullable=true)
  114.      */
  115.     protected $locality;
  116.     /**
  117.      * @ORM\Column(name="zip", type="string", length=191, nullable=true)
  118.      */
  119.     protected $zip;
  120.     /**
  121.      * @ORM\Column(name="id_city", type="bigint", nullable=true)
  122.      */
  123.     protected $idCity;
  124.     /**
  125.      * @ORM\Column(name="id_province", type="bigint", nullable=true)
  126.      */
  127.     protected $idProvince;
  128.     /**
  129.      * @ORM\Column(name="closures", type="text", nullable=true)
  130.      */
  131.     protected $closures;
  132.     
  133.     /**
  134.      * @ORM\Column(name="openings", type="text", nullable=true)
  135.      */
  136.     protected $openings;
  137.     /**
  138.      * @ORM\Column(name="notes", type="text", nullable=true)
  139.      */
  140.     protected $notes;
  141.     /**
  142.      * @ORM\Column(name="directory_path", type="string", length=191, nullable=true)
  143.      */
  144.     protected $directoryPath;
  145.     // OneToOne
  146.         /**
  147.          * @ORM\OneToOne(targetEntity="App\Entity\Slave\Warehouse", mappedBy="client")
  148.          */
  149.         private $warehouse;
  150.     //
  151.     // OneToMany
  152.         /**
  153.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\Termid", mappedBy="client")
  154.          */
  155.         private $termids;
  156.         /**
  157.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\Ticket", mappedBy="client")
  158.          */
  159.         private $tickets;
  160.         /**
  161.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\ClientPhone", mappedBy="client")
  162.          */
  163.         private $phones;
  164.         
  165.         /**
  166.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\ClientFile", mappedBy="client")
  167.          */
  168.         private $files;
  169.         public function __construct()
  170.         {
  171.             $this->termids = new ArrayCollection();
  172.             $this->tickets = new ArrayCollection();
  173.             $this->phones = new ArrayCollection();
  174.             $this->files = new ArrayCollection();
  175.         }
  176.     //
  177.     public function getId(): ?string
  178.     {
  179.         return $this->id;
  180.     }
  181.     public function getCode(): ?string
  182.     {
  183.         return $this->code;
  184.     }
  185.     public function setCode(?string $code): static
  186.     {
  187.         $this->code $code;
  188.         return $this;
  189.     }
  190.     public function getName(): ?string
  191.     {
  192.         return $this->name;
  193.     }
  194.     public function setName(?string $name): static
  195.     {
  196.         $this->name $name;
  197.         return $this;
  198.     }
  199.     public function getNickname(): ?string
  200.     {
  201.         return $this->nickname;
  202.     }
  203.     public function setNickname(?string $nickname): static
  204.     {
  205.         $this->nickname $nickname;
  206.         return $this;
  207.     }
  208.     public function getReferent(): ?string
  209.     {
  210.         return $this->referent;
  211.     }
  212.     public function setReferent(?string $referent): static
  213.     {
  214.         $this->referent $referent;
  215.         return $this;
  216.     }
  217.     public function getFiscalCode(): ?string
  218.     {
  219.         return $this->fiscalCode;
  220.     }
  221.     public function setFiscalCode(?string $fiscalCode): static
  222.     {
  223.         $this->fiscalCode $fiscalCode;
  224.         return $this;
  225.     }
  226.     public function getVat(): ?string
  227.     {
  228.         return $this->vat;
  229.     }
  230.     public function setVat(?string $vat): static
  231.     {
  232.         $this->vat $vat;
  233.         return $this;
  234.     }
  235.     public function getSdi(): ?string
  236.     {
  237.         return $this->sdi;
  238.     }
  239.     public function setSdi(?string $sdi): static
  240.     {
  241.         $this->sdi $sdi;
  242.         return $this;
  243.     }
  244.     public function getAddress(): ?string
  245.     {
  246.         return $this->address;
  247.     }
  248.     public function setAddress(?string $address): static
  249.     {
  250.         $this->address $address;
  251.         return $this;
  252.     }
  253.     public function getLocality(): ?string
  254.     {
  255.         return $this->locality;
  256.     }
  257.     public function setLocality(?string $locality): static
  258.     {
  259.         $this->locality $locality;
  260.         return $this;
  261.     }
  262.     public function getZip(): ?string
  263.     {
  264.         return $this->zip;
  265.     }
  266.     public function setZip(?string $zip): static
  267.     {
  268.         $this->zip $zip;
  269.         return $this;
  270.     }
  271.     public function getIdCity(): ?string
  272.     {
  273.         return $this->idCity;
  274.     }
  275.     public function setIdCity(?string $idCity): static
  276.     {
  277.         $this->idCity $idCity;
  278.         return $this;
  279.     }
  280.     public function getIdProvince(): ?string
  281.     {
  282.         return $this->idProvince;
  283.     }
  284.     public function setIdProvince(?string $idProvince): static
  285.     {
  286.         $this->idProvince $idProvince;
  287.         return $this;
  288.     }
  289.     public function getClosures(): ?string
  290.     {
  291.         return $this->closures;
  292.     }
  293.     public function setClosures(?string $closures): static
  294.     {
  295.         $this->closures $closures;
  296.         return $this;
  297.     }
  298.     public function getOpenings(): ?string
  299.     {
  300.         return $this->openings;
  301.     }
  302.     public function setOpenings(?string $openings): static
  303.     {
  304.         $this->openings $openings;
  305.         return $this;
  306.     }
  307.     public function getNotes(): ?string
  308.     {
  309.         return $this->notes;
  310.     }
  311.     public function setNotes(?string $notes): static
  312.     {
  313.         $this->notes $notes;
  314.         return $this;
  315.     }
  316.     public function getWarehouse(): ?Warehouse
  317.     {
  318.         return $this->warehouse;
  319.     }
  320.     public function setWarehouse(?Warehouse $warehouse): static
  321.     {
  322.         // unset the owning side of the relation if necessary
  323.         if ($warehouse === null && $this->warehouse !== null) {
  324.             $this->warehouse->setClient(null);
  325.         }
  326.         // set the owning side of the relation if necessary
  327.         if ($warehouse !== null && $warehouse->getClient() !== $this) {
  328.             $warehouse->setClient($this);
  329.         }
  330.         $this->warehouse $warehouse;
  331.         return $this;
  332.     }
  333.     /**
  334.      * @return Collection<int, Termid>
  335.      */
  336.     public function getTermids(): Collection
  337.     {
  338.         return $this->termids;
  339.     }
  340.     public function addTermid(Termid $termid): static
  341.     {
  342.         if (!$this->termids->contains($termid)) {
  343.             $this->termids->add($termid);
  344.             $termid->setClient($this);
  345.         }
  346.         return $this;
  347.     }
  348.     public function removeTermid(Termid $termid): static
  349.     {
  350.         if ($this->termids->removeElement($termid)) {
  351.             // set the owning side to null (unless already changed)
  352.             if ($termid->getClient() === $this) {
  353.                 $termid->setClient(null);
  354.             }
  355.         }
  356.         return $this;
  357.     }
  358.     /**
  359.      * @return Collection<int, Ticket>
  360.      */
  361.     public function getTickets(): Collection
  362.     {
  363.         return $this->tickets;
  364.     }
  365.     public function addTicket(Ticket $ticket): static
  366.     {
  367.         if (!$this->tickets->contains($ticket)) {
  368.             $this->tickets->add($ticket);
  369.             $ticket->setClient($this);
  370.         }
  371.         return $this;
  372.     }
  373.     public function removeTicket(Ticket $ticket): static
  374.     {
  375.         if ($this->tickets->removeElement($ticket)) {
  376.             // set the owning side to null (unless already changed)
  377.             if ($ticket->getClient() === $this) {
  378.                 $ticket->setClient(null);
  379.             }
  380.         }
  381.         return $this;
  382.     }
  383.     /**
  384.      * @return Collection<int, ClientPhone>
  385.      */
  386.     public function getPhones(): Collection
  387.     {
  388.         return $this->phones;
  389.     }
  390.     public function addPhone(ClientPhone $phone): static
  391.     {
  392.         if (!$this->phones->contains($phone)) {
  393.             $this->phones->add($phone);
  394.             $phone->setClient($this);
  395.         }
  396.         return $this;
  397.     }
  398.     public function removePhone(ClientPhone $phone): static
  399.     {
  400.         if ($this->phones->removeElement($phone)) {
  401.             // set the owning side to null (unless already changed)
  402.             if ($phone->getClient() === $this) {
  403.                 $phone->setClient(null);
  404.             }
  405.         }
  406.         return $this;
  407.     }
  408.     public function getDirectoryPath(): ?string
  409.     {
  410.         return $this->directoryPath;
  411.     }
  412.     public function setDirectoryPath(?string $directoryPath): static
  413.     {
  414.         $this->directoryPath $directoryPath;
  415.         return $this;
  416.     }
  417.     /**
  418.      * @return Collection<int, ClientFile>
  419.      */
  420.     public function getFiles(): Collection
  421.     {
  422.         return $this->files;
  423.     }
  424.     public function addFile(ClientFile $file): static
  425.     {
  426.         if (!$this->files->contains($file)) {
  427.             $this->files->add($file);
  428.             $file->setClient($this);
  429.         }
  430.         return $this;
  431.     }
  432.     public function removeFile(ClientFile $file): static
  433.     {
  434.         if ($this->files->removeElement($file)) {
  435.             // set the owning side to null (unless already changed)
  436.             if ($file->getClient() === $this) {
  437.                 $file->setClient(null);
  438.             }
  439.         }
  440.         return $this;
  441.     }
  442. }