src/Entity/Society.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Config;
  4. use App\Repository\SocietyRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\DBAL\Types\Types;
  8. use Doctrine\ORM\Mapping as ORM;
  9. use Symfony\Component\String\Slugger\AsciiSlugger;
  10. /**
  11.  * @ORM\Entity(repositoryClass=SocietyRepository::class)
  12.  */
  13. class Society
  14. {
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\Column(type="string", length=255)
  23.      */
  24.     private $name;
  25.     /**
  26.      * @ORM\Column(type="string", length=255, nullable=true)
  27.      */
  28.     private $siren;
  29.     /**
  30.      * @ORM\OneToOne(targetEntity=User::class, inversedBy="society", cascade={"persist", "remove"})
  31.      * @ORM\JoinColumn(nullable=false)
  32.      */
  33.     private $user;
  34.     /**
  35.      * @ORM\Column(type="string", length=255, nullable=true)
  36.      */
  37.     private $type;
  38.     /**
  39.      * @ORM\Column(type="json")
  40.      */
  41.     private $employe_number = [];
  42.     /**
  43.      * @ORM\Column(type="integer", nullable=true)
  44.      */
  45.     private $ca;
  46.     /**
  47.      * @ORM\Column(type="string", length=255, nullable=true)
  48.      */
  49.     private $contact;
  50.     /**
  51.      * @ORM\Column(type="string", length=255, nullable=true)
  52.      */
  53.     private $phone;
  54.     /**
  55.      * @ORM\Column(type="string", length=255, nullable=true)
  56.      */
  57.     private $site;
  58.     /**
  59.      * @ORM\Column(type="string", length=255, nullable=true)
  60.      */
  61.     private $linkedin;
  62.     /**
  63.      * @ORM\OneToMany(targetEntity=Offer::class, mappedBy="society")
  64.      * @ORM\OrderBy({"id" = "DESC"})
  65.      */
  66.     private $offers;
  67.     /**
  68.      * @ORM\Column(type="integer", nullable=true)
  69.      */
  70.     private $profileView;
  71.     /**
  72.      * @ORM\Column(type="boolean", nullable=true)
  73.      */
  74.     private $canUpload;
  75.     /**
  76.      * @ORM\Column(type="integer")
  77.      */
  78.     private $intercontratNumber 0;
  79.     /**
  80.      * @ORM\Column(type="string", length=255, nullable=true)
  81.      */
  82.     private $package;
  83.     /**
  84.      * @ORM\Column(type="datetime", nullable=true)
  85.      */
  86.     private $packageDate;
  87.     /**
  88.      * @ORM\Column(type="integer", nullable=true)
  89.      */
  90.     private $priorizeNumber;
  91.     /**
  92.      * @ORM\Column(type="integer", nullable=true)
  93.      */
  94.     private $onceEveryday;
  95.     /**
  96.      * @ORM\Column(type="integer", nullable=true)
  97.      */
  98.     private $onceWeek;
  99.     /**
  100.      * @ORM\Column(type="date", nullable=true)
  101.      */
  102.     private $pauseDate;
  103.     /**
  104.      * @ORM\Column(type="datetime", nullable=true)
  105.      */
  106.     private $packageExpireAt;
  107.     /**
  108.      * @ORM\OneToMany(targetEntity=Commande::class, mappedBy="society")
  109.      * @ORM\OrderBy({"id" = "DESC"})
  110.      */
  111.     private $commandes;
  112.     /**
  113.      * @ORM\OneToMany(targetEntity=ProfileVisit::class, mappedBy="society")
  114.      * @ORM\OrderBy({"id" = "DESC"})
  115.      */
  116.     private $profileVisits;
  117.     /**
  118.      * @ORM\OneToMany(targetEntity=Annonce::class, mappedBy="society", orphanRemoval=true)
  119.      */
  120.     private $annonces;
  121.     /**
  122.      * @ORM\Column(type="text")
  123.      */
  124.     private $description;
  125.     /**
  126.      * @ORM\Column(type="string", length=150, nullable=true)
  127.      */
  128.     private $adress;
  129.     /**
  130.      * @ORM\Column(type="string", length=150)
  131.      */
  132.     private $ville;
  133.     /**
  134.      * @ORM\Column(type="integer", nullable=true)
  135.      */
  136.     private $pauseNumber;
  137.     /**
  138.      * @ORM\OneToMany(targetEntity=AnnonceVisit::class, mappedBy="society", orphanRemoval=true)
  139.      */
  140.     private $annonceVisits;
  141.     /**
  142.      * @ORM\Column(type="integer", nullable=true)
  143.      */
  144.     private $intercontratUne;
  145.     /**
  146.      * @ORM\OneToMany(targetEntity=CompteRecrutement::class, mappedBy="societe")
  147.      */
  148.     private $compteRecrutements;
  149.     /**
  150.      * @ORM\Column(type="string", length=255, nullable=true)
  151.      */
  152.     private $twitter;
  153.     /**
  154.      * @ORM\Column(type="string", length=255, nullable=true)
  155.      */
  156.     private $instagram;
  157.     /**
  158.      * @ORM\Column(type="string", length=255, nullable=true)
  159.      */
  160.     private $facebook;
  161.     /**
  162.      * @ORM\Column(type="string", length=255, nullable=true)
  163.      */
  164.     private $presentationYoutube;
  165.     /**
  166.      * @ORM\Column(type="string", length=150, nullable=true)
  167.      */
  168.     private $slug;
  169.     public function __construct()
  170.     {
  171.         $this->offers = new ArrayCollection();
  172.         $this->commandes = new ArrayCollection();
  173.         $this->profileVisits = new ArrayCollection();
  174.         $this->annonces = new ArrayCollection();
  175.         $this->annonceVisits = new ArrayCollection();
  176.         $this->compteRecrutements = new ArrayCollection();
  177.     }
  178.     //----------------------------------------------------
  179.     public function packageIsTest(): ?bool {
  180.         $commandes $this->getCommandes();
  181.         if(! empty($commandes)){
  182.             $lastdate null;
  183.             $cm null;
  184.             foreach ($commandes as $commande){
  185.                 if (! $lastdate){
  186.                     $lastdate $commande->getCreatedAt();
  187.                 }
  188.                 if ($lastdate <= $commande->getCreatedAt()){
  189.                     $cm $commande;
  190.                     $lastdate $commande->getCreatedAt();
  191.                 }
  192.             }
  193.             if($cm){
  194.                 return $cm->isIsTest();
  195.             }
  196.         }
  197.         return false;
  198.     }
  199.     public function packageActive(): ?Commande{
  200.         $commandes $this->getCommandes();
  201.         $commandeEncours = [];
  202.         if(! empty($commandes)){
  203.             foreach ($commandes as $commande){
  204.                 if($commande->getEndDate() > new \DateTime()){
  205.                     $commandeEncours[] = $commande;
  206.                 }
  207.             }
  208.         }
  209.         if(! empty($commandeEncours)){
  210.             $lastdate null;
  211.             $cmEnCour null;
  212.             foreach ($commandeEncours as $commande){
  213.                 if (! $lastdate){
  214.                     $lastdate $commande->getCreatedAt();
  215.                 }
  216.                 if ($lastdate >= $commande->getCreatedAt()){
  217.                     $cmEnCour $commande;
  218.                     $lastdate $commande->getCreatedAt();
  219.                 }
  220.             }
  221.             return $cmEnCour;
  222.         }
  223.         return null;
  224.     }
  225.     public function updateSlug(){
  226.         $slugger = new AsciiSlugger();
  227.         $defaultNum 10000;
  228.         $numero $defaultNum $this->getId();
  229.         $slug strtolower($slugger->slug($numero.'-'.$this->getName()));
  230.         $this->setSlug($slug);
  231.     }
  232.     //----------------------------------------------------
  233.     public function getId(): ?int
  234.     {
  235.         return $this->id;
  236.     }
  237.     public function getName(): ?string
  238.     {
  239.         return $this->name;
  240.     }
  241.     public function setName(string $name): self
  242.     {
  243.         $this->name $name;
  244.         return $this;
  245.     }
  246.     public function getSiren(): ?string
  247.     {
  248.         return $this->siren;
  249.     }
  250.     public function setSiren(?string $siren): self
  251.     {
  252.         $this->siren $siren;
  253.         return $this;
  254.     }
  255.     public function getUser(): ?User
  256.     {
  257.         return $this->user;
  258.     }
  259.     public function setUser(User $user): self
  260.     {
  261.         $this->user $user;
  262.         return $this;
  263.     }
  264.     public function getEmployeNumber(): ?array
  265.     {
  266.         return $this->employe_number;
  267.     }
  268.     public function setEmployeNumber(array $employe_number): self
  269.     {
  270.         $this->employe_number $employe_number;
  271.         return $this;
  272.     }
  273.     public function getContact(): ?string
  274.     {
  275.         return $this->contact;
  276.     }
  277.     public function setContact(?string $contact): self
  278.     {
  279.         $this->contact $contact;
  280.         return $this;
  281.     }
  282.     public function getPhone(): ?string
  283.     {
  284.         return $this->phone;
  285.     }
  286.     public function setPhone(?string $phone): self
  287.     {
  288.         $this->phone $phone;
  289.         return $this;
  290.     }
  291.     public function getSite(): ?string
  292.     {
  293.         return $this->site;
  294.     }
  295.     public function setSite(?string $site): self
  296.     {
  297.         $this->site $site;
  298.         return $this;
  299.     }
  300.     public function getLinkedin(): ?string
  301.     {
  302.         return $this->linkedin;
  303.     }
  304.     public function setLinkedin(?string $linkedin): self
  305.     {
  306.         $this->linkedin $linkedin;
  307.         return $this;
  308.     }
  309.     /**
  310.      * @return Collection|Offer[]
  311.      */
  312.     public function getOffers(): Collection
  313.     {
  314.         return $this->offers;
  315.     }
  316.     public function addOffer(Offer $offer): self
  317.     {
  318.         if (!$this->offers->contains($offer)) {
  319.             $this->offers[] = $offer;
  320.             $offer->setSociety($this);
  321.         }
  322.         return $this;
  323.     }
  324.     public function removeOffer(Offer $offer): self
  325.     {
  326.         if ($this->offers->removeElement($offer)) {
  327.             // set the owning side to null (unless already changed)
  328.             if ($offer->getSociety() === $this) {
  329.                 $offer->setSociety(null);
  330.             }
  331.         }
  332.         return $this;
  333.     }
  334.     public function getProfileView(): ?int
  335.     {
  336.         return $this->profileView;
  337.     }
  338.     public function setProfileView(?int $profileView): self
  339.     {
  340.         $this->profileView $profileView;
  341.         return $this;
  342.     }
  343.     public function getCanUpload(): ?bool
  344.     {
  345.         return $this->canUpload;
  346.     }
  347.     public function setCanUpload(?bool $canUpload): self
  348.     {
  349.         $this->canUpload $canUpload;
  350.         return $this;
  351.     }
  352.     public function getIntercontratNumber(): ?int
  353.     {
  354.         return $this->intercontratNumber;
  355.     }
  356.     public function setIntercontratNumber(int $intercontratNumber): self
  357.     {
  358.         $this->intercontratNumber $intercontratNumber;
  359.         return $this;
  360.     }
  361.     public function getPackage(): ?string
  362.     {
  363.         return $this->package;
  364.     }
  365.     public function setPackage(?string $package): self
  366.     {
  367.         $this->package $package;
  368.         return $this;
  369.     }
  370.     public function getPackageDate(): ?\DateTimeInterface
  371.     {
  372.         return $this->packageDate;
  373.     }
  374.     public function setPackageDate(?\DateTimeInterface $packageDate): self
  375.     {
  376.         $this->packageDate $packageDate;
  377.         return $this;
  378.     }
  379.     public function getPriorizeNumber(): ?int
  380.     {
  381.         return $this->priorizeNumber;
  382.     }
  383.     public function setPriorizeNumber(?int $priorizeNumber): self
  384.     {
  385.         $this->priorizeNumber $priorizeNumber;
  386.         return $this;
  387.     }
  388.     public function getOnceEveryday(): ?int
  389.     {
  390.         return $this->onceEveryday;
  391.     }
  392.     public function setOnceEveryday(?int $onceEveryday): self
  393.     {
  394.         $this->onceEveryday $onceEveryday;
  395.         return $this;
  396.     }
  397.     public function getOnceWeek(): ?int
  398.     {
  399.         return $this->onceWeek;
  400.     }
  401.     public function setOnceWeek(?int $onceWeek): self
  402.     {
  403.         $this->onceWeek $onceWeek;
  404.         return $this;
  405.     }
  406.     public function getPauseDate(): ?\DateTimeInterface
  407.     {
  408.         return $this->pauseDate;
  409.     }
  410.     public function setPauseDate(?\DateTimeInterface $pauseDate): self
  411.     {
  412.         $this->pauseDate $pauseDate;
  413.         return $this;
  414.     }
  415.     public function getPackageExpireAt(): ?\DateTime
  416.     {
  417.         return $this->packageExpireAt;
  418.     }
  419.     public function setPackageExpireAt(?\DateTime $packageExpireAt): self
  420.     {
  421.         $this->packageExpireAt $packageExpireAt;
  422.         return $this;
  423.     }
  424.     /**
  425.      * @return Collection|Commande[]
  426.      */
  427.     public function getCommandes(): Collection
  428.     {
  429.         return $this->commandes;
  430.     }
  431.     public function addCommande(Commande $commande): self
  432.     {
  433.         if (!$this->commandes->contains($commande)) {
  434.             $this->commandes[] = $commande;
  435.             $commande->setSociety($this);
  436.         }
  437.         return $this;
  438.     }
  439.     public function removeCommande(Commande $commande): self
  440.     {
  441.         if ($this->commandes->removeElement($commande)) {
  442.             // set the owning side to null (unless already changed)
  443.             if ($commande->getSociety() === $this) {
  444.                 $commande->setSociety(null);
  445.             }
  446.         }
  447.         return $this;
  448.     }
  449.     public function canViewProfile(): bool
  450.     {
  451.         return $this->profileView 0;
  452.     }
  453.     public function canAddIntercontrat(): bool
  454.     {
  455.         return $this->intercontratNumber || $this->intercontratNumber === -1;
  456.     }
  457.     public function decreaseProfileView()
  458.     {
  459.         $this->profileView--;
  460.     }
  461.     /**
  462.      * @return Collection|ProfileVisit[]
  463.      */
  464.     public function getProfileVisits(): Collection
  465.     {
  466.         return $this->profileVisits;
  467.     }
  468.     public function addProfileVisit(ProfileVisit $profileVisit): self
  469.     {
  470.         if (!$this->profileVisits->contains($profileVisit)) {
  471.             $this->profileVisits[] = $profileVisit;
  472.             $profileVisit->setSociety($this);
  473.         }
  474.         return $this;
  475.     }
  476.     public function removeProfileVisit(ProfileVisit $profileVisit): self
  477.     {
  478.         if ($this->profileVisits->removeElement($profileVisit)) {
  479.             // set the owning side to null (unless already changed)
  480.             if ($profileVisit->getSociety() === $this) {
  481.                 $profileVisit->setSociety(null);
  482.             }
  483.         }
  484.         return $this;
  485.     }
  486.     public function packageString()
  487.     {
  488.         return empty($this->package) ? 'Aucun' Config::PACKAGE_LIST[$this->package]['name'];
  489.     }
  490.     /**
  491.      * @return Collection|Annonce[]
  492.      */
  493.     public function getAnnonces(): Collection
  494.     {
  495.         return $this->annonces;
  496.     }
  497.     public function addAnnonce(Annonce $annonce): self
  498.     {
  499.         if (!$this->annonces->contains($annonce)) {
  500.             $this->annonces[] = $annonce;
  501.             $annonce->setSociety($this);
  502.         }
  503.         return $this;
  504.     }
  505.     public function removeAnnonce(Annonce $annonce): self
  506.     {
  507.         if ($this->annonces->removeElement($annonce)) {
  508.             // set the owning side to null (unless already changed)
  509.             if ($annonce->getSociety() === $this) {
  510.                 $annonce->setSociety(null);
  511.             }
  512.         }
  513.         return $this;
  514.     }
  515.     public function getDescription(): ?string
  516.     {
  517.         return $this->description;
  518.     }
  519.     public function setDescription(string $description): self
  520.     {
  521.         $this->description $description;
  522.         return $this;
  523.     }
  524.     public function getVille(): ?string
  525.     {
  526.         return $this->ville;
  527.     }
  528.     public function setVille(string $ville): self
  529.     {
  530.         $this->ville $ville;
  531.         return $this;
  532.     }
  533.     public function getPauseNumber(): ?int
  534.     {
  535.         return $this->pauseNumber;
  536.     }
  537.     public function setPauseNumber(?int $pauseNumber): self
  538.     {
  539.         $this->pauseNumber $pauseNumber;
  540.         return $this;
  541.     }
  542.     public function decreasePauseNumber(): self
  543.     {
  544.         $this->pauseNumber $this->pauseNumber 1;
  545.         return $this;
  546.     }
  547.     public function isPaused(): bool
  548.     {
  549.         return $this->pauseDate > new \DateTime();
  550.     }
  551.     public function hasActivePackage(): bool
  552.     {
  553.         return $this->getPackage() != null && ! $this->hasExpiredPackage();
  554.     }
  555.     public function hasExpiredPackage(): bool
  556.     {
  557.         return $this->getPackageExpireAt() < new \DateTime();
  558.     }
  559.     /**
  560.      * @return Collection|AnnonceVisit[]
  561.      */
  562.     public function getAnnonceVisits(): Collection
  563.     {
  564.         return $this->annonceVisits;
  565.     }
  566.     public function addAnnonceVisit(AnnonceVisit $annonceVisit): self
  567.     {
  568.         if (!$this->annonceVisits->contains($annonceVisit)) {
  569.             $this->annonceVisits[] = $annonceVisit;
  570.             $annonceVisit->setSociety($this);
  571.         }
  572.         return $this;
  573.     }
  574.     public function removeAnnonceVisit(AnnonceVisit $annonceVisit): self
  575.     {
  576.         if ($this->annonceVisits->removeElement($annonceVisit)) {
  577.             // set the owning side to null (unless already changed)
  578.             if ($annonceVisit->getSociety() === $this) {
  579.                 $annonceVisit->setSociety(null);
  580.             }
  581.         }
  582.         return $this;
  583.     }
  584.     public function getPackageName()
  585.     {
  586.         return Config::PACKAGE_LIST[$this->package]['name'];
  587.     }
  588.     public function getIntercontratUne(): ?int
  589.     {
  590.         return $this->intercontratUne ?? 0;
  591.     }
  592.     public function setIntercontratUne(?int $intercontratUne): self
  593.     {
  594.         $this->intercontratUne $intercontratUne;
  595.         return $this;
  596.     }
  597.     public function isCanUpload(): ?bool
  598.     {
  599.         return $this->canUpload;
  600.     }
  601.     public function getCa(): ?int
  602.     {
  603.         return $this->ca;
  604.     }
  605.     public function setCa(?int $ca): self
  606.     {
  607.         $this->ca $ca;
  608.         return $this;
  609.     }
  610.     public function getAdress(): ?string
  611.     {
  612.         return $this->adress;
  613.     }
  614.     public function setAdress(?string $adress): self
  615.     {
  616.         $this->adress $adress;
  617.         return $this;
  618.     }
  619.     /**
  620.      * @return Collection<int, CompteRecrutement>
  621.      */
  622.     public function getCompteRecrutements(): Collection
  623.     {
  624.         return $this->compteRecrutements;
  625.     }
  626.     public function addCompteRecrutement(CompteRecrutement $compteRecrutement): self
  627.     {
  628.         if (!$this->compteRecrutements->contains($compteRecrutement)) {
  629.             $this->compteRecrutements[] = $compteRecrutement;
  630.             $compteRecrutement->setSociete($this);
  631.         }
  632.         return $this;
  633.     }
  634.     public function removeCompteRecrutement(CompteRecrutement $compteRecrutement): self
  635.     {
  636.         if ($this->compteRecrutements->removeElement($compteRecrutement)) {
  637.             // set the owning side to null (unless already changed)
  638.             if ($compteRecrutement->getSociete() === $this) {
  639.                 $compteRecrutement->setSociete(null);
  640.             }
  641.         }
  642.         return $this;
  643.     }
  644.     public function getType(): ?string
  645.     {
  646.         return $this->type;
  647.     }
  648.     public function setType(?string $type): self
  649.     {
  650.         $this->type $type;
  651.         return $this;
  652.     }
  653.     public function getTwitter(): ?string
  654.     {
  655.         return $this->twitter;
  656.     }
  657.     public function setTwitter(?string $twitter): self
  658.     {
  659.         $this->twitter $twitter;
  660.         return $this;
  661.     }
  662.     public function getInstagram(): ?string
  663.     {
  664.         return $this->instagram;
  665.     }
  666.     public function setInstagram(?string $instagram): self
  667.     {
  668.         $this->instagram $instagram;
  669.         return $this;
  670.     }
  671.     public function getFacebook(): ?string
  672.     {
  673.         return $this->facebook;
  674.     }
  675.     public function setFacebook(?string $facebook): self
  676.     {
  677.         $this->facebook $facebook;
  678.         return $this;
  679.     }
  680.     public function getPresentationYoutube(): ?string
  681.     {
  682.         return $this->presentationYoutube;
  683.     }
  684.     public function setPresentationYoutube(?string $presentationYoutube): self
  685.     {
  686.         $this->presentationYoutube $presentationYoutube;
  687.         return $this;
  688.     }
  689.     public function getSlug(): ?string
  690.     {
  691.         return $this->slug;
  692.     }
  693.     public function setSlug(?string $slug): self
  694.     {
  695.         $this->slug $slug;
  696.         return $this;
  697.     }
  698. }