<?php
namespace App\Entity;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
use JsonSerializable;
use Symfony\Component\Validator\Constraints as Assert;
/**
* StockMvt
*
* @ORM\Table(name="stock_mvt")
* @ORM\Entity(repositoryClass="App\Repository\StockMvtRepository")
*/
class StockMvt implements JsonSerializable
{
const AJOUT = 1;
const RETRAIT = 2;
const INVENTAIRE = 3;
const REASSORT = 4;
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @var int
*
* @ORM\Column(name="typeMvt", type="integer")
*/
private $typeMvt;
/**
* @var int
*
* @ORM\Column(name="qte", type="integer")
* @Assert\Range(max=1000000000,notInRangeMessage="La quantité doit être inférieure à {{ max }}")]
*/
private $qte;
/**
* @var string
*
* @ORM\Column(name="commentaire", type="text", nullable=true)
*/
private $commentaire;
/**
* @var DateTime
*
* @ORM\Column(name="createdAt", type="datetime")
*/
private $createdAt;
/**
*
* @ORM\ManyToOne(targetEntity="App\Entity\TypeStock")
* @ORM\JoinColumn(nullable=false)
*/
protected $typestock;
/**
*
* @ORM\ManyToOne(targetEntity="App\Entity\Article")
* @ORM\JoinColumn(nullable=false)
*/
protected $article;
/**
* @var DateTime
* @ORM\Column(name="dateReassort", type="datetime", nullable=true)
*/
protected $dateReassort;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set typeMvt
*
* @param integer $typeMvt
*
* @return StockMvt
*/
public function setTypeMvt($typeMvt)
{
$this->typeMvt = $typeMvt;
return $this;
}
/**
* Get typeMvt
*
* @return int
*/
public function getTypeMvt()
{
return $this->typeMvt;
}
/**
* Set qte
*
* @param integer $qte
*
* @return StockMvt
*/
public function setQte($qte)
{
$this->qte = $qte;
return $this;
}
/**
* Get qte
*
* @return int
*/
public function getQte()
{
return $this->qte;
}
/**
* Set commentaire
*
* @param string $commentaire
*
* @return StockMvt
*/
public function setCommentaire($commentaire)
{
$this->commentaire = $commentaire;
return $this;
}
/**
* Get commentaire
*
* @return string
*/
public function getCommentaire()
{
return $this->commentaire;
}
/**
* Set createdAt
*
* @param DateTime $createdAt
*
* @return StockMvt
*/
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
/**
* Get createdAt
*
* @return DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Set typestock
*
* @param TypeStock $typestock
*
* @return StockMvt
*/
public function setTypestock(TypeStock $typestock)
{
$this->typestock = $typestock;
return $this;
}
/**
* Get typestock
*
* @return TypeStock
*/
public function getTypestock()
{
return $this->typestock;
}
/**
* Set article
*
* @param Article $article
*
* @return StockMvt
*/
public function setArticle(Article $article)
{
$this->article = $article;
return $this;
}
/**
* Get article
*
* @return Article
*/
public function getArticle()
{
return $this->article;
}
/**
* @return DateTime
*/
public function getDateReassort(): DateTime
{
return $this->dateReassort;
}
/**
* @param DateTime $dateReassort
*/
public function setDateReassort(DateTime $dateReassort)
{
$this->dateReassort = $dateReassort;
}
/**
*
* @return [type] [description]
*/
public function jsonSerialize(){
$data = array(
"id" => $this->getId(),
"qte" => $this->getQte(),
"article" => $this->getArticle(),
"commentaire" => $this->getCommentaire(),
"createdAt" => null,
"typeStock" =>$this->getTypestock(),
);
$data["createdAt"] = $this->getCreatedAt()->format("d/m/Y H:i");
return $data;
}
}