src/Entity/Master/Supplier.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Master;
  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_m_supplier")
  9.  * @ORM\Entity(repositoryClass="App\Repository\Master\SupplierRepository")
  10.  */
  11. class Supplier
  12. {
  13.     public function __toString(){
  14.         return $this->name;
  15.     }
  16.     public function canDelete(){
  17.         if(sizeof($this->companies) > 0) return false;
  18.         return true;
  19.     }
  20.     
  21.     public function mainAddress(){
  22.         foreach($this->getAddresses() as $address){
  23.             if($address->isMain())
  24.                 return $address;
  25.         }
  26.     }
  27.     public function displayCompanies(){
  28.         $result '';
  29.         if(sizeof($this->companies) > 0){
  30.             $first true;
  31.             foreach($this->companies as $jtcs){
  32.                 if($first$first false; else $result.= '<br>';
  33.                 $result.= $jtcs->getCompany()->getName();
  34.             }
  35.         }
  36.         else{
  37.             $result '---';
  38.         }
  39.         return $result;
  40.     }
  41.     
  42.     public function displayOperations(){
  43.         $result '';
  44.         if(sizeof($this->operations) > 0){
  45.             $result '<table class="table table_padding_01 b_none m_b_none">';
  46.             foreach($this->operations as $operation){
  47.                 $result.= '<tr><td class="td_w_200p">'.$operation->getName().'</td><td>'.$operation->getSlug().'</td></tr>';
  48.             }
  49.             $result.= '</table>';
  50.         }
  51.         else{
  52.             $result '---';
  53.         }
  54.         return $result;
  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="nickname", type="string", length=191)
  65.      */
  66.     protected $nickname;
  67.         
  68.     /**
  69.      * @ORM\Column(name="name", type="string", length=191)
  70.      */
  71.     protected $name;
  72.         
  73.     /**
  74.      * @ORM\Column(name="phone", type="string", length=191, nullable=true)
  75.      */
  76.     protected $phone;
  77.     
  78.     // OneToMany
  79.         /**
  80.          * @ORM\OneToMany(targetEntity="App\Entity\Master\JoinTableCompanySupplier", mappedBy="supplier")
  81.          */
  82.         private $companies;
  83.         /**
  84.          * @ORM\OneToMany(targetEntity="App\Entity\Master\SupplierOperation", mappedBy="supplier")
  85.          */
  86.         private $operations;
  87.         /**
  88.          * @ORM\OneToMany(targetEntity="App\Entity\Master\Address", mappedBy="supplier")
  89.          */
  90.         private $addresses;
  91.     //
  92.     /**
  93.      * @ORM\ManyToMany(targetEntity="App\Entity\Master\CompanyMailer", inversedBy="suppliers")
  94.      * @ORM\JoinTable(name="eposm_m_join_table_company_mailer_supplier")
  95.      */
  96.     private $mailers;
  97.     public function __construct()
  98.     {
  99.         $this->companies = new ArrayCollection();
  100.         $this->operations = new ArrayCollection();
  101.         $this->addresses = new ArrayCollection();
  102.         $this->mailers = new ArrayCollection();
  103.     }
  104.     public function getId(): ?string
  105.     {
  106.         return $this->id;
  107.     }
  108.     public function getNickname(): ?string
  109.     {
  110.         return $this->nickname;
  111.     }
  112.     public function setNickname(string $nickname): static
  113.     {
  114.         $this->nickname $nickname;
  115.         return $this;
  116.     }
  117.     public function getName(): ?string
  118.     {
  119.         return $this->name;
  120.     }
  121.     public function setName(string $name): static
  122.     {
  123.         $this->name $name;
  124.         return $this;
  125.     }
  126.     public function getPhone(): ?string
  127.     {
  128.         return $this->phone;
  129.     }
  130.     public function setPhone(?string $phone): static
  131.     {
  132.         $this->phone $phone;
  133.         return $this;
  134.     }
  135.     /**
  136.      * @return Collection<int, JoinTableCompanySupplier>
  137.      */
  138.     public function getCompanies(): Collection
  139.     {
  140.         return $this->companies;
  141.     }
  142.     public function addCompany(JoinTableCompanySupplier $company): static
  143.     {
  144.         if (!$this->companies->contains($company)) {
  145.             $this->companies->add($company);
  146.             $company->setSupplier($this);
  147.         }
  148.         return $this;
  149.     }
  150.     public function removeCompany(JoinTableCompanySupplier $company): static
  151.     {
  152.         if ($this->companies->removeElement($company)) {
  153.             // set the owning side to null (unless already changed)
  154.             if ($company->getSupplier() === $this) {
  155.                 $company->setSupplier(null);
  156.             }
  157.         }
  158.         return $this;
  159.     }
  160.     /**
  161.      * @return Collection<int, SupplierOperation>
  162.      */
  163.     public function getOperations(): Collection
  164.     {
  165.         return $this->operations;
  166.     }
  167.     public function addOperation(SupplierOperation $operation): static
  168.     {
  169.         if (!$this->operations->contains($operation)) {
  170.             $this->operations->add($operation);
  171.             $operation->setSupplier($this);
  172.         }
  173.         return $this;
  174.     }
  175.     public function removeOperation(SupplierOperation $operation): static
  176.     {
  177.         if ($this->operations->removeElement($operation)) {
  178.             // set the owning side to null (unless already changed)
  179.             if ($operation->getSupplier() === $this) {
  180.                 $operation->setSupplier(null);
  181.             }
  182.         }
  183.         return $this;
  184.     }
  185.     /**
  186.      * @return Collection<int, Address>
  187.      */
  188.     public function getAddresses(): Collection
  189.     {
  190.         return $this->addresses;
  191.     }
  192.     public function addAddress(Address $address): static
  193.     {
  194.         if (!$this->addresses->contains($address)) {
  195.             $this->addresses->add($address);
  196.             $address->setSupplier($this);
  197.         }
  198.         return $this;
  199.     }
  200.     public function removeAddress(Address $address): static
  201.     {
  202.         if ($this->addresses->removeElement($address)) {
  203.             // set the owning side to null (unless already changed)
  204.             if ($address->getSupplier() === $this) {
  205.                 $address->setSupplier(null);
  206.             }
  207.         }
  208.         return $this;
  209.     }
  210.     /**
  211.      * @return Collection<int, CompanyMailer>
  212.      */
  213.     public function getMailers(): Collection
  214.     {
  215.         return $this->mailers;
  216.     }
  217.     public function addMailer(CompanyMailer $mailer): static
  218.     {
  219.         if (!$this->mailers->contains($mailer)) {
  220.             $this->mailers->add($mailer);
  221.         }
  222.         return $this;
  223.     }
  224.     public function removeMailer(CompanyMailer $mailer): static
  225.     {
  226.         $this->mailers->removeElement($mailer);
  227.         return $this;
  228.     }
  229. }