src/Entity/Reserva.php line 20

  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\UserStats;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use App\Entity\User;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use JMS\Serializer\Annotation as JMS;
  8. use Dinamic\ShopBundle\Entity\Cupon;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. /**
  11.  * Reserva
  12.  *
  13.  * @ORM\Table(name="reserva")
  14.  * @ORM\Entity(repositoryClass="App\Repository\ReservaRepository")
  15.  */
  16. class Reserva
  17. {
  18.     /**
  19.      * @var integer
  20.      *
  21.      * @ORM\Column(name="id", type="integer")
  22.      * @ORM\Id
  23.      * @ORM\GeneratedValue(strategy="AUTO")
  24.      * @JMS\Groups({"api-stats"})
  25.      */
  26.     private $id;
  27.     /**
  28.     * @ORM\ManyToOne(targetEntity="Oficina", inversedBy="reservas")
  29.     * @ORM\JoinColumn(name="oficina", referencedColumnName="id", nullable=true)
  30.     */
  31.     private $oficina;
  32.     /**
  33.      * @var string
  34.      *
  35.      * @ORM\Column(name="cupon", type="string", length=255, nullable=false)
  36.      */
  37.     private $cupon;
  38.     /**
  39.     * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="reservas")
  40.     * @ORM\JoinColumn(name="usuario", referencedColumnName="id", nullable=true)
  41.     */
  42.     private $usuario;
  43.     /**
  44.      * @var string
  45.      *
  46.      * @ORM\Column(name="anotacion", type="string", length=255, nullable=true)
  47.      */
  48.     private $anotacion;
  49.     /**
  50.      * @var string
  51.      *
  52.      * @ORM\Column(name="estado", type="string", length=255, nullable=true)
  53.      */
  54.     private $estado;
  55.     /**
  56.      * @var \DateTime
  57.      *
  58.      * @ORM\Column(name="horaRecogida", type="time", nullable=true)
  59.      */
  60.     private $horaRecogida;
  61.     /**
  62.      * @ORM\OneToMany(targetEntity="ReservaLinea", mappedBy="reserva", cascade={"persist", "remove"}, orphanRemoval=true)
  63.      */
  64.     private $lineas;
  65.     /**
  66.      * @var \DateTime
  67.      *
  68.      * @ORM\Column(name="fechaRecogida", type="date", nullable=true)
  69.      */
  70.     private $fechaRecogida;
  71.     /**
  72.      * @var string
  73.      *
  74.      * @ORM\Column(name="nombre", type="string", length=255, nullable=true)
  75.      */
  76.     private $nombre;
  77.     /**
  78.      * @var string
  79.      *
  80.      * @ORM\Column(name="apellido", type="string", length=255, nullable=true)
  81.      */
  82.     private $apellido;
  83.     /**
  84.      * @var string
  85.      *
  86.      * @ORM\Column(name="telefono", type="string", length=255, nullable=true)
  87.      */
  88.     private $telefono;
  89.     /**
  90.      * @var string
  91.      *
  92.      * @ORM\Column(name="email", type="string", length=255, nullable=true)
  93.      */
  94.     private $email;
  95.     /**
  96.      * @var string
  97.      *
  98.      * @ORM\Column(name="fechaOperacion", type="datetime", nullable=true)
  99.      */
  100.     private $fechaOperacion;
  101.     /**
  102.      * @var UserStats[]
  103.      * @ORM\ManyToMany(targetEntity="UserStats", mappedBy="bookingConversions")
  104.      *
  105.      */
  106.     protected $userStats;
  107.     
  108.     public function __toString() {
  109.         return "reserva ".$this->getId();
  110.     }
  111.     public function __construct() {
  112.         $this->lineas = new ArrayCollection();
  113.         $this->fechaOperacion =  new \DateTime();
  114.         $this->userStats = new ArrayCollection();
  115.     }
  116.     /**
  117.      * Get id
  118.      *
  119.      * @return integer
  120.      */
  121.     public function getId()
  122.     {
  123.         return $this->id;
  124.     }
  125.     /**
  126.      * Set oficina
  127.      *
  128.      * @param Oficina $oficina
  129.      * @return Reserva
  130.      */
  131.     public function setOficina(Oficina $oficina)
  132.     {
  133.         $this->oficina $oficina;
  134.         return $this;
  135.     }
  136.     /**
  137.      * Get oficina
  138.      *
  139.      * @return Oficina
  140.      */
  141.     public function getOficina()
  142.     {
  143.         return $this->oficina;
  144.     }
  145.     /**
  146.      * Set cupon
  147.      *
  148.      * @param string $cupon
  149.      * @return Transaccion
  150.      */
  151.     public function setCupon($cupon)
  152.     {
  153.         $this->cupon $cupon;
  154.         return $this;
  155.     }
  156.     /**
  157.      * Get cupon
  158.      *
  159.      * @return Cupon
  160.      */
  161.     public function getCupon()
  162.     {
  163.         return $this->cupon;
  164.     }
  165.     /**
  166.      * Set dia
  167.      *
  168.      * @param \DateTime $dia
  169.      * @return Reserva
  170.      */
  171.     public function setDia($dia)
  172.     {
  173.         $this->dia $dia;
  174.         return $this;
  175.     }
  176.     /**
  177.      * Get dia
  178.      *
  179.      * @return \DateTime
  180.      */
  181.     public function getDia()
  182.     {
  183.         return $this->dia;
  184.     }
  185.     /**
  186.      * Set estado
  187.      *
  188.      * @param string $estado
  189.      * @return Reserva
  190.      */
  191.     public function setEstado($estado)
  192.     {
  193.         $this->estado $estado;
  194.         return $this;
  195.     }
  196.     /**
  197.      * Get estado
  198.      *
  199.      * @return string
  200.      */
  201.     public function getEstado()
  202.     {
  203.         return $this->estado;
  204.     }
  205.     /**
  206.      * Set usuario
  207.      *
  208.      * @param User $usuario
  209.      * @return Reserva
  210.      */
  211.     public function setUsuario(User $usuario)
  212.     {
  213.         $this->usuario $usuario;
  214.         return $this;
  215.     }
  216.     /**
  217.      * Get usuario
  218.      *
  219.      * @return User
  220.      */
  221.     public function getUsuario()
  222.     {
  223.         return $this->usuario;
  224.     }
  225.     /**
  226.      * Set anotacion
  227.      *
  228.      * @param string $anotacion
  229.      * @return Reserva
  230.      */
  231.     public function setAnotacion($anotacion)
  232.     {
  233.         $this->anotacion $anotacion;
  234.         return $this;
  235.     }
  236.     /**
  237.      * Get anotacion
  238.      *
  239.      * @return string
  240.      */
  241.     public function getAnotacion()
  242.     {
  243.         return $this->anotacion;
  244.     }
  245.     /**
  246.      * Set linea
  247.      *
  248.      * @param Linea $lineas
  249.      * @return Reserva
  250.      */
  251.     public function setLineas($lineas)
  252.     {
  253.         $this->lineas $lineas;
  254.         return $this;
  255.     }
  256.     /**
  257.      * Get lineas
  258.      *
  259.      * @return string
  260.      */
  261.     public function getLineas()
  262.     {
  263.         return $this->lineas;
  264.     }
  265.     /**
  266.      * Set lineas
  267.      *
  268.      * @param Linea $lineas
  269.      * @return Reserva
  270.      */
  271.     public function addLinea($linea)
  272.     {
  273.         $this->lineas[] = $linea;
  274.         $linea->setReserva($this);
  275.         return $this;
  276.     }
  277.     /**
  278.      * Get lineas
  279.      *
  280.      * @return Reserva
  281.      */
  282.     public function removeLinea($linea)
  283.     {
  284.         $this->franjas->removeElement($linea);
  285.         return $this;
  286.     }
  287.     /**
  288.      * Set horaRecogida
  289.      *
  290.      * @param time  $horaRecogida
  291.      * @return Reserva
  292.      */
  293.     public function setHoraRecogida($horaRecogida)
  294.     {
  295.         $this->horaRecogida $horaRecogida;
  296.         return $this;
  297.     }
  298.     /**
  299.      * Get horaRecogida
  300.      *
  301.      * @return \DateTime
  302.      */
  303.     public function getHoraRecogida()
  304.     {
  305.         return $this->horaRecogida;
  306.     }
  307.     /**
  308.      * Set fechaRecogida
  309.      *
  310.      * @param \DateTime $fechaRecogida
  311.      * @return Pedido
  312.      */
  313.     public function setFechaRecogida($fechaRecogida)
  314.     {
  315.         $this->fechaRecogida $fechaRecogida;
  316.         return $this;
  317.     }
  318.     /**
  319.      * Get fechaRecogida
  320.      *
  321.      * @return \DateTime
  322.      */
  323.     public function getFechaRecogida()
  324.     {
  325.         return $this->fechaRecogida;
  326.     }
  327.     /**
  328.      * Set nombre
  329.      *
  330.      * @param string  $nombre
  331.      * @return Reserva
  332.      */
  333.     public function setNombre($nombre)
  334.     {
  335.         $this->nombre $nombre;
  336.         return $this;
  337.     }
  338.     /**
  339.      * Get nombre
  340.      *
  341.      * @return string
  342.      */
  343.     public function getNombre()
  344.     {
  345.         return $this->nombre;
  346.     }
  347.     /**
  348.      * Set apellido
  349.      *
  350.      * @param string  $apellido
  351.      * @return Reserva
  352.      */
  353.     public function setApellido($apellido)
  354.     {
  355.         $this->apellido $apellido;
  356.         return $this;
  357.     }
  358.     /**
  359.      * Get apellido
  360.      *
  361.      * @return string
  362.      */
  363.     public function getApellido()
  364.     {
  365.         return $this->apellido;
  366.     }
  367.     /**
  368.      * Set telefono
  369.      *
  370.      * @param string  $telefono
  371.      * @return Reserva
  372.      */
  373.     public function setTelefono($telefono)
  374.     {
  375.         $this->telefono $telefono;
  376.         return $this;
  377.     }
  378.     /**
  379.      * Get telefono
  380.      *
  381.      * @return string
  382.      */
  383.     public function getTelefono()
  384.     {
  385.         return $this->telefono;
  386.     }
  387.     /**
  388.      * Set email
  389.      *
  390.      * @param string  $email
  391.      * @return Reserva
  392.      */
  393.     public function setEmail($email)
  394.     {
  395.         $this->email $email;
  396.         return $this;
  397.     }
  398.     /**
  399.      * Get email
  400.      *
  401.      * @return string
  402.      */
  403.     public function getEmail()
  404.     {
  405.         return $this->email;
  406.     }
  407.     /**
  408.      * Set fechaOperacion
  409.      *
  410.      * @param string $fechaOperacion
  411.      * @return Transaccion
  412.      */
  413.     public function setFechaOperacion($fechaOperacion)
  414.     {
  415.         $this->fechaOperacion $fechaOperacion;
  416.         return $this;
  417.     }
  418.     /**
  419.      * Get fechaOperacion
  420.      *
  421.      * @return \DateTime
  422.      */
  423.     public function getFechaOperacion()
  424.     {
  425.         return $this->fechaOperacion;
  426.     }
  427.     /**
  428.      * @return UserStats[]
  429.      */
  430.     public function getUserStats()
  431.     {
  432.         return $this->userStats;
  433.     }
  434.     /**
  435.      * @param UserStats[] $userStats
  436.      */
  437.     public function setUserStats($userStats)
  438.     {
  439.         $this->userStats $userStats;
  440.     }
  441.     
  442.     
  443.     public function lineasHtml()
  444.     {
  445.         $html '
  446.         <table class="table">
  447.         <tbody>
  448.             <tr class="sonata-ba-view-container">
  449.                 <th>Cantidad</th>
  450.                 <th>Divisa Origen</th>
  451.                 <th>Divisa Destino</th>
  452.             </tr>';
  453.                                                                                                     
  454.         foreach ($this->getLineas() as $linea)
  455.         {
  456.             $html .= '<tr><td>'.$linea->getCantidad().'</td><td>'.$linea->getDivisaOrigen().'</td><td>'.$linea->getDivisaDestino().'</td></tr>';
  457.         }
  458.         
  459.         $html .= '</tbody>
  460.                             </table>';
  461.         return $html;
  462.     }
  463. }