src/Entity/ProspectDropped.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Service\GmapsService;
  4. use Doctrine\ORM\Events;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Gedmo\Mapping\Annotation as Gedmo;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. /**
  9.  * @ORM\Entity(repositoryClass="App\Repository\ProspectDroppedRepository")
  10.  */
  11. class ProspectDropped
  12. {
  13.     const TYPE_APPOINTMENT 'appointment';
  14.     const TYPE_CHECKUP 'checkup';
  15.     /**
  16.      * @ORM\Id()
  17.      * @ORM\GeneratedValue()
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\Column(type="datetime")
  23.      * @Gedmo\Timestampable(on="create")
  24.      */
  25.     private $created;
  26.     /**
  27.      * @ORM\Column(type="smallint", nullable=true)
  28.      */
  29.     private $gender;
  30.     /**
  31.      * @ORM\Column(type="string", length=255)
  32.      */
  33.     private $firstname;
  34.     /**
  35.      * @ORM\Column(type="string", length=255)
  36.      */
  37.     private $lastname;
  38.     /**
  39.      * @ORM\Column(type="string", length=255, nullable=true)
  40.      */
  41.     private $address;
  42.     /**
  43.      * @ORM\Column(type="string", length=5)
  44.      * @Assert\Regex(
  45.      *      pattern="/^(([0-8][0-9])|(9[0-5])|(2[ab]))[0-9]{3}$/",
  46.      *      message="Le code postal n'est pas valide"
  47.      * )
  48.      */
  49.     private $postalcode;
  50.     /**
  51.      * @ORM\Column(type="string", length=255, nullable=true)
  52.      */
  53.     private $city;
  54.     /**
  55.      * @ORM\Column(type="string", length=255, nullable=true)
  56.      * @Assert\Email(
  57.      *     message = "L'email '{{ value }}' n'est pas valide",
  58.      *     mode = "strict"
  59.      * )
  60.      */
  61.     private $email;
  62.     /**
  63.      * @ORM\Column(type="string", length=255, nullable=true)
  64.      * @Assert\Regex(pattern="/^(?:\+33|0)\s*[1-9](?:[\s.-]*\d{2}){4}$/", message="Le numéro de téléphone n'est pas valide.")
  65.      */
  66.     private $phoneNumber;
  67.     /**
  68.      * @ORM\Column(type="string", length=4, nullable=true)
  69.      * @Assert\Regex(pattern="/^(19|20)\d{2}$/", message="L'année de naissance n'est pas valide.")
  70.      */
  71.     private $yearOfBirth;
  72.     /**
  73.      * @ORM\Column(type="boolean")
  74.      */
  75.     private $isOptin;
  76.     /**
  77.      * @ORM\Column(type="boolean", nullable=true)
  78.      */
  79.     private $isPartnerOffer;
  80.     /**
  81.      * @ORM\Column(type="string", length=255)
  82.      */
  83.     private $request;
  84.     /**
  85.      * @ORM\Column(type="string", length=255, nullable=true)
  86.      */
  87.     private $acquisitionMode;
  88.     /**
  89.      * @ORM\Column(type="string", length=255, nullable=true)
  90.      */
  91.     private $acquisitionBase;
  92.     /**
  93.      * @ORM\Column(type="string", length=255, nullable=true)
  94.      */
  95.     private $acquisitionKeyword;
  96.     /**
  97.      * @ORM\Column(type="string", length=255, nullable=true)
  98.      */
  99.     private $acquisitionUrl;
  100.     /**
  101.      * @ORM\Column(type="float", nullable=true)
  102.      */
  103.     private $latitude;
  104.     /**
  105.      * @ORM\Column(type="float", nullable=true)
  106.      */
  107.     private $longitude;
  108.     /**
  109.      * @var string
  110.      * @ORM\Column(type="string", length=255, nullable=true)
  111.      */
  112.     private $locationType;
  113.     /**
  114.      * @var string
  115.      * @ORM\Column(type="string", length=255, nullable=true)
  116.      */
  117.     private $countryCode;
  118.     /**
  119.      * Représente l'entité par défault
  120.      * @return string
  121.      */
  122.     public function __toString(){
  123.         return 'Prospect ['.$this->getId().']';
  124.     }
  125.     /**
  126.      * Obtenir l'adresse complète
  127.      * @return string
  128.      */
  129.     public function getFullAddress() {
  130.         return $this->getAddress() . ' ' $this->getPostalcode() . ' ' $this->getCity();
  131.     }
  132.     /**
  133.      * Représente l'entité dans le BO
  134.      * @return string
  135.      */
  136.     public function getLabel(){
  137.         return '#'.$this->getId();
  138.     }
  139.     public function getId(): ?int
  140.     {
  141.         return $this->id;
  142.     }
  143.     public function getGender(): ?int
  144.     {
  145.         return $this->gender;
  146.     }
  147.     public function setGender(?int $gender): self
  148.     {
  149.         $this->gender $gender;
  150.         return $this;
  151.     }
  152.     public function getFirstname(): ?string
  153.     {
  154.         return $this->firstname;
  155.     }
  156.     public function setFirstname(string $firstname): self
  157.     {
  158.         $this->firstname $firstname;
  159.         return $this;
  160.     }
  161.     public function getLastname(): ?string
  162.     {
  163.         return $this->lastname;
  164.     }
  165.     public function setLastname(string $lastname): self
  166.     {
  167.         $this->lastname $lastname;
  168.         return $this;
  169.     }
  170.     public function getEmail(): ?string
  171.     {
  172.         return $this->email;
  173.     }
  174.     public function setEmail(string $email): self
  175.     {
  176.         $this->email $email;
  177.         return $this;
  178.     }
  179.     public function getPhoneNumber(): ?string
  180.     {
  181.         return $this->phoneNumber;
  182.     }
  183.     public function setPhoneNumber(?string $phoneNumber): self
  184.     {
  185.         $phoneNumber str_replace(' '''$phoneNumber);
  186.         $phoneNumber str_replace('+33''0'$phoneNumber);
  187.         $this->phoneNumber $phoneNumber;
  188.         return $this;
  189.     }
  190.     public function getYearOfBirth(): ?string
  191.     {
  192.         return $this->yearOfBirth;
  193.     }
  194.     public function setYearOfBirth(?string $yearOfBirth): self
  195.     {
  196.         $this->yearOfBirth $yearOfBirth;
  197.         return $this;
  198.     }
  199.     public function getDateFromYearOfBirth(): ?\DateTimeInterface {
  200.         return new \DateTime($this->getYearOfBirth() . '-01-01');
  201.     }
  202.     public function getRequest(): ?string
  203.     {
  204.         return $this->request;
  205.     }
  206.     public function setRequest(string $request): self
  207.     {
  208.         $this->request $request;
  209.         return $this;
  210.     }
  211.     public function getIsOptin(): ?bool
  212.     {
  213.         return $this->isOptin;
  214.     }
  215.     public function setIsOptin(bool $isOptin): self
  216.     {
  217.         $this->isOptin $isOptin;
  218.         return $this;
  219.     }
  220.     public function getIsPartnerOffer(): ?bool
  221.     {
  222.         return $this->isPartnerOffer;
  223.     }
  224.     public function setIsPartnerOffer(bool $isPartnerOffer): self
  225.     {
  226.         $this->isPartnerOffer $isPartnerOffer;
  227.         return $this;
  228.     }
  229.     public function getAddress(): ?string
  230.     {
  231.         return $this->address;
  232.     }
  233.     public function setAddress(string $address): self
  234.     {
  235.         $this->address $address;
  236.         return $this;
  237.     }
  238.     public function getPostalcode(): ?string
  239.     {
  240.         return $this->postalcode;
  241.     }
  242.     public function setPostalcode(string $postalcode): self
  243.     {
  244.         if(strlen($postalcode) === 4) {
  245.             $this->postalcode str_pad($postalcode5'0'STR_PAD_LEFT);
  246.         } else {
  247.             $this->postalcode $postalcode;
  248.         }
  249.         return $this;
  250.     }
  251.     public function getCity(): ?string
  252.     {
  253.         return $this->city;
  254.     }
  255.     public function setCity(string $city): self
  256.     {
  257.         $this->city $city;
  258.         return $this;
  259.     }
  260.     public function getCreated(): ?\DateTimeInterface
  261.     {
  262.         return $this->created;
  263.     }
  264.     public function setCreated(\DateTimeInterface $created): self
  265.     {
  266.         $this->created $created;
  267.         return $this;
  268.     }
  269.     public function getAcquisitionMode(): ?string
  270.     {
  271.         return $this->acquisitionMode;
  272.     }
  273.     public function setAcquisitionMode(?string $acquisitionMode): self
  274.     {
  275.         $this->acquisitionMode $acquisitionMode;
  276.         return $this;
  277.     }
  278.     public function getAcquisitionBase(): ?string
  279.     {
  280.         return $this->acquisitionBase;
  281.     }
  282.     public function setAcquisitionBase(?string $acquisitionBase): self
  283.     {
  284.         $this->acquisitionBase $acquisitionBase;
  285.         return $this;
  286.     }
  287.     public function getAcquisitionUrl(): ?string
  288.     {
  289.         return $this->acquisitionUrl;
  290.     }
  291.     public function setAcquisitionUrl(?string $acquisitionUrl): self
  292.     {
  293.         $this->acquisitionUrl $acquisitionUrl;
  294.         return $this;
  295.     }
  296.     public function getLatitude(): ?float
  297.     {
  298.         return $this->latitude;
  299.     }
  300.     public function setLatitude(?float $latitude): self
  301.     {
  302.         $this->latitude $latitude;
  303.         return $this;
  304.     }
  305.     public function getLongitude(): ?float
  306.     {
  307.         return $this->longitude;
  308.     }
  309.     public function setLongitude(?float $longitude): self
  310.     {
  311.         $this->longitude $longitude;
  312.         return $this;
  313.     }
  314.     public function getLocationType(): ?string
  315.     {
  316.         return $this->locationType;
  317.     }
  318.     public function setLocationType(?string $locationType): self
  319.     {
  320.         $this->locationType $locationType;
  321.         return $this;
  322.     }
  323.     public function getCountryCode(): ?string
  324.     {
  325.         return $this->countryCode;
  326.     }
  327.     public function setCountryCode(?string $countryCode): self
  328.     {
  329.         $this->countryCode $countryCode;
  330.         return $this;
  331.     }
  332.     public function getAcquisitionKeyword(): ?string
  333.     {
  334.         return $this->acquisitionKeyword;
  335.     }
  336.     public function setAcquisitionKeyword(?string $acquisitionKeyword): self
  337.     {
  338.         $this->acquisitionKeyword $acquisitionKeyword;
  339.         return $this;
  340.     }
  341.     /**
  342.      * Recupérer les utm et la provenance d'une demande prospect
  343.      *
  344.      * @param $utmContent
  345.      * @param $utmSource
  346.      * @param $utmUrl
  347.      */
  348.     public function serializeUtm($utmContent$utmSource$utmUrl$utmKeyword) {
  349.         // sanitize GET parameter
  350.         $getUtmContent preg_replace('/[^-a-zA-Z0-9_]/'''$utmContent);
  351.         $getUtmSource preg_replace('/[^-a-zA-Z0-9_]/'''$utmSource);
  352.         $getUtmUrl preg_replace('/[^-a-zA-Z0-9_]/'''$utmUrl);
  353.         $getUtmKeyword preg_replace('/[^-a-zA-Z0-9_]/'''$utmKeyword);
  354.         $this->setAcquisitionMode($getUtmContent);
  355.         $this->setAcquisitionBase($getUtmSource);
  356.         $this->setAcquisitionKeyword($getUtmKeyword);
  357.         $this->setAcquisitionUrl($getUtmUrl);
  358.     }
  359. }