<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\ProgrammeContenaireRepository")
*/
class ProgrammeContenaire
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Contenaire", inversedBy="programmeContenaires")
* @ORM\JoinColumn(nullable=false)
*/
private $IdCt;
/**
* @ORM\Column(type="date")
*/
private $DateChargement;
/**
* @ORM\Column(type="date")
*/
private $DateDepart;
/**
* @ORM\Column(type="date")
*/
private $DateArriver;
/**
* @ORM\Column(type="date")
*/
private $DateOperation;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $NomBateau;
/**
* @ORM\Column(type="integer")
*/
private $IdAg;
/**
* @ORM\Column(type="boolean")
*/
private $Flag;
/**
* @ORM\Column(type="string", length=255)
*/
private $NumeroContenaire;
/**
* @ORM\OneToMany(targetEntity="App\Entity\SuiviContenaire", mappedBy="idCtPr", orphanRemoval=true)
*/
private $suiviContenaires;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $transporteur;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Ville")
* @ORM\JoinColumn(nullable=false)
*/
private $IdVille;
/**
* @ORM\OneToMany(targetEntity="App\Entity\DepensesContenaire", mappedBy="idCmd", orphanRemoval=true)
*/
private $depensesContenaires;
/**
* @ORM\Column(type="string", length=2)
*/
private $CompletFlag;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Declarant", mappedBy="idPrCt")
*/
private $declarants;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $ProprietaireConteneur;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $destination;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Commande", mappedBy="IdCtPr")
*/
private $commandes;
/**
* @ORM\Column(type="boolean")
*/
private $validation;
/**
* @ORM\Column(type="integer")
* @Assert\Type(type="integer", message="le champs entier")
*/
private $DepensesPrevue;
private $facturePayer;
private $factureAccompte;
private $factureNonPayer;
private $facturePayerCompassation;
private $factureHors;
private $factureNull;
private $factureModifier;
private $MontantFacturePayerBanque;
private $MontantFacturePayerCash;
private $MontantFacturePayerAvance;
private $MontantFacturePayerReduction;
private $MontantFacturePayerCompassation;
private $MontantTotalAPayer;
private $TotalAPaiyerVolume;
private $MontantTotalAutreFraisPayer;
private $MontantTotalFacturePayer;
private $MontantTotalBalanceFacture;
private $MontantTotalFactureNulle;
private $MontantTotalDepensesReel;
private $TotalCBM;
private $TotalTONNE;
private $TotalCOLIS;
private $lieu;
private $declarant;
/**
* @ORM\OneToMany(targetEntity="App\Entity\RemarqueConteneur", mappedBy="programmeConteneur")
*/
private $remarqueConteneurs;
private $lieuDate;
/**
* @ORM\Column(type="string", length=1000, nullable=true)
*/
private $remarqueConteneur;
/**
* @ORM\Column(type="boolean")
*/
private $isMco;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isRapport;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $dateRapportAt;
/**
* @ORM\Column(type="boolean")
*/
private $isClients;
/**
* @ORM\ManyToOne(targetEntity=Ville::class, inversedBy="programmeContenaires")
*/
private $villeInitiale;
/**
* @ORM\OneToMany(targetEntity=Notification::class, mappedBy="prct")
*/
private $notifications;
/**
* @ORM\OneToMany(targetEntity=TmpConteneurReception::class, mappedBy="programme", orphanRemoval=true)
*/
private $tmpConteneurReceptions;
/**
* @ORM\Column(type="string", length=10)
*/
private $rapport;
public function __construct()
{
$this->DateOperation = new \DateTime();
$this->Flag = false;
$this->isClients = false;
$this->suiviContenaires = new ArrayCollection();
$this->villes = new ArrayCollection();
$this->depensesContenaires = new ArrayCollection();
$this->CompletFlag = '0';
$this->declarants = new ArrayCollection();
$this->remarqueConteneurs = new ArrayCollection();
$this->notifications = new ArrayCollection();
$this->tmpConteneurReceptions = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getIdCt(): ?Contenaire
{
return $this->IdCt;
}
public function setIdCt(?Contenaire $IdCt): self
{
$this->IdCt = $IdCt;
return $this;
}
public function getDateChargement(): ?\DateTimeInterface
{
return $this->DateChargement;
}
public function setDateChargement(\DateTimeInterface $DateChargement): self
{
$this->DateChargement = $DateChargement;
return $this;
}
public function getDateDepart(): ?\DateTimeInterface
{
return $this->DateDepart;
}
public function setDateDepart(\DateTimeInterface $DateDepart): self
{
$this->DateDepart = $DateDepart;
return $this;
}
public function getDateArriver(): ?\DateTimeInterface
{
return $this->DateArriver;
}
public function setDateArriver(\DateTimeInterface $DateArriver): self
{
$this->DateArriver = $DateArriver;
return $this;
}
public function getDateOperation(): ?\DateTimeInterface
{
return $this->DateOperation;
}
public function setDateOperation(\DateTimeInterface $DateOperation): self
{
$this->DateOperation = $DateOperation;
return $this;
}
public function getNomBateau(): ?string
{
return $this->NomBateau;
}
public function setNomBateau(?string $NomBateau): self
{
$this->NomBateau = $NomBateau;
return $this;
}
public function getIdAg(): ?int
{
return $this->IdAg;
}
public function setIdAg(int $IdAg): self
{
$this->IdAg = $IdAg;
return $this;
}
public function getFlag(): ?bool
{
return $this->Flag;
}
public function setFlag(bool $Flag): self
{
$this->Flag = $Flag;
return $this;
}
public function getNumeroContenaire(): ?string
{
return $this->NumeroContenaire;
}
public function setNumeroContenaire(string $NumeroContenaire): self
{
$this->NumeroContenaire = $NumeroContenaire;
return $this;
}
/**
* @return Collection|SuiviContenaire[]
*/
public function getSuiviContenaires(): Collection
{
return $this->suiviContenaires;
}
public function addSuiviContenaire(SuiviContenaire $suiviContenaire): self
{
if (!$this->suiviContenaires->contains($suiviContenaire)) {
$this->suiviContenaires[] = $suiviContenaire;
$suiviContenaire->setIdCtPr($this);
}
return $this;
}
public function removeSuiviContenaire(SuiviContenaire $suiviContenaire): self
{
if ($this->suiviContenaires->contains($suiviContenaire)) {
$this->suiviContenaires->removeElement($suiviContenaire);
// set the owning side to null (unless already changed)
if ($suiviContenaire->getIdCtPr() === $this) {
$suiviContenaire->setIdCtPr(null);
}
}
return $this;
}
public function __toString(){
// to show the name of the Category in the select
return (string) $this->IdCt->getNomContenaire();
// to show the id of the Category in the select
// return $this->id;
}
public function getTransporteur(): ?string
{
return $this->transporteur;
}
public function setTransporteur(string $transporteur): self
{
$this->transporteur = $transporteur;
return $this;
}
public function getIdVille(): ?Ville
{
return $this->IdVille;
}
public function setIdVille(?Ville $IdVille): self
{
$this->IdVille = $IdVille;
return $this;
}
/**
* @return Collection|DepensesContenaire[]
*/
public function getDepensesContenaires(): Collection
{
return $this->depensesContenaires;
}
public function addDepensesContenaire(DepensesContenaire $depensesContenaire): self
{
if (!$this->depensesContenaires->contains($depensesContenaire)) {
$this->depensesContenaires[] = $depensesContenaire;
$depensesContenaire->setIdCmd($this);
}
return $this;
}
public function removeDepensesContenaire(DepensesContenaire $depensesContenaire): self
{
if ($this->depensesContenaires->contains($depensesContenaire)) {
$this->depensesContenaires->removeElement($depensesContenaire);
// set the owning side to null (unless already changed)
if ($depensesContenaire->getIdCmd() === $this) {
$depensesContenaire->setIdCmd(null);
}
}
return $this;
}
public function getCompletFlag(): ?string
{
return $this->CompletFlag;
}
public function setCompletFlag(string $CompletFlag): self
{
$this->CompletFlag = $CompletFlag;
return $this;
}
/**
* @return Collection|Declarant[]
*/
public function getDeclarants(): Collection
{
return $this->declarants;
}
public function addDeclarant(Declarant $declarant): self
{
if (!$this->declarants->contains($declarant)) {
$this->declarants[] = $declarant;
$declarant->setIdPrCt($this);
}
return $this;
}
public function removeDeclarant(Declarant $declarant): self
{
if ($this->declarants->contains($declarant)) {
$this->declarants->removeElement($declarant);
// set the owning side to null (unless already changed)
if ($declarant->getIdPrCt() === $this) {
$declarant->setIdPrCt(null);
}
}
return $this;
}
public function getProprietaireConteneur(): ?string
{
return $this->ProprietaireConteneur;
}
public function setProprietaireConteneur(?string $ProprietaireConteneur): self
{
$this->ProprietaireConteneur = $ProprietaireConteneur;
return $this;
}
public function getDestination(): ?string
{
return $this->destination;
}
public function setDestination(string $destination): self
{
$this->destination = $destination;
return $this;
}
/**
* @return Collection|Paiement[]
*/
public function getCommandes(): Collection
{
return $this->commandes;
}
public function addCommande(Commande $commandes): self
{
if (!$this->commandes->contains($commandes)) {
$this->commandes[] = $commandes;
$commandes->setIdCtPr($this);
}
return $this;
}
public function removeCommande(Commande $commandes): self
{
if ($this->commandes->contains($commandes)) {
$this->commandes->removeElement($commandes);
// set the owning side to null (unless already changed)
if ($commandes->getIdCtPr() === $this) {
$commandes->setIdCtPr(null);
}
}
return $this;
}
public function getValidation(): ?bool
{
return $this->validation;
}
public function setValidation(bool $validation): self
{
$this->validation = $validation;
return $this;
}
public function getDepensesPrevue(): ?int
{
return $this->DepensesPrevue;
}
public function setDepensesPrevue(int $DepensesPrevue): self
{
$this->DepensesPrevue = $DepensesPrevue;
return $this;
}
/**
* @return mixed
*/
public function getFacturePayer()
{
$total = 0;
foreach($this->getCommandes() as $v){
if($v->getBalance() < 1){
$total++;
}
}
return $this->facturePayer = $total;
}
/**
* @return mixed
*/
public function getFactureAccompte()
{
$total = 0;
foreach($this->getCommandes() as $v){
if($v->getBalance() < $v->getTotalAPaiyer() && $v->getBalance() > 0){
$total++;
}
}
return $this->factureAccompte = $total;
}
/**
* @return mixed
*/
public function getFactureNonPayer()
{
$total = 0;
foreach($this->getCommandes() as $v){
if($v->getNetDejaPaie() < 1 && $v->getTotalAPaiyer() > 0){
$total++;
}
}
return $this->factureNonPayer = $total;
}
/**
* @return mixed
*/
public function getFacturePayerCompassation()
{
$total = 0;
foreach($this->getCommandes() as $v){
foreach($v->getReduction() as $k){
if($k->getFlagCompassation() == 1){
$total++;
break;
}
}
}
return $this->facturePayerCompassation = $total;
}
/**
* @return mixed
*/
public function getFactureHors()
{
$total = 0;
foreach($this->getCommandes() as $v){
if($v->getFacturehors() == true){
$total++;
}
}
return $this->factureHors = $total;
}
/**
* @return mixed
*/
public function getFactureNull()
{
$total = 0;
foreach($this->getCommandes() as $v){
if($v->getFactureMarchandiseAbscent() == true){
$total++;
}
}
return $this->factureNull = $total;
}
/**
* @return mixed
*/
public function getFactureModifier()
{
$total = 0;
foreach($this->getCommandes() as $v){
if($v->getModification() == true){
$total++;
}
}
return $this->factureModifier = $total;
}
/**
* @return mixed
*/
public function getMontantFacturePayerBanque()
{
$total = 0;
foreach($this->getCommandes() as $v){
foreach($v->getReduction() as $k){
if($k->getFlagCompassation() == 2){
$total = $total + $k->getMontant();
break;
}
}
}
return $this->MontantFacturePayerBanque = $total;
}
/**
* @return mixed
*/
public function getMontantFacturePayerCash()
{
$total = 0;
foreach($this->getCommandes() as $v){
foreach($v->getPaiements() as $k){
if($k->getFlagEnAvance() == false){
$total = $total + $k->getMontant();
// break;
}
}
}
return $this->MontantFacturePayerCash = $total;
}
/**
* @return mixed
*/
public function getMontantFacturePayerAvance()
{
$total = 0;
foreach($this->getCommandes() as $v){
foreach($v->getPaiements() as $k){
if($k->getFlagEnAvance() == true){
$total = $total + $k->getMontant();
break;
}
}
}
return $this->MontantFacturePayerAvance = $total;
}
/**
* @return mixed
*/
public function getMontantFacturePayerReduction()
{
$total = 0;
foreach($this->getCommandes() as $v){
foreach($v->getReduction() as $k){
if($k->getFlagCompassation() == 0){
$total = $total + $k->getMontant();
break;
}
}
}
return $this->MontantFacturePayerReduction = $total;
}
/**
* @return mixed
*/
public function getMontantFacturePayerCompassation()
{
$total = 0;
foreach($this->getCommandes() as $v){
foreach($v->getReduction() as $k){
if($k->getFlagCompassation() == 1){
$total = $total + $k->getMontant();
break;
}
}
}
return $this->MontantFacturePayerCompassation = $total;
}
/**
* @return mixed
*/
public function getMontantTotalFacturePayer()
{
return $this->MontantTotalFacturePayer = $this->getMontantFacturePayerCash() + $this->getMontantFacturePayerAvance() + $this->getMontantFacturePayerBanque() + $this->getMontantFacturePayerCompassation() + $this->getMontantFacturePayerReduction();
}
/**
* @return mixed
*/
public function getMontantTotalBalanceFacture()
{
return $this->MontantTotalBalanceFacture = $this->getMontantTotalAPayer() - $this->getMontantTotalFactureNulle() - $this->getMontantTotalFacturePayer();
}
/**
* @return mixed
*/
public function getMontantTotalAPayer()
{
$total = 0;
foreach($this->getCommandes() as $v){
$total = $total + $v->getTotalAPaiyer();
}
return $this->MontantTotalAPayer = $total;
}
/**
* @return mixed
*/
public function getMontantTotalDepensesReel()
{
$total = 0;
foreach($this->getDepensesContenaires() as $v){
$total = $total + $v->getMontant();
}
return $this->MontantTotalDepensesReel = $total;
}
/**
* @return mixed
*/
public function getMontantTotalFactureNulle()
{
$total = 0;
foreach($this->getCommandes() as $v){
if($v->getFactureMarchandiseAbscent() == true){
$total = $total + $v->getTotalAPaiyer();
}
}
return $this->MontantTotalFactureNulle = $total;
}
/**
* @return mixed
*/
public function getTotalCBM()
{
$total = 0;
foreach($this->getCommandes() as $v){
foreach($v->getTmpVolumes() as $k){
if($k->getUnite() == 'CBM'){
$total = $total + $k->getVolume();
}
}
}
return $this->TotalCBM = $total;
}
/**
* @return mixed
*/
public function getTotalTONNE()
{
$total = 0;
foreach($this->getCommandes() as $v){
foreach($v->getTmpVolumes() as $k){
if($k->getUnite() == 'TONNE'){
$total = $total + $k->getVolume();
}
}
}
return $this->TotalTONNE = $total;
}
/**
* @return mixed
*/
public function getLieu()
{
$position = 'A DETERMINER';
foreach($this->getSuiviContenaires() as $v){
if($v->getPositionActuelleFlag() === true){
$position = $v->getLieu();
}
}
return $this->lieu = $position;
}
/**
* @return mixed
*/
public function getLieuDate()
{
$positionDate = new \DateTime(date('d-m-Y'));
foreach($this->getSuiviContenaires() as $v){
if($v->getPositionActuelleFlag() === true){
$positionDate = $v->getDateOperation();
}
}
return $this->lieuDate = $positionDate;
}
/**
* @return mixed
*/
public function getDeclarant()
{
$declarant = 'A DETERMINER';
foreach($this->getDeclarants() as $v){
$declarant = $v->getNomDeclarant();
}
return $this->declarant = $declarant;
}
/**
* @return Collection|RemarqueConteneur[]
*/
public function getRemarqueConteneurs(): Collection
{
return $this->remarqueConteneurs;
}
public function addRemarqueConteneur(RemarqueConteneur $remarqueConteneur): self
{
if (!$this->remarqueConteneurs->contains($remarqueConteneur)) {
$this->remarqueConteneurs[] = $remarqueConteneur;
$remarqueConteneur->setProgrammeConteneur($this);
}
return $this;
}
public function removeRemarqueConteneur(RemarqueConteneur $remarqueConteneur): self
{
if ($this->remarqueConteneurs->contains($remarqueConteneur)) {
$this->remarqueConteneurs->removeElement($remarqueConteneur);
// set the owning side to null (unless already changed)
if ($remarqueConteneur->getProgrammeConteneur() === $this) {
$remarqueConteneur->setProgrammeConteneur(null);
}
}
return $this;
}
/**
* @return mixed
*/
public function getTotalCOLIS()
{
$total = 0;
foreach($this->getCommandes() as $v){
$total = $total + $v->getTotalCOLIS();
}
return $this->TotalCOLIS = $total;
}
/**
* @return mixed
*/
public function getMontantTotalAutreFraisPayer()
{
$total = 0;
foreach($this->getCommandes() as $v){
$total = $total + $v->getTotalAPaiyerAutraiFrais();
}
return $this->MontantTotalAutreFraisPayer = $total;
}
/**
* @return mixed
*/
public function getTotalAPaiyerVolume()
{
$total = 0;
foreach($this->getCommandes() as $v){
$total = $total + $v->getTotalAPaiyerVolume();
}
return $this->TotalAPaiyerVolume = $total;
}
/**
* @return mixed
*/
public function getRemarqueConteneur()
{
return $this->remarqueConteneur;
}
/**
* @param mixed $remarqueConteneur
*/
public function setRemarqueConteneur($remarqueConteneur)
{
$this->remarqueConteneur = $remarqueConteneur;
}
public function isIsMco(): ?bool
{
return $this->isMco;
}
public function setIsMco(bool $isMco): self
{
$this->isMco = $isMco;
return $this;
}
public function isIsRapport(): ?bool
{
return $this->isRapport;
}
public function setIsRapport(bool $isRapport): self
{
$this->isRapport = $isRapport;
return $this;
}
public function getDateRapportAt(): ?\DateTimeInterface
{
return $this->dateRapportAt;
}
public function setDateRapportAt(?\DateTimeInterface $dateRapportAt): self
{
$this->dateRapportAt = $dateRapportAt;
return $this;
}
public function isIsClients(): ?bool
{
return $this->isClients;
}
public function setIsClients(bool $isClients): self
{
$this->isClients = $isClients;
return $this;
}
public function getVilleInitiale(): ?Ville
{
return $this->villeInitiale;
}
public function setVilleInitiale(?Ville $villeInitiale): self
{
$this->villeInitiale = $villeInitiale;
return $this;
}
/**
* @return Collection<int, Notification>
*/
public function getNotifications(): Collection
{
return $this->notifications;
}
public function addNotification(Notification $notification): self
{
if (!$this->notifications->contains($notification)) {
$this->notifications[] = $notification;
$notification->setPrct($this);
}
return $this;
}
public function removeNotification(Notification $notification): self
{
if ($this->notifications->removeElement($notification)) {
// set the owning side to null (unless already changed)
if ($notification->getPrct() === $this) {
$notification->setPrct(null);
}
}
return $this;
}
/**
* @return Collection<int, TmpConteneurReception>
*/
public function getTmpConteneurReceptions(): Collection
{
return $this->tmpConteneurReceptions;
}
public function addTmpConteneurReception(TmpConteneurReception $tmpConteneurReception): self
{
if (!$this->tmpConteneurReceptions->contains($tmpConteneurReception)) {
$this->tmpConteneurReceptions[] = $tmpConteneurReception;
$tmpConteneurReception->setProgramme($this);
}
return $this;
}
public function removeTmpConteneurReception(TmpConteneurReception $tmpConteneurReception): self
{
if ($this->tmpConteneurReceptions->removeElement($tmpConteneurReception)) {
// set the owning side to null (unless already changed)
if ($tmpConteneurReception->getProgramme() === $this) {
$tmpConteneurReception->setProgramme(null);
}
}
return $this;
}
public function getRapport(): ?string
{
return $this->rapport;
}
public function setRapport(string $rapport): self
{
$this->rapport = $rapport;
return $this;
}
}