templates/admin/admin_products/index.html.twig line 1

Open in your IDE?
  1. {% extends 'layouts/layouts_admin/base_administration.html.twig' %}
  2. {% block headerContent %}
  3.     {% include 'admin/admin_products/tpl_header.html.twig' with {'title': "Produits", 'subtitle': "Gérer l'ensemble de vos produits"} %}
  4. {% endblock %}
  5. {% block title %}Gestion des produits{% endblock %}
  6. {% block javascripts %}
  7.     <script src="{{ asset('assets/DataTables/datatables.min.js') }}"></script>
  8.     <script src="{{ asset('js_admin/products/products.js') }}"></script>
  9. {% endblock %}
  10. {% block stylesheets %}
  11.     <link rel="stylesheet" href="{{ asset('assets/DataTables/datatables.min.css') }}">
  12. {% endblock %}
  13. {% block content %}
  14.     {{ include('admin/admin_products/tpl_onglets.html.twig') }}
  15.     <div class="row">
  16.         <div class="col-md-12">
  17.             <div class="main-card mb-3 card">
  18.                 <div class="card-body">
  19.                     <div class="card-header flexJustify">Liste des produits</div>
  20.                     <div class="card-body">
  21.                         <table style="width: 100%;" id="data_table_products" class="table table-hover">
  22.                             <thead>
  23.                             <tr>
  24.                                 <th></th>
  25.                                 <th></th>
  26.                                 <th class="align-middle">Nom</th>
  27.                                 <th class="align-middle">Catégorie</th>
  28.                                 <th class="align-middle">
  29.                                     Type Odyssée
  30.                                 </th>
  31.                                 <th class="align-middle">Date de création</th>
  32.                                 {% if stockManagement %}
  33.                                     <th class="align-middle">Stock alerte</th>
  34.                                 {% endif %}
  35.                                 <th></th>
  36.                                 <th></th>
  37.                             </tr>
  38.                             </thead>
  39.                             <tbody>
  40.                             {% for product in productsList %}
  41.                                 {# QUAND LE PRODUIT N'A PAS DE REFERENCE #}
  42.                                 {% set refCount = 0 %}
  43.                                 {% set typeOdyssee = '' %}
  44.                                 {% for ref in referencesList %}
  45.                                     {% if ref.productId == product.id %}
  46.                                         {% set refCount = refCount+1 %}
  47.                                         {% set typeOdyssee = ref.typeOdyssee %}
  48.                                     {% endif %}
  49.                                 {% endfor %}
  50.                                 <tr id="row{{ product.id }}">
  51.                                     <td class="text-center align-middle">
  52.                                         <div class="mb-0 mr-0 badge badge-dot badge-dot-lg badge-{% if product.getProdIsonline() %}success{% else %}danger{% endif %}">{% if product.getProdIsonline() == 1 %}1{% else %}0{% endif %}</div>
  53.                                     </td>
  54.                                     <td>
  55.                                         <img src="{{ asset('/medias_front/products/' ~ product.prodPicture, projectDirectory) }}"
  56.                                              alt="{{ product.prodTitle }}" style="max-width: 50px;">
  57.                                     </td>
  58.                                     <td>
  59.                                         <a href="{{ path('admin_product_edit', {prod_id:product.getId()}) }}">{{ product.getProdModel() }}</a>
  60.                                         {% if refCount == 0 and product.prodType == 'single' %}
  61.                                             <span class="badge badge-warning ml-3">Vous devez définir un prix pour cet article</span>
  62.                                         {% elseif refCount == 0 and product.prodType == 'multiple' %}
  63.                                             <span class="badge badge-warning ml-3">Vous devez définir des références sur ce produit</span>
  64.                                         {% endif %}
  65.                                     </td>
  66.                                     <td class="align-middle">
  67.                                         {% for categ in categsList %}
  68.                                             {% if categ.id == product.getCategoryId() %}
  69.                                                 {{ categ.categ_entitled }}
  70.                                             {% endif %}
  71.                                         {% endfor %}
  72.                                     </td>
  73.                                     <td>
  74.                                         {{ typeOdyssee }}
  75.                                     </td>
  76.                                     <td class="align-middle">
  77.                                         {% if product.getProdCreationDate()|date("H:i:s") != '00:00:00' %}
  78.                                             {{ product.getProdCreationDate()|date("d/m/Y H:i") }}
  79.                                         {% else %}
  80.                                             {{ product.getProdCreationDate()|date("d/m/Y") }}
  81.                                         {% endif %}
  82.                                     </td>
  83.                                     {% if stockManagement %}
  84.                                         <td class="align-middle">
  85.                                             {% set alert = false %}
  86.                                             {% for ref in referencesList if not alert %}
  87.                                                 {% if ref.refQuantity <= ref.stockAlert %}
  88.                                                     {% if ref.productId == product.id %}
  89.                                                         {% set alert = true %}
  90.                                                     {% endif %}
  91.                                                 {% endif %}
  92.                                             {% endfor %}
  93.                                             {% if alert %}
  94.                                                 <span class="badge badge-pill badge-danger">Stock faible</span>
  95.                                             {% else %}
  96.                                                 <span class="badge badge-pill badge-success">Stock bon</span>
  97.                                             {% endif %}
  98.                                         </td>
  99.                                     {% endif %}
  100.                                     <td class="align-middle">
  101.                                         <button class="border-0 btn-transition btn btn-outline-info"
  102.                                                 onclick="window.location = '{{ path('admin_product_edit', {prod_id:product.getId()}) }}';">
  103.                                             <i class="fa fa-cog"></i>
  104.                                         </button>
  105.                                     </td>
  106.                                     <td class="align-middle">
  107.                                         <button class="border-0 btn-transition btn btn-outline-danger"
  108.                                                 onclick="if (confirm('Voulez-vous supprimer ce produit ?')) removeProduct({{ product.getId() }});">
  109.                                             <i class="fa fa-trash-alt"></i>
  110.                                         </button>
  111.                                     </td>
  112.                                 </tr>
  113.                             {% endfor %}
  114.                             </tbody>
  115.                         </table>
  116.                     </div>
  117.                 </div>
  118.             </div>
  119.         </div>
  120.     </div>
  121. {% endblock %}