{% extends '@ajax-layout/layout.twig' %}
{% block body %}
    <script>
    	function addslashes(str) {
    		str = str.replace(/\\/g, '\\\\');
    		str = str.replace(/\'/g, '\\\'');
    		str = str.replace(/\"/g, '\\"');
    		str = str.replace(/\0/g, '\\0');
    		return str;
    	}
    	 
    	function stripslashes(str) {
    		str = str.replace(/\\'/g, '\'');
    		str = str.replace(/\\"/g, '"');
    		str = str.replace(/\\0/g, '\0');
    		str = str.replace(/\\\\/g, '\\');
    		return str;
    	}
    </script>
	<center>
	<div id="genetableau">
		<form method="POST" id='formulaireListe'>
			<input type="hidden" name="divCode" value="{{ post.divCode }}" />
			<input type="hidden" name="divLibelle" value="{{ post.divLibelle }}" />
			<table class="table" id="tableau">
				<thead class="thead-dark">
    				<tr>
						{% if societe == '' and infoCSType.TBLSECTO | boolSql %}
							<th>{{ triTable('COD_STE',  infoPagination.filter.tri_COD_STE, 'Société' | trad, 'genetableau', path, 'formulaireListe') }}</th>
						{% endif %}
    					<th>{{ triTable('CODEDICO',  infoPagination.filter.tri_CODEDICO, 'Code' | trad, 'genetableau', path, 'formulaireListe') }}</th>
    					<th>{{ triTable('LIBELLE',  infoPagination.filter.tri_LIB01DICO, 'Libellé' | trad, 'genetableau', path, 'formulaireListe') }}</th>
    				</tr>
    			</thead>
    			<tbody>
    				<tr>
						{% if societe == '' and infoCSType.TBLSECTO | boolSql %}
							<th>{{ filterTable('egal_COD_STE', infoPagination.filter.filter_egal_COD_STE, '', 'genetableau', path, 'formulaireListe') }}</th>
						{% endif %}
    					<th>{{ filterTable('CODEDICO', infoPagination.filter.filter_CODEDICO, '', 'genetableau', path, 'formulaireListe') }}</th>
    					<th>{{ filterTable('LIB01DICO', infoPagination.filter.filter_LIB01DICO, '', 'genetableau', path, 'formulaireListe') }}</th>
    				</tr>
    				{% for tsDon in entity %}
					<tr onclick="
						{{ attrJs('addslashes', [post.divCode])}};
						{{ attrJs('changeCodeLibelle', [
							post.divCode, tsDon.CODEDICO, post.divLibelle, 
							tsDon.LIB01DICO ~ ' (' ~ tsDon.CODEDICO ~ ')'
						])}};desactivePopup()"
					>
					 	{% if societe == '' and infoCSType.TBLSECTO | boolSql %}
							<td>{{ tsDon.COD_STE   | convert_encoding('UTF-8', 'ISO-8859-1') }}</td>
						{% endif %}
    					<td>{{ tsDon.CODEDICO   | convert_encoding('UTF-8', 'ISO-8859-1') }}</td>
    					<td>{{ tsDon.LIB01DICO  | convert_encoding('UTF-8', 'ISO-8859-1') }}</td>
    				</tr>
    				{% endfor %}
    			</tbody>
			</table>
		</form>
		{{ paginations(path,infoPagination.nombreDePage, infoPagination.page, infoPagination.post, 'modal-body') }}
	</div>
	</center>
{% endblock %}