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.     //
  169.     public function getId(): ?string
  170.     {
  171.         return $this->id;
  172.     }
  173.     public function getName(): ?string
  174.     {
  175.         return $this->name;
  176.     }
  177.     public function setName(string $name): static
  178.     {
  179.         $this->name $name;
  180.         return $this;
  181.     }
  182.     public function getSlug(): ?string
  183.     {
  184.         return $this->slug;
  185.     }
  186.     public function setSlug(string $slug): static
  187.     {
  188.         $this->slug $slug;
  189.         return $this;
  190.     }
  191.     public function getAmountRegenerate(): ?string
  192.     {
  193.         return $this->amountRegenerate;
  194.     }
  195.     public function setAmountRegenerate(?string $amountRegenerate): static
  196.     {
  197.         $this->amountRegenerate $amountRegenerate;
  198.         return $this;
  199.     }
  200.     public function getIdSupplier(): ?string
  201.     {
  202.         return $this->idSupplier;
  203.     }
  204.     public function setIdSupplier(?string $idSupplier): static
  205.     {
  206.         $this->idSupplier $idSupplier;
  207.         return $this;
  208.     }
  209.     public function getOperationMapping(): ?string
  210.     {
  211.         return $this->operationMapping;
  212.     }
  213.     public function setOperationMapping(?string $operationMapping): static
  214.     {
  215.         $this->operationMapping $operationMapping;
  216.         return $this;
  217.     }
  218.     public function getAmountTicketExtraHour(): ?string
  219.     {
  220.         return $this->amountTicketExtraHour;
  221.     }
  222.     public function setAmountTicketExtraHour(?string $amountTicketExtraHour): static
  223.     {
  224.         $this->amountTicketExtraHour $amountTicketExtraHour;
  225.         return $this;
  226.     }
  227.     public function getOperationNotBillableCodes(): ?string
  228.     {
  229.         return $this->operationNotBillableCodes;
  230.     }
  231.     public function setOperationNotBillableCodes(?string $operationNotBillableCodes): static
  232.     {
  233.         $this->operationNotBillableCodes $operationNotBillableCodes;
  234.         return $this;
  235.     }
  236.     public function isActive(): ?bool
  237.     {
  238.         return $this->active;
  239.     }
  240.     public function setActive(bool $active): static
  241.     {
  242.         $this->active $active;
  243.         return $this;
  244.     }
  245.     /**
  246.      * @return Collection<int, Ticket>
  247.      */
  248.     public function getTickets(): Collection
  249.     {
  250.         return $this->tickets;
  251.     }
  252.     public function addTicket(Ticket $ticket): static
  253.     {
  254.         if (!$this->tickets->contains($ticket)) {
  255.             $this->tickets->add($ticket);
  256.             $ticket->setSupplier($this);
  257.         }
  258.         return $this;
  259.     }
  260.     public function removeTicket(Ticket $ticket): static
  261.     {
  262.         if ($this->tickets->removeElement($ticket)) {
  263.             // set the owning side to null (unless already changed)
  264.             if ($ticket->getSupplier() === $this) {
  265.                 $ticket->setSupplier(null);
  266.             }
  267.         }
  268.         return $this;
  269.     }
  270.     /**
  271.      * @return Collection<int, Operation>
  272.      */
  273.     public function getOperations(): Collection
  274.     {
  275.         return $this->operations;
  276.     }
  277.     public function addOperation(Operation $operation): static
  278.     {
  279.         if (!$this->operations->contains($operation)) {
  280.             $this->operations->add($operation);
  281.             $operation->setSupplier($this);
  282.         }
  283.         return $this;
  284.     }
  285.     public function removeOperation(Operation $operation): static
  286.     {
  287.         if ($this->operations->removeElement($operation)) {
  288.             // set the owning side to null (unless already changed)
  289.             if ($operation->getSupplier() === $this) {
  290.                 $operation->setSupplier(null);
  291.             }
  292.         }
  293.         return $this;
  294.     }
  295.     /**
  296.      * @return Collection<int, JoinTableUserSupplier>
  297.      */
  298.     public function getUsers(): Collection
  299.     {
  300.         return $this->users;
  301.     }
  302.     public function addUser(JoinTableUserSupplier $user): static
  303.     {
  304.         if (!$this->users->contains($user)) {
  305.             $this->users->add($user);
  306.             $user->setSupplier($this);
  307.         }
  308.         return $this;
  309.     }
  310.     public function removeUser(JoinTableUserSupplier $user): static
  311.     {
  312.         if ($this->users->removeElement($user)) {
  313.             // set the owning side to null (unless already changed)
  314.             if ($user->getSupplier() === $this) {
  315.                 $user->setSupplier(null);
  316.             }
  317.         }
  318.         return $this;
  319.     }
  320.     /**
  321.      * @return Collection<int, ProductTransfer>
  322.      */
  323.     public function getTransfers(): Collection
  324.     {
  325.         return $this->transfers;
  326.     }
  327.     public function addTransfer(ProductTransfer $transfer): static
  328.     {
  329.         if (!$this->transfers->contains($transfer)) {
  330.             $this->transfers->add($transfer);
  331.             $transfer->setSupplier($this);
  332.         }
  333.         return $this;
  334.     }
  335.     public function removeTransfer(ProductTransfer $transfer): static
  336.     {
  337.         if ($this->transfers->removeElement($transfer)) {
  338.             // set the owning side to null (unless already changed)
  339.             if ($transfer->getSupplier() === $this) {
  340.                 $transfer->setSupplier(null);
  341.             }
  342.         }
  343.         return $this;
  344.     }
  345.     /**
  346.      * @return Collection<int, SupplierTicketEmail>
  347.      */
  348.     public function getTicketEmails(): Collection
  349.     {
  350.         return $this->ticketEmails;
  351.     }
  352.     public function addTicketEmail(SupplierTicketEmail $ticketEmail): static
  353.     {
  354.         if (!$this->ticketEmails->contains($ticketEmail)) {
  355.             $this->ticketEmails->add($ticketEmail);
  356.             $ticketEmail->setSupplier($this);
  357.         }
  358.         return $this;
  359.     }
  360.     public function removeTicketEmail(SupplierTicketEmail $ticketEmail): static
  361.     {
  362.         if ($this->ticketEmails->removeElement($ticketEmail)) {
  363.             // set the owning side to null (unless already changed)
  364.             if ($ticketEmail->getSupplier() === $this) {
  365.                 $ticketEmail->setSupplier(null);
  366.             }
  367.         }
  368.         return $this;
  369.     }
  370.     /**
  371.      * @return Collection<int, JoinTableProductModelSupplier>
  372.      */
  373.     public function getModels(): Collection
  374.     {
  375.         return $this->models;
  376.     }
  377.     public function addModel(JoinTableProductModelSupplier $model): static
  378.     {
  379.         if (!$this->models->contains($model)) {
  380.             $this->models->add($model);
  381.             $model->setSupplier($this);
  382.         }
  383.         return $this;
  384.     }
  385.     public function removeModel(JoinTableProductModelSupplier $model): static
  386.     {
  387.         if ($this->models->removeElement($model)) {
  388.             // set the owning side to null (unless already changed)
  389.             if ($model->getSupplier() === $this) {
  390.                 $model->setSupplier(null);
  391.             }
  392.         }
  393.         return $this;
  394.     }
  395.     /**
  396.      * @return Collection<int, ProductRegenerated>
  397.      */
  398.     public function getRegeneratedProducts(): Collection
  399.     {
  400.         return $this->regeneratedProducts;
  401.     }
  402.     public function addRegeneratedProduct(ProductRegenerated $regeneratedProduct): static
  403.     {
  404.         if (!$this->regeneratedProducts->contains($regeneratedProduct)) {
  405.             $this->regeneratedProducts->add($regeneratedProduct);
  406.             $regeneratedProduct->setSupplier($this);
  407.         }
  408.         return $this;
  409.     }
  410.     public function removeRegeneratedProduct(ProductRegenerated $regeneratedProduct): static
  411.     {
  412.         if ($this->regeneratedProducts->removeElement($regeneratedProduct)) {
  413.             // set the owning side to null (unless already changed)
  414.             if ($regeneratedProduct->getSupplier() === $this) {
  415.                 $regeneratedProduct->setSupplier(null);
  416.             }
  417.         }
  418.         return $this;
  419.     }
  420.     /**
  421.      * @return Collection<int, TicketColumnValue>
  422.      */
  423.     public function getTicketColumnValues(): Collection
  424.     {
  425.         return $this->ticketColumnValues;
  426.     }
  427.     public function addTicketColumnValue(TicketColumnValue $ticketColumnValue): static
  428.     {
  429.         if (!$this->ticketColumnValues->contains($ticketColumnValue)) {
  430.             $this->ticketColumnValues->add($ticketColumnValue);
  431.             $ticketColumnValue->setSupplier($this);
  432.         }
  433.         return $this;
  434.     }
  435.     public function removeTicketColumnValue(TicketColumnValue $ticketColumnValue): static
  436.     {
  437.         if ($this->ticketColumnValues->removeElement($ticketColumnValue)) {
  438.             // set the owning side to null (unless already changed)
  439.             if ($ticketColumnValue->getSupplier() === $this) {
  440.                 $ticketColumnValue->setSupplier(null);
  441.             }
  442.         }
  443.         return $this;
  444.     }
  445.     /**
  446.      * @return Collection<int, Product>
  447.      */
  448.     public function getProducts(): Collection
  449.     {
  450.         return $this->products;
  451.     }
  452.     public function addProduct(Product $product): static
  453.     {
  454.         if (!$this->products->contains($product)) {
  455.             $this->products->add($product);
  456.             $product->addSupplier($this);
  457.         }
  458.         return $this;
  459.     }
  460.     public function removeProduct(Product $product): static
  461.     {
  462.         if ($this->products->removeElement($product)) {
  463.             $product->removeSupplier($this);
  464.         }
  465.         return $this;
  466.     }
  467.     /**
  468.      * @return Collection<int, User>
  469.      */
  470.     public function getAutoAssignUsers(): Collection
  471.     {
  472.         return $this->autoAssignUsers;
  473.     }
  474.     public function addAutoAssignUser(User $autoAssignUser): static
  475.     {
  476.         if (!$this->autoAssignUsers->contains($autoAssignUser)) {
  477.             $this->autoAssignUsers->add($autoAssignUser);
  478.             $autoAssignUser->addAutoAssignSupplier($this);
  479.         }
  480.         return $this;
  481.     }
  482.     public function removeAutoAssignUser(User $autoAssignUser): static
  483.     {
  484.         if ($this->autoAssignUsers->removeElement($autoAssignUser)) {
  485.             $autoAssignUser->removeAutoAssignSupplier($this);
  486.         }
  487.         return $this;
  488.     }
  489. }