src/Entity/Slave/Operation.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_operation")
  9.  * @ORM\Entity(repositoryClass="App\Repository\Slave\OperationRepository")
  10.  */
  11. class Operation
  12. {
  13.     public function __toString(){
  14.         return $this->getSupplier().' - '.$this->getValue();
  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 displayEmailParameters($parameter)
  30.     {
  31.         $result '';
  32.         if($this->getEmailParams() != null){
  33.             $params json_decode($this->getEmailParams(), true);
  34.             switch($parameter){
  35.                 case 'address'$result $params['emailAddress']; break;
  36.                 case 'host'$result $params['emailHost']; break;
  37.                 case 'port'$result $params['emailPort']; break;
  38.                 case 'encryption'$result $params['emailEncryption']; break;
  39.                 case 'user'$result $params['emailUser']; break;
  40.                 case 'password'$result $params['emailPassword']; break;
  41.                 case 'all'$result '<table class="table table-sm b_none m_b_none"><tr><th style="padding: 0.1rem 0.1rem !important">Indirizzo</th><td style="padding: 0.1rem 0.1rem !important">'.$params['emailAddress'].'</td></tr><tr><th style="padding: 0.1rem 0.1rem !important">Host</th><td style="padding: 0.1rem 0.1rem !important">'.$params['emailHost'].'</td></tr><tr><th style="padding: 0.1rem 0.1rem !important">Porta</th><td style="padding: 0.1rem 0.1rem !important">'.$params['emailPort'].'</td></tr><tr><th style="padding: 0.1rem 0.1rem !important">Metodo crittografico</th><td style="padding: 0.1rem 0.1rem !important">'.$params['emailEncryption'].'</td></tr><tr><th style="padding: 0.1rem 0.1rem !important">Utente</th><td style="padding: 0.1rem 0.1rem !important">'.$params['emailUser'].'</td></tr><tr><th style="padding: 0.1rem 0.1rem !important">Password</th><td style="padding: 0.1rem 0.1rem !important">'.$params['emailPassword'].'</td></tr></table>'; break;
  42.                 default: break;
  43.             }
  44.         }
  45.         return $result;
  46.     }
  47.     public function displaySupplierAndValue()
  48.                                                                                                     {
  49.                                                                                                         return $this->getSupplier().' - '.$this->getValue();
  50.                                                                                                     }
  51.     public function getKeyTicketNumber()
  52.                                                                                                     {
  53.                                                                                                         foreach($this->getKeyMappings() as $key){
  54.                                                                                                             if($key->isTicketNumber())
  55.                                                                                                                 return $key;
  56.                                                                                                         }
  57.                                                                                                         return false;
  58.                                                                                                     }
  59.     public function getKeyTermid()
  60.                                                                                                     {
  61.                                                                                                         foreach($this->getKeyMappings() as $key){
  62.                                                                                                             if($key->isTermid())
  63.                                                                                                                 return $key;
  64.                                                                                                         }
  65.                                                                                                         return false;
  66.                                                                                                     }
  67.     
  68.     public function getKeyValueByValue($value)
  69.                                                                                                     {
  70.                                                                                                         foreach($this->getKeyMappings() as $key){
  71.                                                                                                             if($key->getTicketColumn() == $value){
  72.                                                                                                                 return $key->getMappingValue();
  73.                                                                                                             }
  74.                                                                                                         }
  75.                                                                                                         return false;
  76.                                                                                                     }
  77.     
  78.     public function getKeyByValue($value)
  79.                                                                                                     {
  80.                                                                                                         foreach($this->getKeyMappings() as $key){
  81.                                                                                                             if($key->getTicketColumn() == $value){
  82.                                                                                                                 return $key;
  83.                                                                                                             }
  84.                                                                                                         }
  85.                                                                                                         return false;
  86.                                                                                                     }
  87.     
  88.     /**
  89.      * @ORM\Column(name="id", type="bigint")
  90.      * @ORM\Id
  91.      * @ORM\GeneratedValue(strategy="AUTO")
  92.      */
  93.     protected $id;
  94.     
  95.     /**
  96.      * @ORM\Column(name="value", type="string", length=191, nullable=true)
  97.      */
  98.     protected $value;
  99.     /**
  100.      * @ORM\Column(name="slug_master", type="string", length=191)
  101.      */
  102.     protected $slugMaster;
  103.     
  104.     /**
  105.      * @ORM\Column(name="code_client", type="string", length=191, nullable=true)
  106.      */
  107.     protected $codeClient;
  108.     
  109.     /**
  110.      * @ORM\Column(name="identifier_regex", type="text", nullable=true)
  111.      */
  112.     protected $identifierRegex;
  113.     
  114.     /**
  115.      * @ORM\Column(name="is_uav", type="boolean")
  116.      */
  117.     protected $uav false;
  118.     /**
  119.      * @ORM\Column(name="active", type="boolean")
  120.      */
  121.     protected $active false;
  122.     // ManyToOne
  123.         /**
  124.          * @ORM\ManyToOne(targetEntity="App\Entity\Slave\Supplier", inversedBy="operations")
  125.          * @ORM\JoinColumn(name="supplier_id", referencedColumnName="id")
  126.          */
  127.         private $supplier;
  128.         
  129.         /**
  130.          * @ORM\ManyToOne(targetEntity="App\Entity\Slave\OperationGroup", inversedBy="operations")
  131.          * @ORM\JoinColumn(name="group_id", referencedColumnName="id")
  132.          */
  133.         private $group;
  134.     //
  135.     // OneToMany
  136.         /**
  137.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\OperationTariff", mappedBy="operation")
  138.          */
  139.         private $tariffs;
  140.         /**
  141.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\Ticket", mappedBy="operation")
  142.          */
  143.         private $tickets;
  144.         
  145.         /**
  146.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\OperationKeyMapping", mappedBy="operation")
  147.          * @ORM\OrderBy({"priority" = "ASC"})
  148.          */
  149.         private $keyMappings;
  150.         
  151.         /**
  152.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\OperationSubjectMapping", mappedBy="operation")
  153.          */
  154.         private $subjectMappings;
  155.         
  156.         /**
  157.          * @ORM\OneToMany(targetEntity="App\Entity\Slave\OperationAlgorithm", mappedBy="operation")
  158.          */
  159.         private $algorithms;
  160.         public function __construct()
  161.         {
  162.             $this->tariffs = new ArrayCollection();
  163.             $this->tickets = new ArrayCollection();
  164.             $this->keyMappings = new ArrayCollection();
  165.             $this->subjectMappings = new ArrayCollection();
  166.             $this->algorithms = new ArrayCollection();
  167.         }
  168.         public function getId(): ?string
  169.         {
  170.             return $this->id;
  171.         }
  172.         public function getValue(): ?string
  173.         {
  174.             return $this->value;
  175.         }
  176.         public function setValue(?string $value): static
  177.         {
  178.             $this->value $value;
  179.             return $this;
  180.         }
  181.         public function getSlugMaster(): ?string
  182.         {
  183.             return $this->slugMaster;
  184.         }
  185.         public function setSlugMaster(string $slugMaster): static
  186.         {
  187.             $this->slugMaster $slugMaster;
  188.             return $this;
  189.         }
  190.         public function getCodeClient(): ?string
  191.         {
  192.             return $this->codeClient;
  193.         }
  194.         public function setCodeClient(?string $codeClient): static
  195.         {
  196.             $this->codeClient $codeClient;
  197.             return $this;
  198.         }
  199.         public function getIdentifierRegex(): ?string
  200.         {
  201.             return $this->identifierRegex;
  202.         }
  203.         public function setIdentifierRegex(?string $identifierRegex): static
  204.         {
  205.             $this->identifierRegex $identifierRegex;
  206.             return $this;
  207.         }
  208.         public function isUav(): ?bool
  209.         {
  210.             return $this->uav;
  211.         }
  212.         public function setUav(bool $uav): static
  213.         {
  214.             $this->uav $uav;
  215.             return $this;
  216.         }
  217.         public function isActive(): ?bool
  218.         {
  219.             return $this->active;
  220.         }
  221.         public function setActive(bool $active): static
  222.         {
  223.             $this->active $active;
  224.             return $this;
  225.         }
  226.         public function getSupplier(): ?Supplier
  227.         {
  228.             return $this->supplier;
  229.         }
  230.         public function setSupplier(?Supplier $supplier): static
  231.         {
  232.             $this->supplier $supplier;
  233.             return $this;
  234.         }
  235.         public function getGroup(): ?OperationGroup
  236.         {
  237.             return $this->group;
  238.         }
  239.         public function setGroup(?OperationGroup $group): static
  240.         {
  241.             $this->group $group;
  242.             return $this;
  243.         }
  244.         /**
  245.          * @return Collection<int, OperationTariff>
  246.          */
  247.         public function getTariffs(): Collection
  248.         {
  249.             return $this->tariffs;
  250.         }
  251.         public function addTariff(OperationTariff $tariff): static
  252.         {
  253.             if (!$this->tariffs->contains($tariff)) {
  254.                 $this->tariffs->add($tariff);
  255.                 $tariff->setOperation($this);
  256.             }
  257.             return $this;
  258.         }
  259.         public function removeTariff(OperationTariff $tariff): static
  260.         {
  261.             if ($this->tariffs->removeElement($tariff)) {
  262.                 // set the owning side to null (unless already changed)
  263.                 if ($tariff->getOperation() === $this) {
  264.                     $tariff->setOperation(null);
  265.                 }
  266.             }
  267.             return $this;
  268.         }
  269.         /**
  270.          * @return Collection<int, Ticket>
  271.          */
  272.         public function getTickets(): Collection
  273.         {
  274.             return $this->tickets;
  275.         }
  276.         public function addTicket(Ticket $ticket): static
  277.         {
  278.             if (!$this->tickets->contains($ticket)) {
  279.                 $this->tickets->add($ticket);
  280.                 $ticket->setOperation($this);
  281.             }
  282.             return $this;
  283.         }
  284.         public function removeTicket(Ticket $ticket): static
  285.         {
  286.             if ($this->tickets->removeElement($ticket)) {
  287.                 // set the owning side to null (unless already changed)
  288.                 if ($ticket->getOperation() === $this) {
  289.                     $ticket->setOperation(null);
  290.                 }
  291.             }
  292.             return $this;
  293.         }
  294.         /**
  295.          * @return Collection<int, OperationKeyMapping>
  296.          */
  297.         public function getKeyMappings(): Collection
  298.         {
  299.             return $this->keyMappings;
  300.         }
  301.         public function addKeyMapping(OperationKeyMapping $keyMapping): static
  302.         {
  303.             if (!$this->keyMappings->contains($keyMapping)) {
  304.                 $this->keyMappings->add($keyMapping);
  305.                 $keyMapping->setOperation($this);
  306.             }
  307.             return $this;
  308.         }
  309.         public function removeKeyMapping(OperationKeyMapping $keyMapping): static
  310.         {
  311.             if ($this->keyMappings->removeElement($keyMapping)) {
  312.                 // set the owning side to null (unless already changed)
  313.                 if ($keyMapping->getOperation() === $this) {
  314.                     $keyMapping->setOperation(null);
  315.                 }
  316.             }
  317.             return $this;
  318.         }
  319.         /**
  320.          * @return Collection<int, OperationSubjectMapping>
  321.          */
  322.         public function getSubjectMappings(): Collection
  323.         {
  324.             return $this->subjectMappings;
  325.         }
  326.         public function addSubjectMapping(OperationSubjectMapping $subjectMapping): static
  327.         {
  328.             if (!$this->subjectMappings->contains($subjectMapping)) {
  329.                 $this->subjectMappings->add($subjectMapping);
  330.                 $subjectMapping->setOperation($this);
  331.             }
  332.             return $this;
  333.         }
  334.         public function removeSubjectMapping(OperationSubjectMapping $subjectMapping): static
  335.         {
  336.             if ($this->subjectMappings->removeElement($subjectMapping)) {
  337.                 // set the owning side to null (unless already changed)
  338.                 if ($subjectMapping->getOperation() === $this) {
  339.                     $subjectMapping->setOperation(null);
  340.                 }
  341.             }
  342.             return $this;
  343.         }
  344.         /**
  345.          * @return Collection<int, OperationAlgorithm>
  346.          */
  347.         public function getAlgorithms(): Collection
  348.         {
  349.             return $this->algorithms;
  350.         }
  351.         public function addAlgorithm(OperationAlgorithm $algorithm): static
  352.         {
  353.             if (!$this->algorithms->contains($algorithm)) {
  354.                 $this->algorithms->add($algorithm);
  355.                 $algorithm->setOperation($this);
  356.             }
  357.             return $this;
  358.         }
  359.         public function removeAlgorithm(OperationAlgorithm $algorithm): static
  360.         {
  361.             if ($this->algorithms->removeElement($algorithm)) {
  362.                 // set the owning side to null (unless already changed)
  363.                 if ($algorithm->getOperation() === $this) {
  364.                     $algorithm->setOperation(null);
  365.                 }
  366.             }
  367.             return $this;
  368.         }
  369. }