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