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