src/Entity/StockMvt.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use DateTime;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use JsonSerializable;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. /**
  8.  * StockMvt
  9.  *
  10.  * @ORM\Table(name="stock_mvt")
  11.  * @ORM\Entity(repositoryClass="App\Repository\StockMvtRepository")
  12.  */
  13. class StockMvt implements JsonSerializable
  14. {
  15.     const AJOUT 1;
  16.     const RETRAIT 2;
  17.     const INVENTAIRE 3;
  18.     const REASSORT 4;
  19.     /**
  20.      * @var int
  21.      *
  22.      * @ORM\Column(name="id", type="integer")
  23.      * @ORM\Id
  24.      * @ORM\GeneratedValue(strategy="AUTO")
  25.      */
  26.     private $id;
  27.     /**
  28.      * @var int
  29.      *
  30.      * @ORM\Column(name="typeMvt", type="integer")
  31.      */
  32.     private $typeMvt;
  33.     /**
  34.      * @var int
  35.      *
  36.      * @ORM\Column(name="qte", type="integer")
  37.      * @Assert\Range(max=1000000000,notInRangeMessage="La quantité doit être inférieure à {{ max }}")]
  38.      */
  39.     private $qte;
  40.     /**
  41.      * @var string
  42.      *
  43.      * @ORM\Column(name="commentaire", type="text", nullable=true)
  44.      */
  45.     private $commentaire;
  46.     /**
  47.      * @var DateTime
  48.      *
  49.      * @ORM\Column(name="createdAt", type="datetime")
  50.      */
  51.     private $createdAt;
  52.     
  53.      /**
  54.      * 
  55.      * @ORM\ManyToOne(targetEntity="App\Entity\TypeStock")
  56.      * @ORM\JoinColumn(nullable=false)
  57.      */ 
  58.     protected $typestock;
  59.     
  60.      /**
  61.      * 
  62.      * @ORM\ManyToOne(targetEntity="App\Entity\Article")
  63.      * @ORM\JoinColumn(nullable=false)
  64.      */ 
  65.     protected $article;
  66.     /**
  67.      * @var DateTime
  68.      * @ORM\Column(name="dateReassort", type="datetime", nullable=true)
  69.      */
  70.     protected $dateReassort;
  71.     /**
  72.      * Get id
  73.      *
  74.      * @return int
  75.      */
  76.     public function getId()
  77.     {
  78.         return $this->id;
  79.     }
  80.     /**
  81.      * Set typeMvt
  82.      *
  83.      * @param integer $typeMvt
  84.      *
  85.      * @return StockMvt
  86.      */
  87.     public function setTypeMvt($typeMvt)
  88.     {
  89.         $this->typeMvt $typeMvt;
  90.         return $this;
  91.     }
  92.     /**
  93.      * Get typeMvt
  94.      *
  95.      * @return int
  96.      */
  97.     public function getTypeMvt()
  98.     {
  99.         return $this->typeMvt;
  100.     }
  101.     /**
  102.      * Set qte
  103.      *
  104.      * @param integer $qte
  105.      *
  106.      * @return StockMvt
  107.      */
  108.     public function setQte($qte)
  109.     {
  110.         $this->qte $qte;
  111.         return $this;
  112.     }
  113.     /**
  114.      * Get qte
  115.      *
  116.      * @return int
  117.      */
  118.     public function getQte()
  119.     {
  120.         return $this->qte;
  121.     }
  122.     /**
  123.      * Set commentaire
  124.      *
  125.      * @param string $commentaire
  126.      *
  127.      * @return StockMvt
  128.      */
  129.     public function setCommentaire($commentaire)
  130.     {
  131.         $this->commentaire $commentaire;
  132.         return $this;
  133.     }
  134.     /**
  135.      * Get commentaire
  136.      *
  137.      * @return string
  138.      */
  139.     public function getCommentaire()
  140.     {
  141.         return $this->commentaire;
  142.     }
  143.     /**
  144.      * Set createdAt
  145.      *
  146.      * @param DateTime $createdAt
  147.      *
  148.      * @return StockMvt
  149.      */
  150.     public function setCreatedAt($createdAt)
  151.     {
  152.         $this->createdAt $createdAt;
  153.         return $this;
  154.     }
  155.     /**
  156.      * Get createdAt
  157.      *
  158.      * @return DateTime
  159.      */
  160.     public function getCreatedAt()
  161.     {
  162.         return $this->createdAt;
  163.     }
  164.     /**
  165.      * Set typestock
  166.      *
  167.      * @param TypeStock $typestock
  168.      *
  169.      * @return StockMvt
  170.      */
  171.     public function setTypestock(TypeStock $typestock)
  172.     {
  173.         $this->typestock $typestock;
  174.         return $this;
  175.     }
  176.     /**
  177.      * Get typestock
  178.      *
  179.      * @return TypeStock
  180.      */
  181.     public function getTypestock()
  182.     {
  183.         return $this->typestock;
  184.     }
  185.     /**
  186.      * Set article
  187.      *
  188.      * @param Article $article
  189.      *
  190.      * @return StockMvt
  191.      */
  192.     public function setArticle(Article $article)
  193.     {
  194.         $this->article $article;
  195.         return $this;
  196.     }
  197.     /**
  198.      * Get article
  199.      *
  200.      * @return Article
  201.      */
  202.     public function getArticle()
  203.     {
  204.         return $this->article;
  205.     }
  206.     /**
  207.      * @return DateTime
  208.      */
  209.     public function getDateReassort(): DateTime
  210.     {
  211.         return $this->dateReassort;
  212.     }
  213.     /**
  214.      * @param DateTime $dateReassort
  215.      */
  216.     public function setDateReassort(DateTime $dateReassort)
  217.     {
  218.         $this->dateReassort $dateReassort;
  219.     }
  220.     /**
  221.      * 
  222.      * @return [type] [description]
  223.      */
  224.     public function jsonSerialize(){
  225.         $data =  array(
  226.             "id" => $this->getId(),
  227.             "qte" => $this->getQte(),
  228.             "article" => $this->getArticle(),
  229.             "commentaire" => $this->getCommentaire(),
  230.             "createdAt" => null,
  231.             "typeStock" =>$this->getTypestock(),
  232.         );
  233.         $data["createdAt"] = $this->getCreatedAt()->format("d/m/Y H:i");
  234.         return $data;
  235.     }
  236. }