src/Entity/ActionPlan.php line 82

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Doctrine\Orm\Filter\DateFilter;
  4. use ApiPlatform\Doctrine\Orm\Filter\SearchFilter;
  5. use ApiPlatform\Metadata\ApiFilter;
  6. use ApiPlatform\Metadata\ApiResource;
  7. use ApiPlatform\Metadata\Delete;
  8. use ApiPlatform\Metadata\Get;
  9. use ApiPlatform\Metadata\GetCollection;
  10. use ApiPlatform\Metadata\Post;
  11. use ApiPlatform\Metadata\Put;
  12. use App\Controller\Action\ActionPlansReportController;
  13. use App\Controller\Action\EvaluationAutoConformity;
  14. use App\Controller\Action\UploadFileApController;
  15. use App\Controller\ActionPlanController;
  16. use App\Filter\ActionPlanDateFilter;
  17. use App\Filter\ActionPlanSiteFilter;
  18. use App\Repository\ActionPlanRepository;
  19. use App\State\ActionPlanDeleteProcessor;
  20. use App\Traits\AutoTimestampTrait;
  21. use Doctrine\Common\Collections\ArrayCollection;
  22. use Doctrine\Common\Collections\Collection;
  23. use Doctrine\DBAL\Types\Types;
  24. use Doctrine\ORM\Mapping as ORM;
  25. use Symfony\Component\Serializer\Annotation\Groups;
  26. use ApiPlatform\Doctrine\Orm\Filter\RangeFilter;
  27. #[ORM\Entity(repositoryClassActionPlanRepository::class)]
  28. #[ApiResource(
  29.     operations: [
  30.         new GetCollection(),
  31.         new Post(
  32.             securityPostDenormalize"is_granted('CREATE', object) or user.isMasterAdmin()",
  33.         ),
  34.         new Get(),
  35.         new GetCollection(
  36.             name'_api_/action_plans_report',
  37.             uriTemplate'/action_plans_report',
  38.             controllerActionPlansReportController::class,
  39.             writefalse,
  40.             readfalse
  41.         ),
  42.         new Put(
  43.             name'_api_/action_plans{id}',
  44.             uriTemplate'/action_plans/{id}',
  45.             controllerEvaluationAutoConformity::class,
  46.             writefalse,
  47.             readfalse,
  48.             security"is_granted('EDIT', object) or user.isMasterAdmin()",
  49.         ),
  50.         new Delete(
  51.             processorActionPlanDeleteProcessor::class, security"is_granted('DELETE', object) or user.isMasterAdmin()"
  52.         ),
  53.         new Delete(
  54.             name'_api_/action_plans/clone/{action_plan_id}/{evaluation_id}',
  55.             uriTemplate'action_plans/clone/{action_plan_id}/{evaluation_id}',
  56.             controllerActionPlanController::class,
  57.             writefalse,
  58.             readfalsesecurity"is_granted('DELETE', object) or user.isMasterAdmin()"
  59.         )
  60.     ],
  61.     normalizationContext: ['groups' => ['plan.get']],
  62.     denormalizationContext: ['groups' => ['plan.write']],
  63.     order: ['id' => 'ASC'],
  64. )]
  65. #[ApiFilter(ActionPlanSiteFilter::class)]
  66. #[ApiFilter(
  67.     SearchFilter::class, properties: [
  68.     'site' => 'exact',
  69.     'title' => 'ipartial',
  70.     'priority' => 'exact',
  71.     'evaluation' => 'exact',
  72. ]
  73. )]
  74. #[ApiFilter(ActionPlanDateFilter::class)]
  75. #[ApiFilter(RangeFilter::class, properties: ['rateProgress'])]
  76. #[ApiFilter(DateFilter::class, properties: ['startDate''endDate''revisedEndDate'])]
  77. #[ORM\HasLifecycleCallbacks]
  78. class ActionPlan
  79. {
  80.     use AutoTimestampTrait;
  81.     #[ORM\Id]
  82.     #[ORM\GeneratedValue]
  83.     #[ORM\Column]
  84.     #[Groups(['plan.get''plan.write'])]
  85.     private ?int $id null;
  86.     #[ORM\Column(name'title'typeTypes::TEXT)]
  87.     #[Groups(['plan.get''plan.write'])]
  88.     private ?string $title null;
  89.     #[ORM\Column(length255nullabletrue)]
  90.     #[Groups(['plan.get''plan.write'])]
  91.     private ?string $reference null;
  92.     #[ORM\ManyToOne]
  93.     #[Groups(['plan.get''plan.write'])]
  94.     private ?Category $subDomain null;
  95.     #[ORM\Column(length255nullabletrue)]
  96.     #[Groups(['plan.get''plan.write'])]
  97.     private ?string $priority null;
  98.     #[ORM\Column(name'start_date'type'datetime')]
  99.     #[Groups(['plan.get''plan.write'])]
  100.     private $startDate;
  101.     #[ORM\Column(name'end_date'type'datetime')]
  102.     #[Groups(['plan.get''plan.write'])]
  103.     private $endDate;
  104.     #[ORM\Column(name'revised_end_date'type'datetime')]
  105.     #[Groups(['plan.get''plan.write'])]
  106.     private $revisedEndDate;
  107.     #[ORM\Column(type'datetime'nullabletrue)]
  108.     #[Groups(['plan.get''plan.write'])]
  109.     private $verificationDate;
  110.     #[ORM\ManyToOne]
  111.     #[Groups(['plan.get''plan.write'])]
  112.     private ?User $userPilot null;
  113.     #[ORM\ManyToOne]
  114.     #[Groups(['plan.get''plan.write'])]
  115.     private ?User $userInCharge null;
  116.     #[ORM\Column(length255nullabletrue)]
  117.     #[Groups(['plan.get''plan.write'])]
  118.     private ?string $typeProgression null;
  119.     #[ORM\Column(nullabletrue)]
  120.     #[Groups(['plan.get''plan.write'])]
  121.     private ?int $rateProgress null;
  122.     #[ORM\Column(nullabletrue)]
  123.     #[Groups(['plan.get''plan.write'])]
  124.     private ?int $periodicReminderTime null;
  125.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  126.     #[Groups(['plan.get''plan.write'])]
  127.     private ?string $others null;
  128.     #[ORM\Column(length255nullabletrue)]
  129.     #[Groups(['plan.get''plan.write'])]
  130.     private ?string $risksOpportunities null;
  131.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  132.     #[Groups(['plan.get''plan.write'])]
  133.     private ?string $verificationType null;
  134.     #[ORM\Column(name'comment'type'text'nullabletrue)]
  135.     #[Groups(['plan.get''plan.write'])]
  136.     private ?string $comment null;
  137.     #[ORM\ManyToOne]
  138.     #[Groups(['plan.get''plan.write'])]
  139.     private ?User $verifierUser null;
  140.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  141.     #[Groups(['plan.get''plan.write'])]
  142.     private ?string $financialResources null;
  143.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  144.     #[Groups(['plan.get''plan.write'])]
  145.     private ?string $operationalResource null;
  146.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  147.     #[Groups(['plan.get''plan.write'])]
  148.     private ?string $technologicalResources null;
  149.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  150.     #[Groups(['plan.get''plan.write'])]
  151.     private ?string $humainResources null;
  152.     #[ORM\ManyToOne]
  153.     #[Groups(['plan.get''plan.write'])]
  154.     private ?User $createdBy null;
  155.     #[ORM\ManyToOne]
  156.     #[Groups(['plan.get''plan.write'])]
  157.     private ?User $updatedBy null;
  158.     #[ORM\Column(nullabletrue)]
  159.     #[Groups(['plan.get''plan.write'])]
  160.     private ?bool $reminderFixed null;
  161.     #[ORM\Column(nullabletrue)]
  162.     #[Groups(['plan.get''plan.write'])]
  163.     private ?bool $reminderPeriodic null;
  164.     #[ORM\Column(nullabletrue)]
  165.     #[Groups(['plan.get''plan.write'])]
  166.     private ?int $reminderBeforeDeadline null;
  167.     #[ORM\ManyToOne]
  168.     #[ORM\JoinColumn(nullablefalse)]
  169.     #[Groups(['plan.get''plan.write'])]
  170.     private ?Site $site null;
  171.     #[ORM\OneToMany(mappedBy'actionPlan'targetEntityActionPlanTasks::class)]
  172.     #[Groups(['plan.get'])]
  173.     private Collection $actionPlanTasks;
  174.     #[ORM\OneToMany(mappedBy'actionPlan'targetEntityActionPlanComment::class)]
  175.     #[Groups(['plan.get'])]
  176.     private Collection $actionPlanComments;
  177.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  178.     #[Groups(['plan.get''plan.write'])]
  179.     private ?string $process null;
  180.     #[ORM\ManyToMany(targetEntityEvaluation::class, inversedBy'actionPlans'orphanRemovalfalsecascade: ['persist'])]
  181.     #[Groups(['plan.get''plan.write'])]
  182.     private Collection $evaluation;
  183.     #[ORM\Column(name'last_notification'type'datetime'nullabletrue)]
  184.     #[Groups(['plan.get''plan.write'])]
  185.     private $lastNotification null;
  186.     #[ORM\Column(length255nullabletrue)]
  187.     private ?string $oldId null;
  188.     #[ORM\ManyToOne(inversedBy'actionsPlanFile')]
  189.     #[Groups(['plan.get''plan.write'])]
  190.     private ?Media $action_plan_file null;
  191.     public function __construct()
  192.     {
  193.         $this->actionPlanTasks = new ArrayCollection();
  194.         $this->actionPlanComments = new ArrayCollection();
  195.         $this->evaluation = new ArrayCollection();
  196.     }
  197.     public function getId(): ?int
  198.     {
  199.         return $this->id;
  200.     }
  201.     public function getTitle(): ?string
  202.     {
  203.         return $this->title;
  204.     }
  205.     public function setTitle(string $title): self
  206.     {
  207.         $this->title $title;
  208.         return $this;
  209.     }
  210.     public function getReference(): ?string
  211.     {
  212.         return $this->reference;
  213.     }
  214.     public function setReference(?string $reference): self
  215.     {
  216.         $this->reference $reference;
  217.         return $this;
  218.     }
  219.     public function getSubDomain(): ?Category
  220.     {
  221.         return $this->subDomain;
  222.     }
  223.     public function setSubDomain(?Category $subDomain): self
  224.     {
  225.         $this->subDomain $subDomain;
  226.         return $this;
  227.     }
  228.     public function getPriority(): ?string
  229.     {
  230.         return $this->priority;
  231.     }
  232.     public function setPriority(string $priority): self
  233.     {
  234.         $this->priority $priority;
  235.         return $this;
  236.     }
  237.     public function getStartDate(): ?\DateTimeInterface
  238.     {
  239.         return $this->startDate;
  240.     }
  241.     public function setStartDate(\DateTimeInterface $startDate): self
  242.     {
  243.         $this->startDate $startDate;
  244.         return $this;
  245.     }
  246.     public function getEndDate(): ?\DateTimeInterface
  247.     {
  248.         return $this->endDate;
  249.     }
  250.     public function setEndDate(\DateTimeInterface $endDate): self
  251.     {
  252.         $this->endDate $endDate;
  253.         return $this;
  254.     }
  255.     public function getRevisedEndDate(): ?\DateTimeInterface
  256.     {
  257.         return $this->revisedEndDate;
  258.     }
  259.     public function setRevisedEndDate(\DateTimeInterface $revisedEndDate): self
  260.     {
  261.         $this->revisedEndDate $revisedEndDate;
  262.         return $this;
  263.     }
  264.     public function getVerificationDate(): ?\DateTimeInterface
  265.     {
  266.         return $this->verificationDate;
  267.     }
  268.     public function setVerificationDate(?\DateTimeInterface $verificationDate): self
  269.     {
  270.         $this->verificationDate $verificationDate;
  271.         return $this;
  272.     }
  273. //    public function getUpdatedAt(): ?\DateTimeInterface
  274. //    {
  275. //        return $this->updatedAt;
  276. //    }
  277. //
  278. //    public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  279. //    {
  280. //        $this->updatedAt = $updatedAt;
  281. //
  282. //        return $this;
  283. //    }
  284. //
  285. //    public function getCreatedAt(): ?\DateTimeInterface
  286. //    {
  287. //        return $this->createdAt;
  288. //    }
  289. //
  290. //    public function setCreatedAt(?\DateTimeInterface $createdAt): self
  291. //    {
  292. //        $this->createdAt = $createdAt;
  293. //
  294. //        return $this;
  295. //    }
  296.     public function getUserPilot(): ?User
  297.     {
  298.         return $this->userPilot;
  299.     }
  300.     public function setUserPilot(?User $userPilot): self
  301.     {
  302.         $this->userPilot $userPilot;
  303.         return $this;
  304.     }
  305.     public function getUserInCharge(): ?User
  306.     {
  307.         return $this->userInCharge;
  308.     }
  309.     public function setUserInCharge(?User $userInCharge): self
  310.     {
  311.         $this->userInCharge $userInCharge;
  312.         return $this;
  313.     }
  314.     public function getTypeProgression(): ?string
  315.     {
  316.         return $this->typeProgression;
  317.     }
  318.     public function setTypeProgression(string $typeProgression): self
  319.     {
  320.         $this->typeProgression $typeProgression;
  321.         return $this;
  322.     }
  323.     public function getRateProgress(): ?int
  324.     {
  325.         return $this->rateProgress;
  326.     }
  327.     public function setRateProgress(?int $rateProgress): self
  328.     {
  329.         $this->rateProgress $rateProgress;
  330.         return $this;
  331.     }
  332.     public function getPeriodicReminderTime(): ?int
  333.     {
  334.         return $this->periodicReminderTime;
  335.     }
  336.     public function setPeriodicReminderTime(?int $periodicReminderTime): self
  337.     {
  338.         $this->periodicReminderTime $periodicReminderTime;
  339.         return $this;
  340.     }
  341.     public function getOthers(): ?string
  342.     {
  343.         return $this->others;
  344.     }
  345.     public function setOthers(?string $others): self
  346.     {
  347.         $this->others $others;
  348.         return $this;
  349.     }
  350.     public function getRisksOpportunities(): ?string
  351.     {
  352.         return $this->risksOpportunities;
  353.     }
  354.     public function setRisksOpportunities(string $risksOpportunities): self
  355.     {
  356.         $this->risksOpportunities $risksOpportunities;
  357.         return $this;
  358.     }
  359.     public function getVerificationType(): ?string
  360.     {
  361.         return $this->verificationType;
  362.     }
  363.     public function setVerificationType(?string $verificationType): self
  364.     {
  365.         $this->verificationType $verificationType;
  366.         return $this;
  367.     }
  368.     public function getComment(): ?string
  369.     {
  370.         return $this->comment;
  371.     }
  372.     public function setComment(?string $comment): self
  373.     {
  374.         $this->comment $comment;
  375.         return $this;
  376.     }
  377.     public function getVerifierUser(): ?User
  378.     {
  379.         return $this->verifierUser;
  380.     }
  381.     public function setVerifierUser(?User $verifierUser): self
  382.     {
  383.         $this->verifierUser $verifierUser;
  384.         return $this;
  385.     }
  386.     public function getFinancialResources(): ?string
  387.     {
  388.         return $this->financialResources;
  389.     }
  390.     public function setFinancialResources(?string $financialResources): self
  391.     {
  392.         $this->financialResources $financialResources;
  393.         return $this;
  394.     }
  395.     public function getOperationalResource(): ?string
  396.     {
  397.         return $this->operationalResource;
  398.     }
  399.     public function setOperationalResource(?string $operationalResource): self
  400.     {
  401.         $this->operationalResource $operationalResource;
  402.         return $this;
  403.     }
  404.     public function getTechnologicalResources(): ?string
  405.     {
  406.         return $this->technologicalResources;
  407.     }
  408.     public function setTechnologicalResources(?string $technologicalResources): self
  409.     {
  410.         $this->technologicalResources $technologicalResources;
  411.         return $this;
  412.     }
  413.     public function getHumainResources(): ?string
  414.     {
  415.         return $this->humainResources;
  416.     }
  417.     public function setHumainResources(?string $humainResources): self
  418.     {
  419.         $this->humainResources $humainResources;
  420.         return $this;
  421.     }
  422.     public function getCreatedBy(): ?User
  423.     {
  424.         return $this->createdBy;
  425.     }
  426.     public function setCreatedBy(?User $createdBy): self
  427.     {
  428.         $this->createdBy $createdBy;
  429.         return $this;
  430.     }
  431.     public function getUpdatedBy(): ?User
  432.     {
  433.         return $this->updatedBy;
  434.     }
  435.     public function setUpdatedBy(?User $updatedBy): self
  436.     {
  437.         $this->updatedBy $updatedBy;
  438.         return $this;
  439.     }
  440.     public function isReminderFixed(): ?bool
  441.     {
  442.         return $this->reminderFixed;
  443.     }
  444.     public function setReminderFixed(?bool $reminderFixed): self
  445.     {
  446.         $this->reminderFixed $reminderFixed;
  447.         return $this;
  448.     }
  449.     public function isReminderPeriodic(): ?bool
  450.     {
  451.         return $this->reminderPeriodic;
  452.     }
  453.     public function setReminderPeriodic(?bool $reminderPeriodic): self
  454.     {
  455.         $this->reminderPeriodic $reminderPeriodic;
  456.         return $this;
  457.     }
  458.     public function getReminderBeforeDeadline(): ?int
  459.     {
  460.         return $this->reminderBeforeDeadline;
  461.     }
  462.     public function setReminderBeforeDeadline(?int $reminderBeforeDeadline): self
  463.     {
  464.         $this->reminderBeforeDeadline $reminderBeforeDeadline;
  465.         return $this;
  466.     }
  467.     public function getSite(): ?Site
  468.     {
  469.         return $this->site;
  470.     }
  471.     public function setSite(?Site $site): self
  472.     {
  473.         $this->site $site;
  474.         return $this;
  475.     }
  476.     /**
  477.      * @return Collection<int, ActionPlanTasks>
  478.      */
  479.     public function getActionPlanTasks(): Collection
  480.     {
  481.         return $this->actionPlanTasks;
  482.     }
  483.     public function addActionPlanTask(ActionPlanTasks $actionPlanTask): self
  484.     {
  485.         if (!$this->actionPlanTasks->contains($actionPlanTask)) {
  486.             $this->actionPlanTasks->add($actionPlanTask);
  487.             $actionPlanTask->setActionPlan($this);
  488.         }
  489.         return $this;
  490.     }
  491.     public function removeActionPlanTask(ActionPlanTasks $actionPlanTask): self
  492.     {
  493.         if ($this->actionPlanTasks->removeElement($actionPlanTask)) {
  494.             // set the owning side to null (unless already changed)
  495.             if ($actionPlanTask->getActionPlan() === $this) {
  496.                 $actionPlanTask->setActionPlan(null);
  497.             }
  498.         }
  499.         return $this;
  500.     }
  501.     /**
  502.      * @return Collection<int, ActionPlanComment>
  503.      */
  504.     public function getActionPlanComments(): Collection
  505.     {
  506.         return $this->actionPlanComments;
  507.     }
  508.     public function addActionPlanComment(ActionPlanComment $actionPlanComment): self
  509.     {
  510.         if (!$this->actionPlanComments->contains($actionPlanComment)) {
  511.             $this->actionPlanComments->add($actionPlanComment);
  512.             $actionPlanComment->setActionPlan($this);
  513.         }
  514.         return $this;
  515.     }
  516.     public function removeActionPlanComment(ActionPlanComment $actionPlanComment): self
  517.     {
  518.         if ($this->actionPlanComments->removeElement($actionPlanComment)) {
  519.             // set the owning side to null (unless already changed)
  520.             if ($actionPlanComment->getActionPlan() === $this) {
  521.                 $actionPlanComment->setActionPlan(null);
  522.             }
  523.         }
  524.         return $this;
  525.     }
  526.     public function getProcess(): ?string
  527.     {
  528.         return $this->process;
  529.     }
  530.     public function setProcess(?string $process): self
  531.     {
  532.         $this->process $process;
  533.         return $this;
  534.     }
  535.     /**
  536.      * @return Collection<int, Evaluation>
  537.      */
  538.     public function getEvaluation(): Collection
  539.     {
  540.         return $this->evaluation;
  541.     }
  542.     public function addEvaluation(Evaluation $evaluation): self
  543.     {
  544.         if (!$this->evaluation->contains($evaluation)) {
  545.             $this->evaluation->add($evaluation);
  546.         }
  547.         return $this;
  548.     }
  549.     public function removeEvaluation(Evaluation $evaluation): self
  550.     {
  551.         $this->evaluation->removeElement($evaluation);
  552.         return $this;
  553.     }
  554.     /**
  555.      * @return mixed
  556.      */
  557.     public function getLastNotification(): mixed
  558.     {
  559.         return $this->lastNotification;
  560.     }
  561.     /**
  562.      * @param mixed $lastNotification
  563.      */
  564.     public function setLastNotification($lastNotification): void
  565.     {
  566.         $this->lastNotification $lastNotification;
  567.     }
  568.     #[Groups(['plan.get'])]
  569.     public function getPathSite(): ?string
  570.     {
  571.         return $this->site->getPath()['full_path'] ?? '';
  572.     }
  573.     public function getOldId(): ?string
  574.     {
  575.         return $this->oldId;
  576.     }
  577.     public function setOldId(?string $oldId): self
  578.     {
  579.         $this->oldId $oldId;
  580.         return $this;
  581.     }
  582.     /**
  583.      * @return Media|null
  584.      */
  585.     public function getActionPlanFile(): ?Media
  586.     {
  587.         return $this->action_plan_file;
  588.     }
  589.     /**
  590.      * @param Media|null $action_plan_file
  591.      */
  592.     public function setActionPlanFile(?Media $action_plan_file): void
  593.     {
  594.         $this->action_plan_file $action_plan_file;
  595.     }
  596. }