src/Entity/Lot.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\LotRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=LotRepository::class)
  9.  */
  10. class Lot
  11. {
  12.     const IMAGE_SAVE_PATH 'uploads/lots_images/';
  13.     
  14.     const BROCHURE_SAVE_PATH 'uploads/brochures/';
  15.     const PLAN_MASSE_SAVE_PATH 'uploads/plans_masse/';
  16.     const STATUTS = [
  17.         'vendu' => 'red',
  18.         'libre' => 'green',
  19.         'option' => 'yellow',
  20.         'reserve' => 'purple',
  21.     ];
  22.     const NATURES = [
  23.         'appartement' => 'Appartement',
  24.         'maison' => 'Maison',
  25.         'terrain' => 'Terrain',
  26.         'local_commercial' => 'Local commercial',
  27.     ];
  28.     const ETATS_PRODUCTION = [
  29.         'incomplet' => 'INCOMPLET',
  30.         'en_preparation' => 'EN PREPARATION',
  31.         'complet' => 'PRET A L\'ENVOI',
  32.     ];
  33.     const INTITULES_PREDEFINIS = [
  34.         'visuels_3d' => 'Visuels 3D',
  35.         'localisation' => 'Localisation',
  36.         'insertion_3d' => 'Insertion 3D sur plan masse / maquette',
  37.         'mise_en_couleur' => 'Mise en couleur du lot',
  38.         'flechage_niveau' => 'Fléchage plan de niveau/ plan de coupe',
  39.         'flechage_masse' => 'Fléchage sur plan masse/ maquette 3D',
  40.         'stationnements' => 'Stationnements / Caves',
  41.         'local_velo' => 'Local vélo',
  42.         'acces_transports' => 'Accès & Transports',
  43.         'prestations_generales' => 'Prestations Générales',
  44.         'photos_appartement' => 'Photos de l\'appartement',
  45.         'photos_construction' => 'Photos du site de construction',
  46.         'photos_environnement' => 'Photos de l\'environnement du site',
  47.         'itineraire_geneve' => 'Itinéraire site de construction - Genève',
  48.         'itineraire_annecy' => 'Itinéraire site de construction - Lac d\'Annecy',
  49.         'itineraire_aeroport' => 'Itinéraire site de construction - aéroport Genève',
  50.         'itineraire_gare' => 'Itinéraire site de construction - Gare / CEVA EXPRESS',
  51.         'itineraire_personnalise' => 'Itinéraire personnalisé'
  52.     ];
  53.     /**
  54.      * @ORM\Id
  55.      * @ORM\GeneratedValue
  56.      * @ORM\Column(type="integer")
  57.      */
  58.     private $id;
  59.     /**
  60.      * @ORM\Column(type="string", length=255, nullable=true)
  61.      */
  62.     private $reference;
  63.     /**
  64.      * @ORM\Column(type="string", length=255, nullable=true)
  65.      */
  66.     private $type;
  67.     /**
  68.      * @ORM\Column(type="string", length=255, nullable=true)
  69.      */
  70.     private $adresse;
  71.     /**
  72.      * @ORM\Column(type="string", length=255, nullable=true)
  73.      */
  74.     private $ville;
  75.     /**
  76.      * @ORM\Column(type="string", length=10, nullable=true)
  77.      */
  78.     private $codePostal;
  79.     /**
  80.      * @ORM\Column(type="float", nullable=true)
  81.      */
  82.     private $prix;
  83.     /**
  84.      * @ORM\Column(type="datetime", nullable=true)
  85.      */
  86.     private $dateLivraison;
  87.     /**
  88.      * @ORM\Column(type="string", length=255, nullable=true)
  89.      */
  90.     private $titre;
  91.     /**
  92.      * @ORM\Column(type="text", nullable=true)
  93.      */
  94.     private $description;
  95.     /**
  96.      * @ORM\Column(type="float", nullable=true)
  97.      */
  98.     private $latitude;
  99.     /**
  100.      * @ORM\Column(type="float", nullable=true)
  101.      */
  102.     private $longitude;
  103.     /**
  104.      * @ORM\Column(type="string", length=64, nullable=true)
  105.      */
  106.     private $etage;
  107.     /**
  108.      * @ORM\Column(type="float", nullable=true)
  109.      */
  110.     private $superficie;
  111.     /**
  112.      * @ORM\Column(type="float", nullable=true)
  113.      */
  114.     private $terrasse;
  115.     /**
  116.      * @ORM\Column(type="string", length=32, nullable=true)
  117.      */
  118.     private $orientation;
  119.     /**
  120.      * @ORM\Column(type="string", length=128, nullable=true)
  121.      */
  122.     private $annexes;
  123.     /**
  124.      * @ORM\Column(type="string", length=64, nullable=true)
  125.      */
  126.     private $livraison;
  127.     /**
  128.      * @ORM\Column(type="string", length=128, nullable=true)
  129.      */
  130.     private $promoteur;
  131.     /**
  132.      * @ORM\Column(type="string", length=64, nullable=true)
  133.      */
  134.     private $programme;
  135.     /**
  136.      * @ORM\OneToMany(targetEntity=PieceJointe::class, mappedBy="lot", cascade={"persist", "remove"})
  137.      * @ORM\OrderBy({"ordre" = "ASC"})
  138.      */
  139.     private $pjs;
  140.     /**
  141.      * @ORM\Column(type="string", length=255, nullable=true)
  142.      */
  143.     private $image;
  144.     /**
  145.      * @ORM\Column(type="float", nullable=true)
  146.      */
  147.     private $jardin;
  148.     /**
  149.      * @ORM\Column(type="float", nullable=true)
  150.      */
  151.     private $terrasse2;
  152.     /**
  153.      * @ORM\OneToMany(targetEntity=Proposition::class, mappedBy="lot", orphanRemoval=true)
  154.      */
  155.     private $propositions;
  156.     /**
  157.      * @ORM\Column(type="string", length=255, nullable=false)
  158.      */
  159.     private $fraisNotaireType 'reduits';
  160.     /**
  161.      * @ORM\Column(type="float", nullable=true)
  162.      */
  163.     private $fraisNotaireInclus;
  164.     /**
  165.      * @ORM\Column(type="string", length=255, nullable=true)
  166.      */
  167.     private $brochure;
  168.     /**
  169.      * @ORM\ManyToMany(targetEntity=Historique::class, mappedBy="lots")
  170.      */
  171.     private $historiques;
  172.     /**
  173.      * @ORM\ManyToOne(targetEntity=Programme::class, inversedBy="lots")
  174.      * @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
  175.      */
  176.     private $programmeParent;
  177.     /**
  178.      * @ORM\Column(type="text", length=255, nullable=true)
  179.      */
  180.     private $planMasse;
  181.     /**
  182.      * @ORM\Column(type="string", length=255, nullable=true)
  183.      */
  184.     private $statut;
  185.     /**
  186.      * @ORM\Column(type="string", length=255, nullable=true)
  187.      */
  188.     private $nature;
  189.     /**
  190.      * @ORM\Column(type="string", length=255, nullable=true)
  191.      */
  192.     private $typeMoteurRecherche;
  193.     /**
  194.      * @ORM\Column(type="string", length=64, nullable=true)
  195.      */
  196.     private $etageMoteurRecherche;
  197.     /**
  198.      * @ORM\Column(type="string", length=255, nullable=true)
  199.      */
  200.     private $etatLot;
  201.     /**
  202.      * @ORM\Column(type="json", nullable=true)
  203.      */
  204.     private $pjProgression = [];
  205.     public static function getStatutsString() {
  206.         $tab = [];
  207.         foreach(self::STATUTS as $k => $v) {
  208.             $tab[$k] = ucfirst($k); 
  209.         }
  210.         return $tab;
  211.     }
  212.     public static function getStatutsForForm() {
  213.         return [
  214.             'Vendu' => 'vendu',
  215.             'Libre' => 'libre',
  216.             'Option' => 'option',
  217.             'Réservé' => 'reserve',
  218.         ];
  219.     }    
  220.     public function __construct()
  221.     {
  222.         $this->pjs = new ArrayCollection();
  223.         $this->propositions = new ArrayCollection();
  224.         $this->historiques = new ArrayCollection();
  225.         $this->etatLot 'incomplet';
  226.     }
  227.     public function __clone()
  228.     {
  229.         if ($this->id) {
  230.             $this->id null;
  231.             $clonedPjs = new ArrayCollection();
  232.             foreach ($this->pjs as $pj) {
  233.                 $clonedPj = clone $pj;
  234.                 $clonedPj->setLot($this);
  235.                 $clonedPjs->add($clonedPj);
  236.             }
  237.             $this->pjs $clonedPjs;
  238.         }
  239.     }
  240.     public function __toString() {
  241.         if($this->getId() == null) {
  242.             return 'Nouveau lot';
  243.         } else {
  244.             $etatLotKey $this->getetatLot();
  245.             $etatLotValue array_key_exists($etatLotKeyself::ETATS_PRODUCTION) ? self::ETATS_PRODUCTION[$etatLotKey] : 'N/A';
  246.             return trim((trim($this->getReference()) != '' 'n°' $this->getReference() . ' - ' '')). ' ' trim((trim($this->getVille()) != '' '' $this->getVille() . ' - ' '') . $this->getProgramme() . ' (' $this->getType() . ') - ' number_format($this->getPrix(), 2','' ') . '€' ' - ' $etatLotValue);
  247.         }
  248.     }
  249.     public function getId(): ?int
  250.     {
  251.         return $this->id;
  252.     }
  253.     public function getReference(): ?string
  254.     {
  255.         return strtoupper($this->reference);
  256.     }
  257.     public function setReference(?string $reference): self
  258.     {
  259.         $this->reference $reference;
  260.         return $this;
  261.     }
  262.     public function getType(): ?string
  263.     {
  264.         return str_replace('é''É',
  265.             str_replace('è''È',
  266.                 str_replace('à''À',
  267.                     strtoupper($this->type)
  268.                 )
  269.             )
  270.         );
  271.     }
  272.     public function setType(?string $type): self
  273.     {
  274.         $this->type $type;
  275.         return $this;
  276.     }
  277.     public function getAdresse(): ?string
  278.     {
  279.         return str_replace('é''É',
  280.             str_replace('è''È',
  281.                 str_replace('à''À',
  282.                     strtoupper($this->adresse)
  283.                 )
  284.             )
  285.         );
  286.     }
  287.     public function setAdresse(?string $adresse): self
  288.     {
  289.         $this->adresse $adresse;
  290.         return $this;
  291.     }
  292.     public function getVille(): ?string
  293.     {
  294.         return strtoupper($this->ville);
  295.     }
  296.     public function setVille(?string $ville): self
  297.     {
  298.         $this->ville $ville;
  299.         return $this;
  300.     }
  301.     public function getCodePostal(): ?string
  302.     {
  303.         return strtoupper($this->codePostal);
  304.     }
  305.     public function setCodePostal(?string $codePostal): self
  306.     {
  307.         $this->codePostal $codePostal;
  308.         return $this;
  309.     }
  310.     public function getPrix(): ?float
  311.     {
  312.         return $this->prix;
  313.     }
  314.     public function setPrix(?float $prix): self
  315.     {
  316.         $this->prix $prix;
  317.         return $this;
  318.     }
  319.     public function getDateLivraison(): ?\DateTimeInterface
  320.     {
  321.         return $this->dateLivraison;
  322.     }
  323.     public function setDateLivraison(?\DateTimeInterface $dateLivraison): self
  324.     {
  325.         $this->dateLivraison $dateLivraison;
  326.         return $this;
  327.     }
  328.     public function getTitre(): ?string
  329.     {
  330.         return strtoupper($this->titre);
  331.     }
  332.     public function setTitre(?string $titre): self
  333.     {
  334.         $this->titre $titre;
  335.         return $this;
  336.     }
  337.     public function getDescription(): ?string
  338.     {
  339.         return html_entity_decode(strip_tags($this->description));
  340.     }
  341.     public function setDescription(?string $description): self
  342.     {
  343.         $this->description $description;
  344.         return $this;
  345.     }
  346.     public function getLatitude(): ?float
  347.     {
  348.         return $this->latitude;
  349.     }
  350.     public function setLatitude(?float $latitude): self
  351.     {
  352.         $this->latitude $latitude;
  353.         return $this;
  354.     }
  355.     public function getLongitude(): ?float
  356.     {
  357.         return $this->longitude;
  358.     }
  359.     public function setLongitude(?float $longitude): self
  360.     {
  361.         $this->longitude $longitude;
  362.         return $this;
  363.     }
  364.     public function getEtage(): ?string
  365.     {
  366.         return strtoupper($this->etage);
  367.     }
  368.     public function setEtage(?string $etage): self
  369.     {
  370.         $this->etage $etage;
  371.         return $this;
  372.     }
  373.     public function getSuperficie(): ?float
  374.     {
  375.         return $this->superficie;
  376.     }
  377.     public function setSuperficie(?float $superficie): self
  378.     {
  379.         $this->superficie $superficie;
  380.         return $this;
  381.     }
  382.     public function getTerrasse(): ?float
  383.     {
  384.         return $this->terrasse;
  385.     }
  386.     public function setTerrasse(?float $terrasse): self
  387.     {
  388.         $this->terrasse $terrasse;
  389.         return $this;
  390.     }
  391.     public function getOrientation(): ?string
  392.     {
  393.         return $this->orientation;
  394.     }
  395.     public function setOrientation(?string $orientation): self
  396.     {
  397.         $this->orientation $orientation;
  398.         return $this;
  399.     }
  400.     public function getAnnexes(): ?string
  401.     {
  402.         return $this->annexes;
  403.     }
  404.     public function setAnnexes(?string $annexes): self
  405.     {
  406.         $this->annexes $annexes;
  407.         return $this;
  408.     }
  409.     public function getLivraison(): ?string
  410.     {
  411.         return strtoupper($this->livraison);
  412.     }
  413.     public function setLivraison(?string $livraison): self
  414.     {
  415.         $this->livraison $livraison;
  416.         return $this;
  417.     }
  418.     public function getPromoteur(): ?string
  419.     {
  420.         return strtoupper($this->promoteur);
  421.     }
  422.     public function setPromoteur(?string $promoteur): self
  423.     {
  424.         $this->promoteur $promoteur;
  425.         return $this;
  426.     }
  427.     public function getProgramme(): ?string
  428.     {
  429.         if($this->getProgrammeParent()) return strtoupper($this->getProgrammeParent()->getNom());
  430.         return strtoupper($this->programme);
  431.     }
  432.     public function setProgramme(?string $programme): self
  433.     {
  434.         $this->programme $programme;
  435.         return $this;
  436.     }
  437.     public function getPlan() {
  438.         foreach($this->getPjs() as $pj) {
  439.             if($pj->getEstUnPlan()) {
  440.                 return $pj;
  441.             }
  442.         }
  443.         return null;
  444.     }
  445.     public function getImageAdminLot() {
  446.         foreach($this->getPjs() as $pj) {
  447.             if($pj->getEstImageAdmin()) {
  448.                 return $pj;
  449.             }
  450.         }
  451.         return null;
  452.     }
  453.     public function getPjByOrdre($ordre) {
  454.         foreach($this->getPjs() as $pj) {
  455.             if($pj->getOrdre() == $ordre) {
  456.                 return $pj;
  457.             }
  458.         }
  459.         return null;
  460.     }
  461.     /**
  462.      * @return Collection|PieceJointe[]
  463.      */
  464.     public function getPjs(): Collection
  465.     {
  466.         return $this->pjs;
  467.     }
  468.     public function addPj(PieceJointe $pj): self
  469.     {
  470.         if (!$this->pjs->contains($pj)) {
  471.             $this->pjs[] = $pj;
  472.             $pj->setLot($this);
  473.         }
  474.         return $this;
  475.     }
  476.     public function removePj(PieceJointe $pj): self
  477.     {
  478.         if ($this->pjs->removeElement($pj)) {
  479.             // set the owning side to null (unless already changed)
  480.             if ($pj->getLot() === $this) {
  481.                 $pj->setLot(null);
  482.             }
  483.         }
  484.         return $this;
  485.     }
  486.     public function getImage(): ?string
  487.     {
  488.         return $this->image;
  489.     }
  490.     public function setImage(?string $image): self
  491.     {
  492.         $this->image $image;
  493.         return $this;
  494.     }
  495.     public function getJardin(): ?float
  496.     {
  497.         return $this->jardin;
  498.     }
  499.     public function setJardin(?float $jardin): self
  500.     {
  501.         $this->jardin $jardin;
  502.         return $this;
  503.     }
  504.     public function getTerrasse2(): ?float
  505.     {
  506.         return $this->terrasse2;
  507.     }
  508.     public function setTerrasse2(?float $terrasse2): self
  509.     {
  510.         $this->terrasse2 $terrasse2;
  511.         return $this;
  512.     }
  513.     /**
  514.      * @return Collection|Proposition[]
  515.      */
  516.     public function getPropositions(): Collection
  517.     {
  518.         return $this->propositions;
  519.     }
  520.     public function addProposition(Proposition $proposition): self
  521.     {
  522.         if (!$this->propositions->contains($proposition)) {
  523.             $this->propositions[] = $proposition;
  524.             $proposition->setActiveProposition(true);
  525.             $proposition->setLot($this);
  526.         }
  527.         return $this;
  528.     }
  529.     public function removeProposition(Proposition $proposition): self
  530.     {
  531.         if ($this->propositions->removeElement($proposition)) {
  532.             // set the owning side to null (unless already changed)
  533.             if ($proposition->getLot() === $this) {
  534.                 $proposition->setLot(null);
  535.             }
  536.         }
  537.         return $this;
  538.     }
  539.     public function getFraisNotaireType(): ?string
  540.     {
  541.         return $this->fraisNotaireType;
  542.     }
  543.     public function setFraisNotaireType(?string $fraisNotaireType): self
  544.     {
  545.         $this->fraisNotaireType $fraisNotaireType;
  546.         return $this;
  547.     }
  548.     public function getFraisNotaireInclus(): ?float
  549.     {
  550.         return $this->fraisNotaireInclus;
  551.     }
  552.     public function setFraisNotaireInclus(?float $fraisNotaireInclus): self
  553.     {
  554.         $this->fraisNotaireInclus $fraisNotaireInclus;
  555.         return $this;
  556.     }
  557.     public function getBrochure(): ?string
  558.     {
  559.         return $this->brochure;
  560.     }
  561.     public function setBrochure(?string $brochure): self
  562.     {
  563.         $this->brochure $brochure;
  564.         return $this;
  565.     }
  566.     /**
  567.      * @return Collection|Historique[]
  568.      */
  569.     public function getHistoriques(): Collection
  570.     {
  571.         return $this->historiques;
  572.     }
  573.     public function addHistorique(Historique $historique): self
  574.     {
  575.         if (!$this->historiques->contains($historique)) {
  576.             $this->historiques[] = $historique;
  577.             $historique->addLot($this);
  578.         }
  579.         return $this;
  580.     }
  581.     public function removeHistorique(Historique $historique): self
  582.     {
  583.         if ($this->historiques->removeElement($historique)) {
  584.             $historique->removeLot($this);
  585.         }
  586.         return $this;
  587.     }
  588.     public function getProgrammeParent(): ?Programme
  589.     {
  590.         return $this->programmeParent;
  591.     }
  592.     public function setProgrammeParent(?Programme $programmeParent): self
  593.     {
  594.         $this->programmeParent $programmeParent;
  595.         return $this;
  596.     }
  597.     public function getPlanMasse(): ?string
  598.     {
  599.         return $this->planMasse;
  600.     }
  601.     public function setPlanMasse(?string $planMasse): self
  602.     {
  603.         $this->planMasse $planMasse;
  604.         return $this;
  605.     }
  606.     public function getStatut(): ?string
  607.     {
  608.         return $this->statut;
  609.     }
  610.     public function setStatut(?string $statut): self
  611.     {
  612.         $this->statut $statut;
  613.         return $this;
  614.     }
  615.     public function getStatutString(): ?String
  616.     {
  617.         return ucfirst($this->getStatut());
  618.     }
  619.     public function getStatutClass(): ?String
  620.     {
  621.         return self::STATUTS[$this->getStatut()];
  622.     }
  623.     public function getNature(): ?string
  624.     {
  625.         return $this->nature;
  626.     }
  627.     public function setNature(?string $nature): self
  628.     {
  629.         $this->nature $nature;
  630.         return $this;
  631.     }
  632.     public function getTypeMoteurRecherche(): ?string
  633.     {
  634.         return $this->typeMoteurRecherche;
  635.     }
  636.     public function setTypeMoteurRecherche(?string $typeMoteurRecherche): self
  637.     {
  638.         $this->typeMoteurRecherche $typeMoteurRecherche;
  639.         return $this;
  640.     }
  641.     public function getEtageMoteurRecherche(): ?string
  642.     {
  643.         return $this->etageMoteurRecherche;
  644.     }
  645.     public function setEtageMoteurRecherche(?string $etageMoteurRecherche): self
  646.     {
  647.         $this->etageMoteurRecherche $etageMoteurRecherche;
  648.         return $this;
  649.     }
  650.     public function getetatLot(): ?string
  651.     {
  652.         return $this->etatLot;
  653.     }
  654.     public function setetatLot(?string $etatLot): self
  655.     {
  656.         $this->etatLot $etatLot;
  657.         return $this;
  658.     }
  659.     public function getPjProgression(): ?array
  660.     {
  661.         return $this->pjProgression;
  662.     }
  663.     public function setPjProgression(?array $pjProgression): self
  664.     {
  665.         $this->pjProgression $pjProgression;
  666.         return $this;
  667.     }
  668. }