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