templates/events/include-event-tickets.html.twig line 1

Open in your IDE?
  1. {% if page is defined %}
  2.     {% if page.total==0 and page.offset == 0 %}
  3.         <div class="row justify-content-md-center">
  4.             <div class="col-12 text-center">
  5.                 No hay tickets disponibles
  6.             </div>
  7.         </div>
  8.     {% endif %}
  9.     {# Tickets sold #}
  10.     {% if pageSoldOut.tickets is not empty %}
  11.         {% for ticket in pageSoldOut.tickets %}
  12.             {% set symbol = 'USD' %}
  13.             {% if from_argentina %}
  14.                 {% set ticket = ticket|merge({'price': ticket.price * conversion}) %}
  15.                 {% set symbol = 'ARS' %}
  16.             {% endif %}
  17.         <div class="row card-event-ticket mb-4 align-items-center">
  18.             <div class="col-lg-2 col-12 d-flex justify-content-lg-start justify-content-center">
  19.                 <div class="card-event-ticket-img">
  20.                     <img src="{{ ticket.imageThumb }}">
  21.                 </div>
  22.             </div>
  23.             <div class="col-lg-6 col-12">
  24.                 <h5 class="text-truncate mt-xl-0 mt-3"><b>{{ ticket.name }}</b></h5>
  25.                 <p class="text-muted text-truncate mt-2">{{ ticket.event.name }}</p>
  26.             </div>
  27.             <div class="col-xl-2 col-12 mt-xl-0 mt-4 d-flex justify-content-xl-end justify-content-center">
  28.                 <h5><b>{{ ticket.price|number_format(2, ',', '.') }} {{ symbol }}</b></h5>
  29.             </div>
  30.             <div class="col-xl-2 col-12 mt-xl-0 mt-4 d-flex align-items-center box-small-ticket" style="flex-direction: column;">
  31.                 <button class="btn-md blue btn_add_ticket mt-3 buy" href="javascript:void(0)" data-ticket_small="{{ ticket.id }}">entradas agotadas</button>
  32.             </div>
  33.         </div>
  34.         {% endfor %}
  35.     {% endif %}
  36.     {# Tickets available #}
  37.     {% if page.tickets is not empty %}
  38.         {% for ticket in page.tickets %}
  39.             {% if ticket.price > 0 %}
  40.                 {% set symbol = 'USD' %}
  41.                 {% if from_argentina %}
  42.                     {% set ticket = ticket|merge({'price': ticket.price * conversion}) %}
  43.                     {% set symbol = 'ARS' %}
  44.                 {% endif %}
  45.                 <div class="row card-event-ticket mb-4 align-items-center">
  46.                     <div class="col-xl-2 col-12 d-flex justify-content-xl-start justify-content-center">
  47.                         <div class="card-event-ticket-img d-flex justify-content-xl-start justify-content-center">
  48.                             <img src="{{ ticket.imageThumb }}">
  49.                         </div>
  50.                     </div>
  51.                     <div class="col-xl-6 col-12 align-items-xl-start align-items-center" style="flex-direction: column;">
  52.                         <h5 class="text-truncate mt-xl-0 mt-3"><b>{{ ticket.name }}</b></h5>
  53.                         <p class="text-muted text-truncate mt-2">{{ ticket.event.name }}</p>
  54.                     </div>
  55.                     <div class="col-xl-2 col-12 mt-xl-0 mt-4 d-flex justify-content-xl-end justify-content-center">
  56.                         <h5><b>{{ ticket.price|number_format(2, ',', '.') }} {{ symbol }}</b></h5>
  57.                     </div>
  58.                     <div class="col-xl-2 col-12 mt-xl-0 mt-4 d-flex align-items-center box-small-ticket" style="flex-direction: column;">
  59.                         <div class="card-event-ticket-amount">
  60.                             <input type="button" value="-"  class="quantity_btn remove_quantity_btn" id="remove_quantity_btn">
  61.                             <input type="number" id="quantity" placeholder="1" class="text-center inpt-number-tickets input_number_tickets" max="{{ ticket.quantity }}" data-max="{{ ticket.quantity }}" readonly>
  62.                             <input type="button" value="+" class="quantity_btn add_quantity_btn" id="add_quantity_btn">
  63.                         </div>
  64.                         <button class="btn-md blue btn_add_ticket mt-3 buy" href="javascript:void(0)" data-ticket_small="{{ ticket.id }}">Comprar</button>
  65.                     </div>
  66.                     
  67.                 </div>
  68.             {%  endif %}            
  69.         {% endfor %}
  70.         {% block javascripts %}
  71.             <script>
  72.                 $( document ).ready(function() {
  73.                     $("#page_next").val({{page.offset+page.limit}});
  74.                     $("#page_total").val({{page.total}});
  75.                 });
  76.                 $(".add_quantity_btn").click( function() {
  77.                     if(!$(this).closest(".box-small-ticket").find(".inpt-number-tickets").val()){
  78.                         quantity=1;
  79.                     }
  80.                     else{
  81.                         quantity = $(this).closest(".box-small-ticket").find(".inpt-number-tickets").val();  
  82.                     }
  83.                     
  84.                     max = $(this).closest(".box-small-ticket").find(".inpt-number-tickets").data("max");
  85.                     quantity++;
  86.                     if(quantity > max){
  87.                         quantity = max;
  88.                     }
  89.                     $(this).closest(".box-small-ticket").find(".inpt-number-tickets").val(quantity);
  90.                 });
  91.                 $(".remove_quantity_btn").click( function() {
  92.                     quantity = $(this).closest(".box-small-ticket").find(".inpt-number-tickets").val();
  93.                     quantity--;
  94.                     if(quantity <= 0){
  95.                         quantity = 1;
  96.                     }
  97.                     $(this).closest(".box-small-ticket").find(".inpt-number-tickets").val(quantity);
  98.                 });
  99.                 $(document).on('click', '.buy', function() {
  100.                     
  101.                     const cus = '{{ check_user_session }}';
  102.                     if(!cus) {
  103.                         swal({
  104.                             title: '<h4 class="py-3">Debes iniciar sesiĆ³n</h4>',
  105.                             html: true,
  106.                             type: 'info',
  107.                             showConfirmButton: true,
  108.                             confirmButtonColor: "#5902EC"
  109.                         });
  110.                                                 
  111.                         return false;
  112.                     }
  113.                     quantity = $(this).closest(".box-small-ticket").find(".inpt-number-tickets").val();
  114.                     if(quantity.length <= 0){
  115.                         quantity = 1;
  116.                     }
  117.                     url = "{{ path('ticket-buy', {'ticketId': 'value_ticket'}) }}?quantity=" + quantity;
  118.                     url = url.replace("value_ticket", $(this).data("ticket_small"));
  119.                     
  120.                     location.href = url;
  121.                 });
  122.             </script>
  123.         {% endblock %}
  124.     {% endif %}
  125. {% endif %}