src/Entity/Scheduler/Task.php line 34

  1. <?php
  2. namespace App\Entity\Scheduler;
  3. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  4. use ApiPlatform\Metadata\ApiFilter;
  5. use ApiPlatform\Metadata\ApiResource;
  6. use App\Doctrine\Type\Scheduler\TaskStatus;
  7. use App\Doctrine\Type\Scheduler\TaskType;
  8. use App\Entity\Common;
  9. use App\Entity\Expediting\ShippingPlan;
  10. use App\Entity\Expediting\ShippingSegment;
  11. use App\Entity\Identity\User;
  12. use App\Entity\Sales\WorkOrder;
  13. use App\Repository\Scheduler\TaskRepository;
  14. use App\Validator\IsValidEnum\IsValidEnum;
  15. use DateTimeInterface;
  16. use Doctrine\Common\Collections\ArrayCollection;
  17. use Doctrine\Common\Collections\Collection;
  18. use Doctrine\DBAL\Types\Types;
  19. use Doctrine\ORM\Mapping as ORM;
  20. use Gedmo\Mapping\Annotation as Gedmo;
  21. use Symfony\Component\Validator\Constraints as Assert;
  22. #[ORM\Table(name'task')]
  23. #[ORM\Index(columns: ['assignee_id'], name'task_assignee_id_idx')]
  24. #[ORM\Index(columns: ['created_by'], name'task_created_by_idx')]
  25. #[ORM\Index(columns: ['updated_by'], name'task_updated_by_idx')]
  26. #[ORM\Entity(repositoryClassTaskRepository::class)]
  27. #[ApiResource]
  28. #[ApiFilter(SearchFilter::class, properties: [
  29.     'type' => 'exact',
  30. ])]
  31. class Task
  32. {
  33.     use Common\Blameable;
  34.     use Common\Trackable;
  35.     #[ORM\Id]
  36.     #[ORM\GeneratedValue(strategy'IDENTITY')]
  37.     #[ORM\SequenceGenerator(sequenceName'task_id_seq')]
  38.     #[ORM\Column(typeTypes::INTEGER)]
  39.     private ?int $id null;
  40.     /** @var Collection<int, WorkOrder> */
  41.     #[ORM\ManyToMany(targetEntityWorkOrder::class, inversedBy'tasks')]
  42.     #[ORM\JoinTable(name'work_order_task_map')]
  43.     #[ORM\JoinColumn(name'task_id')]
  44.     #[ORM\InverseJoinColumn(name'work_order_id')]
  45.     private Collection $workOrders;
  46.     /** @var Collection<int, ShippingPlan> */
  47.     #[ORM\ManyToMany(targetEntityShippingPlan::class, inversedBy'tasks')]
  48.     #[ORM\JoinTable(name'expediting_shipping_plan_task_map')]
  49.     #[ORM\JoinColumn(name'task_id')]
  50.     #[ORM\InverseJoinColumn(name'shipping_plan_id')]
  51.     private Collection $shippingPlans;
  52.     /** @var Collection<int, ShippingSegment> */
  53.     #[ORM\ManyToMany(targetEntityShippingSegment::class, inversedBy'tasks')]
  54.     #[ORM\JoinTable(name'expediting_shipping_segment_task_map')]
  55.     #[ORM\JoinColumn(name'task_id')]
  56.     #[ORM\InverseJoinColumn(name'shipping_segment_id')]
  57.     private Collection $shippingSegments;
  58.     #[ORM\ManyToOne(targetEntityUser::class)]
  59.     #[ORM\JoinColumn(name'assignee_id')]
  60.     private ?User $assignee null;
  61.     #[Assert\NotNull]
  62.     #[Assert\Type(typeTypes::STRING)]
  63.     #[ORM\Column(typeTypes::STRING)]
  64.     private ?string $description null;
  65.     #[Assert\NotNull]
  66.     #[Assert\Type(typeTypes::STRING)]
  67.     #[ORM\Column(typeTypes::STRING)]
  68.     private ?string $entity null;
  69.     #[Assert\NotNull]
  70.     #[Assert\Type(typeTypes::INTEGER)]
  71.     #[ORM\Column(typeTypes::INTEGER)]
  72.     private ?int $entityId null;
  73.     #[Assert\NotNull]
  74.     #[IsValidEnum(enumTaskType::class)]
  75.     #[ORM\Column(typeTypes::STRINGenumTypeTaskType::class)]
  76.     private ?TaskType $type null;
  77.     #[Assert\Type(typeTypes::BOOLEAN)]
  78.     #[ORM\Column(typeTypes::BOOLEANoptions: ['default' => false])]
  79.     private bool $isProgressive false;
  80.     #[Assert\Type(typeTypes::BOOLEAN)]
  81.     #[ORM\Column(typeTypes::BOOLEANoptions: ['default' => false])]
  82.     private bool $isAction false;
  83.     #[Assert\Type(typeTypes::BOOLEAN)]
  84.     #[ORM\Column(typeTypes::BOOLEANoptions: ['default' => false])]
  85.     private bool $delayed false;
  86.     #[Assert\Type(typeTypes::BOOLEAN)]
  87.     #[ORM\Column(typeTypes::BOOLEANoptions: ['default' => false])]
  88.     private bool $urgent false;
  89.     #[Assert\Type(typeDateTimeInterface::class)]
  90.     #[ORM\Column(typeTypes::DATETIMETZ_MUTABLE)]
  91.     private ?DateTimeInterface $plannedFor null;
  92.     #[Assert\Type(typeDateTimeInterface::class)]
  93.     #[ORM\Column(typeTypes::DATETIMETZ_MUTABLEnullabletrue)]
  94.     private ?DateTimeInterface $startedOn null;
  95.     #[Assert\Type(typeDateTimeInterface::class)]
  96.     #[ORM\Column(typeTypes::DATETIMETZ_MUTABLEnullabletrue)]
  97.     private ?DateTimeInterface $completedOn null;
  98.     #[Assert\NotNull]
  99.     #[IsValidEnum(enumTaskStatus::class)]
  100.     #[ORM\Column(typeTypes::STRINGenumTypeTaskStatus::class, options: ['default' => 'PLANNED'])]
  101.     private TaskStatus $status TaskStatus::PLANNED;
  102.     #[Gedmo\Blameable(on'create')]
  103.     #[ORM\ManyToOne(targetEntityUser::class)]
  104.     #[ORM\JoinColumn(name'created_by'nullabletrue)]
  105.     protected ?User $createdBy null;
  106.     public function __construct()
  107.     {
  108.         $this->workOrders = new ArrayCollection();
  109.         $this->shippingPlans = new ArrayCollection();
  110.         $this->shippingSegments = new ArrayCollection();
  111.     }
  112.     public function getId(): ?int
  113.     {
  114.         return $this->id;
  115.     }
  116.     public function getDescription(): ?string
  117.     {
  118.         return $this->description;
  119.     }
  120.     public function setDescription(string $description): self
  121.     {
  122.         $this->description $description;
  123.         return $this;
  124.     }
  125.     public function getEntity(): ?string
  126.     {
  127.         return $this->entity;
  128.     }
  129.     public function setEntity(string $entity): self
  130.     {
  131.         $this->entity $entity;
  132.         return $this;
  133.     }
  134.     public function getEntityId(): ?int
  135.     {
  136.         return $this->entityId;
  137.     }
  138.     public function setEntityId(?int $entityId): self
  139.     {
  140.         $this->entityId $entityId;
  141.         return $this;
  142.     }
  143.     public function getType(): ?TaskType
  144.     {
  145.         return $this->type;
  146.     }
  147.     public function setType(?TaskType $type): self
  148.     {
  149.         $this->type $type;
  150.         return $this;
  151.     }
  152.     public function isIsProgressive(): ?bool
  153.     {
  154.         return $this->isProgressive;
  155.     }
  156.     public function setIsProgressive(?bool $isProgressive): self
  157.     {
  158.         $this->isProgressive $isProgressive;
  159.         return $this;
  160.     }
  161.     public function isIsAction(): ?bool
  162.     {
  163.         return $this->isAction;
  164.     }
  165.     public function setIsAction(?bool $isAction): self
  166.     {
  167.         $this->isAction $isAction;
  168.         return $this;
  169.     }
  170.     public function isDelayed(): ?bool
  171.     {
  172.         return $this->delayed;
  173.     }
  174.     public function setDelayed(?bool $delayed): self
  175.     {
  176.         $this->delayed $delayed;
  177.         return $this;
  178.     }
  179.     public function isUrgent(): ?bool
  180.     {
  181.         return $this->urgent;
  182.     }
  183.     public function setUrgent(?bool $urgent): self
  184.     {
  185.         $this->urgent $urgent;
  186.         return $this;
  187.     }
  188.     public function getPlannedFor(): ?DateTimeInterface
  189.     {
  190.         return $this->plannedFor;
  191.     }
  192.     public function setPlannedFor(?DateTimeInterface $plannedFor): self
  193.     {
  194.         $this->plannedFor $plannedFor;
  195.         return $this;
  196.     }
  197.     public function getStartedOn(): ?DateTimeInterface
  198.     {
  199.         return $this->startedOn;
  200.     }
  201.     public function setStartedOn(?DateTimeInterface $startedOn): self
  202.     {
  203.         $this->startedOn $startedOn;
  204.         return $this;
  205.     }
  206.     public function getCompletedOn(): ?DateTimeInterface
  207.     {
  208.         return $this->completedOn;
  209.     }
  210.     public function setCompletedOn(?DateTimeInterface $completedOn): self
  211.     {
  212.         $this->completedOn $completedOn;
  213.         return $this;
  214.     }
  215.     public function getStatus(): ?TaskStatus
  216.     {
  217.         return $this->status;
  218.     }
  219.     public function setStatus(?TaskStatus $status): self
  220.     {
  221.         $this->status $status;
  222.         return $this;
  223.     }
  224.     /**
  225.      * @return Collection<int, WorkOrder>
  226.      */
  227.     public function getWorkOrders(): Collection
  228.     {
  229.         return $this->workOrders;
  230.     }
  231.     public function addWorkOrder(WorkOrder $workOrder): self
  232.     {
  233.         if (!$this->workOrders->contains($workOrder)) {
  234.             $this->workOrders[] = $workOrder;
  235.         }
  236.         return $this;
  237.     }
  238.     public function removeWorkOrder(WorkOrder $workOrder): self
  239.     {
  240.         $this->workOrders->removeElement($workOrder);
  241.         return $this;
  242.     }
  243.     /**
  244.      * @return Collection<int, ShippingPlan>
  245.      */
  246.     public function getShippingPlans(): Collection
  247.     {
  248.         return $this->shippingPlans;
  249.     }
  250.     public function addShippingPlan(ShippingPlan $shippingPlans): self
  251.     {
  252.         if (!$this->shippingPlans->contains($shippingPlans)) {
  253.             $this->shippingPlans[] = $shippingPlans;
  254.         }
  255.         return $this;
  256.     }
  257.     public function removeShippingPlan(ShippingPlan $shippingPlans): self
  258.     {
  259.         $this->shippingPlans->removeElement($shippingPlans);
  260.         return $this;
  261.     }
  262.     /**
  263.      * @return Collection<int, ShippingSegment>
  264.      */
  265.     public function getShippingSegments(): Collection
  266.     {
  267.         return $this->shippingSegments;
  268.     }
  269.     public function addShippingSegment(ShippingSegment $shippingSegment): self
  270.     {
  271.         if (!$this->shippingSegments->contains($shippingSegment)) {
  272.             $this->shippingSegments[] = $shippingSegment;
  273.         }
  274.         return $this;
  275.     }
  276.     public function removeShippingSegment(ShippingSegment $shippingSegment): self
  277.     {
  278.         $this->shippingSegments->removeElement($shippingSegment);
  279.         return $this;
  280.     }
  281.     public function getAssignee(): ?User
  282.     {
  283.         return $this->assignee;
  284.     }
  285.     public function setAssignee(?User $assignee): self
  286.     {
  287.         $this->assignee $assignee;
  288.         return $this;
  289.     }
  290. }