{% extends 'base.html.twig' %}
{% block title %}Liste des entreprises{% endblock %}
{% block body %}
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/1.12.1/css/jquery.dataTables.css">
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<script type="text/javascript" charset="utf8" src="https://cdn.datatables.net/1.12.1/js/jquery.dataTables.js"></script>
{{ include('_header.html.twig') }}
<div class="container mt-5">
<div class="row">
<a type="button" href="{{path('app_entreprise_add')}}" class="btn btn-success">Ajouter</a>
</div>
<div class="row mt-4">
<table id="entreprises" class="text-center table table-light table-bordered table-striped" style="width:100%">
<thead>
<tr class="bg-dark">
<th>Raison Sociale</th>
<th style="width:10em">Ville</th>
<th style="width:7em">SIRET</th>
<th style="width:7em">Client</th>
<th style="width:7em">Utilisateur</th>
<th style="width:5em">Action</th>
<th style="display:none">PDL</th>
<th style="display:none">NAF</th>
</tr>
</thead>
</table>
</div>
</div>
{{ include('_footer.html.twig') }}
{% endblock %}
{% block javascripts %}
<script>
var entreprises = $("#entreprises").DataTable({
data:{{entreprises|json_encode|raw}},
columns: [
{ data: 0 }, // Raison Sociale
{ data: 1 }, // Ville
{ data: 2 }, // SIRET
{ data: 3 }, // Client
{ data: 4 }, // Utilisateur
{ data: 5 }, // Action
{ data: 6, visible: false }, // PDL (hidden)
{ data: 7, visible: false } // NAF (hidden)
],
"language": {
"url": "//cdn.datatables.net/plug-ins/9dcbecd42ad/i18n/French.json"
},
"stateSave": true,
"stateDuration": -1, // Keeps state until browser cache is cleared
"search": {
"smart": true,
"regex": false,
"search": ""
}
});
// Store current state before navigating to details
$(document).on('click', 'a[href*="app_entreprise_details"]', function() {
localStorage.setItem('returnToEnterpriseList', 'true');
});
// Check if we're returning from details page
if (localStorage.getItem('returnToEnterpriseList')) {
localStorage.removeItem('returnToEnterpriseList');
// The state will be automatically loaded by DataTables
}
</script>
{% endblock %}