<?php
namespace App\Entity;
use App\Repository\SuiviConsoActivationRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=SuiviConsoActivationRepository::class)
*
*/
class SuiviConsoActivation implements PostAwareInterface
{
const UNITIES = [
'm<sup>3</sup>' => 'm3',
'L' => 'L'
];
const PERIODICITIES = [
'Par heure' => 'hour',
'Par jour' => 'day',
'Par semaine' => 'week',
'Par mois' => 'month'
];
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="suiviConsoActivations")
* @ORM\JoinColumn(nullable=false)
*/
private $customer;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $contractNumber;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $postNumber;
/**
* @ORM\Column(type="boolean")
*/
private $activated;
/**
* @ORM\Column(type="boolean", nullable=true)
* @Assert\Expression(
* "value == false or this.getActivated() == true",
* message="Cannot activate the alert if the detail is not activated"
* )
*/
private $alertToggle;
/**
* @ORM\Column(type="string", length=2, nullable=true)
* @Assert\Choice (choices=SuiviConsoActivation::UNITIES, message="Choose a valid unity")
*/
private $preferedUnity;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $threshold;
/**
* @ORM\Column(type="string", length=5, nullable=true)
* @Assert\Choice (choices=SuiviConsoActivation::PERIODICITIES, message="Choose a valid periodicity")
*/
private $periodicity;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $activationDate;
public function getId(): ?int
{
return $this->id;
}
public function getCustomer(): ?User
{
return $this->customer;
}
public function setCustomer(?User $customer): self
{
$this->customer = $customer;
return $this;
}
public function getContractNumber(): ?string
{
return $this->contractNumber;
}
public function setContractNumber(?string $contractNumber): self
{
$this->contractNumber = $contractNumber;
return $this;
}
public function getPostNumber(): ?string
{
return $this->postNumber;
}
public function setPostNumber(?string $postNumber): self
{
$this->postNumber = $postNumber;
return $this;
}
public function getActivated(): ?bool
{
return $this->activated;
}
public function setActivated(bool $activated): self
{
$this->activated = $activated;
return $this;
}
public function getAlertToggle(): ?bool
{
return $this->alertToggle;
}
public function setAlertToggle(?bool $alertToggle): self
{
$this->alertToggle = $alertToggle;
return $this;
}
public function getPreferedUnity(): ?string
{
return $this->preferedUnity;
}
public function setPreferedUnity(?string $preferedUnity): self
{
$this->preferedUnity = $preferedUnity;
return $this;
}
/**
* @return null|float Alert activation threshold, in m3
*/
public function getThreshold(): ?float
{
return $this->threshold;
}
public function setThreshold(?float $threshold): self
{
$this->threshold = $threshold;
return $this;
}
public function getPeriodicity(): ?string
{
return $this->periodicity;
}
public function setPeriodicity(?string $periodicity): self
{
$this->periodicity = $periodicity;
return $this;
}
public function getActivationDate(): ?\DateTime
{
return $this->activationDate;
}
public function setActivationDate (?\DateTime $activationDate): self
{
$this->activationDate = $activationDate;
return $this;
}
}