<?php
namespace App\Entity;
use App\Repository\ProduitRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Entity(repositoryClass: ProduitRepository::class)]
class Produit
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(length: 255)]
#[Assert\NotBlank(message: 'Le nom du produit est obligatoire')]
#[Assert\Length(min: 2, max: 255, minMessage: 'Le nom doit faire au moins {{ limit }} caractères', maxMessage: 'Le nom ne peut pas dépasser {{ limit }} caractères')]
private ?string $Nom = null;
#[ORM\Column(length: 255, nullable: true)]
#[Assert\Length(max: 255, maxMessage: 'La description ne peut pas dépasser {{ limit }} caractères')]
private ?string $Description = null;
#[ORM\Column(type: Types::DECIMAL, precision: 10, scale: 2)]
#[Assert\PositiveOrZero(message: 'Le prix unitaire doit être positif ou zéro')]
private ?string $prixUnitaire = '0';
#[ORM\Column(type: Types::DECIMAL, precision: 10, scale: 2)]
#[Assert\PositiveOrZero(message: 'La quantité totale doit être positive ou zéro')]
private ?string $quantiteTotale = '0';
#[ORM\Column(type: Types::DECIMAL, precision: 10, scale: 2)]
#[Assert\PositiveOrZero(message: 'La quantité d\'alerte doit être positive ou zéro')]
private ?string $quantiteAlerte = '0';
#[ORM\ManyToOne(inversedBy: 'produits')]
#[ORM\JoinColumn(nullable: false)]
#[Assert\NotNull(message: 'La catégorie est obligatoire')]
private ?Categorie $categorie = null;
#[ORM\OneToMany(mappedBy: 'produit', targetEntity: EntreeStock::class)]
private Collection $entreeStocks;
#[ORM\OneToMany(mappedBy: 'produit', targetEntity: SortieStock::class)]
private Collection $sortieStocks;
#[ORM\ManyToOne(inversedBy: 'produits')]
#[ORM\JoinColumn(nullable: true, onDelete: 'SET NULL')]
private ?User $utilisateur = null;
#[ORM\Column(length: 255, nullable: true)]
#[Assert\Length(max: 255, maxMessage: 'Le code-barres ne peut pas dépasser {{ limit }} caractères')]
private ?string $codeBar = null;
#[ORM\Column(type: Types::DECIMAL, precision: 10, scale: 2, nullable: true)]
#[Assert\PositiveOrZero(message: 'La quantité de production doit être positive ou zéro')]
private ?string $quantitePr = null;
#[ORM\Column(type: Types::DECIMAL, precision: 10, scale: 2, nullable: true)]
#[Assert\PositiveOrZero(message: 'Le coût doit être positif ou zéro')]
private ?string $cout = null;
#[ORM\Column(length: 255, nullable: true)]
#[Assert\Length(max: 255, maxMessage: 'Le numéro de lot ne peut pas dépasser {{ limit }} caractères')]
private ?string $numeroLot = null;
#[ORM\Column(type: Types::DATETIME_MUTABLE, nullable: true)]
private ?\DateTimeInterface $datePeremption = null;
#[ORM\Column(length: 255, nullable: true)]
#[Assert\Length(max: 255, maxMessage: 'L\'unité de mesure ne peut pas dépasser {{ limit }} caractères')]
private ?string $uniteMesure = null;
#[ORM\OneToMany(mappedBy: 'produits', targetEntity: MenuProduit::class)]
private Collection $menuProduits;
public function __construct()
{
$this->prixUnitaire = '0';
$this->quantiteAlerte = '0';
$this->entreeStocks = new ArrayCollection();
$this->sortieStocks = new ArrayCollection();
$this->menuProduits = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getNom(): ?string
{
return $this->Nom;
}
public function setNom(string $Nom): static
{
$this->Nom = $Nom;
return $this;
}
public function getDescription(): ?string
{
return $this->Description;
}
public function setDescription(string $Description): static
{
$this->Description = $Description;
return $this;
}
public function getPrixUnitaire(): ?string
{
return $this->prixUnitaire;
}
public function setPrixUnitaire(string $prixUnitaire): static
{
$this->prixUnitaire = $prixUnitaire;
return $this;
}
public function getQuantiteTotale(): ?string
{
return $this->quantiteTotale;
}
public function setQuantiteTotale(string $quantiteTotale): static
{
$this->quantiteTotale = $quantiteTotale;
return $this;
}
public function getQuantiteAlerte(): ?string
{
return $this->quantiteAlerte;
}
public function setQuantiteAlerte(string $quantiteAlerte): static
{
$this->quantiteAlerte = $quantiteAlerte;
return $this;
}
public function getCategorie(): ?Categorie
{
return $this->categorie;
}
public function setCategorie(?Categorie $categorie): static
{
$this->categorie = $categorie;
return $this;
}
public function getEntreeStocks(): Collection
{
return $this->entreeStocks;
}
public function addEntreeStock(EntreeStock $entreeStock): static
{
if (!$this->entreeStocks->contains($entreeStock)) {
$this->entreeStocks->add($entreeStock);
$entreeStock->setProduit($this);
}
return $this;
}
public function removeEntreeStock(EntreeStock $entreeStock): static
{
if ($this->entreeStocks->removeElement($entreeStock)) {
if ($entreeStock->getProduit() === $this) {
$entreeStock->setProduit(null);
}
}
return $this;
}
public function getSortieStocks(): Collection
{
return $this->sortieStocks;
}
public function addSortieStock(SortieStock $sortieStock): static
{
if (!$this->sortieStocks->contains($sortieStock)) {
$this->sortieStocks->add($sortieStock);
$sortieStock->setProduit($this);
}
return $this;
}
public function removeSortieStock(SortieStock $sortieStock): static
{
if ($this->sortieStocks->removeElement($sortieStock)) {
if ($sortieStock->getProduit() === $this) {
$sortieStock->setProduit(null);
}
}
return $this;
}
public function getUtilisateur(): ?User
{
return $this->utilisateur;
}
public function setUtilisateur(?User $utilisateur): static
{
$this->utilisateur = $utilisateur;
return $this;
}
public function getCodeBar(): ?string
{
return $this->codeBar;
}
public function setCodeBar(?string $codeBar): static
{
$this->codeBar = $codeBar;
return $this;
}
public function getQuantitePr(): ?string
{
return $this->quantitePr;
}
public function setQuantitePr(?string $quantitePr): static
{
$this->quantitePr = $quantitePr;
return $this;
}
public function getCout(): ?string
{
return $this->cout;
}
public function setCout(?string $cout): static
{
$this->cout = $cout;
return $this;
}
public function getNumeroLot(): ?string
{
return $this->numeroLot;
}
public function setNumeroLot(?string $numeroLot): static
{
$this->numeroLot = $numeroLot;
return $this;
}
public function getDatePeremption(): ?\DateTimeInterface
{
return $this->datePeremption;
}
public function setDatePeremption(?\DateTimeInterface $datePeremption): static
{
$this->datePeremption = $datePeremption;
return $this;
}
public function getUniteMesure(): ?string
{
return $this->uniteMesure;
}
public function setUniteMesure(?string $uniteMesure): static
{
$this->uniteMesure = $uniteMesure;
return $this;
}
public function getMenuProduits(): Collection
{
return $this->menuProduits;
}
public function addMenuProduit(MenuProduit $menuProduit): static
{
if (!$this->menuProduits->contains($menuProduit)) {
$this->menuProduits->add($menuProduit);
$menuProduit->setProduits($this);
}
return $this;
}
public function removeMenuProduit(MenuProduit $menuProduit): static
{
if ($this->menuProduits->removeElement($menuProduit)) {
if ($menuProduit->getProduits() === $this) {
$menuProduit->setProduits(null);
}
}
return $this;
}
}