<?php
/**
* CommandeSpeciale.php
* Created by Stéphane Brun
* Date: 08/06/2018 at 10:26
*/
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\CommandeSpecialeRepository")
* @ORM\Table(name="commande_speciale")
*/
class CommandeSpeciale
{
const HISTORY_WATCH = array(
'telephone' => 'Telephone',
'client' => 'Client',
'bonCommande' => 'Bon de commande',
'clientAdl' => 'Adresse de livraison',
'commentaire' => 'Commentaire',
);
/**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(name="telephone", type="string", length=50, nullable=true)
*/
protected $telephone;
/**
* @ORM\Column(name="date_demande", type="datetime")
*/
protected $dateDemande;
/**
* @ORM\Column(name="date_limite", type="datetime", nullable=true)
*/
protected $dateLimite;
/**
* @ORM\Column(name="numero", type="string", length=50, nullable=true)
*/
protected $numero;
/**
* @ORM\Column(name="acompte_recu", type="boolean")
*/
protected $acompteRecu = false;
/**
* @ORM\Column(name="commentaire", type="text", nullable=true)
*/
protected $commentaire;
/**
* @ORM\Column(name="bon_commande", type="string", length=100, nullable=true)
*/
protected $bonCommande;
/**
* @ORM\Column(name="commande_en_ligne_courriel ", type="string", length=255, nullable=true)
*/
protected $commandeEnLigneCourriel;
/**
* has one SysUser
*
* @ORM\ManyToOne(targetEntity="App\Entity\SysUsers")
* @ORM\JoinColumn(name="user_id", referencedColumnName="id")
*/
protected $user;
/**
* has one Client
*
* @ORM\ManyToOne(targetEntity="App\Entity\Clients")
* @ORM\JoinColumn(name="client_id", referencedColumnName="id")
*/
protected $client;
/**
* has one ClientsAdressesLivraison
*
* @ORM\ManyToOne(targetEntity="App\Entity\ClientsAdressesLivraison")
* @ORM\JoinColumn(name="clientADL_id", referencedColumnName="id", nullable=true)
*/
protected $clientADL;
/**
* has many CommandeSpecialeDetail
*
* @ORM\OneToMany(targetEntity="CommandeSpecialeDetail", mappedBy="commandeSpeciale", 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 CommandeEnLigneType
*
* @ORM\ManyToOne(targetEntity="App\Entity\CommandeEnLigneType")
* @ORM\JoinColumn(name="commande_en_ligne_type_id", referencedColumnName="id", nullable=true)
*/
protected $commandeEnLigneType;
/**
* @ORM\Column(name="mail_order_receive_count", type="integer", nullable=false)
*/
protected $mailOrderReceiveCount = 0;
/**
* @ORM\Column(name="date_rembourse", type="datetime", nullable=true)
*/
protected $dateRembourse;
/**
* @ORM\Column(name="notes", type="text", nullable=true)
*/
protected $notes;
/**
* @ORM\Column(name="comptant", type="float", nullable=true)
*/
protected $comptant;
/**
* @ORM\Column(name="mastercard", type="float", nullable=true)
*/
protected $mastercard;
/**
* @ORM\Column(name="visa", type="float", nullable=true)
*/
protected $visa;
/**
* @ORM\Column(name="interact", type="float", nullable=true)
*/
protected $interact;
/**
* @ORM\Column(name="certificat_cadeau", type="float", nullable=true)
*/
protected $certificatCadeau;
/**
* @ORM\Column(name="acompte_update", type="boolean")
*/
protected $acompteUpdate = false;
public function __construct()
{
$this->details = new ArrayCollection();
$this->dateDemande = new \DateTime();
}
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @return mixed
*/
public function getTelephone()
{
return $this->telephone;
}
/**
* @param mixed $telephone
*/
public function setTelephone($telephone)
{
$this->telephone = $telephone;
}
/**
* @return mixed
*/
public function getDateDemande()
{
return $this->dateDemande;
}
/**
* @param mixed $dateDemande
*/
public function setDateDemande(\DateTime $dateDemande)
{
$this->dateDemande = $dateDemande;
}
/**
* @return mixed
*/
public function getDateLimite()
{
return $this->dateLimite;
}
/**
* @param mixed $dateLimite
*/
public function setDateLimite(\DateTime $dateLimite)
{
$this->dateLimite = $dateLimite;
}
/**
* @return mixed
*/
public function getNumero()
{
if ($this->numero){
return $this->numero;
} else if ($this->getId()) {
return "N".$this->getId();
} else {
return "NA";
}
}
/**
* @param mixed $numero
*/
public function setNumero($numero)
{
$this->numero = $numero;
}
/**
* @return mixed
*/
public function getCommentaire()
{
return $this->commentaire;
}
/**
* @param mixed $commentaire
*/
public function setCommentaire($commentaire)
{
$this->commentaire = $commentaire;
}
/**
* @return mixed
*/
public function getClient()
{
return $this->client;
}
/**
* @param mixed $client
*/
public function setClient(Clients $client)
{
$this->client = $client;
}
/**
* @return mixed
*/
public function getClientADL()
{
return $this->clientADL;
}
/**
* @param mixed $clientADL
*/
public function setClientADL($clientADL=null)
{
$this->clientADL = $clientADL;
}
/**
* @return mixed
*/
public function getDetails()
{
return $this->details;
}
/**
* @param mixed $details
*/
public function setDetails($details)
{
$this->details = $details;
}
/**
* @param CommandeSpecialeDetail $detail
* @return CommandeSpeciale
*/
public function addDetail(CommandeSpecialeDetail $detail)
{
if (!$this->details->contains($detail)) {
$this->details->add($detail);
$detail->setCommandeSpeciale($this);
}
return $this;
}
/**
* @param CommandeSpecialeDetail $detail
* @return CommandeSpeciale
*/
public function removeDetail(CommandeSpecialeDetail $detail)
{
if ($this->details->contains($detail)) {
$this->details->removeElement($detail);
$detail->setCommandeSpeciale(null);
}
return $this;
}
/**
* @return mixed
*/
public function getCompany()
{
return $this->company;
}
/**
* @param mixed $company
* @return CommandeSpeciale
*/
public function setCompany(Company $company)
{
$this->company = $company;
return $this;
}
/**
* @return mixed
*/
public function getUser()
{
return $this->user;
}
/**
* @param mixed $user
* @return CommandeSpeciale
*/
public function setUser(SysUsers $user)
{
$this->user = $user;
return $this;
}
/**
* @return mixed
*/
public function getBonCommande()
{
return $this->bonCommande;
}
/**
* @param mixed $bonCommande
* @return CommandeSpeciale
*/
public function setBonCommande($bonCommande)
{
$this->bonCommande = $bonCommande;
return $this;
}
/**
* @return mixed
*/
public function getMailOrderReceiveCount()
{
return $this->mailOrderReceiveCount;
}
/**
* @param mixed $mailOrderReceiveCount
*/
public function setMailOrderReceiveCount($mailOrderReceiveCount)
{
$this->mailOrderReceiveCount = $mailOrderReceiveCount;
}
/**
* @return mixed
*/
public function getCommandeEnLigneCourriel()
{
return $this->commandeEnLigneCourriel;
}
/**
* @param mixed $commandeEnLigneCourriel
* @return CommandeSpeciale
*/
public function setCommandeEnLigneCourriel($commandeEnLigneCourriel)
{
$this->commandeEnLigneCourriel = $commandeEnLigneCourriel;
return $this;
}
/**
* @return mixed
*/
public function getCommandeEnLigneType()
{
return $this->commandeEnLigneType;
}
/**
* @param mixed $commandeEnLigneType
* @return CommandeSpeciale
*/
public function setCommandeEnLigneType($commandeEnLigneType)
{
$this->commandeEnLigneType = $commandeEnLigneType;
return $this;
}
/**
* @return mixed
*/
public function getAcompteRecu()
{
return $this->acompteRecu;
}
/**
* @param mixed $acompteRecu
* @return CommandeSpeciale
*/
public function setAcompteRecu($acompteRecu)
{
$this->acompteRecu = $acompteRecu;
return $this;
}
/**
* @return mixed
*/
public function getNotes()
{
return $this->notes;
}
/**
* @param mixed $notes
* @return CommandeSpeciale
*/
public function setNotes($notes)
{
$this->notes = $notes;
return $this;
}
/**
* @return mixed
*/
public function getComptant()
{
return $this->comptant;
}
/**
* @param mixed $comptant
* @return CommandeSpeciale
*/
public function setComptant($comptant)
{
$this->comptant = $comptant;
return $this;
}
/**
* @return mixed
*/
public function getMastercard()
{
return $this->mastercard;
}
/**
* @param mixed $mastercard
* @return CommandeSpeciale
*/
public function setMastercard($mastercard)
{
$this->mastercard = $mastercard;
return $this;
}
/**
* @return mixed
*/
public function getVisa()
{
return $this->visa;
}
/**
* @param mixed $visa
* @return CommandeSpeciale
*/
public function setVisa($visa)
{
$this->visa = $visa;
return $this;
}
/**
* @return mixed
*/
public function getInteract()
{
return $this->interact;
}
/**
* @param mixed $interact
* @return CommandeSpeciale
*/
public function setInteract($interact)
{
$this->interact = $interact;
return $this;
}
/**
* @return mixed
*/
public function getCertificatCadeau()
{
return $this->certificatCadeau;
}
/**
* @param mixed $certificatCadeau
* @return CommandeSpeciale
*/
public function setCertificatCadeau($certificatCadeau)
{
$this->certificatCadeau = $certificatCadeau;
return $this;
}
/**
* @return mixed
*/
public function getAcompteUpdate()
{
return $this->acompteUpdate;
}
/**
* @param mixed $acompteUpdate
* @return CommandeSpeciale
*/
public function setAcompteUpdate($acompteUpdate)
{
$this->acompteUpdate = $acompteUpdate;
return $this;
}
/**
* @return mixed
*/
public function getDateRembourse()
{
return $this->dateRembourse;
}
/**
* @param mixed $dateRembourse
* @return CommandeSpeciale
*/
public function setDateRembourse($dateRembourse)
{
$this->dateRembourse = $dateRembourse;
return $this;
}
public function getTotalCommande() {
if (empty($this->details)) {
return 0;
}
$total = 0;
/** @var CommandeSpecialeDetail $detail */
foreach ($this->details as $detail) {
$total += $detail->getPvu() * $detail->getQuantite();
}
return $total;
}
}