src/Entity/Chantier.php line 17

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\EntityTrait;
  4. use App\Repository\ChantierRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  10. /**
  11.  * @Vich\Uploadable
  12.  * @ORM\Entity(repositoryClass=ChantierRepository::class)
  13.  */
  14. class Chantier
  15. {
  16.     use EntityTrait {
  17.         EntityTrait::__construct as private __entityConstruct;
  18.     }
  19.     /**
  20.      * @ORM\Column(type="string", length=255)
  21.      */
  22.     private $name;
  23.     /**
  24.      * @ORM\Column(type="string", length=255)
  25.      */
  26.     private $address;
  27.     /**
  28.      * @ORM\Column(type="string", length=255)
  29.      */
  30.     private $postal_code;
  31.     /**
  32.      * @ORM\Column(type="string", length=255)
  33.      */
  34.     private $city;
  35.     /**
  36.      * @ORM\Column(type="float")
  37.      */
  38.     private $discount;
  39.     /**
  40.      * @ORM\Column(type="boolean")
  41.      */
  42.     private $nacelle;
  43.     /**
  44.      * @ORM\Column(type="string", length=255, nullable=true)
  45.      */
  46.     private $nacelle_type;
  47.     /**
  48.      * @ORM\Column(type="string", nullable=true)
  49.      */
  50.     private $nacelle_size;
  51.     /**
  52.      * @ORM\Column(type="string", length=255, nullable=true)
  53.      */
  54.     private $nacelle_emplacement;
  55.     /**
  56.      * @ORM\Column(type="boolean")
  57.      */
  58.     private $harnais;
  59.     /**
  60.      * @ORM\Column(type="string", length=255, nullable=true)
  61.      */
  62.     private $acces_chantier;
  63.     /**
  64.      * @ORM\Column(type="string", length=255, nullable=true)
  65.      */
  66.     private $ascenseur_monte_charge;
  67.     /**
  68.      * @ORM\ManyToOne(targetEntity=CustomerContact::class, inversedBy="chantiers")
  69.      */
  70.     private $customer_contact;
  71.     /**
  72.      * @ORM\Column(type="string", length=255, nullable=true)
  73.      */
  74.     private $customer_company_code;
  75.     /**
  76.      * @ORM\Column(type="string", length=255)
  77.      */
  78.     private $customer_company_name;
  79.     /**
  80.      * @ORM\Column(type="string", length=255, nullable=true)
  81.      */
  82.     private $customer_company_email;
  83.     /**
  84.      * @ORM\Column(type="string", length=255, nullable=true)
  85.      */
  86.     private $customer_company_phone;
  87.     /**
  88.      * @ORM\Column(type="string", length=255)
  89.      */
  90.     private $customer_contact_lastname;
  91.     /**
  92.      * @ORM\Column(type="string", length=255)
  93.      */
  94.     private $customer_contact_firstname;
  95.     /**
  96.      * @ORM\Column(type="string", length=255)
  97.      */
  98.     private $customer_contact_address;
  99.     /**
  100.      * @ORM\Column(type="string", length=255)
  101.      */
  102.     private $customer_contact_city;
  103.     /**
  104.      * @ORM\Column(type="string", length=255)
  105.      */
  106.     private $customer_contact_postal_code;
  107.     /**
  108.      * @ORM\Column(type="string", length=255)
  109.      */
  110.     private $customer_contact_email;
  111.     /**
  112.      * @ORM\Column(type="string", length=255)
  113.      */
  114.     private $customer_contact_phone;
  115.     /**
  116.      * @ORM\Column(type="string", length=255, nullable=true)
  117.      */
  118.     private $customer_contact_additional_phone;
  119.     /**
  120.      * @ORM\Column(type="string", length=255)
  121.      */
  122.     private $customer_contact_position_in_company;
  123.     /**
  124.      * @ORM\ManyToOne(targetEntity=User::class, inversedBy="chantiers")
  125.      */
  126.     private $user;
  127.     /**
  128.      * @ORM\OneToMany(targetEntity=ChantierProduct::class, mappedBy="chantier", orphanRemoval=true)
  129.      */
  130.     private $chantierProducts;
  131.     /**
  132.      * @ORM\OneToMany(targetEntity=ChantierImage::class, mappedBy="chantier", orphanRemoval=true)
  133.      */
  134.     private $chantierImages;
  135.     /**
  136.      * @ORM\Column(type="integer")
  137.      */
  138.     private $status;
  139.     /**
  140.      * @ORM\Column(type="float", nullable=true)
  141.      */
  142.     private $montant_devis;
  143.     /**
  144.      * @ORM\JoinColumn(name="devis_id", nullable=true,onDelete="SET NULL")
  145.      * @ORM\OneToOne(targetEntity=Devis::class)
  146.      */
  147.     private $devis;
  148.     /**
  149.      * @Vich\UploadableField(mapping="devis", fileNameProperty="devis")
  150.      * @var File
  151.      */
  152.     private $devisFile;
  153.     /**
  154.      * @ORM\ManyToMany(targetEntity=User::class, inversedBy="worker_chantiers")
  155.      */
  156.     private $user_worker;
  157.     /**
  158.      * @ORM\OneToMany(targetEntity=Comment::class, mappedBy="chantier", orphanRemoval=true)
  159.      */
  160.     private $comments;
  161.     /**
  162.      * @ORM\OneToMany(targetEntity=ChantierHistorique::class, mappedBy="chantier", orphanRemoval=true)
  163.      */
  164.     private $chantierHistoriques;
  165.     /**
  166.      * @ORM\OneToMany(targetEntity=CommercialNotification::class, mappedBy="chantier", orphanRemoval=true)
  167.      */
  168.     private $commercialNotifications;
  169.     /**
  170.      * @ORM\OneToMany(targetEntity=Devis::class, mappedBy="chantier", cascade={"persist"},orphanRemoval=true)
  171.      * * @ORM\OrderBy({"created_at" = "DESC"})
  172.      */
  173.     private $devis_chantier;
  174.     public function __construct()
  175.     {
  176.         $this->__entityConstruct();
  177.         $this->chantierProducts = new ArrayCollection();
  178.         $this->chantierImages = new ArrayCollection();
  179.         $this->user_worker = new ArrayCollection();
  180.         // $this->devis_lists = new ArrayCollection();
  181.         $this->comments = new ArrayCollection();
  182.         $this->chantierHistoriques = new ArrayCollection();
  183.         $this->commercialNotifications = new ArrayCollection();
  184.         $this->devis_chantier = new ArrayCollection();
  185.     }
  186.     public function getName(): ?string
  187.     {
  188.         return $this->name;
  189.     }
  190.     public function setName(string $name): self
  191.     {
  192.         $this->name $name;
  193.         return $this;
  194.     }
  195.     public function getAddress(): ?string
  196.     {
  197.         return $this->address;
  198.     }
  199.     public function setAddress(string $address): self
  200.     {
  201.         $this->address $address;
  202.         return $this;
  203.     }
  204.     public function getPostalCode(): ?string
  205.     {
  206.         return $this->postal_code;
  207.     }
  208.     public function setPostalCode(string $postal_code): self
  209.     {
  210.         $this->postal_code $postal_code;
  211.         return $this;
  212.     }
  213.     public function getCity(): ?string
  214.     {
  215.         return $this->city;
  216.     }
  217.     public function setCity(string $city): self
  218.     {
  219.         $this->city $city;
  220.         return $this;
  221.     }
  222.     public function getDiscount(): ?float
  223.     {
  224.         return $this->discount;
  225.     }
  226.     public function setDiscount(float $discount): self
  227.     {
  228.         $this->discount $discount;
  229.         return $this;
  230.     }
  231.     public function getNacelle(): ?bool
  232.     {
  233.         return $this->nacelle;
  234.     }
  235.     public function setNacelle(bool $nacelle): self
  236.     {
  237.         $this->nacelle $nacelle;
  238.         return $this;
  239.     }
  240.     public function getNacelleType(): ?string
  241.     {
  242.         return $this->nacelle_type;
  243.     }
  244.     public function setNacelleType(?string $nacelle_type): self
  245.     {
  246.         $this->nacelle_type $nacelle_type;
  247.         return $this;
  248.     }
  249.     public function getNacelleSize(): ?string
  250.     {
  251.         return $this->nacelle_size;
  252.     }
  253.     public function setNacelleSize(?string $nacelle_size): self
  254.     {
  255.         $this->nacelle_size $nacelle_size;
  256.         return $this;
  257.     }
  258.     public function getNacelleEmplacement(): ?string
  259.     {
  260.         return $this->nacelle_emplacement;
  261.     }
  262.     public function setNacelleEmplacement(?string $nacelle_emplacement): self
  263.     {
  264.         $this->nacelle_emplacement $nacelle_emplacement;
  265.         return $this;
  266.     }
  267.     public function getHarnais(): ?bool
  268.     {
  269.         return $this->harnais;
  270.     }
  271.     public function setHarnais(bool $harnais): self
  272.     {
  273.         $this->harnais $harnais;
  274.         return $this;
  275.     }
  276.     public function getAccesChantier(): ?string
  277.     {
  278.         return $this->acces_chantier;
  279.     }
  280.     public function setAccesChantier(?string $acces_chantier): self
  281.     {
  282.         $this->acces_chantier $acces_chantier;
  283.         return $this;
  284.     }
  285.     public function getAscenseurMonteCharge(): ?string
  286.     {
  287.         return $this->ascenseur_monte_charge;
  288.     }
  289.     public function setAscenseurMonteCharge(?string $ascenseur_monte_charge): self
  290.     {
  291.         $this->ascenseur_monte_charge $ascenseur_monte_charge;
  292.         return $this;
  293.     }
  294.     public function getCustomerContact(): ?CustomerContact
  295.     {
  296.         return $this->customer_contact;
  297.     }
  298.     public function setCustomerContact(?CustomerContact $customer_contact): self
  299.     {
  300.         $this->customer_contact $customer_contact;
  301.         return $this;
  302.     }
  303.     public function getCustomerCompanyCode(): ?string
  304.     {
  305.         return $this->customer_company_code;
  306.     }
  307.     public function setCustomerCompanyCode(?string $customer_company_code): self
  308.     {
  309.         $this->customer_company_code $customer_company_code;
  310.         return $this;
  311.     }
  312.     public function getCustomerCompanyName(): ?string
  313.     {
  314.         return $this->customer_company_name;
  315.     }
  316.     public function setCustomerCompanyName(string $customer_company_name): self
  317.     {
  318.         $this->customer_company_name $customer_company_name;
  319.         return $this;
  320.     }
  321.     public function getCustomerCompanyEmail(): ?string
  322.     {
  323.         return $this->customer_company_email;
  324.     }
  325.     public function setCustomerCompanyEmail(?string $customer_company_email): self
  326.     {
  327.         $this->customer_company_email $customer_company_email;
  328.         return $this;
  329.     }
  330.     public function getCustomerCompanyPhone(): ?string
  331.     {
  332.         return $this->customer_company_phone;
  333.     }
  334.     public function setCustomerCompanyPhone(?string $customer_company_phone): self
  335.     {
  336.         $this->customer_company_phone $customer_company_phone;
  337.         return $this;
  338.     }
  339.     public function getContactLabel()
  340.     {
  341.         return $this->customer_contact_firstname ' ' strtoupper(substr($this->customer_contact_lastname01)) . '.';
  342.     }
  343.     public function getCustomerContactLastname(): ?string
  344.     {
  345.         return $this->customer_contact_lastname;
  346.     }
  347.     public function setCustomerContactLastname(string $customer_contact_lastname): self
  348.     {
  349.         $this->customer_contact_lastname $customer_contact_lastname;
  350.         return $this;
  351.     }
  352.     public function getCustomerContactFirstname(): ?string
  353.     {
  354.         return $this->customer_contact_firstname;
  355.     }
  356.     public function setCustomerContactFirstname(string $customer_contact_firstname): self
  357.     {
  358.         $this->customer_contact_firstname $customer_contact_firstname;
  359.         return $this;
  360.     }
  361.     public function getCustomerContactAddress(): ?string
  362.     {
  363.         return $this->customer_contact_address;
  364.     }
  365.     public function setCustomerContactAddress(string $customer_contact_address): self
  366.     {
  367.         $this->customer_contact_address $customer_contact_address;
  368.         return $this;
  369.     }
  370.     public function getCustomerContactCity(): ?string
  371.     {
  372.         return $this->customer_contact_city;
  373.     }
  374.     public function setCustomerContactCity(string $customer_contact_city): self
  375.     {
  376.         $this->customer_contact_city $customer_contact_city;
  377.         return $this;
  378.     }
  379.     public function getCustomerContactPostalCode(): ?string
  380.     {
  381.         return $this->customer_contact_postal_code;
  382.     }
  383.     public function setCustomerContactPostalCode(string $customer_contact_postal_code): self
  384.     {
  385.         $this->customer_contact_postal_code $customer_contact_postal_code;
  386.         return $this;
  387.     }
  388.     public function getCustomerContactEmail(): ?string
  389.     {
  390.         return $this->customer_contact_email;
  391.     }
  392.     public function setCustomerContactEmail(string $customer_contact_email): self
  393.     {
  394.         $this->customer_contact_email $customer_contact_email;
  395.         return $this;
  396.     }
  397.     public function getCustomerContactPhone(): ?string
  398.     {
  399.         return $this->customer_contact_phone;
  400.     }
  401.     public function setCustomerContactPhone(string $customer_contact_phone): self
  402.     {
  403.         $this->customer_contact_phone $customer_contact_phone;
  404.         return $this;
  405.     }
  406.     public function getCustomerContactAdditionalPhone()
  407.     {
  408.         return $this->customer_contact_additional_phone;
  409.     }
  410.     public function setCustomerContactAdditionalPhone($customer_contact_additional_phone): self
  411.     {
  412.         $this->customer_contact_additional_phone $customer_contact_additional_phone;
  413.         return $this;
  414.     }
  415.     public function getCustomerContactPositionInCompany(): ?string
  416.     {
  417.         return $this->customer_contact_position_in_company;
  418.     }
  419.     public function setCustomerContactPositionInCompany(string $customer_contact_position_in_company): self
  420.     {
  421.         $this->customer_contact_position_in_company $customer_contact_position_in_company;
  422.         return $this;
  423.     }
  424.     public function getUser(): ?User
  425.     {
  426.         return $this->user;
  427.     }
  428.     public function setUser(?User $user): self
  429.     {
  430.         $this->user $user;
  431.         return $this;
  432.     }
  433.     /**
  434.      * @return Collection|ChantierProduct[]
  435.      */
  436.     public function getChantierProducts(): Collection
  437.     {
  438.         return $this->chantierProducts;
  439.     }
  440.     public function addChantierProduct(ChantierProduct $chantierProduct): self
  441.     {
  442.         if (!$this->chantierProducts->contains($chantierProduct)) {
  443.             $this->chantierProducts[] = $chantierProduct;
  444.             $chantierProduct->setChantier($this);
  445.         }
  446.         return $this;
  447.     }
  448.     public function removeChantierProduct(ChantierProduct $chantierProduct): self
  449.     {
  450.         if ($this->chantierProducts->removeElement($chantierProduct)) {
  451.             // set the owning side to null (unless already changed)
  452.             if ($chantierProduct->getChantier() === $this) {
  453.                 $chantierProduct->setChantier(null);
  454.             }
  455.         }
  456.         return $this;
  457.     }
  458.     /**
  459.      * @return Collection|ChantierImage[]
  460.      */
  461.     public function getChantierImages(): Collection
  462.     {
  463.         return $this->chantierImages;
  464.     }
  465.     public function addChantierImage(ChantierImage $chantierImage): self
  466.     {
  467.         if (!$this->chantierImages->contains($chantierImage)) {
  468.             $this->chantierImages[] = $chantierImage;
  469.             $chantierImage->setChantier($this);
  470.         }
  471.         return $this;
  472.     }
  473.     public function removeChantierImage(ChantierImage $chantierImage): self
  474.     {
  475.         if ($this->chantierImages->removeElement($chantierImage)) {
  476.             // set the owning side to null (unless already changed)
  477.             if ($chantierImage->getChantier() === $this) {
  478.                 $chantierImage->setChantier(null);
  479.             }
  480.         }
  481.         return $this;
  482.     }
  483.     public function getStatus(): ?int
  484.     {
  485.         return $this->status;
  486.     }
  487.     public function getStatusLabel()
  488.     {
  489.         switch ($this->status) {
  490.             case 1:
  491.                 $label 'Prise de côte';
  492.                 break;
  493.             case 2:
  494.                 $label 'Attente de devis';
  495.                 break;
  496.             case 3:
  497.                 $label 'Devis effectué';
  498.                 break;
  499.             case 4:
  500.                 $label 'En portefeuille';
  501.                 break;
  502.             case 5:
  503.                 $label 'Gagné';
  504.                 break;
  505.             case 6:
  506.                 $label 'Perdu';
  507.                 break;
  508.             case 7:
  509.                 $label 'Abandonné';
  510.                 break;
  511.             case 8:
  512.                 $label 'En pose';
  513.                 break;
  514.             case 9:
  515.                 $label 'Posé';
  516.                 break;
  517.             case 10:
  518.                 $label 'En fabrication';
  519.                 break;
  520.             case 11:
  521.                 $label 'Fabriqué';
  522.                 break;
  523.             case 12:
  524.                 $label 'Côtes à reprendre';
  525.                 break;
  526.             case 13:
  527.                 $label 'Côtes ok';
  528.                 break;
  529.             default:
  530.                 $label '';
  531.                 break;
  532.         }
  533.         return $label;
  534.     }
  535.     public function setStatus(int $status): self
  536.     {
  537.         $this->status $status;
  538.         return $this;
  539.     }
  540.     public function getMontantDevis(): ?float
  541.     {
  542.         return $this->montant_devis;
  543.     }
  544.     public function setMontantDevis(?float $montant_devis): self
  545.     {
  546.         $this->montant_devis $montant_devis;
  547.         return $this;
  548.     }
  549.     public function getDevis(): ?Devis
  550.     {
  551.         return $this->devis;
  552.     }
  553.     public function setDevis(?Devis $devis): self
  554.     {
  555.         $this->devis $devis;
  556.         return $this;
  557.     }
  558.     /**
  559.      * @return File
  560.      */
  561.     public function getDevisFile()
  562.     {
  563.         return $this->devisFile;
  564.     }
  565.     /**
  566.      * @param File $devisFile
  567.      * @throws \Exception
  568.      */
  569.     public function setDevisFile($devisFile)
  570.     {
  571.         $this->devisFile $devisFile;
  572.         if ($devisFile) {
  573.             $this->setUpdatedAt(new \DateTime('now'));
  574.         }
  575.     }
  576.     /**
  577.      * @return Collection|User[]
  578.      */
  579.     public function getUserWorker(): Collection
  580.     {
  581.         return $this->user_worker;
  582.     }
  583.     public function addUserWorker(User $userWorker): self
  584.     {
  585.         if (!$this->user_worker->contains($userWorker)) {
  586.             $this->user_worker[] = $userWorker;
  587.         }
  588.         return $this;
  589.     }
  590.     public function removeUserWorker(User $userWorker): self
  591.     {
  592.         $this->user_worker->removeElement($userWorker);
  593.         return $this;
  594.     }
  595.     // /**
  596.     //  * @return Collection|Devis[]
  597.     //  */
  598.     // public function getDevisLists(): Collection
  599.     // {
  600.     //     return $this->devis_lists;
  601.     // }
  602.     // public function addDevisList(Devis $devisList): self
  603.     // {
  604.     //     if (!$this->devis_lists->contains($devisList)) {
  605.     //         $this->devis_lists[] = $devisList;
  606.     //         $devisList->setChantier($this);
  607.     //     }
  608.     //     return $this;
  609.     // }
  610.     // public function removeDevisList(Devis $devisList): self
  611.     // {
  612.     //     if ($this->devis_lists->removeElement($devisList)) {
  613.     //         // set the owning side to null (unless already changed)
  614.     //         if ($devisList->getChantier() === $this) {
  615.     //             $devisList->setChantier(null);
  616.     //         }
  617.     //     }
  618.     //     return $this;
  619.     // }
  620.     /**
  621.      * @return Collection|Comment[]
  622.      */
  623.     public function getComments(): Collection
  624.     {
  625.         return $this->comments;
  626.     }
  627.     public function addComment(Comment $comment): self
  628.     {
  629.         if (!$this->comments->contains($comment)) {
  630.             $this->comments[] = $comment;
  631.             $comment->setChantier($this);
  632.         }
  633.         return $this;
  634.     }
  635.     public function removeComment(Comment $comment): self
  636.     {
  637.         if ($this->comments->removeElement($comment)) {
  638.             // set the owning side to null (unless already changed)
  639.             if ($comment->getChantier() === $this) {
  640.                 $comment->setChantier(null);
  641.             }
  642.         }
  643.         return $this;
  644.     }
  645.     /**
  646.      * @return Collection|ChantierHistorique[]
  647.      */
  648.     public function getChantierHistoriques(): Collection
  649.     {
  650.         return $this->chantierHistoriques;
  651.     }
  652.     public function addChantierHistorique(ChantierHistorique $chantierHistorique): self
  653.     {
  654.         if (!$this->chantierHistoriques->contains($chantierHistorique)) {
  655.             $this->chantierHistoriques[] = $chantierHistorique;
  656.             $chantierHistorique->setChantier($this);
  657.         }
  658.         return $this;
  659.     }
  660.     public function removeChantierHistorique(ChantierHistorique $chantierHistorique): self
  661.     {
  662.         if ($this->chantierHistoriques->removeElement($chantierHistorique)) {
  663.             // set the owning side to null (unless already changed)
  664.             if ($chantierHistorique->getChantier() === $this) {
  665.                 $chantierHistorique->setChantier(null);
  666.             }
  667.         }
  668.         return $this;
  669.     }
  670.     /**
  671.      * @return Collection|CommercialNotification[]
  672.      */
  673.     public function getCommercialNotifications(): Collection
  674.     {
  675.         return $this->commercialNotifications;
  676.     }
  677.     public function addCommercialNotification(CommercialNotification $commercialNotification): self
  678.     {
  679.         if (!$this->commercialNotifications->contains($commercialNotification)) {
  680.             $this->commercialNotifications[] = $commercialNotification;
  681.             $commercialNotification->setChantier($this);
  682.         }
  683.         return $this;
  684.     }
  685.     public function removeCommercialNotification(CommercialNotification $commercialNotification): self
  686.     {
  687.         if ($this->commercialNotifications->removeElement($commercialNotification)) {
  688.             // set the owning side to null (unless already changed)
  689.             if ($commercialNotification->getChantier() === $this) {
  690.                 $commercialNotification->setChantier(null);
  691.             }
  692.         }
  693.         return $this;
  694.     }
  695.     /**
  696.      * @return Collection|Devis[]
  697.      */
  698.     public function getDevisChantier(): Collection
  699.     {
  700.         return $this->devis_chantier;
  701.     }
  702.     public function addDevisChantier(Devis $devisChantier): self
  703.     {
  704.         if (!$this->devis_chantier->contains($devisChantier)) {
  705.             $this->devis_chantier[] = $devisChantier;
  706.             $devisChantier->setChantier($this);
  707.         }
  708.         return $this;
  709.     }
  710.     public function removeDevisChantier(Devis $devisChantier): self
  711.     {
  712.         if ($this->devis_chantier->removeElement($devisChantier)) {
  713.             // set the owning side to null (unless already changed)
  714.             if ($devisChantier->getChantier() === $this) {
  715.                 $devisChantier->setChantier(null);
  716.             }
  717.         }
  718.         return $this;
  719.     }
  720. }
  721.