<?php
namespace App\Entity;
use App\Repository\AgentRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\CommandeRepository")
*/
class Commande
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Agent", inversedBy="agent")
*/
private $IdAg;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Agent", inversedBy="agent")
*/
private $IdCl;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\ProgrammeContenaire", inversedBy="$commandes")
*/
private $IdCtPr;
/**
* @ORM\Column(type="date")
*/
private $DateCommande;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Paiement", mappedBy="IdCmd", orphanRemoval=true,cascade={"persist"})
*/
private $paiements;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $AliasClient;
/**
* @ORM\Column(type="integer")
*/
private $QtePrint;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $contact;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $facturehors;
/**
* @ORM\Column(type="boolean")
*/
private $NouvelleFacture;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $factureMarchandiseAbscent;
/**
* @ORM\OneToMany(targetEntity="App\Entity\TmpMarchandise", mappedBy="commande",cascade={"persist"})
*/
private $tmpMarchandises;
/**
* @ORM\OneToMany(targetEntity="App\Entity\TmpVolume", mappedBy="commande",cascade={"persist"})
*/
private $tmpVolumes;
/**
* @ORM\OneToMany(targetEntity="App\Entity\AutreFrais", mappedBy="commande",cascade={"persist"})
*/
private $autreFrais;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Reduction", mappedBy="IdCmd", cascade={"persist"})
*/
private $reduction;
/**
* @ORM\Column(type="boolean")
*/
private $isPaid;
/**
* @ORM\Column(type="boolean")
*/
private $modification;
/**
* @var
*/
private $reductionTotal;
/**
* @var
*/
private $paiementAvance;
/**
* @var
*/
private $totalAPaiyer;
/**
* @var
*/
private $balance;
/**
* @var
*/
private $cbm;
/**
* @var
*/
private $kg;
/**
* @var
*/
private $tonne;
/**
* @var
*/
private $AutresFr;
/**
* @var
*/
private $fret;
/**
* @var
*/
private $netDejaPaie;
/**
* @ORM\Column(type="string", length=8000, nullable=true)
*/
private $remarque;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Remarque", mappedBy="commande",cascade={"persist"})
*/
private $remarques;
/**
* @ORM\Column(type="boolean")
*/
private $flagflutterNotification;
/**
* @ORM\OneToMany(targetEntity=Depot::class, mappedBy="commande")
*/
private $depots;
/**
* @ORM\Column(type="string", length=10, nullable=true)
*/
private $pkg;
/**
* @ORM\Column(type="string", length=25, nullable=true)
*/
private $ville;
public function __construct()
{
$this->DateCommande = new \DateTime();
$this->paiements = new ArrayCollection();
$this->QtePrint = 0;
$this->modification = 0;
$this->NouvelleFacture = true;
$this->factureMarchandiseAbscent = false;
$this->facturehors = false;
$this->tmpMarchandises = new ArrayCollection();
$this->tmpVolumes = new ArrayCollection();
$this->autreFrais = new ArrayCollection();
$this->reduction = new ArrayCollection();
$this->remarques = new ArrayCollection();
$this->depots = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getIdCtPr(): ?ProgrammeContenaire
{
return $this->IdCtPr;
}
public function setIdCtPr(?ProgrammeContenaire $IdCtPr): self
{
$this->IdCtPr = $IdCtPr;
return $this;
}
public function getIdCl(): ?Agent
{
return $this->IdCl;
}
public function setIdCl(?Agent $IdCl): self
{
$this->IdCl = $IdCl;
return $this;
}
public function getIdAg(): ?Agent
{
return $this->IdCl;
}
public function setIdAg(?Agent $IdAg): self
{
$this->IdAg = $IdAg;
return $this;
}
public function getDateCommande(): ?\DateTimeInterface
{
return $this->DateCommande;
}
public function setDateCommande(\DateTimeInterface $DateCommande): self
{
$this->DateCommande = $DateCommande;
return $this;
}
/**
* @return Collection|Paiement[]
*/
public function getPaiements(): Collection
{
return $this->paiements;
}
public function addPaiement(Paiement $paiement): self
{
if (!$this->paiements->contains($paiement)) {
$this->paiements[] = $paiement;
$paiement->setIdCmd($this);
}
return $this;
}
public function removePaiement(Paiement $paiement): self
{
if ($this->paiements->contains($paiement)) {
$this->paiements->removeElement($paiement);
// set the owning side to null (unless already changed)
if ($paiement->getIdCmd() === $this) {
$paiement->setIdCmd(null);
}
}
return $this;
}
public function __toString(){
// to show the name of the Category in the select
return (string) $this->id;
// to show the id of the Category in the select
// return $this->id;
}
public function getAliasClient(): ?string
{
return $this->AliasClient;
}
public function setAliasClient(?string $AliasClient): self
{
$this->AliasClient = $AliasClient;
return $this;
}
public function getQtePrint(): ?int
{
return $this->QtePrint;
}
public function setQtePrint(int $QtePrint): self
{
$this->QtePrint = $QtePrint;
return $this;
}
public function getContact(): ?string
{
return $this->contact;
}
public function setContact(?string $contact): self
{
$this->contact = $contact;
return $this;
}
public function getFacturehors(): ?bool
{
return $this->facturehors;
}
public function setFacturehors(?bool $facturehors): self
{
$this->facturehors = $facturehors;
return $this;
}
public function getNouvelleFacture(): ?bool
{
return $this->NouvelleFacture;
}
public function setNouvelleFacture(bool $NouvelleFacture): self
{
$this->NouvelleFacture = $NouvelleFacture;
return $this;
}
public function getFactureMarchandiseAbscent(): ?bool
{
return $this->factureMarchandiseAbscent;
}
public function setFactureMarchandiseAbscent(?bool $factureMarchandiseAbscent): self
{
$this->factureMarchandiseAbscent = $factureMarchandiseAbscent;
return $this;
}
/**
* @return Collection|TmpMarchandise[]
*/
public function getTmpMarchandises(): Collection
{
return $this->tmpMarchandises;
}
public function addTmpMarchandise(TmpMarchandise $tmpMarchandise): self
{
if (!$this->tmpMarchandises->contains($tmpMarchandise)) {
$this->tmpMarchandises[] = $tmpMarchandise;
$tmpMarchandise->setCommande($this);
}
return $this;
}
public function removeTmpMarchandise(TmpMarchandise $tmpMarchandise): self
{
if ($this->tmpMarchandises->contains($tmpMarchandise)) {
$this->tmpMarchandises->removeElement($tmpMarchandise);
// set the owning side to null (unless already changed)
if ($tmpMarchandise->getCommande() === $this) {
$tmpMarchandise->setCommande(null);
}
}
return $this;
}
/**
* @return Collection|TmpVolume[]
*/
public function getTmpVolumes(): Collection
{
return $this->tmpVolumes;
}
public function addTmpVolume(TmpVolume $tmpVolume): self
{
if (!$this->tmpVolumes->contains($tmpVolume)) {
$this->tmpVolumes[] = $tmpVolume;
$tmpVolume->setCommande($this);
}
return $this;
}
public function removeTmpVolume(TmpVolume $tmpVolume): self
{
if ($this->tmpVolumes->contains($tmpVolume)) {
$this->tmpVolumes->removeElement($tmpVolume);
// set the owning side to null (unless already changed)
if ($tmpVolume->getCommande() === $this) {
$tmpVolume->setCommande(null);
}
}
return $this;
}
/**
* @return Collection|AutreFrais[]
*/
public function getAutreFrais(): Collection
{
return $this->autreFrais;
}
public function addAutreFrai(AutreFrais $autreFrai): self
{
if (!$this->autreFrais->contains($autreFrai)) {
$this->autreFrais[] = $autreFrai;
$autreFrai->setCommande($this);
}
return $this;
}
public function removeAutreFrai(AutreFrais $autreFrai): self
{
if ($this->autreFrais->contains($autreFrai)) {
$this->autreFrais->removeElement($autreFrai);
// set the owning side to null (unless already changed)
if ($autreFrai->getCommande() === $this) {
$autreFrai->setCommande(null);
}
}
return $this;
}
public function getModification(): ?bool
{
return $this->modification;
}
public function setModification(bool $modification): self
{
$this->modification = $modification;
return $this;
}
public function getNomAgent(Commande $commande): string
{
return $this;
}
public function getTotalAPaiyerVolume(){
$somme1 = 0;
$Tab = $this->getTmpVolumes();
for($i = 0; $i < count($Tab); $i++){
$somme = $Tab[$i]->getVolume() * $Tab[$i]->getPrixUnit();
$somme1 = round($somme) + $somme1;
}
return round($somme1);
}
public function getTotalAPaiyerAutraiFrais(){
$somme = 0;
$Tab = $this->getAutreFrais();
for($i = 0; $i < count($Tab); $i++){
$somme += $Tab[$i]->getMontant();
}
return $somme;
}
/**
* Renvoie le total des Paiements pour une facture
*
* @return float
*/
public function getTotalPaiement(){
$somme = 0;
$Tab = $this->getPaiements();
for($i = 0; $i < count($Tab); $i++){
$somme += $Tab[$i]->getMontant();
}
return $somme;
}
/**
* Renvoie le total des Paiements Cash pour une facture
*
* @return float
*/
public function getTotalPaiementPaiement(){
$somme = 0;
$Tab = $this->getPaiements();
for($i = 0; $i < count($Tab); $i++){
if($Tab[$i]->getFlagEnAvance() === '0')
$somme += $Tab[$i]->getMontant();
}
return $somme;
}
/**
* Renvoie le total des Paiements avance pour une facture
*
* @return float
*/
public function getTotalPaiementAvance(){
$somme = 0;
$Tab = $this->getPaiements();
for($i = 0; $i < count($Tab); $i++){
if($Tab[$i]->getFlagEnAvance() === true)
$somme += $Tab[$i]->getMontant();
}
return $somme;
}
/**
* Renvoie le total des reductions pour une facture
*
* @return float
*/
public function getTotalReduction(){
$somme = 0;
$Tab = $this->getReduction();
for($i = 0; $i < count($Tab); $i++){
$somme += $Tab[$i]->getMontant();
}
return $this->reductionTotal = $somme;
}
/**
* Renvoie le total des reductions pour une facture
*
* @return float
*/
public function getTotalReductionReduction(){
$somme = 0;
$Tab = $this->getReduction();
for($i = 0; $i < count($Tab); $i++){
if($Tab[$i]->getFlagCompassation() === '0'){
$somme += $Tab[$i]->getMontant();
}
}
return $somme;
}
/**
* Renvoie le total paie par compassation pour une facture
*
* @return float
*/
public function getTotalCompassation(){
$somme = 0;
$Tab = $this->getReduction();
for($i = 0; $i < count($Tab); $i++){
if($Tab[$i]->getFlagCompassation() === '1'){
$somme += $Tab[$i]->getMontant();
}
}
return $somme;
}
/**
* Renvoie le total paie a la banque pour une facture
*
* @return float
*/
public function getTotalBanque(){
$somme = 0;
$Tab = $this->getReduction();
for($i = 0; $i < count($Tab); $i++){
if($Tab[$i]->getFlagCompassation() === '2'){
$somme += $Tab[$i]->getMontant();
}
}
return $somme;
}
/**
* Renvoie le total volime
*
* @return float
*/
public function getTotalCBM(){
$somme = 0;
$Tab = $this->getTmpVolumes();
for($i = 0; $i < count($Tab); $i++){
if($Tab[$i]->getUnite() === 'CBM'){
$somme += $Tab[$i]->getVolume();
}
}
return $somme;
}
/**
* Renvoie le total volime
*
* @return float
*/
public function getTotalKG(){
$somme = 0;
$Tab = $this->getTmpVolumes();
for($i = 0; $i < count($Tab); $i++){
if($Tab[$i]->getUnite() === 'KG'){
$somme += $Tab[$i]->getVolume();
}
}
return $somme;
}
/**
* Renvoie le total colis
*
* @return float
*/
public function getTotalCOLIS(){
$somme = 0;
$Tab = $this->getTmpMarchandises();
for($i = 0; $i < count($Tab); $i++){
$somme += $Tab[$i]->getQte();
}
return $somme;
}
/**
* Renvoie le total colis
*
* @return float
*/
public function getTotalSortieDepot(){
$somme = 0;
$Tab = $this->getDepots();
for($i = 0; $i < count($Tab); $i++){
$somme += $Tab[$i]->getQuantite();
}
return $somme;
}
/**
* Renvoie le total tonnage
*
* @return float
*/
public function getTotalTONNE(){
$somme = 0;
$Tab = $this->getTmpVolumes();
for($i = 0; $i < count($Tab); $i++){
if($Tab[$i]->getUnite() === 'TONNE'){
$somme += $Tab[$i]->getVolume();
}
}
return $somme;
}
/**
* Renvoie le total autreFrais
*
* @return float
*/
public function getTotalAF(){
$somme = 0;
$Tab = $this->getAutreFrais();
for($i = 0; $i < count($Tab); $i++){
$somme += $Tab[$i]->getMontant();
}
return $somme;
}
/**
* Renvoie le total net a payer pour une facture
*
* @return float
*/
public function getTotalAPaiyer(){
return $this->totalAPaiyer = $this->getTotalAPaiyerVolume() + $this->getTotalAPaiyerAutraiFrais();
}
/**
* Renvoie la balance net d'une facture
*
* @return float
*/
public function getBalance(){
$this->balance = $this->getTotalAPaiyer() - $this->getTotalReduction() - $this->getTotalPaiement();
return $this->balance;
}
/**
* Renvoie la balance net d'une facture
*
* @return float
*/
public function getNetDejaPaie(){
$this->netDejaPaie = $this->getTotalReduction() + $this->getTotalPaiement();
return $this->netDejaPaie;
}
/**
* @return Collection|Reduction[]
*/
public function getReduction(): Collection
{
return $this->reduction;
}
public function addReduction(Reduction $reduction): self
{
if (!$this->reduction->contains($reduction)) {
$this->reduction[] = $reduction;
$reduction->setIdCmd($this);
}
return $this;
}
public function removeReduction(Reduction $reduction): self
{
if ($this->reduction->contains($reduction)) {
$this->reduction->removeElement($reduction);
// set the owning side to null (unless already changed)
if ($reduction->getIdCmd() === $this) {
$reduction->setIdCmd(null);
}
}
return $this;
}
public function getRemarque(): ?string
{
return $this->remarque;
}
public function setRemarque(?string $remarque): self
{
$this->remarque = $remarque;
return $this;
}
/**
* @return mixed
*/
public function getPaiementAvance()
{
return $this->paiementAvance = $this->getTotalPaiementAvance();
}
/**
* @return mixed
*/
public function getReductionTotal()
{
return $this->reductionTotal = $this->getTotalReductionReduction();
}
/**
* @return Collection|Remarque[]
*/
public function getRemarques(): Collection
{
return $this->remarques;
}
public function addRemarque(Remarque $remarque): self
{
if (!$this->remarques->contains($remarque)) {
$this->remarques[] = $remarque;
$remarque->setCommande($this);
}
return $this;
}
public function removeRemarque(Remarque $remarque): self
{
if ($this->remarques->contains($remarque)) {
$this->remarques->removeElement($remarque);
// set the owning side to null (unless already changed)
if ($remarque->getCommande() === $this) {
$remarque->setCommande(null);
}
}
return $this;
}
public function getCbm()
{
return $this->cbm = $this->getTotalCBM()/1;
}
public function getKg()
{
return $this->kg = $this->getTotalKG()/1;
}
/**
* @return mixed
*/
public function getTonne()
{
return $this->tonne = $this->getTotalTONNE()/1;
}
/**
* @return mixed
*/
public function getAutresFr()
{
return $this->AutresFr = $this->getTotalAF();
}
/**
* @return mixed
*/
public function getFret()
{
return $this->fret = $this->getTotalAPaiyerVolume();
}
public function getFlagflutterNotification(): ?bool
{
return $this->flagflutterNotification;
}
public function setFlagflutterNotification(bool $flagflutterNotification): self
{
$this->flagflutterNotification = $flagflutterNotification;
return $this;
}
/**
* @return Collection<int, Depot>
*/
public function getDepots(): Collection
{
return $this->depots;
}
public function addDepot(Depot $depot): self
{
if (!$this->depots->contains($depot)) {
$this->depots[] = $depot;
$depot->setCommande($this);
}
return $this;
}
public function removeDepot(Depot $depot): self
{
if ($this->depots->removeElement($depot)) {
// set the owning side to null (unless already changed)
if ($depot->getCommande() === $this) {
$depot->setCommande(null);
}
}
return $this;
}
public function isIsPaid(): ?bool
{
return $this->isPaid;
}
public function setIsPaid(bool $isPaid): self
{
$this->isPaid = $isPaid;
return $this;
}
public function getPkg(): ?string
{
return $this->pkg;
}
public function setPkg(?string $pkg): self
{
$this->pkg = $pkg;
return $this;
}
public function getVille(): ?string
{
return $this->ville;
}
public function setVille(?string $ville): self
{
$this->ville = $ville;
return $this;
}
}