src/Entity/Kpi/KpiObjectifs.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Kpi;
  3. use App\Entity\Adherent\Magasin;
  4. use App\Repository\Kpi\KpiObjectifsRepository;
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Entity(repositoryClassKpiObjectifsRepository::class)]
  7. class KpiObjectifs
  8. {
  9.     #[ORM\Id]
  10.     #[ORM\GeneratedValue]
  11.     #[ORM\Column]
  12.     private ?int $id null;
  13.     #[ORM\Column(type'json')]
  14.     private array $objectifs = [];
  15.     #[ORM\Column(nullabletrue)]
  16.     private ?\DateTimeImmutable $created_at;
  17.     #[ORM\Column(nullabletrue)]
  18.     private ?\DateTimeImmutable $updated_at;
  19.     #[ORM\ManyToOne]
  20.     #[ORM\JoinColumn(name'magasin'referencedColumnName'k_adherent')]
  21.     private ?Magasin $magasin null;
  22.     #[ORM\OneToOne(inversedBy'objectifs'cascade: ['persist'])]
  23.     #[ORM\JoinColumn(nullablefalse)]
  24.     private ?KpiParameters $exercice;
  25.     public function __construct()
  26.     {
  27.         $this->created_at = new \DateTimeImmutable();
  28.     }
  29.     public function getId(): ?int
  30.     {
  31.         return $this->id;
  32.     }
  33.     public function getObjectifs(): ?array
  34.     {
  35.         return $this->objectifs;
  36.     }
  37.     public function setObjectifs(array $objectifs): self
  38.     {
  39.         $this->objectifs $objectifs;
  40.         return $this;
  41.     }
  42.     public function getCreatedAt(): ?\DateTimeImmutable
  43.     {
  44.         return $this->created_at;
  45.     }
  46.     public function setCreatedAt(?\DateTimeImmutable $created_at): static
  47.     {
  48.         $this->created_at $created_at;
  49.         return $this;
  50.     }
  51.     public function getUpdatedAt(): ?\DateTimeImmutable
  52.     {
  53.         return $this->updated_at;
  54.     }
  55.     public function setUpdatedAt(?\DateTimeImmutable $updated_at): static
  56.     {
  57.         $this->updated_at $updated_at;
  58.         return $this;
  59.     }
  60.     public function getMagasin(): ?Magasin
  61.     {
  62.         return $this->magasin;
  63.     }
  64.     public function setMagasin(?Magasin $magasin): void
  65.     {
  66.         $this->magasin $magasin;
  67.     }
  68.     public function getExercice(): ?KpiParameters
  69.     {
  70.         return $this->exercice;
  71.     }
  72.     public function setExercice(?KpiParameters $exercice): self
  73.     {
  74.         $this->exercice $exercice;
  75.         return $this;
  76.     }
  77.     public static function getDefaultObjectifs(\DateTimeInterface $startExercice\DateTimeInterface $endExercice): array
  78.     {
  79.         $objectifs = [];
  80.         $periode = new \DatePeriod(
  81.             $startExercice,
  82.             new \DateInterval('P1M'),
  83.             $endExercice
  84.         );
  85.         foreach ($periode as $date) {
  86.             $key $date->format('Ym');
  87.             $objectifs[$key] = 20000;
  88.         }
  89.         return $objectifs;
  90.     }
  91. }