templates/entreprise/index.html.twig line 1

Open in your IDE?
  1. {% extends 'base.html.twig' %}
  2. {% block title %}Liste des entreprises{% endblock %}
  3. {% block body %}
  4. <link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.12.1/css/jquery.dataTables.css">
  5. <script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
  6. <script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.12.1/js/jquery.dataTables.js"></script>
  7. {{ include('_header.html.twig') }}
  8.     <div class="container mt-5">
  9.         <div class="row">
  10.             <a type="button" href="{{path('app_entreprise_add')}}" class="btn btn-success">Ajouter</a>
  11.         </div>
  12.         <div class="row mt-4">
  13.             <table id="entreprises" class="text-center table table-light table-bordered table-striped" style="width:100%">
  14.                 <thead>
  15.                     <tr class="bg-dark">
  16.                         <th>Raison Sociale</th>
  17.                         <th style="width:10em">Ville</th>
  18.                         <th style="width:7em">SIRET</th>
  19.                         <th style="width:7em">Client</th>
  20.                         <th style="width:7em">Utilisateur</th>
  21.                         <th style="width:5em">Action</th>
  22.                         <th style="display:none">PDL</th>
  23.                         <th style="display:none">NAF</th>
  24.                     </tr>
  25.                 </thead>
  26.             </table>
  27.         </div>
  28.     </div>
  29. {{ include('_footer.html.twig') }}
  30. {% endblock %}
  31. {% block javascripts %}
  32.     <script>
  33.         var entreprises = $("#entreprises").DataTable({
  34.             data:{{entreprises|json_encode|raw}},
  35.             columns: [
  36.                 { data: 0 }, // Raison Sociale
  37.                 { data: 1 }, // Ville
  38.                 { data: 2 }, // SIRET
  39.                 { data: 3 }, // Client
  40.                 { data: 4 }, // Utilisateur
  41.                 { data: 5 }, // Action
  42.                 { data: 6, visible: false }, // PDL (hidden)
  43.                 { data: 7, visible: false } // NAF (hidden)
  44.             ],
  45.             "language": {
  46.                 "url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/French.json"
  47.             },
  48.             "stateSave": true,
  49.             "stateDuration": -1, // Keeps state until browser cache is cleared
  50.             "search": {
  51.                 "smart": true,
  52.                 "regex": false,
  53.                 "search": ""
  54.             }
  55.         });
  56.         // Store current state before navigating to details
  57.         $(document).on('click', 'a[href*="app_entreprise_details"]', function() {
  58.             localStorage.setItem('returnToEnterpriseList', 'true');
  59.         });
  60.         // Check if we're returning from details page
  61.         if (localStorage.getItem('returnToEnterpriseList')) {
  62.             localStorage.removeItem('returnToEnterpriseList');
  63.             // The state will be automatically loaded by DataTables
  64.         }
  65.     </script>
  66. {% endblock %}