<?php
/**
* Commande.php
* Created by Stéphane Brun
* Date: 03/07/2018 at 15:20
*/
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\CommandeRepository")
* @ORM\Table(name="commande")
*/
class Commande
{
const HISTORY_WATCH = array(
'livraison' => 'Livraison',
'message' => 'Message',
'date' => 'Date',
);
const TYPE_REASSORT = 1;
const TYPE_PROMO_IN_PLACE = 2;
const TYPE_AGREEMENT_SPECIAL = 3;
const TYPE_OFFICE = 4;
const TYPE_ADD_OFFICE = 5;
const TYPE_DEPOSIT_CONS_COURT = 6;
const TYPE_DEPOSIT_CONS_LONG = 7;
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(name="date", type="datetime")
*/
protected $date;
/**
* @ORM\Column(name="imprimee", type="boolean")
*/
protected $imprimee = false;
/**
* @ORM\Column(name="fermee", type="boolean")
*/
protected $fermee = false;
/**
* @ORM\Column(name="recue", type="boolean")
*/
protected $recue = false;
/**
* @ORM\Column(name="date_recue", type="datetime", nullable=true)
*/
protected $dateRecue;
/**
* @ORM\Column(name="date_transmise", type="datetime", nullable=true)
*/
protected $dateTransmise;
/**
* @ORM\Column(name="date_confirme", type="datetime", nullable=true)
*/
protected $dateConfirme;
/**
* @ORM\Column(name="accepte_pas_subst", type="boolean")
*/
protected $acceptePasSubst = false;
/**
* @ORM\Column(name="message", type="string", length=150, nullable=true)
*/
protected $message;
/**
* has one CommandeType
*
* @ORM\ManyToOne(targetEntity="App\Entity\CommandeType")
* @ORM\JoinColumn(name="type_id", referencedColumnName="id", nullable=true)
*/
protected $type;
/**
* has one Fournisseurs
*
* @ORM\ManyToOne(targetEntity="App\Entity\Fournisseurs", inversedBy="commandes")
* @ORM\JoinColumn(name="fournisseur_id", referencedColumnName="id", nullable=true)
*/
protected $fournisseur;
/**
* has one CommandeLivraison
*
* @ORM\ManyToOne(targetEntity="App\Entity\Fournisseurs")
* @ORM\JoinColumn(name="livraison_id", referencedColumnName="id", nullable=true)
*/
protected $livraison;
/**
* has many CommandeDetail
*
* @ORM\OneToMany(targetEntity="CommandeDetail", mappedBy="commande", cascade={"persist", "remove"}, orphanRemoval=true)
*/
protected $details;
/**
* has one Company
*
* @ORM\ManyToOne(targetEntity="App\Entity\Company")
* @ORM\JoinColumn(name="company_id", referencedColumnName="id")
*/
protected $company;
/**
* has one SysUser
*
* @ORM\ManyToOne(targetEntity="App\Entity\SysUsers")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
protected $user;
/**
* @ORM\Column(name="promo_code", type="string", length=150, nullable=true)
*/
protected $promotionalCode;
/**
* @ORM\Column(name="terms", type="string", length=150, nullable=true)
*/
protected $terms;
/**
* @ORM\Column(name="date_return", type="datetime", nullable=true)
*/
protected $dateReturn;
/**
* @ORM\Column(name="date_delivery", type="datetime", nullable=true)
*/
protected $dateDelivery;
/**
* @ORM\Column(name="noted_until", type="datetime", nullable=true)
*/
protected $notedUntil;
/**
* One Product has Many Features.
* @ORM\OneToMany(targetEntity="Reception", mappedBy="commandeVisee")
*/
protected $receptions;
public function __construct()
{
$this->details = new ArrayCollection();
$this->date = new \DateTime();
}
public function __toString()
{
return (string)$this->getId();
}
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @return mixed
*/
public function getDate()
{
return $this->date;
}
/**
* @param mixed $date
* @return Commande
*/
public function setDate($date)
{
$this->date = $date;
return $this;
}
/**
* @return mixed
*/
public function getImprimee()
{
return $this->imprimee;
}
/**
* @param mixed $imprimee
* @return Commande
*/
public function setImprimee($imprimee)
{
$this->imprimee = $imprimee;
return $this;
}
/**
* @return mixed
*/
public function getFermee()
{
return $this->fermee;
}
/**
* @param mixed $fermee
* @return Commande
*/
public function setFermee($fermee)
{
$this->fermee = $fermee;
return $this;
}
/**
* @return mixed
*/
public function getRecue()
{
return $this->recue;
}
/**
* @param mixed $recue
* @return Commande
*/
public function setRecue($recue)
{
$this->recue = $recue;
return $this;
}
/**
* @return mixed
*/
public function getDateRecue()
{
return $this->dateRecue;
}
/**
* @param mixed $dateRecue
* @return Commande
*/
public function setDateRecue($dateRecue)
{
$this->dateRecue = $dateRecue;
return $this;
}
/**
* @return mixed
*/
public function getDateTransmise()
{
return $this->dateTransmise;
}
/**
* @param mixed $dateTransmise
* @return Commande
*/
public function setDateTransmise($dateTransmise)
{
$this->dateTransmise = $dateTransmise;
return $this;
}
/**
* @return mixed
*/
public function getDateConfirme()
{
return $this->dateConfirme;
}
/**
* @param mixed $dateConfirme
* @return Commande
*/
public function setDateConfirme($dateConfirme)
{
$this->dateConfirme = $dateConfirme;
return $this;
}
/**
* @return mixed
*/
public function getAcceptePasSubst()
{
return $this->acceptePasSubst;
}
/**
* @param mixed $acceptePasSubst
* @return Commande
*/
public function setAcceptePasSubst($acceptePasSubst)
{
$this->acceptePasSubst = $acceptePasSubst;
return $this;
}
/**
* @return mixed
*/
public function getMessage()
{
return $this->message;
}
/**
* @param mixed $message
* @return Commande
*/
public function setMessage($message)
{
$this->message = $message;
return $this;
}
/**
* @return CommandeType
*/
public function getType()
{
return $this->type;
}
/**
* @param CommandeType $type
* @return Commande
*/
public function setType(CommandeType $type)
{
$this->type = $type;
return $this;
}
/**
* @return mixed
*/
public function getFournisseur()
{
return $this->fournisseur;
}
/**
* @param mixed $fournisseur
* @return Commande
*/
public function setFournisseur($fournisseur)
{
$this->fournisseur = $fournisseur;
return $this;
}
/**
* @return Fournisseurs
*/
public function getLivraison()
{
return $this->livraison;
}
/**
* @param Fournisseurs $livraison
* @return Commande
*/
public function setLivraison(Fournisseurs $livraison)
{
$this->livraison = $livraison;
return $this;
}
/**
* @return mixed
*/
public function getDetails()
{
return $this->details;
}
/**
* @param mixed $details
* @return Commande
*/
public function setDetails($details)
{
$this->details = $details;
return $this;
}
/**
* @param CommandeDetail $detail
* @return Commande
*/
public function addDetail(CommandeDetail $detail)
{
if (!$this->details->contains($detail)) {
$this->details->add($detail);
$detail->setCommande($this);
}
return $this;
}
/**
* @param CommandeDetail $detail
* @return Commande
*/
public function removeDetail(CommandeDetail $detail)
{
if ($this->details->contains($detail)) {
$this->details->removeElement($detail);
$detail->setCommande(null);
}
return $this;
}
/**
* @return mixed
*/
public function getCompany()
{
return $this->company;
}
/**
* @param mixed $company
* @return Commande
*/
public function setCompany($company)
{
$this->company = $company;
return $this;
}
/**
* @return SysUsers
*/
public function getUser()
{
return $this->user;
}
/**
* @param SysUsers $user
* @return Commande
*/
public function setUser(SysUsers $user)
{
$this->user = $user;
return $this;
}
/**
* @return string
*/
public function getPromotionalCode()
{
return $this->promotionalCode;
}
/**
* @param string $promotionalCode
*/
public function setPromotionalCode($promotionalCode)
{
$this->promotionalCode = $promotionalCode;
}
/**
* @return string
*/
public function getTerms()
{
return $this->terms;
}
/**
* @param string $terms
*/
public function setTerms($terms)
{
$this->terms = $terms;
}
/**
* @return \DateTime|null
*/
public function getDateReturn()
{
return $this->dateReturn;
}
/**
* @param \DateTime|null $dateReturn
*/
public function setDateReturn($dateReturn)
{
$this->dateReturn = $dateReturn;
}
/**
* @return \DateTime|null
*/
public function getDateDelivery()
{
return $this->dateDelivery;
}
/**
* @param \DateTime|null $dateDelivery
*/
public function setDateDelivery($dateDelivery)
{
$this->dateDelivery = $dateDelivery;
}
/**
* @return \DateTime|null
*/
public function getNotedUntil()
{
return $this->notedUntil;
}
/**
* @param \DateTime|null $notedUntil
*/
public function setNotedUntil($notedUntil)
{
$this->notedUntil = $notedUntil;
}
/**
* @return bool
*/
public function isTransmit()
{
if (!empty($this->getDateTransmise()) || true === $this->getImprimee()) {
return true;
}
return false;
}
/**
* @return mixed
*/
public function getReceptions()
{
return $this->receptions;
}
/**
* @param mixed $receptions
*/
public function setReceptions($receptions): void
{
$this->receptions = $receptions;
}
}