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