<?php
/**
* CommandeDetail.php
* Created by Stéphane Brun
* Date: 03/07/2018 at 15:21
*/
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity()
* @ORM\Table(name="commande_detail")
*/
class CommandeDetail
{
const HISTORY_WATCH = array(
'quantiteCommandee' => 'Quantité commandé',
);
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* has one Commande
*
* @ORM\ManyToOne(targetEntity="App\Entity\Commande", inversedBy="details")
* @ORM\JoinColumn(name="commande_id", referencedColumnName="id")
*/
protected $commande;
/**
* has one CommandeSpecialeDetail
*
* @ORM\ManyToOne(targetEntity="App\Entity\CommandeSpecialeDetail")
* @ORM\JoinColumn(name="commande_speciale_detail_id", referencedColumnName="id", nullable=true)
*/
protected $commandeSpecialeDetail;
/**
* has one Titre
*
* @ORM\ManyToOne(targetEntity="App\Entity\Titre")
* @ORM\JoinColumn(name="titre_id", referencedColumnName="TISBN")
*/
protected $produit;
/**
* has one TitreCompany
*
* @ORM\ManyToOne(targetEntity="App\Entity\TitreCompany")
* @ORM\JoinColumn(name="titre_company_id", referencedColumnName="id")
*/
protected $titreCompany;
/**
* has one Company
*
* @ORM\ManyToOne(targetEntity="App\Entity\Company")
* @ORM\JoinColumn(name="company_id", referencedColumnName="id")
*/
protected $company;
/**
* @ORM\Column(name="quantite_commandee", type="integer", nullable=true)
*/
protected $quantiteCommandee = 0;
/**
* @ORM\Column(name="quantite_recue", type="integer", nullable=true)
*/
protected $quantiteRecue = 0;
/**
* @ORM\Column(name="pvu", type="float", nullable=true)
*/
protected $pvu = 0;
/**
* @ORM\Column(name="pu", type="float", nullable=true)
*/
protected $pu;
/**
* @ORM\Column(name="titre", type="string", length=150, nullable=true)
*/
protected $titre;
/**
* @ORM\Column(name="remise", type="integer", nullable=true)
*/
protected $remise = 0;
/**
* @ORM\Column(name="garder_notes", type="boolean")
*/
protected $garderNotes = false;
/**
* @ORM\Column(name="recu_bon", type="string", length=50, nullable=true)
*/
protected $recuBon;
/**
* @ORM\Column(name="note", type="integer")
*/
protected $note = false;
/**
* has one CommandeReponse
*
* @ORM\ManyToOne(targetEntity="App\Entity\CommandeReponse")
* @ORM\JoinColumn(name="reponse", referencedColumnName="id")
*/
protected $reponse;
/**
* @ORM\Column(name="date_limite", type="datetime", nullable=true)
*/
protected $dateLimite;
/**
* @ORM\OneToMany(targetEntity="ReceptionDetail", mappedBy="originalCommandeDetail")
*/
private $receptionDetail;
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @param mixed $id
* @return CommandeDetail
*/
public function setId($id)
{
$this->id = $id;
return $this;
}
/**
* @return Commande
*/
public function getCommande()
{
return $this->commande;
}
/**
* @param mixed $commande
* @return CommandeDetail
*/
public function setCommande(Commande $commande)
{
$this->commande = $commande;
return $this;
}
/**
* @return CommandeSpecialeDetail
*/
public function getCommandeSpecialeDetail()
{
return $this->commandeSpecialeDetail;
}
/**
* @param CommandeSpecialeDetail $commandeSpecialeDetail
* @return CommandeDetail
*/
public function setCommandeSpecialeDetail(CommandeSpecialeDetail $commandeSpecialeDetail=null)
{
$this->commandeSpecialeDetail = $commandeSpecialeDetail;
return $this;
}
/**
* @return Titre
*/
public function getProduit()
{
return $this->produit;
}
/**
* @param Titre $produit
* @return CommandeDetail
*/
public function setProduit(Titre $produit)
{
$this->produit = $produit;
return $this;
}
/**
* @return Company
*/
public function getCompany()
{
return $this->company;
}
/**
* @param Company $company
* @return CommandeDetail
*/
public function setCompany(Company $company)
{
$this->company = $company;
return $this;
}
/**
* @return mixed
*/
public function getQuantiteCommandee()
{
return $this->quantiteCommandee;
}
/**
* @param mixed $quantiteCommandee
* @return CommandeDetail
*/
public function setQuantiteCommandee($quantiteCommandee)
{
$this->quantiteCommandee = $quantiteCommandee;
return $this;
}
/**
* @return mixed
*/
public function getQuantiteRecue()
{
return $this->quantiteRecue;
}
/**
* @param mixed $quantiteRecue
* @return CommandeDetail
*/
public function setQuantiteRecue($quantiteRecue)
{
$this->quantiteRecue = $quantiteRecue;
return $this;
}
/**
* @return mixed
*/
public function getPvu()
{
return $this->pvu;
}
/**
* @param mixed $pvu
* @return CommandeDetail
*/
public function setPvu($pvu)
{
$this->pvu = $pvu;
return $this;
}
/**
* @return mixed
*/
public function getPu()
{
return $this->pu;
}
/**
* @param mixed $pu
* @return CommandeDetail
*/
public function setPu($pu)
{
$this->pu = $pu;
return $this;
}
/**
* @return mixed
*/
public function getTitre()
{
return $this->titre;
}
/**
* @param mixed $titre
* @return CommandeDetail
*/
public function setTitre($titre)
{
$this->titre = $titre;
return $this;
}
/**
* @return mixed
*/
public function getRemise()
{
return $this->remise;
}
/**
* @param mixed $remise
* @return CommandeDetail
*/
public function setRemise($remise)
{
$this->remise = $remise;
return $this;
}
/**
* @return mixed
*/
public function getGarderNotes()
{
return $this->garderNotes;
}
/**
* @param mixed $garderNotes
* @return CommandeDetail
*/
public function setGarderNotes($garderNotes)
{
$this->garderNotes = $garderNotes;
return $this;
}
/**
* @return mixed
*/
public function getRecuBon()
{
return $this->recuBon;
}
/**
* @param mixed $recuBon
* @return CommandeDetail
*/
public function setRecuBon($recuBon)
{
$this->recuBon = $recuBon;
return $this;
}
/**
* @return mixed
*/
public function getNote()
{
return $this->note;
}
/**
* @param mixed $note
* @return CommandeDetail
*/
public function setNote($note)
{
$this->note = $note;
return $this;
}
/**
* @return mixed
*/
public function getReponse()
{
return $this->reponse;
}
/**
* @param mixed $reponse
* @return CommandeDetail
*/
public function setReponse($reponse)
{
$this->reponse = $reponse;
return $this;
}
/**
* @return mixed
*/
public function getDateLimite()
{
return $this->dateLimite;
}
/**
* @param mixed $dateLimite
* @return CommandeDetail
*/
public function setDateLimite($dateLimite)
{
$this->dateLimite = $dateLimite;
return $this;
}
/**
* @return TitreCompany
*/
public function getTitreCompany()
{
return $this->titreCompany;
}
/**
* @param TitreCompany $titreCompany
* @return CommandeDetail
*/
public function setTitreCompany(TitreCompany $titreCompany)
{
$this->titreCompany = $titreCompany;
return $this;
}
/**
* @return mixed
*/
public function getReceptionDetail()
{
return $this->receptionDetail;
}
/**
* @param mixed $receptionDetail
*/
public function setReceptionDetail($receptionDetail): void
{
$this->receptionDetail = $receptionDetail;
}
public function getDisponibilite()
{
$disp = $this->getTitreCompany()->getQem()
- $this->getTitreCompany()->getQManquante()
- $this->getTitreCompany()->getQMisDeCote()
- $this->getTitreCompany()->getQAbimes()
;
return $disp;
}
public function getReponseTexte()
{
/** @var CommandeReponse $reponse */
if (!empty($this->getReponse())) {
return $this->getReponse()->getDescription();
}
return '';
// switch ($this->getReponse()) {
// default:
// case 0:
// $texte = "Disponible";
// break;
// case 1:
// $texte = "Épuisé";
// break;
// case 2:
// $texte = "Non noté";
// break;
// case 3:
// $texte = "Réimp noté";
// break;
// case 4:
// $texte = "Sur commande";
// break;
// case 5:
// $texte = "Solde";
// break;
// case 6:
// $texte = "Réimp non noté";
// break;
// case 7:
// $texte = "Noté";
// break;
// case 15:
// $texte = "Substitution";
// break;
// case 11:
// $texte = "Abîmés";
// break;
// case 12:
// $texte = "Arrêt commercialisation";
// break;
// }
// return $texte;
}
public function getBrut()
{
return $this->getProduit()->getCoutant() * $this->getQuantiteCommandee();
}
public function __toString()
{
return (string)$this->getId();
}
}