<?php
namespace App\Entity;
use App\Entity\Traits\EntityTrait;
use App\Repository\ChantierRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* @Vich\Uploadable
* @ORM\Entity(repositoryClass=ChantierRepository::class)
*/
class Chantier
{
use EntityTrait {
EntityTrait::__construct as private __entityConstruct;
}
/**
* @ORM\Column(type="string", length=255)
*/
private $name;
/**
* @ORM\Column(type="string", length=255)
*/
private $address;
/**
* @ORM\Column(type="string", length=255)
*/
private $postal_code;
/**
* @ORM\Column(type="string", length=255)
*/
private $city;
/**
* @ORM\Column(type="float")
*/
private $discount;
/**
* @ORM\Column(type="boolean")
*/
private $nacelle;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $nacelle_type;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $nacelle_size;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $nacelle_emplacement;
/**
* @ORM\Column(type="boolean")
*/
private $harnais;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $acces_chantier;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $ascenseur_monte_charge;
/**
* @ORM\ManyToOne(targetEntity=CustomerContact::class, inversedBy="chantiers")
*/
private $customer_contact;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $customer_company_code;
/**
* @ORM\Column(type="string", length=255)
*/
private $customer_company_name;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $customer_company_email;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $customer_company_phone;
/**
* @ORM\Column(type="string", length=255)
*/
private $customer_contact_lastname;
/**
* @ORM\Column(type="string", length=255)
*/
private $customer_contact_firstname;
/**
* @ORM\Column(type="string", length=255)
*/
private $customer_contact_address;
/**
* @ORM\Column(type="string", length=255)
*/
private $customer_contact_city;
/**
* @ORM\Column(type="string", length=255)
*/
private $customer_contact_postal_code;
/**
* @ORM\Column(type="string", length=255)
*/
private $customer_contact_email;
/**
* @ORM\Column(type="string", length=255)
*/
private $customer_contact_phone;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $customer_contact_additional_phone;
/**
* @ORM\Column(type="string", length=255)
*/
private $customer_contact_position_in_company;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="chantiers")
*/
private $user;
/**
* @ORM\OneToMany(targetEntity=ChantierProduct::class, mappedBy="chantier", orphanRemoval=true)
*/
private $chantierProducts;
/**
* @ORM\OneToMany(targetEntity=ChantierImage::class, mappedBy="chantier", orphanRemoval=true)
*/
private $chantierImages;
/**
* @ORM\Column(type="integer")
*/
private $status;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $montant_devis;
/**
* @ORM\JoinColumn(name="devis_id", nullable=true,onDelete="SET NULL")
* @ORM\OneToOne(targetEntity=Devis::class)
*/
private $devis;
/**
* @Vich\UploadableField(mapping="devis", fileNameProperty="devis")
* @var File
*/
private $devisFile;
/**
* @ORM\ManyToMany(targetEntity=User::class, inversedBy="worker_chantiers")
*/
private $user_worker;
/**
* @ORM\OneToMany(targetEntity=Comment::class, mappedBy="chantier", orphanRemoval=true)
*/
private $comments;
/**
* @ORM\OneToMany(targetEntity=ChantierHistorique::class, mappedBy="chantier", orphanRemoval=true)
*/
private $chantierHistoriques;
/**
* @ORM\OneToMany(targetEntity=CommercialNotification::class, mappedBy="chantier", orphanRemoval=true)
*/
private $commercialNotifications;
/**
* @ORM\OneToMany(targetEntity=Devis::class, mappedBy="chantier", cascade={"persist"},orphanRemoval=true)
* * @ORM\OrderBy({"created_at" = "DESC"})
*/
private $devis_chantier;
public function __construct()
{
$this->__entityConstruct();
$this->chantierProducts = new ArrayCollection();
$this->chantierImages = new ArrayCollection();
$this->user_worker = new ArrayCollection();
// $this->devis_lists = new ArrayCollection();
$this->comments = new ArrayCollection();
$this->chantierHistoriques = new ArrayCollection();
$this->commercialNotifications = new ArrayCollection();
$this->devis_chantier = new ArrayCollection();
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getAddress(): ?string
{
return $this->address;
}
public function setAddress(string $address): self
{
$this->address = $address;
return $this;
}
public function getPostalCode(): ?string
{
return $this->postal_code;
}
public function setPostalCode(string $postal_code): self
{
$this->postal_code = $postal_code;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(string $city): self
{
$this->city = $city;
return $this;
}
public function getDiscount(): ?float
{
return $this->discount;
}
public function setDiscount(float $discount): self
{
$this->discount = $discount;
return $this;
}
public function getNacelle(): ?bool
{
return $this->nacelle;
}
public function setNacelle(bool $nacelle): self
{
$this->nacelle = $nacelle;
return $this;
}
public function getNacelleType(): ?string
{
return $this->nacelle_type;
}
public function setNacelleType(?string $nacelle_type): self
{
$this->nacelle_type = $nacelle_type;
return $this;
}
public function getNacelleSize(): ?string
{
return $this->nacelle_size;
}
public function setNacelleSize(?string $nacelle_size): self
{
$this->nacelle_size = $nacelle_size;
return $this;
}
public function getNacelleEmplacement(): ?string
{
return $this->nacelle_emplacement;
}
public function setNacelleEmplacement(?string $nacelle_emplacement): self
{
$this->nacelle_emplacement = $nacelle_emplacement;
return $this;
}
public function getHarnais(): ?bool
{
return $this->harnais;
}
public function setHarnais(bool $harnais): self
{
$this->harnais = $harnais;
return $this;
}
public function getAccesChantier(): ?string
{
return $this->acces_chantier;
}
public function setAccesChantier(?string $acces_chantier): self
{
$this->acces_chantier = $acces_chantier;
return $this;
}
public function getAscenseurMonteCharge(): ?string
{
return $this->ascenseur_monte_charge;
}
public function setAscenseurMonteCharge(?string $ascenseur_monte_charge): self
{
$this->ascenseur_monte_charge = $ascenseur_monte_charge;
return $this;
}
public function getCustomerContact(): ?CustomerContact
{
return $this->customer_contact;
}
public function setCustomerContact(?CustomerContact $customer_contact): self
{
$this->customer_contact = $customer_contact;
return $this;
}
public function getCustomerCompanyCode(): ?string
{
return $this->customer_company_code;
}
public function setCustomerCompanyCode(?string $customer_company_code): self
{
$this->customer_company_code = $customer_company_code;
return $this;
}
public function getCustomerCompanyName(): ?string
{
return $this->customer_company_name;
}
public function setCustomerCompanyName(string $customer_company_name): self
{
$this->customer_company_name = $customer_company_name;
return $this;
}
public function getCustomerCompanyEmail(): ?string
{
return $this->customer_company_email;
}
public function setCustomerCompanyEmail(?string $customer_company_email): self
{
$this->customer_company_email = $customer_company_email;
return $this;
}
public function getCustomerCompanyPhone(): ?string
{
return $this->customer_company_phone;
}
public function setCustomerCompanyPhone(?string $customer_company_phone): self
{
$this->customer_company_phone = $customer_company_phone;
return $this;
}
public function getContactLabel()
{
return $this->customer_contact_firstname . ' ' . strtoupper(substr($this->customer_contact_lastname, 0, 1)) . '.';
}
public function getCustomerContactLastname(): ?string
{
return $this->customer_contact_lastname;
}
public function setCustomerContactLastname(string $customer_contact_lastname): self
{
$this->customer_contact_lastname = $customer_contact_lastname;
return $this;
}
public function getCustomerContactFirstname(): ?string
{
return $this->customer_contact_firstname;
}
public function setCustomerContactFirstname(string $customer_contact_firstname): self
{
$this->customer_contact_firstname = $customer_contact_firstname;
return $this;
}
public function getCustomerContactAddress(): ?string
{
return $this->customer_contact_address;
}
public function setCustomerContactAddress(string $customer_contact_address): self
{
$this->customer_contact_address = $customer_contact_address;
return $this;
}
public function getCustomerContactCity(): ?string
{
return $this->customer_contact_city;
}
public function setCustomerContactCity(string $customer_contact_city): self
{
$this->customer_contact_city = $customer_contact_city;
return $this;
}
public function getCustomerContactPostalCode(): ?string
{
return $this->customer_contact_postal_code;
}
public function setCustomerContactPostalCode(string $customer_contact_postal_code): self
{
$this->customer_contact_postal_code = $customer_contact_postal_code;
return $this;
}
public function getCustomerContactEmail(): ?string
{
return $this->customer_contact_email;
}
public function setCustomerContactEmail(string $customer_contact_email): self
{
$this->customer_contact_email = $customer_contact_email;
return $this;
}
public function getCustomerContactPhone(): ?string
{
return $this->customer_contact_phone;
}
public function setCustomerContactPhone(string $customer_contact_phone): self
{
$this->customer_contact_phone = $customer_contact_phone;
return $this;
}
public function getCustomerContactAdditionalPhone()
{
return $this->customer_contact_additional_phone;
}
public function setCustomerContactAdditionalPhone($customer_contact_additional_phone): self
{
$this->customer_contact_additional_phone = $customer_contact_additional_phone;
return $this;
}
public function getCustomerContactPositionInCompany(): ?string
{
return $this->customer_contact_position_in_company;
}
public function setCustomerContactPositionInCompany(string $customer_contact_position_in_company): self
{
$this->customer_contact_position_in_company = $customer_contact_position_in_company;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
/**
* @return Collection|ChantierProduct[]
*/
public function getChantierProducts(): Collection
{
return $this->chantierProducts;
}
public function addChantierProduct(ChantierProduct $chantierProduct): self
{
if (!$this->chantierProducts->contains($chantierProduct)) {
$this->chantierProducts[] = $chantierProduct;
$chantierProduct->setChantier($this);
}
return $this;
}
public function removeChantierProduct(ChantierProduct $chantierProduct): self
{
if ($this->chantierProducts->removeElement($chantierProduct)) {
// set the owning side to null (unless already changed)
if ($chantierProduct->getChantier() === $this) {
$chantierProduct->setChantier(null);
}
}
return $this;
}
/**
* @return Collection|ChantierImage[]
*/
public function getChantierImages(): Collection
{
return $this->chantierImages;
}
public function addChantierImage(ChantierImage $chantierImage): self
{
if (!$this->chantierImages->contains($chantierImage)) {
$this->chantierImages[] = $chantierImage;
$chantierImage->setChantier($this);
}
return $this;
}
public function removeChantierImage(ChantierImage $chantierImage): self
{
if ($this->chantierImages->removeElement($chantierImage)) {
// set the owning side to null (unless already changed)
if ($chantierImage->getChantier() === $this) {
$chantierImage->setChantier(null);
}
}
return $this;
}
public function getStatus(): ?int
{
return $this->status;
}
public function getStatusLabel()
{
switch ($this->status) {
case 1:
$label = 'Prise de côte';
break;
case 2:
$label = 'Attente de devis';
break;
case 3:
$label = 'Devis effectué';
break;
case 4:
$label = 'En portefeuille';
break;
case 5:
$label = 'Gagné';
break;
case 6:
$label = 'Perdu';
break;
case 7:
$label = 'Abandonné';
break;
case 8:
$label = 'En pose';
break;
case 9:
$label = 'Posé';
break;
case 10:
$label = 'En fabrication';
break;
case 11:
$label = 'Fabriqué';
break;
case 12:
$label = 'Côtes à reprendre';
break;
case 13:
$label = 'Côtes ok';
break;
default:
$label = '';
break;
}
return $label;
}
public function setStatus(int $status): self
{
$this->status = $status;
return $this;
}
public function getMontantDevis(): ?float
{
return $this->montant_devis;
}
public function setMontantDevis(?float $montant_devis): self
{
$this->montant_devis = $montant_devis;
return $this;
}
public function getDevis(): ?Devis
{
return $this->devis;
}
public function setDevis(?Devis $devis): self
{
$this->devis = $devis;
return $this;
}
/**
* @return File
*/
public function getDevisFile()
{
return $this->devisFile;
}
/**
* @param File $devisFile
* @throws \Exception
*/
public function setDevisFile($devisFile)
{
$this->devisFile = $devisFile;
if ($devisFile) {
$this->setUpdatedAt(new \DateTime('now'));
}
}
/**
* @return Collection|User[]
*/
public function getUserWorker(): Collection
{
return $this->user_worker;
}
public function addUserWorker(User $userWorker): self
{
if (!$this->user_worker->contains($userWorker)) {
$this->user_worker[] = $userWorker;
}
return $this;
}
public function removeUserWorker(User $userWorker): self
{
$this->user_worker->removeElement($userWorker);
return $this;
}
// /**
// * @return Collection|Devis[]
// */
// public function getDevisLists(): Collection
// {
// return $this->devis_lists;
// }
// public function addDevisList(Devis $devisList): self
// {
// if (!$this->devis_lists->contains($devisList)) {
// $this->devis_lists[] = $devisList;
// $devisList->setChantier($this);
// }
// return $this;
// }
// public function removeDevisList(Devis $devisList): self
// {
// if ($this->devis_lists->removeElement($devisList)) {
// // set the owning side to null (unless already changed)
// if ($devisList->getChantier() === $this) {
// $devisList->setChantier(null);
// }
// }
// return $this;
// }
/**
* @return Collection|Comment[]
*/
public function getComments(): Collection
{
return $this->comments;
}
public function addComment(Comment $comment): self
{
if (!$this->comments->contains($comment)) {
$this->comments[] = $comment;
$comment->setChantier($this);
}
return $this;
}
public function removeComment(Comment $comment): self
{
if ($this->comments->removeElement($comment)) {
// set the owning side to null (unless already changed)
if ($comment->getChantier() === $this) {
$comment->setChantier(null);
}
}
return $this;
}
/**
* @return Collection|ChantierHistorique[]
*/
public function getChantierHistoriques(): Collection
{
return $this->chantierHistoriques;
}
public function addChantierHistorique(ChantierHistorique $chantierHistorique): self
{
if (!$this->chantierHistoriques->contains($chantierHistorique)) {
$this->chantierHistoriques[] = $chantierHistorique;
$chantierHistorique->setChantier($this);
}
return $this;
}
public function removeChantierHistorique(ChantierHistorique $chantierHistorique): self
{
if ($this->chantierHistoriques->removeElement($chantierHistorique)) {
// set the owning side to null (unless already changed)
if ($chantierHistorique->getChantier() === $this) {
$chantierHistorique->setChantier(null);
}
}
return $this;
}
/**
* @return Collection|CommercialNotification[]
*/
public function getCommercialNotifications(): Collection
{
return $this->commercialNotifications;
}
public function addCommercialNotification(CommercialNotification $commercialNotification): self
{
if (!$this->commercialNotifications->contains($commercialNotification)) {
$this->commercialNotifications[] = $commercialNotification;
$commercialNotification->setChantier($this);
}
return $this;
}
public function removeCommercialNotification(CommercialNotification $commercialNotification): self
{
if ($this->commercialNotifications->removeElement($commercialNotification)) {
// set the owning side to null (unless already changed)
if ($commercialNotification->getChantier() === $this) {
$commercialNotification->setChantier(null);
}
}
return $this;
}
/**
* @return Collection|Devis[]
*/
public function getDevisChantier(): Collection
{
return $this->devis_chantier;
}
public function addDevisChantier(Devis $devisChantier): self
{
if (!$this->devis_chantier->contains($devisChantier)) {
$this->devis_chantier[] = $devisChantier;
$devisChantier->setChantier($this);
}
return $this;
}
public function removeDevisChantier(Devis $devisChantier): self
{
if ($this->devis_chantier->removeElement($devisChantier)) {
// set the owning side to null (unless already changed)
if ($devisChantier->getChantier() === $this) {
$devisChantier->setChantier(null);
}
}
return $this;
}
}