src/Entity/Scheduler/Task.php line 34
<?php
namespace App\Entity\Scheduler;
use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
use ApiPlatform\Metadata\ApiFilter;
use ApiPlatform\Metadata\ApiResource;
use App\Doctrine\Type\Scheduler\TaskStatus;
use App\Doctrine\Type\Scheduler\TaskType;
use App\Entity\Common;
use App\Entity\Expediting\ShippingPlan;
use App\Entity\Expediting\ShippingSegment;
use App\Entity\Identity\User;
use App\Entity\Sales\WorkOrder;
use App\Repository\Scheduler\TaskRepository;
use App\Validator\IsValidEnum\IsValidEnum;
use DateTimeInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Table(name: 'task')]
#[ORM\Index(columns: ['assignee_id'], name: 'task_assignee_id_idx')]
#[ORM\Index(columns: ['created_by'], name: 'task_created_by_idx')]
#[ORM\Index(columns: ['updated_by'], name: 'task_updated_by_idx')]
#[ORM\Entity(repositoryClass: TaskRepository::class)]
#[ApiResource]
#[ApiFilter(SearchFilter::class, properties: [
'type' => 'exact',
])]
class Task
{
use Common\Blameable;
use Common\Trackable;
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'IDENTITY')]
#[ORM\SequenceGenerator(sequenceName: 'task_id_seq')]
#[ORM\Column(type: Types::INTEGER)]
private ?int $id = null;
/** @var Collection<int, WorkOrder> */
#[ORM\ManyToMany(targetEntity: WorkOrder::class, inversedBy: 'tasks')]
#[ORM\JoinTable(name: 'work_order_task_map')]
#[ORM\JoinColumn(name: 'task_id')]
#[ORM\InverseJoinColumn(name: 'work_order_id')]
private Collection $workOrders;
/** @var Collection<int, ShippingPlan> */
#[ORM\ManyToMany(targetEntity: ShippingPlan::class, inversedBy: 'tasks')]
#[ORM\JoinTable(name: 'expediting_shipping_plan_task_map')]
#[ORM\JoinColumn(name: 'task_id')]
#[ORM\InverseJoinColumn(name: 'shipping_plan_id')]
private Collection $shippingPlans;
/** @var Collection<int, ShippingSegment> */
#[ORM\ManyToMany(targetEntity: ShippingSegment::class, inversedBy: 'tasks')]
#[ORM\JoinTable(name: 'expediting_shipping_segment_task_map')]
#[ORM\JoinColumn(name: 'task_id')]
#[ORM\InverseJoinColumn(name: 'shipping_segment_id')]
private Collection $shippingSegments;
#[ORM\ManyToOne(targetEntity: User::class)]
#[ORM\JoinColumn(name: 'assignee_id')]
private ?User $assignee = null;
#[Assert\NotNull]
#[Assert\Type(type: Types::STRING)]
#[ORM\Column(type: Types::STRING)]
private ?string $description = null;
#[Assert\NotNull]
#[Assert\Type(type: Types::STRING)]
#[ORM\Column(type: Types::STRING)]
private ?string $entity = null;
#[Assert\NotNull]
#[Assert\Type(type: Types::INTEGER)]
#[ORM\Column(type: Types::INTEGER)]
private ?int $entityId = null;
#[Assert\NotNull]
#[IsValidEnum(enum: TaskType::class)]
#[ORM\Column(type: Types::STRING, enumType: TaskType::class)]
private ?TaskType $type = null;
#[Assert\Type(type: Types::BOOLEAN)]
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])]
private bool $isProgressive = false;
#[Assert\Type(type: Types::BOOLEAN)]
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])]
private bool $isAction = false;
#[Assert\Type(type: Types::BOOLEAN)]
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])]
private bool $delayed = false;
#[Assert\Type(type: Types::BOOLEAN)]
#[ORM\Column(type: Types::BOOLEAN, options: ['default' => false])]
private bool $urgent = false;
#[Assert\Type(type: DateTimeInterface::class)]
#[ORM\Column(type: Types::DATETIMETZ_MUTABLE)]
private ?DateTimeInterface $plannedFor = null;
#[Assert\Type(type: DateTimeInterface::class)]
#[ORM\Column(type: Types::DATETIMETZ_MUTABLE, nullable: true)]
private ?DateTimeInterface $startedOn = null;
#[Assert\Type(type: DateTimeInterface::class)]
#[ORM\Column(type: Types::DATETIMETZ_MUTABLE, nullable: true)]
private ?DateTimeInterface $completedOn = null;
#[Assert\NotNull]
#[IsValidEnum(enum: TaskStatus::class)]
#[ORM\Column(type: Types::STRING, enumType: TaskStatus::class, options: ['default' => 'PLANNED'])]
private TaskStatus $status = TaskStatus::PLANNED;
#[Gedmo\Blameable(on: 'create')]
#[ORM\ManyToOne(targetEntity: User::class)]
#[ORM\JoinColumn(name: 'created_by', nullable: true)]
protected ?User $createdBy = null;
public function __construct()
{
$this->workOrders = new ArrayCollection();
$this->shippingPlans = new ArrayCollection();
$this->shippingSegments = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(string $description): self
{
$this->description = $description;
return $this;
}
public function getEntity(): ?string
{
return $this->entity;
}
public function setEntity(string $entity): self
{
$this->entity = $entity;
return $this;
}
public function getEntityId(): ?int
{
return $this->entityId;
}
public function setEntityId(?int $entityId): self
{
$this->entityId = $entityId;
return $this;
}
public function getType(): ?TaskType
{
return $this->type;
}
public function setType(?TaskType $type): self
{
$this->type = $type;
return $this;
}
public function isIsProgressive(): ?bool
{
return $this->isProgressive;
}
public function setIsProgressive(?bool $isProgressive): self
{
$this->isProgressive = $isProgressive;
return $this;
}
public function isIsAction(): ?bool
{
return $this->isAction;
}
public function setIsAction(?bool $isAction): self
{
$this->isAction = $isAction;
return $this;
}
public function isDelayed(): ?bool
{
return $this->delayed;
}
public function setDelayed(?bool $delayed): self
{
$this->delayed = $delayed;
return $this;
}
public function isUrgent(): ?bool
{
return $this->urgent;
}
public function setUrgent(?bool $urgent): self
{
$this->urgent = $urgent;
return $this;
}
public function getPlannedFor(): ?DateTimeInterface
{
return $this->plannedFor;
}
public function setPlannedFor(?DateTimeInterface $plannedFor): self
{
$this->plannedFor = $plannedFor;
return $this;
}
public function getStartedOn(): ?DateTimeInterface
{
return $this->startedOn;
}
public function setStartedOn(?DateTimeInterface $startedOn): self
{
$this->startedOn = $startedOn;
return $this;
}
public function getCompletedOn(): ?DateTimeInterface
{
return $this->completedOn;
}
public function setCompletedOn(?DateTimeInterface $completedOn): self
{
$this->completedOn = $completedOn;
return $this;
}
public function getStatus(): ?TaskStatus
{
return $this->status;
}
public function setStatus(?TaskStatus $status): self
{
$this->status = $status;
return $this;
}
/**
* @return Collection<int, WorkOrder>
*/
public function getWorkOrders(): Collection
{
return $this->workOrders;
}
public function addWorkOrder(WorkOrder $workOrder): self
{
if (!$this->workOrders->contains($workOrder)) {
$this->workOrders[] = $workOrder;
}
return $this;
}
public function removeWorkOrder(WorkOrder $workOrder): self
{
$this->workOrders->removeElement($workOrder);
return $this;
}
/**
* @return Collection<int, ShippingPlan>
*/
public function getShippingPlans(): Collection
{
return $this->shippingPlans;
}
public function addShippingPlan(ShippingPlan $shippingPlans): self
{
if (!$this->shippingPlans->contains($shippingPlans)) {
$this->shippingPlans[] = $shippingPlans;
}
return $this;
}
public function removeShippingPlan(ShippingPlan $shippingPlans): self
{
$this->shippingPlans->removeElement($shippingPlans);
return $this;
}
/**
* @return Collection<int, ShippingSegment>
*/
public function getShippingSegments(): Collection
{
return $this->shippingSegments;
}
public function addShippingSegment(ShippingSegment $shippingSegment): self
{
if (!$this->shippingSegments->contains($shippingSegment)) {
$this->shippingSegments[] = $shippingSegment;
}
return $this;
}
public function removeShippingSegment(ShippingSegment $shippingSegment): self
{
$this->shippingSegments->removeElement($shippingSegment);
return $this;
}
public function getAssignee(): ?User
{
return $this->assignee;
}
public function setAssignee(?User $assignee): self
{
$this->assignee = $assignee;
return $this;
}
}