<?phpnamespace App\Entity\Kpi;use App\Entity\Adherent\Magasin;use App\Repository\Kpi\KpiObjectifsRepository;use Doctrine\ORM\Mapping as ORM;#[ORM\Entity(repositoryClass: KpiObjectifsRepository::class)]class KpiObjectifs{ #[ORM\Id] #[ORM\GeneratedValue] #[ORM\Column] private ?int $id = null; #[ORM\Column(type: 'json')] private array $objectifs = []; #[ORM\Column(nullable: true)] private ?\DateTimeImmutable $created_at; #[ORM\Column(nullable: true)] private ?\DateTimeImmutable $updated_at; #[ORM\ManyToOne] #[ORM\JoinColumn(name: 'magasin', referencedColumnName: 'k_adherent')] private ?Magasin $magasin = null; #[ORM\OneToOne(inversedBy: 'objectifs', cascade: ['persist'])] #[ORM\JoinColumn(nullable: false)] private ?KpiParameters $exercice; public function __construct() { $this->created_at = new \DateTimeImmutable(); } public function getId(): ?int { return $this->id; } public function getObjectifs(): ?array { return $this->objectifs; } public function setObjectifs(array $objectifs): self { $this->objectifs = $objectifs; return $this; } public function getCreatedAt(): ?\DateTimeImmutable { return $this->created_at; } public function setCreatedAt(?\DateTimeImmutable $created_at): static { $this->created_at = $created_at; return $this; } public function getUpdatedAt(): ?\DateTimeImmutable { return $this->updated_at; } public function setUpdatedAt(?\DateTimeImmutable $updated_at): static { $this->updated_at = $updated_at; return $this; } public function getMagasin(): ?Magasin { return $this->magasin; } public function setMagasin(?Magasin $magasin): void { $this->magasin = $magasin; } public function getExercice(): ?KpiParameters { return $this->exercice; } public function setExercice(?KpiParameters $exercice): self { $this->exercice = $exercice; return $this; } public static function getDefaultObjectifs(\DateTimeInterface $startExercice, \DateTimeInterface $endExercice): array { $objectifs = []; $periode = new \DatePeriod( $startExercice, new \DateInterval('P1M'), $endExercice ); foreach ($periode as $date) { $key = $date->format('Ym'); $objectifs[$key] = 20000; } return $objectifs; }}