src/Entity/User.php line 52

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\Collection;
  4. use Doctrine\DBAL\Types\Types;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. use App\Entity\TransaccionAfiliado;
  7. use App\Entity\Transaccion;
  8. use Symfony\Component\Validator\ExecutionContextInterface;
  9. use FOS\UserBundle\Model\User as BaseUser;
  10. use FOS\UserBundle\Model\UserInterface;
  11. // use Sonata\UserBundle\Model\UserInterface;
  12. // use Sonata\UserBundle\Entity\BaseUser;
  13. use Doctrine\Common\Collections\ArrayCollection;
  14. use Doctrine\ORM\Mapping as ORM;
  15. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  16. use Symfony\Component\Validator\Constraints\NotBlank;
  17. use App\Entity\Oficina;
  18. use JMS\Serializer\Annotation as JMS;
  19. use Knp\DoctrineBehaviors\Contract\Entity\TimestampableInterface;
  20. use Knp\DoctrineBehaviors\Model\Timestampable\TimestampableTrait;
  21. /**
  22.  * @ORM\Entity(repositoryClass="App\Repository\UserRepository")
  23.  * @ORM\Table(name="usuarios")
  24.  * @UniqueEntity(fields="username")
  25.  * @ORM\HasLifecycleCallbacks
  26.  * @ORM\AttributeOverrides({
  27.  *      @ORM\AttributeOverride(name="email",
  28.  *          column=@ORM\Column(
  29.  *              name     = "email",
  30.  *              length   = 255,
  31.  *              nullable=true,
  32.  *              unique=false
  33.  *          )
  34.  *      )
  35.  * })
  36.  * @ORM\AttributeOverrides({
  37.  *     @ORM\AttributeOverride(name="emailCanonical",
  38.  *         column=@ORM\Column(
  39.  *             name="email_canonical",
  40.  *             length=255,
  41.  *             nullable=true,
  42.  *             unique=false
  43.  *         )
  44.  *     )
  45.  * })
  46.  */
  47. class User extends BaseUser implements UserInterface /*implements TimestampableInterface
  48. {
  49.     use TimestampableTrait;
  50. */
  51. {
  52.     const SALUTE_SR     1;
  53.     const SALUTE_SRA    2;
  54.     const SALUTE_SRTA   3;
  55.     const R_USER        "ROLE_USER";
  56.     const R_ADMIN       "ROLE_ADMIN";
  57.     const R_MANAGER     "ROLE_MANAGER";
  58.     const R_SUPER_ADMIN "ROLE_SUPER_ADMIN";
  59.     const R_AFILIADO    "ROLE_AFILIADO";
  60.     const R_NOAFILIADO  "ROLE_NOAFILIADO";
  61.     /**
  62.      * @ORM\Id
  63.      * @ORM\Column(type="integer")
  64.      * @ORM\GeneratedValue(strategy="AUTO")
  65.      * @JMS\Groups({"api-stats"})
  66.      */
  67.     protected $id;
  68.     /**
  69.      * @ORM\Column(type="string")
  70.      * @JMS\Groups({"api-stats"})
  71.      */
  72.     protected $idCard;
  73.     /**
  74.      * @ORM\Column(type="string", nullable=true)
  75.      * @JMS\Groups({"api-stats"})
  76.      */
  77.     protected $erpId;
  78.     /**
  79.      * @ORM\Column(type="string", nullable=true)
  80.     */
  81.     protected $fidCard;
  82.     /**
  83.      * @ORM\Column(type="smallint")
  84.      */
  85.     protected $salute self::SALUTE_SR;
  86.     /**
  87.      * @ORM\Column(type="string")
  88.      * @NotBlank(message="Por favor, ingrese un nombre")
  89.      */
  90.     protected $name "";
  91.     /**
  92.      * @ORM\Column(type="string", nullable=true)
  93.      */
  94.     protected $fullName "";
  95.     protected $telefono "";
  96.     /**
  97.      * @ORM\Column(type="date", nullable=true)
  98.      */
  99.     protected $birthDate;
  100.     /**
  101.     * @ORM\ManyToOne(targetEntity="Oficina")
  102.     * @ORM\JoinColumn(name="oficina", referencedColumnName="id", nullable=true)
  103.     */
  104.     protected $oficinaGestion;
  105.     /**
  106.      *
  107.      * @ORM\Column(type="boolean")
  108.      */
  109.     protected $newsletter true;
  110.     /**
  111.      * @ORM\Column(type="string", nullable=true)
  112.      */
  113.     protected $mobile;
  114.     /**
  115.      * Contraseña plana
  116.      */
  117. //     protected ?string $plainPassword = "";
  118.     /**
  119.      * @ORM\Column(type="string", nullable=true)
  120.      */
  121.     protected $role;
  122.     /**
  123.      * @ORM\Column(type="datetime")
  124.      */
  125.     protected $registerDate;
  126.     /**
  127.      *
  128.      * @ORM\Column(type="boolean")
  129.      */
  130.     protected $estado true;
  131.     /**
  132.      *
  133.      * @ORM\Column(type="string", nullable=true)
  134.      *
  135.      * @Assert\File(maxSize = "10M", mimeTypes={ "image/jpeg", "image/jpg", "image/png", "image/gif", "image/bmp", "image/x-windows-bmp"}, groups = {"create"} )
  136.      */
  137.     protected $urlImagen;
  138.     protected $urlImagenCheckbox;
  139.     /**
  140.     *
  141.     *@ORM\Column(type="string" , nullable=true)
  142.     *
  143.     * @Assert\File(maxSize = "10M", mimeTypes={ "image/jpeg", "image/jpg", "image/png", "image/gif", "image/bmp", "image/x-windows-bmp"}, groups = {"create"})
  144.     */
  145.     protected $urlImagen2;
  146.     /**
  147.      * @ORM\Column(type="string", nullable=true)
  148.      */
  149.     protected $nombreVisible;
  150.     /**
  151.      * @Assert\GreaterThan("today")
  152.      */
  153.     protected $fechaCaducidad;
  154.     protected $fechaNacimiento;
  155.      /**
  156.      * @var ArrayCollection
  157.      *
  158.      * @ORM\OneToMany(targetEntity="Transaccion", mappedBy="usuario")
  159.      */
  160.     protected $transacciones;
  161.    /**
  162.    * @var ArrayCollection
  163.    *
  164.    * @ORM\OneToMany(targetEntity="TransaccionAfiliado", mappedBy="afiliado")
  165.    * @ORM\OrderBy({"fechaEntrega" = "DESC"})
  166.    */
  167.    protected $transaccionesDelAfiliado;
  168.     /**
  169.      * @var ArrayCollection
  170.      *
  171.      * @ORM\OneToMany(targetEntity="Reserva", mappedBy="usuario")
  172.      */
  173.     protected $reservas;
  174.     /**
  175.      * @var ArrayCollection
  176.      *
  177.      * @ORM\OneToMany(targetEntity="Alerta", mappedBy="usuario", orphanRemoval=true)
  178.      */
  179.     protected $alerts;
  180.     /**
  181.      * @ORM\Column(type="string", nullable=true)
  182.      */
  183.     private $idiomaPreferido;
  184.     
  185.     /**
  186.      * @ORM\Column(type="string", nullable=true)
  187.     */
  188.     protected $aliceId;
  189.     protected $tipoDocumento;
  190.     protected $pais;
  191.     
  192.     /**
  193.      * @ORM\Column(type="string", nullable=true)
  194.     */
  195.     protected $direccion1;
  196.     
  197.     /**
  198.      * @ORM\Column(type="string", nullable=true)
  199.     */
  200.     protected $ciudad;
  201.     
  202.     /**
  203.      * @ORM\Column(type="string", nullable=true)
  204.     */
  205.     protected $county;
  206.     
  207.     /**
  208.      * @ORM\Column(type="string", nullable=true)
  209.     */
  210.     protected $cp;
  211.     
  212.     
  213.     /**
  214.      * @var ArrayCollection
  215.      *
  216.      * @ORM\OneToMany(targetEntity="UserStats", mappedBy="user", orphanRemoval=true, cascade={"remove"})
  217.      * @ORM\OrderBy({"id" = "DESC"})
  218.      */
  219.     protected $userStats;
  220.     /**
  221.      * @var ArrayCollection
  222.      *
  223.      * @ORM\OneToMany(targetEntity="HistorialDevolucion", mappedBy="usuario")
  224.      */
  225.     protected $historialDevoluciones;
  226.     
  227.     public function __construct()
  228.     {
  229. //         parent::__construct();
  230.         $this->registerDate = new \DateTime("now");
  231.         $this->lineas = new ArrayCollection();
  232.         $this->transacciones = new ArrayCollection();
  233.         $this->transaccionesDelAfiliado = new ArrayCollection();
  234.         $this->reservas = new ArrayCollection();
  235.         $this->alerts = new ArrayCollection();
  236.         $this->userStats = new ArrayCollection();
  237.         $this->roles = [];
  238.         $this->enabled true;
  239.         $this->historialDevoluciones = new ArrayCollection();
  240.     }
  241.     public function isEnabled(): bool
  242.     {
  243.         //return(count($this->transacciones)>0);
  244.         return $this->enabled;
  245.     }
  246.     /**
  247.      * Set erpId
  248.      *
  249.      * @param string $erpId
  250.      * @return User
  251.      */
  252.     public function setErpId($erpId)
  253.     {
  254.         $this->erpId $erpId;
  255.         return $this;
  256.     }
  257.     /**
  258.      * Get erpId
  259.      *
  260.      * @return string
  261.      */
  262.     public function getErpId()
  263.     {
  264.         return $this->erpId;
  265.     }
  266.     public function getUrlImagenCheckbox(){
  267.       return $this->urlImagenCheckbox;
  268.     }
  269.     public function setUrlImagenCheckbox($urlImagenCheckbox){
  270.       $this->urlImagenCheckbox $urlImagenCheckbox;
  271.       return $this;
  272.     }
  273.     /**
  274.      * Set pais
  275.      *
  276.      * @param string $pais
  277.      * @return User
  278.      */
  279.     public function setPais($pais)
  280.     {
  281.         $this->pais $pais;
  282.         return $this;
  283.     }
  284.     /**
  285.      * Get pais
  286.      *
  287.      * @return string
  288.      */
  289.     public function getPais()
  290.     {
  291.         return $this->pais;
  292.     }
  293.     /**
  294.      * Get id
  295.      *
  296.      * @return integer
  297.      */
  298.     public function getId()
  299.     {
  300.         return $this->id;
  301.     }
  302.     /**
  303.      * Set salute
  304.      *
  305.      * @param integer $salute
  306.      * @return User
  307.      */
  308.     public function setSalute($salute)
  309.     {
  310.         $this->salute $salute;
  311.         return $this;
  312.     }
  313.     /**
  314.      * Get salute
  315.      *
  316.      * @return integer
  317.      */
  318.     public function getSalute()
  319.     {
  320.         return $this->salute;
  321.     }
  322.     /**
  323.      * Set name
  324.      *
  325.      * @param string $name
  326.      * @return User
  327.      */
  328.     public function setName($name)
  329.     {
  330.         $this->name $name;
  331.         return $this;
  332.     }
  333.     /**
  334.      * Get name
  335.      *
  336.      * @return string
  337.      */
  338.     public function getName()
  339.     {
  340.         return $this->name;
  341.     }
  342.     /**
  343.      * Set fullName
  344.      *
  345.      * @param string $fullName
  346.      * @return User
  347.      */
  348.     public function setFullName($fullName)
  349.     {
  350.         $this->fullName $fullName;
  351.         return $this;
  352.     }
  353.     /**
  354.      * Get fullName
  355.      *
  356.      * @return string
  357.      */
  358.     public function getFullName()
  359.     {
  360.         return $this->fullName;
  361.     }
  362.     /**
  363.      * Set fidCard
  364.      *
  365.      * @param string $fidCard
  366.      * @return User
  367.      */
  368.     public function setFidCard($fidCard)
  369.     {
  370.         $this->fidCard $fidCard;
  371.         return $this;
  372.     }
  373.     /**
  374.      * Get fidCard
  375.      *
  376.      * @return string
  377.      */
  378.     public function getFidCard()
  379.     {
  380.         return $this->fidCard;
  381.     }
  382.     /**
  383.      * Set idCard
  384.      *
  385.      * @param string $idCard
  386.      * @return User
  387.      */
  388.     public function setIdCard($idCard)
  389.     {
  390.         $this->idCard $idCard;
  391.         if (!$this->id)
  392.             $this->setUsername($idCard);
  393.         return $this;
  394.     }
  395.     /**
  396.      * Get idCard
  397.      *
  398.      * @return string
  399.      */
  400.     public function getIdCard()
  401.     {
  402.         return $this->idCard;
  403.     }
  404.     /**
  405.      * Set idCard
  406.      *
  407.      * @param string $idCard
  408.      * @return User
  409.      */
  410.     public function setTelefono($telefono)
  411.     {
  412.         $this->telefono $telefono;
  413.     }
  414.     /**
  415.      * Get idCard
  416.      *
  417.      * @return string
  418.      */
  419.     public function getTelefono()
  420.     {
  421.         return $this->telefono;
  422.     }
  423.     /**
  424.      * Set birthDate
  425.      *
  426.      * @param string $birthDate
  427.      * @return User
  428.      */
  429.     public function setBirthDate($birthDate)
  430.     {
  431.         $this->birthDate $birthDate;
  432.         return $this;
  433.     }
  434.     /**
  435.      * Get birthDate
  436.      *
  437.      * @return string
  438.      */
  439.     public function getBirthDate()
  440.     {
  441.         return $this->birthDate;
  442.     }
  443.     /**
  444.      * Set urlImagen
  445.      *
  446.      * @param string $urlImagen
  447.      * @return User
  448.      */
  449.     public function setUrlImagen($urlImagen)
  450.     {
  451.         $this->urlImagen $urlImagen;
  452.         return $this;
  453.     }
  454.     /**
  455.      * Get urlImagen
  456.      *
  457.      * @return string
  458.      */
  459.     public function getUrlImagen()
  460.     {
  461.         return $this->urlImagen;
  462.     }
  463.     /**
  464.      * Set urlImagen2
  465.      *
  466.      * @param string $urlImagen2
  467.      * @return User
  468.      */
  469.     public function setUrlImagen2($urlImagen2)
  470.     {
  471.         $this->urlImagen2 $urlImagen2;
  472.         return $this;
  473.     }
  474.     /**
  475.      * Get urlImagen2
  476.      *
  477.      * @return string
  478.      */
  479.     public function getUrlImagen2()
  480.     {
  481.         return $this->urlImagen2;
  482.     }
  483.     /*public function addUrlImage($urlImagen)
  484.     {
  485.     $this->urlImagenes[0] = $urlImagen->first();
  486.     $this->urlImagenes[1] = $urlImagen->last();
  487.     return $this;
  488.   }*/
  489.     /**
  490.      * Set nombreVisible
  491.      *
  492.      * @param string $nombreVisible
  493.      * @return User
  494.      */
  495.     public function setNombreVisible($nombreVisible)
  496.     {
  497.         $this->nombreVisible $nombreVisible;
  498.         return $this;
  499.     }
  500.     /**
  501.      * Get nombreVisible
  502.      *
  503.      * @return string
  504.      */
  505.     public function getNombreVisible()
  506.     {
  507.         return $this->nombreVisible;
  508.     }
  509.     /**
  510.      * Set register Date
  511.      *
  512.      * @param $date Date
  513.      * @return User
  514.      */
  515.     public function setRegisterDate($date)
  516.     {
  517.         $this->registerDate $date;
  518.         return $this;
  519.     }
  520.     /**
  521.      * Get registerDate
  522.      *
  523.      * @return date
  524.      */
  525.     public function getRegisterDate()
  526.     {
  527.         return $this->registerDate;
  528.     }
  529.     /**
  530.      * Set estado
  531.      *
  532.      * @param string $estado
  533.      * @return User
  534.      */
  535.     public function setEstado($estado){
  536.         $this->estado $estado;
  537.         return $this;
  538.     }
  539.     /**
  540.      * Get estado
  541.      *
  542.      * @return boolean
  543.      */
  544.     public function getEstado(){
  545.         return $this->estado;
  546.     }
  547.     /**
  548.      * Set newsletter
  549.      *
  550.      * @param string $newsletter
  551.      * @return User
  552.      */
  553.     public function setNewsletter($newsletter){
  554.         $this->newsletter $newsletter;
  555.         return $this;
  556.     }
  557.     /**
  558.      * Get newsletter
  559.      *
  560.      * @return boolean
  561.      */
  562.     public function getNewsletter(){
  563.         return $this->newsletter;
  564.     }
  565.     /**
  566.      * Set fechaCaducidad
  567.      *
  568.      * @param date $fechaCaducidad
  569.      * @return User
  570.      */
  571.     public function setFechaCaducidad($fechaCaducidad){
  572.         $this->fechaCaducidad $fechaCaducidad;
  573.         return $this;
  574.     }
  575.     /**
  576.      * Get fechaCaducidad
  577.      *
  578.      * @return date
  579.      */
  580.     public function getFechaCaducidad(){
  581.         return $this->fechaCaducidad;
  582.     }
  583.     /**
  584.      * @Assert\IsTrue(message = "user.fullAge")
  585.      */
  586.     public function isFechaNacimientoLegal()
  587.     {
  588.         if($this->fechaNacimiento){
  589.             $date$this->fechaNacimiento->format('Y-m-d');
  590.             if (time() < strtotime('+18 years'strtotime($date))) {
  591.                 return false;
  592.             }
  593.         }
  594.         return true;
  595.     }
  596.     /**
  597.      * @Assert\IsTrue(message = "user.expiredDocument")
  598.      */
  599.     public function isFechaCaducidadLegal(){
  600.         if($this->fechaCaducidad){
  601.             $date$this->fechaCaducidad->format('Y-m-d');
  602.             if ( time() > strtotime('+1 day'strtotime($date))) {
  603.                 return false;
  604.             }
  605.         }
  606.         return true;
  607.     }
  608.     /**
  609.      * Set fechaNacimiento
  610.      *
  611.      * @param date $fechaNacimiento
  612.      * @return User
  613.      */
  614.     public function setFechaNacimiento($fechaNacimiento){
  615.         $this->fechaNacimiento $fechaNacimiento;
  616.         return $this;
  617.     }
  618.     /**
  619.      * Get fechaCaducidad
  620.      *
  621.      * @return date
  622.      */
  623.     public function getFechaNacimiento(){
  624.         return $this->fechaNacimiento;
  625.     }
  626.     /**
  627.      * Set mobile
  628.      *
  629.      * @param string $mobile
  630.      * @return User
  631.      */
  632.     public function setMobile($mobile)
  633.     {
  634.         $this->mobile $mobile;
  635.         return $this;
  636.     }
  637.     /**
  638.      * Get mobile
  639.      *
  640.      * @return string
  641.      */
  642.     public function getMobile()
  643.     {
  644.         return $this->mobile;
  645.     }
  646. //     /**
  647. //      * @return mixed
  648. //      */
  649. //     public function getPlainPassword(): string
  650. //     {
  651. //         return $this->plainPassword;
  652. //     }
  653. // 
  654. //     /**
  655. //      * @param string $plainPassword
  656. //      */
  657. //     public function setPlainPassword($plainPassword): void
  658. //     {
  659. //         $this->plainPassword = $plainPassword;
  660. //     }
  661.     public function setRole($role)
  662.     {
  663.         $this->role $role;
  664.     }
  665.     public function getRole()
  666.     {
  667.         return $this->role;
  668.     }
  669.     /**
  670.      * Set oficina
  671.      *
  672.      * @param Oficina $oficina
  673.      * @return Oficina
  674.      */
  675.     public function setOficinaGestion($oficina)
  676.     {
  677.         $this->oficinaGestion $oficina;
  678.     }
  679.     /**
  680.      * @return mixed
  681.      */
  682.     public function getOficinaGestion()
  683.     {
  684.         return $this->oficinaGestion;
  685.     }
  686.     public function __toString()
  687.     {
  688.         if ($this->fullName)
  689.             return $this->fullName;
  690.         else
  691.             return $this->name." (".$this->email.")";
  692.     }
  693.     public static function getPossibleRoles()
  694.     {
  695.         return array(
  696.             self::R_USER        => "Usuario",
  697.             self::R_ADMIN       => "Administrador",
  698.             self::R_MANAGER     => "Gestor",
  699.             self::R_SUPER_ADMIN => "Super Administrador",
  700.             self::R_AFILIADO    => "Afiliado",
  701.         );
  702.     }
  703.     /**
  704.      * Returns an array of the user roles that an admin can create a user with
  705.      */
  706.     public static function getAdminRoles()
  707.     {
  708.         return array(
  709.            self::R_MANAGER     => "Gestor",
  710.            self::R_ADMIN       => "Administrador",
  711.         );
  712.     }
  713.     
  714.     /**
  715.      * Returns an array of the user roles that an admin can create a user with
  716.      */
  717.     public static function getAfiliadoRol()
  718.     {
  719.         return array(
  720.            self::R_AFILIADO    => "Afiliado",
  721.            self::R_NOAFILIADO  => "No afiliado",
  722.         );
  723.     }
  724.     public function checkUserActive(ExecutionContextInterface $context)
  725.     {
  726.         if(!$this->isEnabled())
  727.         {
  728.             $context->addViolationAt(
  729.                 'email',
  730.                 'Su cuenta está desactivada. Póngase en contacto con el administrador de la web.',
  731.                 array(),
  732.                 null
  733.             );
  734.         }
  735.     }
  736.     public function getTipoDocumento(){
  737.         return $this->tipoDocumento;
  738.     }
  739.     public function setTipoDocumento($tipoDocumento){
  740.         $this->tipoDocumento=$tipoDocumento;
  741.     }
  742.     public function setTransacciones($transacciones)
  743.     {
  744.         $this->transacciones $transacciones;
  745.         return $this;
  746.     }
  747.     public function getTransacciones()
  748.     {
  749.         return $this->transacciones;
  750.     }
  751. public function setTransaccionesAfiliadas($transaccionesDelAfiliado)
  752. {
  753.     $this->transaccionesAfiliadas $transaccionesDelAfiliado;
  754.     return $this;
  755. }
  756. public function getTransaccionesAfiliadas()
  757. {
  758.     return $this->transaccionesAfiliadas;
  759. }
  760. public function setTransaccionesDelAfiliado($transaccionesDelAfiliado)
  761. {
  762.     $this->transaccionesDelAfiliado $transaccionesDelAfiliado;
  763.     return $this;
  764. }
  765. public function getTransaccionesDelAfiliado()
  766. {
  767.     return $this->transaccionesDelAfiliado;
  768. }
  769.     public function setReservas($reservas)
  770.     {
  771.         $this->reservas $reservas;
  772.         return $this;
  773.     }
  774.     public function getReservas()
  775.     {
  776.         return $this->reservas;
  777.     }
  778.     public function setIdiomaPreferido($idiomaPreferido)
  779.     {
  780.         $this->idiomaPreferido $idiomaPreferido;
  781.         return $this;
  782.     }
  783.     public function getIdiomaPreferido()
  784.     {
  785.         return $this->idiomaPreferido;
  786.     }
  787.     /**
  788.      * @return ArrayCollection
  789.      */
  790.     public function getAlerts()
  791.     {
  792.         return $this->alerts;
  793.     }
  794.     /**
  795.      * @param ArrayCollection $alerts
  796.      * @return ArrayCollection
  797.      */
  798.     public function setAlerts(ArrayCollection $alerts)
  799.     {
  800.         return $this->alerts=$alerts;
  801.     }
  802.     /**
  803.      * @param Alerta $alerta
  804.      * @return $this
  805.      */
  806.     public function addAlerta(Alerta $alerta){
  807.         $this->alerts[]=$alerta;
  808.         $alerta->setUsuario($this);
  809.         return $this;
  810.     }
  811.     /**
  812.      * @param Alerta $alerta
  813.      * @return $this
  814.      */
  815.     public function removeAlerta(Alerta $alerta)
  816.     {
  817.         $this->alerts->removeElement($alerta);
  818.         return $this;
  819.     }
  820.     
  821.     /**
  822.      * @ORM\PrePersist
  823.     */
  824.     public function setCreateRole(): void
  825.     {
  826.         if ( $this->role == 'ROLE_MANAGER' ) {
  827.             $this->addRole('ROLE_MANAGER');
  828.             $this->idCard $this->username;
  829.         } elseif ( $this->role == 'ROLE_ADMIN' ) {
  830.             $this->addRole('ROLE_ADMIN');
  831.             $this->idCard $this->username;
  832.         } elseif ( $this->role == 'ROLE_AFILIADO' ) {
  833.             $this->addRole('ROLE_AFILIADO');
  834.         } elseif ( $this->role == 'ROLE_NOAFILIADO' ) {
  835.             
  836.         }
  837.     }
  838.     
  839.     /**
  840.      * @ORM\PreUpdate
  841.     */
  842.     public function setEditRole(): void
  843.     {
  844.         if ( $this->role == 'ROLE_MANAGER' ) {
  845.             $this->removeRole('ROLE_ADMIN');
  846.             $this->addRole('ROLE_MANAGER');
  847.         } elseif ( $this->role == 'ROLE_ADMIN' ) {
  848.             $this->removeRole('ROLE_MANAGER');
  849.             $this->addRole('ROLE_ADMIN');
  850.         } elseif ( $this->role == 'ROLE_AFILIADO' ) {
  851.             $this->addRole('ROLE_AFILIADO');
  852.         } elseif ( $this->role == 'ROLE_NOAFILIADO' ) {
  853.             $this->removeRole('ROLE_AFILIADO');
  854.         }
  855.     }
  856.     
  857.     /**
  858.      * Set aliceId
  859.      *
  860.      * @return string
  861.      */
  862.     public function setAliceId($aliceId)
  863.     {
  864.         $this->aliceId $aliceId;
  865.         return $this;
  866.     }
  867.     /**
  868.      * Get aliceId
  869.      *
  870.      * @return string
  871.      */
  872.     public function getAliceId()
  873.     {
  874.         return $this->aliceId;
  875.     }
  876.     public function isNewsletter(): ?bool
  877.     {
  878.         return $this->newsletter;
  879.     }
  880.     public function isEstado(): ?bool
  881.     {
  882.         return $this->estado;
  883.     }
  884.     public function addTransaccione(Transaccion $transaccione): self
  885.     {
  886.         if (!$this->transacciones->contains($transaccione)) {
  887.             $this->transacciones->add($transaccione);
  888.             $transaccione->setUsuario($this);
  889.         }
  890.         return $this;
  891.     }
  892.     public function removeTransaccione(Transaccion $transaccione): self
  893.     {
  894.         if ($this->transacciones->removeElement($transaccione)) {
  895.             // set the owning side to null (unless already changed)
  896.             if ($transaccione->getUsuario() === $this) {
  897.                 $transaccione->setUsuario(null);
  898.             }
  899.         }
  900.         return $this;
  901.     }
  902.     public function addTransaccionesDelAfiliado(TransaccionAfiliado $transaccionesDelAfiliado): self
  903.     {
  904.         if (!$this->transaccionesDelAfiliado->contains($transaccionesDelAfiliado)) {
  905.             $this->transaccionesDelAfiliado->add($transaccionesDelAfiliado);
  906.             $transaccionesDelAfiliado->setAfiliado($this);
  907.         }
  908.         return $this;
  909.     }
  910.     public function removeTransaccionesDelAfiliado(TransaccionAfiliado $transaccionesDelAfiliado): self
  911.     {
  912.         if ($this->transaccionesDelAfiliado->removeElement($transaccionesDelAfiliado)) {
  913.             // set the owning side to null (unless already changed)
  914.             if ($transaccionesDelAfiliado->getAfiliado() === $this) {
  915.                 $transaccionesDelAfiliado->setAfiliado(null);
  916.             }
  917.         }
  918.         return $this;
  919.     }
  920.     public function addReserva(Reserva $reserva): self
  921.     {
  922.         if (!$this->reservas->contains($reserva)) {
  923.             $this->reservas->add($reserva);
  924.             $reserva->setUsuario($this);
  925.         }
  926.         return $this;
  927.     }
  928.     public function removeReserva(Reserva $reserva): self
  929.     {
  930.         if ($this->reservas->removeElement($reserva)) {
  931.             // set the owning side to null (unless already changed)
  932.             if ($reserva->getUsuario() === $this) {
  933.                 $reserva->setUsuario(null);
  934.             }
  935.         }
  936.         return $this;
  937.     }
  938.     public function addAlert(Alerta $alert): self
  939.     {
  940.         if (!$this->alerts->contains($alert)) {
  941.             $this->alerts->add($alert);
  942.             $alert->setUsuario($this);
  943.         }
  944.         return $this;
  945.     }
  946.     public function removeAlert(Alerta $alert): self
  947.     {
  948.         if ($this->alerts->removeElement($alert)) {
  949.             // set the owning side to null (unless already changed)
  950.             if ($alert->getUsuario() === $this) {
  951.                 $alert->setUsuario(null);
  952.             }
  953.         }
  954.         return $this;
  955.     }
  956.     public function getDireccion1(): ?string
  957.     {
  958.         return $this->direccion1;
  959.     }
  960.     public function setDireccion1(?string $direccion1): self
  961.     {
  962.         $this->direccion1 $direccion1;
  963.         return $this;
  964.     }
  965.     public function getCiudad(): ?string
  966.     {
  967.         return $this->ciudad;
  968.     }
  969.     public function setCiudad(?string $ciudad): self
  970.     {
  971.         $this->ciudad $ciudad;
  972.         return $this;
  973.     }
  974.     public function getCounty(): ?string
  975.     {
  976.         return $this->county;
  977.     }
  978.     public function setCounty(?string $county): self
  979.     {
  980.         $this->county $county;
  981.         return $this;
  982.     }
  983.     public function getCp(): ?string
  984.     {
  985.         return $this->cp;
  986.     }
  987.     public function setCp(?string $cp): self
  988.     {
  989.         $this->cp $cp;
  990.         return $this;
  991.     }
  992.     public function getHistorialDevoluciones()
  993.     {
  994.         return $this->historialDevoluciones;
  995.     }
  996.     public function addHistorialDevolucion($historialDevolucion)
  997.     {
  998.         if (!$this->historialDevoluciones->contains($historialDevolucion)) {
  999.             $this->historialDevoluciones->add($historialDevolucion);
  1000.             $historialDevolucion->setUsuario($this);
  1001.         }
  1002.         return $this;
  1003.     }
  1004.     public function removeHistorialDevolucion($historialDevolucion)
  1005.     {
  1006.         if ($this->historialDevoluciones->removeElement($historialDevolucion)) {
  1007.             // set the owning side to null (unless already changed)
  1008.             if ($historialDevolucion->getUsuario() === $this) {
  1009.                 $historialDevolucion->setUsuario(null);
  1010.             }
  1011.         }
  1012.         return $this;
  1013.     }
  1014. }