<?php
namespace App\Entity\Slave;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="eposm_s_operation_group")
* @ORM\Entity(repositoryClass="App\Repository\Slave\OperationGroupRepository")
*/
class OperationGroup
{
public function __toString()
{
return $this->getValue();
}
public function getCanDelete(){
if(sizeof($this->operations) > 0) return false;
return true;
}
public function displayOperations()
{
$html = '<table class="m_b_none"><tbody>';
foreach($this->operations as $operation){
$html.= '<tr><td>'.$operation->getSupplier().' - '.$operation->getValue().'</td></tr>';
}
$html.= '</tbody></table>';
return $html;
}
/**
* @ORM\Column(name="id", type="bigint")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(name="slug", type="string", length=191)
*/
protected $slug;
/**
* @ORM\Column(name="value", type="string", length=191, nullable=true)
*/
protected $value;
/**
* @ORM\Column(name="is_maintenance", type="boolean")
*/
protected $maintenance = false;
/**
* @ORM\Column(name="is_uav", type="boolean")
*/
protected $uav = false;
// OneToMany
/**
* @ORM\OneToMany(targetEntity="App\Entity\Slave\Operation", mappedBy="group")
*/
private $operations;
//
// ManyToMany
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Slave\InterventionActivityType", mappedBy="operationGroups")
*/
private $activityTypes;
public function __construct()
{
$this->operations = new ArrayCollection();
$this->activityTypes = new ArrayCollection();
}
//
public function getId(): ?string
{
return $this->id;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): static
{
$this->slug = $slug;
return $this;
}
public function getValue(): ?string
{
return $this->value;
}
public function setValue(?string $value): static
{
$this->value = $value;
return $this;
}
public function isMaintenance(): ?bool
{
return $this->maintenance;
}
public function setMaintenance(bool $maintenance): static
{
$this->maintenance = $maintenance;
return $this;
}
public function isUav(): ?bool
{
return $this->uav;
}
public function setUav(bool $uav): static
{
$this->uav = $uav;
return $this;
}
/**
* @return Collection<int, Operation>
*/
public function getOperations(): Collection
{
return $this->operations;
}
public function addOperation(Operation $operation): static
{
if (!$this->operations->contains($operation)) {
$this->operations->add($operation);
$operation->setGroup($this);
}
return $this;
}
public function removeOperation(Operation $operation): static
{
if ($this->operations->removeElement($operation)) {
// set the owning side to null (unless already changed)
if ($operation->getGroup() === $this) {
$operation->setGroup(null);
}
}
return $this;
}
/**
* @return Collection<int, InterventionActivityType>
*/
public function getActivityTypes(): Collection
{
return $this->activityTypes;
}
public function addActivityType(InterventionActivityType $activityType): static
{
if (!$this->activityTypes->contains($activityType)) {
$this->activityTypes->add($activityType);
$activityType->addOperationGroup($this);
}
return $this;
}
public function removeActivityType(InterventionActivityType $activityType): static
{
if ($this->activityTypes->removeElement($activityType)) {
$activityType->removeOperationGroup($this);
}
return $this;
}
}