src/Entity/Slave/Supplier.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_supplier")
  9.  * @ORM\Entity(repositoryClass="App\Repository\Slave\SupplierRepository")
  10.  */
  11. class Supplier
  12. {
  13.     public function __toString(){ 
  14.                                                                                                                                                                                                                                                                                                                                             return $this->getName();
  15.                                                                                                                                                                                                                                                                                                                                         }
  16.     public function getCanDelete(){
  17.         if($this->idSupplier != null) return false;
  18.         if(sizeof($this->products) > 0) return false;
  19.         if(sizeof($this->tickets) > 0) return false;
  20.         if(sizeof($this->operations) > 0) return false;
  21.         if(sizeof($this->models) > 0) return false;
  22.         return true;
  23.     }
  24.     
  25.     public function getUAVOperation(){
  26.         foreach($this->getOperations() as $operation){
  27.             if($operation->isUav()){
  28.                 return $operation;
  29.                 break;
  30.             }
  31.         }
  32.     }
  33.     public function displayTicketEmails()
  34.     {
  35.         $html '<table class="table table-sm b_none m_b_none font_14"><tbody>';
  36.         foreach($this->ticketEmails as $te){
  37.             $html.= '<tr><td>'.$te->getValue().'</td></tr>';
  38.         }
  39.         $html.= '</tbody></table>';
  40.         return $html;
  41.     }
  42.     public function getOperationMaintenance()
  43.     {
  44.         foreach($this->getOperations() as $operation){
  45.             if($operation->getGroup()->isMaintenance())
  46.                 return $operation;
  47.         }
  48.     }
  49.     /**
  50.      * @ORM\Column(name="id", type="bigint")
  51.      * @ORM\Id
  52.      * @ORM\GeneratedValue(strategy="AUTO")
  53.      */
  54.     protected $id;
  55.     
  56.     /**
  57.      * @ORM\Column(name="name", type="string", length=191)
  58.      */
  59.     protected $name;
  60.     
  61.     /**
  62.      * @ORM\Column(name="slug", type="string", length=191)
  63.      */
  64.     protected $slug;
  65.     
  66.     /**
  67.      * @ORM\Column(name="amount_regenerate", type="decimal", scale=2, nullable=true)
  68.      */
  69.     protected $amountRegenerate;
  70.     
  71.     /**
  72.      * @ORM\Column(name="id_supplier", type="bigint", nullable=true)
  73.      */
  74.     protected $idSupplier;
  75.     
  76.     /**
  77.      * @ORM\Column(name="operation_mapping", type="string", length=191, nullable=true)
  78.      */
  79.     protected $operationMapping;
  80.     
  81.     /**
  82.      * @ORM\Column(name="amount_ticket_extra_hour", type="decimal", scale=2, nullable=true)
  83.      */
  84.     protected $amountTicketExtraHour;
  85.     // OneToMany
  86.         /**
  87.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\Ticket", mappedBy="supplier")
  88.          */
  89.         private $tickets;
  90.         /**
  91.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\Operation", mappedBy="supplier")
  92.          */
  93.         private $operations;
  94.         
  95.         /**
  96.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\JoinTableUserSupplier", mappedBy="supplier")
  97.          */
  98.         private $users;
  99.         
  100.         /**
  101.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\ProductTransfer", mappedBy="supplier")
  102.          */
  103.         private $transfers;
  104.         
  105.         /**
  106.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\SupplierTicketEmail", mappedBy="supplier")
  107.          */
  108.         private $ticketEmails;
  109.         /**
  110.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\JoinTableProductModelSupplier", mappedBy="supplier")
  111.          */
  112.         private $models;
  113.         /**
  114.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\ProductRegenerated", mappedBy="supplier")
  115.          */
  116.         private $regeneratedProducts;
  117.         
  118.         /**
  119.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\TicketColumnValue", mappedBy="supplier")
  120.          */
  121.         private $ticketColumnValues;
  122.     //
  123.     // ManyToMany
  124.         /**
  125.          * @ORM\ManyToMany(targetEntity="App\Entity\Slave\Product", mappedBy="suppliers")
  126.          */
  127.         private $products;
  128.         /**
  129.          * @ORM\ManyToMany(targetEntity="App\Entity\Slave\User", mappedBy="autoAssignSuppliers")
  130.          */
  131.         private $autoAssignUsers;
  132.         public function __construct()
  133.         {
  134.             $this->tickets = new ArrayCollection();
  135.             $this->operations = new ArrayCollection();
  136.             $this->users = new ArrayCollection();
  137.             $this->transfers = new ArrayCollection();
  138.             $this->ticketEmails = new ArrayCollection();
  139.             $this->models = new ArrayCollection();
  140.             $this->regeneratedProducts = new ArrayCollection();
  141.             $this->ticketColumnValues = new ArrayCollection();
  142.             $this->products = new ArrayCollection();
  143.             $this->autoAssignUsers = new ArrayCollection();
  144.         }
  145.     //
  146.     public function getId(): ?string
  147.     {
  148.         return $this->id;
  149.     }
  150.     public function getName(): ?string
  151.     {
  152.         return $this->name;
  153.     }
  154.     public function setName(string $name): static
  155.     {
  156.         $this->name $name;
  157.         return $this;
  158.     }
  159.     public function getSlug(): ?string
  160.     {
  161.         return $this->slug;
  162.     }
  163.     public function setSlug(string $slug): static
  164.     {
  165.         $this->slug $slug;
  166.         return $this;
  167.     }
  168.     public function getAmountRegenerate(): ?string
  169.     {
  170.         return $this->amountRegenerate;
  171.     }
  172.     public function setAmountRegenerate(?string $amountRegenerate): static
  173.     {
  174.         $this->amountRegenerate $amountRegenerate;
  175.         return $this;
  176.     }
  177.     public function getIdSupplier(): ?string
  178.     {
  179.         return $this->idSupplier;
  180.     }
  181.     public function setIdSupplier(?string $idSupplier): static
  182.     {
  183.         $this->idSupplier $idSupplier;
  184.         return $this;
  185.     }
  186.     public function getOperationMapping(): ?string
  187.     {
  188.         return $this->operationMapping;
  189.     }
  190.     public function setOperationMapping(?string $operationMapping): static
  191.     {
  192.         $this->operationMapping $operationMapping;
  193.         return $this;
  194.     }
  195.     public function getAmountTicketExtraHour(): ?string
  196.     {
  197.         return $this->amountTicketExtraHour;
  198.     }
  199.     public function setAmountTicketExtraHour(?string $amountTicketExtraHour): static
  200.     {
  201.         $this->amountTicketExtraHour $amountTicketExtraHour;
  202.         return $this;
  203.     }
  204.     /**
  205.      * @return Collection<int, Ticket>
  206.      */
  207.     public function getTickets(): Collection
  208.     {
  209.         return $this->tickets;
  210.     }
  211.     public function addTicket(Ticket $ticket): static
  212.     {
  213.         if (!$this->tickets->contains($ticket)) {
  214.             $this->tickets->add($ticket);
  215.             $ticket->setSupplier($this);
  216.         }
  217.         return $this;
  218.     }
  219.     public function removeTicket(Ticket $ticket): static
  220.     {
  221.         if ($this->tickets->removeElement($ticket)) {
  222.             // set the owning side to null (unless already changed)
  223.             if ($ticket->getSupplier() === $this) {
  224.                 $ticket->setSupplier(null);
  225.             }
  226.         }
  227.         return $this;
  228.     }
  229.     /**
  230.      * @return Collection<int, Operation>
  231.      */
  232.     public function getOperations(): Collection
  233.     {
  234.         return $this->operations;
  235.     }
  236.     public function addOperation(Operation $operation): static
  237.     {
  238.         if (!$this->operations->contains($operation)) {
  239.             $this->operations->add($operation);
  240.             $operation->setSupplier($this);
  241.         }
  242.         return $this;
  243.     }
  244.     public function removeOperation(Operation $operation): static
  245.     {
  246.         if ($this->operations->removeElement($operation)) {
  247.             // set the owning side to null (unless already changed)
  248.             if ($operation->getSupplier() === $this) {
  249.                 $operation->setSupplier(null);
  250.             }
  251.         }
  252.         return $this;
  253.     }
  254.     /**
  255.      * @return Collection<int, JoinTableUserSupplier>
  256.      */
  257.     public function getUsers(): Collection
  258.     {
  259.         return $this->users;
  260.     }
  261.     public function addUser(JoinTableUserSupplier $user): static
  262.     {
  263.         if (!$this->users->contains($user)) {
  264.             $this->users->add($user);
  265.             $user->setSupplier($this);
  266.         }
  267.         return $this;
  268.     }
  269.     public function removeUser(JoinTableUserSupplier $user): static
  270.     {
  271.         if ($this->users->removeElement($user)) {
  272.             // set the owning side to null (unless already changed)
  273.             if ($user->getSupplier() === $this) {
  274.                 $user->setSupplier(null);
  275.             }
  276.         }
  277.         return $this;
  278.     }
  279.     /**
  280.      * @return Collection<int, ProductTransfer>
  281.      */
  282.     public function getTransfers(): Collection
  283.     {
  284.         return $this->transfers;
  285.     }
  286.     public function addTransfer(ProductTransfer $transfer): static
  287.     {
  288.         if (!$this->transfers->contains($transfer)) {
  289.             $this->transfers->add($transfer);
  290.             $transfer->setSupplier($this);
  291.         }
  292.         return $this;
  293.     }
  294.     public function removeTransfer(ProductTransfer $transfer): static
  295.     {
  296.         if ($this->transfers->removeElement($transfer)) {
  297.             // set the owning side to null (unless already changed)
  298.             if ($transfer->getSupplier() === $this) {
  299.                 $transfer->setSupplier(null);
  300.             }
  301.         }
  302.         return $this;
  303.     }
  304.     /**
  305.      * @return Collection<int, SupplierTicketEmail>
  306.      */
  307.     public function getTicketEmails(): Collection
  308.     {
  309.         return $this->ticketEmails;
  310.     }
  311.     public function addTicketEmail(SupplierTicketEmail $ticketEmail): static
  312.     {
  313.         if (!$this->ticketEmails->contains($ticketEmail)) {
  314.             $this->ticketEmails->add($ticketEmail);
  315.             $ticketEmail->setSupplier($this);
  316.         }
  317.         return $this;
  318.     }
  319.     public function removeTicketEmail(SupplierTicketEmail $ticketEmail): static
  320.     {
  321.         if ($this->ticketEmails->removeElement($ticketEmail)) {
  322.             // set the owning side to null (unless already changed)
  323.             if ($ticketEmail->getSupplier() === $this) {
  324.                 $ticketEmail->setSupplier(null);
  325.             }
  326.         }
  327.         return $this;
  328.     }
  329.     /**
  330.      * @return Collection<int, JoinTableProductModelSupplier>
  331.      */
  332.     public function getModels(): Collection
  333.     {
  334.         return $this->models;
  335.     }
  336.     public function addModel(JoinTableProductModelSupplier $model): static
  337.     {
  338.         if (!$this->models->contains($model)) {
  339.             $this->models->add($model);
  340.             $model->setSupplier($this);
  341.         }
  342.         return $this;
  343.     }
  344.     public function removeModel(JoinTableProductModelSupplier $model): static
  345.     {
  346.         if ($this->models->removeElement($model)) {
  347.             // set the owning side to null (unless already changed)
  348.             if ($model->getSupplier() === $this) {
  349.                 $model->setSupplier(null);
  350.             }
  351.         }
  352.         return $this;
  353.     }
  354.     /**
  355.      * @return Collection<int, ProductRegenerated>
  356.      */
  357.     public function getRegeneratedProducts(): Collection
  358.     {
  359.         return $this->regeneratedProducts;
  360.     }
  361.     public function addRegeneratedProduct(ProductRegenerated $regeneratedProduct): static
  362.     {
  363.         if (!$this->regeneratedProducts->contains($regeneratedProduct)) {
  364.             $this->regeneratedProducts->add($regeneratedProduct);
  365.             $regeneratedProduct->setSupplier($this);
  366.         }
  367.         return $this;
  368.     }
  369.     public function removeRegeneratedProduct(ProductRegenerated $regeneratedProduct): static
  370.     {
  371.         if ($this->regeneratedProducts->removeElement($regeneratedProduct)) {
  372.             // set the owning side to null (unless already changed)
  373.             if ($regeneratedProduct->getSupplier() === $this) {
  374.                 $regeneratedProduct->setSupplier(null);
  375.             }
  376.         }
  377.         return $this;
  378.     }
  379.     /**
  380.      * @return Collection<int, TicketColumnValue>
  381.      */
  382.     public function getTicketColumnValues(): Collection
  383.     {
  384.         return $this->ticketColumnValues;
  385.     }
  386.     public function addTicketColumnValue(TicketColumnValue $ticketColumnValue): static
  387.     {
  388.         if (!$this->ticketColumnValues->contains($ticketColumnValue)) {
  389.             $this->ticketColumnValues->add($ticketColumnValue);
  390.             $ticketColumnValue->setSupplier($this);
  391.         }
  392.         return $this;
  393.     }
  394.     public function removeTicketColumnValue(TicketColumnValue $ticketColumnValue): static
  395.     {
  396.         if ($this->ticketColumnValues->removeElement($ticketColumnValue)) {
  397.             // set the owning side to null (unless already changed)
  398.             if ($ticketColumnValue->getSupplier() === $this) {
  399.                 $ticketColumnValue->setSupplier(null);
  400.             }
  401.         }
  402.         return $this;
  403.     }
  404.     /**
  405.      * @return Collection<int, Product>
  406.      */
  407.     public function getProducts(): Collection
  408.     {
  409.         return $this->products;
  410.     }
  411.     public function addProduct(Product $product): static
  412.     {
  413.         if (!$this->products->contains($product)) {
  414.             $this->products->add($product);
  415.             $product->addSupplier($this);
  416.         }
  417.         return $this;
  418.     }
  419.     public function removeProduct(Product $product): static
  420.     {
  421.         if ($this->products->removeElement($product)) {
  422.             $product->removeSupplier($this);
  423.         }
  424.         return $this;
  425.     }
  426.     /**
  427.      * @return Collection<int, User>
  428.      */
  429.     public function getAutoAssignUsers(): Collection
  430.     {
  431.         return $this->autoAssignUsers;
  432.     }
  433.     public function addAutoAssignUser(User $autoAssignUser): static
  434.     {
  435.         if (!$this->autoAssignUsers->contains($autoAssignUser)) {
  436.             $this->autoAssignUsers->add($autoAssignUser);
  437.             $autoAssignUser->addAutoAssignSupplier($this);
  438.         }
  439.         return $this;
  440.     }
  441.     public function removeAutoAssignUser(User $autoAssignUser): static
  442.     {
  443.         if ($this->autoAssignUsers->removeElement($autoAssignUser)) {
  444.             $autoAssignUser->removeAutoAssignSupplier($this);
  445.         }
  446.         return $this;
  447.     }
  448. }