src/Entity/ActionPlan.php line 86

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