src/Entity/Rangements/Emplacement.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Rangements;
  3. use App\Entity\Articles\Article;
  4. use App\Entity\Inventaires\Inventaire;
  5. use App\Entity\Utilisateur\Utilisateur;
  6. use DateTime;
  7. use Doctrine\Common\Collections\ArrayCollection;
  8. use Doctrine\Common\Collections\Collection;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Gedmo\Mapping\Annotation as Gedmo;
  11. use Symfony\Component\Validator\Constraints as Assert;
  12. use Doctrine\ORM\Mapping\Index;
  13. /**
  14.  * Emplacement
  15.  *
  16.  * @ORM\Table("article__emplacement")
  17.  * @ORM\Entity(repositoryClass="App\Repository\Rangements\EmplacementRepository")
  18.  * @Gedmo\SoftDeleteable(fieldName="dateSuppression",timeAware=false)
  19.  * @ORM\HasLifecycleCallbacks()
  20.  */
  21. class Emplacement
  22. {
  23.     /**
  24.      * @ORM\Column(name="id", type="integer")
  25.      * @ORM\Id
  26.      * @ORM\GeneratedValue(strategy="AUTO")
  27.      */
  28.     private $id;
  29.     /**
  30.      * @ORM\ManyToOne(targetEntity="App\Entity\Utilisateur\Utilisateur", inversedBy="emplacements")
  31.      * @ORM\JoinColumn(nullable=true)
  32.      */
  33.     private $utilisateur;
  34.     /**
  35.      * @ORM\Column(name="ordre", type="integer", nullable=true)
  36.      * @Assert\NotBlank(message="Ordre obligatoire")
  37.      */
  38.     private $ordre;
  39.     /**
  40.      * @ORM\Column(name="statut", type="boolean", nullable=true)
  41.      */
  42.     private $defaut;
  43.     /**
  44.      * @ORM\Column(name="stock", type="float", nullable=true)
  45.      */
  46.     private $stock;
  47.     /**
  48.      * @ORM\Column(name="stockReserve", type="float", nullable=true)
  49.      */
  50.     private $stockReserve;
  51.     /**
  52.      * @ORM\ManyToOne(targetEntity="App\Entity\Articles\Article", inversedBy="emplacements")
  53.      * @ORM\JoinColumn(nullable=true)
  54.      */
  55.     private $article;
  56.     /**
  57.      * @ORM\ManyToOne(targetEntity="App\Entity\Rangements\NiveauUn", inversedBy="emplacements")
  58.      * @ORM\JoinColumn(nullable=true)
  59.      */
  60.     private $niveauUn;
  61.     /**
  62.      * @ORM\ManyToOne(targetEntity="App\Entity\Rangements\NiveauDeux", inversedBy="emplacements")
  63.      * @ORM\JoinColumn(nullable=true)
  64.      */
  65.     private $niveauDeux;
  66.     /**
  67.      * @ORM\ManyToOne(targetEntity="App\Entity\Rangements\NiveauTrois", inversedBy="emplacements")
  68.      * @ORM\JoinColumn(nullable=true)
  69.      */
  70.     private $niveauTrois;
  71.     /**
  72.      * @ORM\ManyToOne(targetEntity="App\Entity\Rangements\NiveauQuatre", inversedBy="emplacements")
  73.      * @ORM\JoinColumn(nullable=true)
  74.      */
  75.     private $niveauQuatre;
  76.     /**
  77.      * @ORM\OneToMany(targetEntity="App\Entity\Inventaires\Inventaire", mappedBy="emplacement")
  78.      */
  79.     private $inventaires;
  80.     /**
  81.      * @ORM\Column(name="libelle", type="string", length=255,nullable=true)
  82.      */
  83.     private $libelle;
  84.     /**
  85.      * @var boolean
  86.      *
  87.      * @ORM\Column(name="visibilite", type="boolean",nullable=true)
  88.      */
  89.     private $visibilite;
  90.     /**
  91.      * @ORM\Column(name="dateMaj", type="datetime", nullable=true)
  92.      */
  93.     private $dateMaj;
  94.     /**
  95.      * @ORM\Column(name="nouveau", type="boolean", nullable=true)
  96.      */
  97.     private $nouveau;
  98.     /**
  99.      * @ORM\Column(name="date_supression", type="datetime", nullable=true)
  100.      */
  101.     private $dateSuppression;
  102.     /**
  103.      * @ORM\Column(name="date_chgt_visibilite", type="datetime", nullable=true)
  104.      */
  105.     private $dateChgtVisibilite;
  106.     public function getId(): int
  107.     {
  108.         return $this->id;
  109.     }
  110.     public function setOrdre(?int $ordre): Emplacement
  111.     {
  112.         $this->ordre $ordre;
  113.         return $this;
  114.     }
  115.     public function getOrdre(): ?int
  116.     {
  117.         return $this->ordre;
  118.     }
  119.     public function setStock(?float $stock): Emplacement
  120.     {
  121.         $this->stock $stock;
  122.         return $this;
  123.     }
  124.     public function getStock(): ?float
  125.     {
  126.         return $this->stock;
  127.     }
  128.     public function setStockReserve(?float $stockReserve): Emplacement
  129.     {
  130.         $this->stockReserve $stockReserve;
  131.         return $this;
  132.     }
  133.     public function getStockReserve(): ?float
  134.     {
  135.         return $this->stockReserve;
  136.     }
  137.     public function setArticle(?Article $article): Emplacement
  138.     {
  139.         $this->article $article;
  140.         return $this;
  141.     }
  142.     public function getArticle(): ?Article
  143.     {
  144.         return $this->article;
  145.     }
  146.     public function setNiveauUn(?NiveauUn $niveauUn): Emplacement
  147.     {
  148.         $this->niveauUn $niveauUn;
  149.         $this->setLibelle2();
  150.         return $this;
  151.     }
  152.     public function getNiveauUn(): ?NiveauUn
  153.     {
  154.         return $this->niveauUn;
  155.     }
  156.     public function setNiveauDeux(?NiveauDeux $niveauDeux): Emplacement
  157.     {
  158.         $this->niveauDeux $niveauDeux;
  159.         $this->setLibelle2();
  160.         return $this;
  161.     }
  162.     public function getNiveauDeux(): ?NiveauDeux
  163.     {
  164.         return $this->niveauDeux;
  165.     }
  166.     public function setNiveauTrois(?NiveauTrois $niveauTrois): Emplacement
  167.     {
  168.         $this->niveauTrois $niveauTrois;
  169.         $this->setLibelle2();
  170.         return $this;
  171.     }
  172.     public function getNiveauTrois(): ?NiveauTrois
  173.     {
  174.         return $this->niveauTrois;
  175.     }
  176.     public function setNiveauQuatre(?NiveauQuatre $niveauQuatre): Emplacement
  177.     {
  178.         $this->niveauQuatre $niveauQuatre;
  179.         $this->setLibelle2();
  180.         return $this;
  181.     }
  182.     public function getNiveauQuatre(): ?NiveauQuatre
  183.     {
  184.         return $this->niveauQuatre;
  185.     }
  186.     public function setDefaut(?bool $defaut): Emplacement
  187.     {
  188.         $this->defaut $defaut;
  189.         return $this;
  190.     }
  191.     public function getDefaut(): ?bool
  192.     {
  193.         return $this->defaut;
  194.     }
  195.     public function setUtilisateur(?Utilisateur $utilisateur): Emplacement
  196.     {
  197.         $this->utilisateur $utilisateur;
  198.         return $this;
  199.     }
  200.     public function getUtilisateur(): ?Utilisateur
  201.     {
  202.         return $this->utilisateur;
  203.     }
  204.     /**
  205.      * @ORM\PrePersist
  206.      */
  207.     public function setLibelle2(): Emplacement
  208.     {
  209.         $libelle "";
  210.         if(is_object($this->getNiveauUn())) $libelle .= $this->getNiveauUn()->getLibelle();
  211.         if(is_object($this->getNiveauDeux())) $libelle .= "-".$this->getNiveauDeux()->getLibelle();
  212.         if(is_object($this->getNiveauTrois())) $libelle .= "-".$this->getNiveauTrois()->getLibelle();
  213.         if(is_object($this->getNiveauQuatre())) $libelle .= "-".$this->getNiveauQuatre()->getLibelle();
  214.         if($libelle == ""$this->libelle $this->getId();
  215.         else {
  216.             //$libelle .= "|";
  217.             $libelle .= "";
  218.             $libelle str_replace("||","",$libelle);
  219.             $this->libelle $libelle;
  220.         }
  221.         return $this;
  222.     }
  223.     public function setLibelle(?string $libelle): Emplacement
  224.     {
  225.         $this->libelle $libelle;
  226.         return $this;
  227.     }
  228.     public function getLibelle(): ?string
  229.     {
  230.         return $this->libelle;
  231.         /*
  232.         $libelle = str_replace("|","",$this->libelle);
  233.         return $libelle;
  234.         */
  235.     }
  236.     public function __construct()
  237.     {
  238.         $this->inventaires = new ArrayCollection();
  239.         $this->visibilite 1;
  240.     }
  241.     public function setDateMaj(?DateTime $dateMaj): Emplacement
  242.     {
  243.         $this->dateMaj $dateMaj;
  244.         return $this;
  245.     }
  246.     public function getDateMaj(): ?DateTime
  247.     {
  248.         return $this->dateMaj;
  249.     }
  250.     public function setNouveau(?bool $nouveau): Emplacement
  251.     {
  252.         $this->nouveau $nouveau;
  253.         return $this;
  254.     }
  255.     public function getNouveau(): ?bool
  256.     {
  257.         return $this->nouveau;
  258.     }
  259.     public function addInventaire(Inventaire $inventaire): Emplacement
  260.     {
  261.         $this->inventaires[] = $inventaire;
  262.         return $this;
  263.     }
  264.     public function removeInventaire(Inventaire $inventaire)
  265.     {
  266.         $this->inventaires->removeElement($inventaire);
  267.     }
  268.     public function getInventaires()
  269.     {
  270.         return $this->inventaires;
  271.     }
  272.     public function setVisibilite(?bool $visibilite): Emplacement
  273.     {
  274.         if($this->visibilite != $visibilite$this->setDateChgtVisibilite(new Datetime);
  275.         $this->visibilite $visibilite;
  276.         return $this;
  277.     }
  278.     public function getVisibilite(): ?bool
  279.     {
  280.         return $this->visibilite;
  281.     }
  282.     public function setDateSuppression(?DateTime $dateSuppression): Emplacement
  283.     {
  284.         $this->dateSuppression $dateSuppression;
  285.         return $this;
  286.     }
  287.     public function getDateSuppression(): ?DateTime
  288.     {
  289.         return $this->dateSuppression;
  290.     }
  291.     public function setDateChgtVisibilite(?DateTime $dateChgtVisibilite): Emplacement
  292.     {
  293.         $this->dateChgtVisibilite $dateChgtVisibilite;
  294.         return $this;
  295.     }
  296.     public function getDateChgtVisibilite(): ?DateTime
  297.     {
  298.         return $this->dateChgtVisibilite;
  299.     }
  300. }