<?php
namespace App\Entity\Rangements;
use App\Entity\Articles\Article;
use App\Entity\Inventaires\Inventaire;
use App\Entity\Utilisateur\Utilisateur;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping\Index;
/**
* Emplacement
*
* @ORM\Table("article__emplacement")
* @ORM\Entity(repositoryClass="App\Repository\Rangements\EmplacementRepository")
* @Gedmo\SoftDeleteable(fieldName="dateSuppression",timeAware=false)
* @ORM\HasLifecycleCallbacks()
*/
class Emplacement
{
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Utilisateur\Utilisateur", inversedBy="emplacements")
* @ORM\JoinColumn(nullable=true)
*/
private $utilisateur;
/**
* @ORM\Column(name="ordre", type="integer", nullable=true)
* @Assert\NotBlank(message="Ordre obligatoire")
*/
private $ordre;
/**
* @ORM\Column(name="statut", type="boolean", nullable=true)
*/
private $defaut;
/**
* @ORM\Column(name="stock", type="float", nullable=true)
*/
private $stock;
/**
* @ORM\Column(name="stockReserve", type="float", nullable=true)
*/
private $stockReserve;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Articles\Article", inversedBy="emplacements")
* @ORM\JoinColumn(nullable=true)
*/
private $article;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Rangements\NiveauUn", inversedBy="emplacements")
* @ORM\JoinColumn(nullable=true)
*/
private $niveauUn;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Rangements\NiveauDeux", inversedBy="emplacements")
* @ORM\JoinColumn(nullable=true)
*/
private $niveauDeux;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Rangements\NiveauTrois", inversedBy="emplacements")
* @ORM\JoinColumn(nullable=true)
*/
private $niveauTrois;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Rangements\NiveauQuatre", inversedBy="emplacements")
* @ORM\JoinColumn(nullable=true)
*/
private $niveauQuatre;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Inventaires\Inventaire", mappedBy="emplacement")
*/
private $inventaires;
/**
* @ORM\Column(name="libelle", type="string", length=255,nullable=true)
*/
private $libelle;
/**
* @var boolean
*
* @ORM\Column(name="visibilite", type="boolean",nullable=true)
*/
private $visibilite;
/**
* @ORM\Column(name="dateMaj", type="datetime", nullable=true)
*/
private $dateMaj;
/**
* @ORM\Column(name="nouveau", type="boolean", nullable=true)
*/
private $nouveau;
/**
* @ORM\Column(name="date_supression", type="datetime", nullable=true)
*/
private $dateSuppression;
/**
* @ORM\Column(name="date_chgt_visibilite", type="datetime", nullable=true)
*/
private $dateChgtVisibilite;
public function getId(): int
{
return $this->id;
}
public function setOrdre(?int $ordre): Emplacement
{
$this->ordre = $ordre;
return $this;
}
public function getOrdre(): ?int
{
return $this->ordre;
}
public function setStock(?float $stock): Emplacement
{
$this->stock = $stock;
return $this;
}
public function getStock(): ?float
{
return $this->stock;
}
public function setStockReserve(?float $stockReserve): Emplacement
{
$this->stockReserve = $stockReserve;
return $this;
}
public function getStockReserve(): ?float
{
return $this->stockReserve;
}
public function setArticle(?Article $article): Emplacement
{
$this->article = $article;
return $this;
}
public function getArticle(): ?Article
{
return $this->article;
}
public function setNiveauUn(?NiveauUn $niveauUn): Emplacement
{
$this->niveauUn = $niveauUn;
$this->setLibelle2();
return $this;
}
public function getNiveauUn(): ?NiveauUn
{
return $this->niveauUn;
}
public function setNiveauDeux(?NiveauDeux $niveauDeux): Emplacement
{
$this->niveauDeux = $niveauDeux;
$this->setLibelle2();
return $this;
}
public function getNiveauDeux(): ?NiveauDeux
{
return $this->niveauDeux;
}
public function setNiveauTrois(?NiveauTrois $niveauTrois): Emplacement
{
$this->niveauTrois = $niveauTrois;
$this->setLibelle2();
return $this;
}
public function getNiveauTrois(): ?NiveauTrois
{
return $this->niveauTrois;
}
public function setNiveauQuatre(?NiveauQuatre $niveauQuatre): Emplacement
{
$this->niveauQuatre = $niveauQuatre;
$this->setLibelle2();
return $this;
}
public function getNiveauQuatre(): ?NiveauQuatre
{
return $this->niveauQuatre;
}
public function setDefaut(?bool $defaut): Emplacement
{
$this->defaut = $defaut;
return $this;
}
public function getDefaut(): ?bool
{
return $this->defaut;
}
public function setUtilisateur(?Utilisateur $utilisateur): Emplacement
{
$this->utilisateur = $utilisateur;
return $this;
}
public function getUtilisateur(): ?Utilisateur
{
return $this->utilisateur;
}
/**
* @ORM\PrePersist
*/
public function setLibelle2(): Emplacement
{
$libelle = "";
if(is_object($this->getNiveauUn())) $libelle .= $this->getNiveauUn()->getLibelle();
if(is_object($this->getNiveauDeux())) $libelle .= "-".$this->getNiveauDeux()->getLibelle();
if(is_object($this->getNiveauTrois())) $libelle .= "-".$this->getNiveauTrois()->getLibelle();
if(is_object($this->getNiveauQuatre())) $libelle .= "-".$this->getNiveauQuatre()->getLibelle();
if($libelle == "") $this->libelle = $this->getId();
else {
//$libelle .= "|";
$libelle .= "";
$libelle = str_replace("||","",$libelle);
$this->libelle = $libelle;
}
return $this;
}
public function setLibelle(?string $libelle): Emplacement
{
$this->libelle = $libelle;
return $this;
}
public function getLibelle(): ?string
{
return $this->libelle;
/*
$libelle = str_replace("|","",$this->libelle);
return $libelle;
*/
}
public function __construct()
{
$this->inventaires = new ArrayCollection();
$this->visibilite = 1;
}
public function setDateMaj(?DateTime $dateMaj): Emplacement
{
$this->dateMaj = $dateMaj;
return $this;
}
public function getDateMaj(): ?DateTime
{
return $this->dateMaj;
}
public function setNouveau(?bool $nouveau): Emplacement
{
$this->nouveau = $nouveau;
return $this;
}
public function getNouveau(): ?bool
{
return $this->nouveau;
}
public function addInventaire(Inventaire $inventaire): Emplacement
{
$this->inventaires[] = $inventaire;
return $this;
}
public function removeInventaire(Inventaire $inventaire)
{
$this->inventaires->removeElement($inventaire);
}
public function getInventaires()
{
return $this->inventaires;
}
public function setVisibilite(?bool $visibilite): Emplacement
{
if($this->visibilite != $visibilite) $this->setDateChgtVisibilite(new Datetime);
$this->visibilite = $visibilite;
return $this;
}
public function getVisibilite(): ?bool
{
return $this->visibilite;
}
public function setDateSuppression(?DateTime $dateSuppression): Emplacement
{
$this->dateSuppression = $dateSuppression;
return $this;
}
public function getDateSuppression(): ?DateTime
{
return $this->dateSuppression;
}
public function setDateChgtVisibilite(?DateTime $dateChgtVisibilite): Emplacement
{
$this->dateChgtVisibilite = $dateChgtVisibilite;
return $this;
}
public function getDateChgtVisibilite(): ?DateTime
{
return $this->dateChgtVisibilite;
}
}