<?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, cascade={"persist", "remove"})
*/
private $suiviContenaires;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $transporteur;
/**
* @ORM\ManyToOne(targetEntity=Ville::class, inversedBy="programmeContenaires")
* @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;
/**
* @ORM\Column(type="boolean")
*/
private $isElectronique;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
private $dateValidation;
/**
* @ORM\Column(type="boolean")
*/
private $isNotifier;
/**
* @ORM\Column(type="string", length=1, nullable=true)
*/
private $fin;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
private $dateValidationFin;
/**
* @ORM\Column(type="datetime_immutable", nullable=true)
*/
private $dateattribution;
/**
* CHANGÉ DE OneToOne À ManyToOne POUR LA GESTION MULTI-PROGRAMMES
* @ORM\ManyToOne(targetEntity=Agent::class, inversedBy="programmeContenaireGestionnaire")
*/
private $agentGestionnaire;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $payeGestionnaire;
public function __construct()
{
$this->DateOperation = new \DateTime();
$this->Flag = false;
$this->isClients = false;
$this->validation = false;
$this->isNotifier = false;
$this->isElectronique = false;
$this->isMco = false;
$this->suiviContenaires = 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();
$this->commandes = new ArrayCollection();
$this->payeGestionnaire = false;
}
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 getFin(): ?string { return $this->fin; }
public function setFin(?string $fin): self { $this->fin = $fin; return $this; }
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);
if ($suiviContenaire->getIdCtPr() === $this) { $suiviContenaire->setIdCtPr(null); }
}
return $this;
}
public function __toString(){
return $this->IdCt ? (string) $this->IdCt->getNomContenaire() : 'Conteneur non défini';
}
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);
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);
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|Commande[] */
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);
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; }
/** --- MÉTHODES MÉTIER DE CALCUL --- **/
public function getFacturePayer()
{
$total = 0;
foreach($this->getCommandes() as $v){ if($v->getBalance() < 1){ $total++; } }
return $this->facturePayer = $total;
}
public function getFactureAccompte()
{
$total = 0;
foreach($this->getCommandes() as $v){ if($v->getBalance() < $v->getTotalAPaiyer() && $v->getBalance() > 0){ $total++; } }
return $this->factureAccompte = $total;
}
public function getFactureNonPayer()
{
$total = 0;
foreach($this->getCommandes() as $v){ if($v->getNetDejaPaie() < 1 && $v->getTotalAPaiyer() > 0){ $total++; } }
return $this->factureNonPayer = $total;
}
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;
}
public function getFactureHors()
{
$total = 0;
foreach($this->getCommandes() as $v){ if($v->getFacturehors() == true){ $total++; } }
return $this->factureHors = $total;
}
public function getFactureNull()
{
$total = 0;
foreach($this->getCommandes() as $v){ if($v->getFactureMarchandiseAbscent() == true){ $total++; } }
return $this->factureNull = $total;
}
public function getFactureModifier()
{
$total = 0;
foreach($this->getCommandes() as $v){ if($v->getModification() == true){ $total++; } }
return $this->factureModifier = $total;
}
public function getMontantFacturePayerBanque()
{
$total = 0;
foreach($this->getCommandes() as $v){
foreach($v->getReduction() as $k){ if($k->getFlagCompassation() == 2){ $total += $k->getMontant(); break; } }
}
return $this->MontantFacturePayerBanque = $total;
}
public function getMontantFacturePayerCash()
{
$total = 0;
foreach($this->getCommandes() as $v){
foreach($v->getPaiements() as $k){ if($k->getFlagEnAvance() == false){ $total += $k->getMontant(); } }
}
return $this->MontantFacturePayerCash = $total;
}
public function getMontantFacturePayerAvance()
{
$total = 0;
foreach($this->getCommandes() as $v){
foreach($v->getPaiements() as $k){ if($k->getFlagEnAvance() == true){ $total += $k->getMontant(); break; } }
}
return $this->MontantFacturePayerAvance = $total;
}
public function getMontantFacturePayerReduction()
{
$total = 0;
foreach($this->getCommandes() as $v){
foreach($v->getReduction() as $k){ if($k->getFlagCompassation() == 0){ $total += $k->getMontant(); break; } }
}
return $this->MontantFacturePayerReduction = $total;
}
public function getMontantFacturePayerCompassation()
{
$total = 0;
foreach($this->getCommandes() as $v){
foreach($v->getReduction() as $k){ if($k->getFlagCompassation() == 1){ $total += $k->getMontant(); break; } }
}
return $this->MontantFacturePayerCompassation = $total;
}
public function getMontantTotalFacturePayer()
{
return $this->MontantTotalFacturePayer = $this->getMontantFacturePayerCash() + $this->getMontantFacturePayerAvance() + $this->getMontantFacturePayerBanque() + $this->getMontantFacturePayerCompassation() + $this->getMontantFacturePayerReduction();
}
public function getMontantTotalBalanceFacture()
{
return $this->MontantTotalBalanceFacture = $this->getMontantTotalAPayer() - $this->getMontantTotalFactureNulle() - $this->getMontantTotalFacturePayer();
}
public function getMontantTotalAPayer()
{
$total = 0;
foreach($this->getCommandes() as $v){ $total += $v->getTotalAPaiyer(); }
return $this->MontantTotalAPayer = $total;
}
public function getMontantTotalDepensesReel()
{
$total = 0;
foreach($this->getDepensesContenaires() as $v){ $total += $v->getMontant(); }
return $this->MontantTotalDepensesReel = $total;
}
public function getMontantTotalFactureNulle()
{
$total = 0;
foreach($this->getCommandes() as $v){ if($v->getFactureMarchandiseAbscent() == true){ $total += $v->getTotalAPaiyer(); } }
return $this->MontantTotalFactureNulle = $total;
}
public function getTotalCBM()
{
$total = 0;
foreach($this->getCommandes() as $v){
foreach($v->getTmpVolumes() as $k){ if($k->getUnite() == 'CBM'){ $total += $k->getVolume(); } }
}
return $this->TotalCBM = $total;
}
public function getTotalTONNE()
{
$total = 0;
foreach($this->getCommandes() as $v){
foreach($v->getTmpVolumes() as $k){ if($k->getUnite() == 'TONNE'){ $total += $k->getVolume(); } }
}
return $this->TotalTONNE = $total;
}
public function getLieu()
{
$position = 'A DETERMINER';
foreach($this->getSuiviContenaires() as $v){ if($v->getPositionActuelleFlag() === true){ $position = $v->getLieu(); } }
return $this->lieu = $position;
}
public function getLieuDate()
{
$positionDate = new \DateTime();
foreach($this->getSuiviContenaires() as $v){ if($v->getPositionActuelleFlag() === true){ $positionDate = $v->getDateOperation(); } }
return $this->lieuDate = $positionDate;
}
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);
if ($remarqueConteneur->getProgrammeConteneur() === $this) { $remarqueConteneur->setProgrammeConteneur(null); }
}
return $this;
}
public function getTotalCOLIS()
{
$total = 0;
foreach($this->getCommandes() as $v){ $total += $v->getTotalCOLIS(); }
return $this->TotalCOLIS = $total;
}
public function getMontantTotalAutreFraisPayer()
{
$total = 0;
foreach($this->getCommandes() as $v){ $total += $v->getTotalAPaiyerAutraiFrais(); }
return $this->MontantTotalAutreFraisPayer = $total;
}
public function getTotalAPaiyerVolume()
{
$total = 0;
foreach($this->getCommandes() as $v){ $total += $v->getTotalAPaiyerVolume(); }
return $this->TotalAPaiyerVolume = $total;
}
public function getRemarqueConteneur() { return $this->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)) {
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)) {
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; }
public function isIsElectronique(): ?bool { return $this->isElectronique; }
public function setIsElectronique(bool $isElectronique): self { $this->isElectronique = $isElectronique; return $this; }
public function getDateValidation(): ?\DateTimeImmutable { return $this->dateValidation; }
public function setDateValidation(?\DateTimeImmutable $dateValidation): self { $this->dateValidation = $dateValidation; return $this; }
public function getDateValidationFin(): ?\DateTimeImmutable { return $this->dateValidationFin; }
public function setDateValidationFin(?\DateTimeImmutable $dateValidationFin): self { $this->dateValidationFin = $dateValidationFin; return $this; }
public function getDateattibution(): ?\DateTimeImmutable { return $this->dateattribution; }
public function setDateattibution(?\DateTimeImmutable $dateattribution): self { $this->dateattribution = $dateattribution; return $this; }
public function isIsNotifier(): ?bool { return $this->isNotifier; }
public function setIsNotifier(bool $isNotifier): self { $this->isNotifier = $isNotifier; return $this; }
public function getAgentGestionnaire(): ?Agent { return $this->agentGestionnaire; }
public function setAgentGestionnaire(?Agent $agentGestionnaire): self
{
$this->agentGestionnaire = $agentGestionnaire;
return $this;
}
public function isPayeGestionnaire(): ?bool { return $this->payeGestionnaire; }
public function setPayeGestionnaire(?bool $payeGestionnaire): self { $this->payeGestionnaire = $payeGestionnaire; return $this; }
}