templates/products/list.html.twig line 1

Open in your IDE?
  1. {% extends "base.html.twig" %}
  2. {% block headerStyles %}
  3.     {{ parent() }}
  4.     <style>
  5.         .cabecera_filtrada{
  6.             cursor:pointer;
  7.             min-width:150px;
  8.         }
  9.         .cabecera_filtrada:after{
  10.             content: "↓";
  11.             right: 0.5em;
  12.             float:right;
  13.             bottom: 0.9em;
  14.             display: block;
  15.             opacity: .3;
  16.         }
  17.         .cabecera_filtrada:before{
  18.             right: 1em;
  19.             content: "↑";
  20.             float:right;
  21.             bottom: 0.9em;
  22.             display: block;
  23.             opacity: 1;
  24.         }
  25.     </style>
  26. {% endblock %}
  27. {% block content %}
  28.     <div class="page-content">
  29.          <div class="page-breadcrumb d-none d-sm-flex align-items-center mb-3">
  30.             <div class="breadcrumb-title pe-3">Productos</div>
  31.              <form action="{{ path("productos") }}" method="GET" class="ms-auto">
  32.                 <div class=" d-sm-flex align-items-center ms-auto">
  33.                     <div class="form-group pe-3">
  34.                      <input type="text" name="s" id="s" class="form-control" placeholder="Buscar por nombre" value="{{ s }}"/>
  35.                     </div>
  36.                     <div class="form-group pe-3">
  37.                         <button type="submit" class="btn btn-primary">Buscar</button>
  38.                     </div>
  39.                 
  40.                 </div>
  41.             </form>
  42.             <div class="ms-auto">
  43.                    
  44.                          <!--a href="?{{ app.request.query.all | url_encode() }}" class="btn btn-primary mx-3">Exportar datos</a-->  
  45.                          <a href="{{ path('add_product' , { 'page': productos.currentPageNumber }) }}" class="btn btn-primary" ><i class="bx bx-plus"></i></a>
  46.                    
  47.                 
  48.             </div>
  49.         </div>
  50.         <div class="row">
  51.             <div class="card">
  52.                     <div class="card-body">
  53.                             <table class="table mb-0">
  54.                                     <thead>
  55.                                             <tr>
  56.                                                     <th scope="col">Imagen</th>
  57.                                                     <th scope="col" class="cabecera_filtrada" data-filter="sku">SKU</th>
  58.                                                     <th scope="col" class="cabecera_filtrada" data-filter="name">Nombre</th>
  59.                                                     <th scope="col">Categoría</th>
  60.                                                     <th class="cabecera_filtrada" data-filter="price" scope="col">Precio</th>
  61.                                                     <th scope="col">IVA</th>
  62.                                                     <th scope="col" class="cabecera_filtrada" data-filter="globalStock">Stock</th>
  63.                                                     <th scope="col">Web</th>
  64.                                                     <th scope="col">Variacion principal</th>
  65.                                                     <th scope="col">Variaciones</th>
  66.                                                     <th scope="col">Detalles</th>
  67.                                                     
  68.                                             </tr>
  69.                                     </thead>
  70.                                     <tbody>
  71.                                         {% for prod in productos %}
  72.                                             <tr>
  73.                                                     <th scope="row">{% if prod.getImage()!="" and prod.getImage() != null %}<img src="{{ asset('assets/images/products/'~prod.getImage()) }}" class="product-img-2"/>{% else %}<img src="{{ asset('assets/images/logos/logo-nubes.png') }}" class="product-img-2"/>{% endif %}</th>
  74.                                                     <td>{{ prod.getSku() }}</td>
  75.                                                     <td>{{ prod.getName() }}</td>
  76.                                                     <td>{{ prod.getId() | getCatsName() }}</td>
  77.                                                     <td>{{ prod.getPrice() }}</td>
  78.                                                     <td>{{ prod.getIva() }}</td>
  79.                                                     <td>{{ prod.getGlobalStock() }}</td>
  80.                                                     <td>{% if(prod.getWpId()!="") %}Si{% else %}No{% endif %}</td>
  81.                                                     <td>
  82.                                                         {% set variacion = prod.getId() | getVariaciones() %}
  83.                                                         {%for key_atr,variat in variacion %}
  84.                                                         
  85.                                                         {{key_atr}} : {% for var_atr in variat %} | {{var_atr}} {% endfor %}<br/>
  86.                                                             
  87.                                                         {%endfor%}
  88.                                                     </td>
  89.                                                     {%set variations = prod.getId() | getProductVariations() %}
  90.                                                     <td>
  91.                                                     
  92.                                                     {%for key,variation in variations %}
  93.                                                     
  94.                                                     {{key}} : {% for var in variation %} | {{var}} {% endfor %}<br/>
  95.                                                         
  96.                                                     {%endfor%}
  97.                                                     </td>
  98.                                                     <td>
  99.                                                         <a href="{{ path('editProduct', { 'id': prod.getId(), 'page': productos.currentPageNumber }) }}" class="btn btn-outline-primary" ><i class="bx bx-pencil"></i></a>
  100.                                                         <a href="{{ path('addProductVariation') }}?id={{ prod.getId() }}" class="btn btn-outline-success" ><i class="bx bx-add-to-queue"></i></a>
  101.                                                         {%if (prod.getId() | getVariaconesNum()) > 0 %}
  102.                                                         <a href="{{ path('viewProductVariations') }}?id={{ prod.getId() }}" class="btn btn-outline-warning" ><i class="bx bx-file-find"></i></a>
  103.                                                         {%endif%}
  104.                                                         <button onclick="generaEtiqueta({{prod.getId()}})" class="btn btn-outline-dark" ><i class="bx bx-label"></i></button>
  105.                                                         <button data-bs-toggle="modal" data-bs-target="#deleteItem" onclick="jQuery('#delete_item_id').val({{prod.getId()}})" class="btn btn-outline-danger" ><i class="bx bx-trash"></i></button>
  106.                                                     </td>
  107.                                                   
  108.                                             </tr>
  109.                                         {% endfor %}
  110.                                     </tbody>
  111.                             </table>
  112.                                       <div class="mt-3 col-md-12 text-center align-content-center">
  113.                             {{ knp_pagination_render(productos) }}
  114.                             </div>
  115.                     </div>
  116.             </div>
  117.         </div>
  118.     
  119.     </div>
  120. {% endblock %}
  121. {% block modals %}
  122.     
  123.    <div class="modal fade" id="addItem" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  124.         <div class="modal-dialog modal-lg">
  125.             <div class="modal-content">
  126.                     <div class="modal-header">
  127.                             <h5 class="modal-title" id="exampleModalLabel">Añadir Cliente</h5>
  128.                             <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  129.                     </div>
  130.                 <div class="modal-body" >
  131.                    
  132.                     
  133.                 </div>
  134.                 
  135.             </div>
  136.         </div>
  137.     </div>
  138.     <div class="modal fade" id="deleteItem" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
  139.         <div class="modal-dialog modal-lg">
  140.             <div class="modal-content">
  141.                 <div class="modal-header ">
  142.                         <h5 class="modal-title" id="exampleModalLabel">Eliminar Producto</h5>
  143.                         <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
  144.                 </div>
  145.                 <form action="{{ path('deleteProduct') }}" method="POST">
  146.                     <div class="modal-body text-center" >
  147.                         <h3>¿Estas seguro que deseas eliminar el producto?</h3>
  148.                         <p class="text-muted">Esta acción no se puede revertir</p>
  149.                         <input type="hidden" id="delete_item_id" name="id" value=""/>
  150.                         <input type="hidden" name="page" value="{{ productos.currentPageNumber }}"/>
  151.                     </div>
  152.                     <div class="modal-footer">
  153.                             <button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Cancelar</button>
  154.                             <button type="submit" class="btn btn-danger">Eliminar</button>
  155.                     </div>
  156.                 </form>
  157.             </div>
  158.         </div>
  159.     </div>
  160. {% endblock %}
  161. {% block footerScripts %}
  162.     {{ parent() }}
  163.     <script>
  164.         var orden = "{{orden}}";
  165.         
  166.         $(document).ready(function(){
  167.             $(".cabecera_filtrada").click(function(){
  168.                 
  169.                 var query = "";
  170.                 if(orden == "ASC"){
  171.                     orden = "DESC";
  172.                 }else{
  173.                     orden = "ASC";
  174.                 }
  175.                 var filter = $(this).data("filter");
  176.                 {%set arr = app.request.query.all%}
  177.                 {%set arr2 = arr | filter((v, k)=> k !="orden") %}
  178.                 {%set arr3 = arr2 | filter((v, k)=> k !="filter") %}
  179.                 window.location.href="{{path('productos')}}?orden="+orden+"&filter="+filter+"&{{arr3 | url_encode |raw}}";
  180.                 
  181.             });
  182.         });
  183.         
  184.         function deleteItem(){
  185.             var id = $("#delete_item_id").val();
  186.             window.location.href="{{ path('deleteProduct' , { 'page': productos.currentPageNumber }) }}?id="+id;
  187.         }
  188.         
  189.         function generaEtiqueta(id){
  190.             $.ajax({
  191.                 url:'{{path("printLabel")}}',
  192.                 type:'POST',
  193.                 async:false,
  194.                 data: {id:id },
  195.                 success:function(html){
  196.                     var mywindow = window.open('', 'PRINT', 'height=400,width=600'); 
  197.                     mywindow.document.write(html);
  198.                     mywindow.document.close();
  199.                     mywindow.focus();
  200.                     setTimeout(mywindow.print(),2000);
  201.                     
  202.                     //mywindow.close();
  203.                 }
  204.             });
  205.         }
  206.         </script>
  207.     
  208. {% endblock %}