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