{% extends '@ajax-layout/layout.twig' %}

{% block body %}
	<center>
		<div id="genetableau">
			<div>
				<form method="POST" id='formulaireListe'>
					<input type="hidden" name="divCode" value="{{ post.divCode }}"/>
					<input type="hidden" name="divLibelle" value="{{ post.divLibelle }}"/>
					<div class="colonne">
						<div class="row">
							{{ inputSwitch(
                                'Uniquement les valides ?' | trad, 
                                'valide', 
                                post.valide, 
                                (post.valide_obligatoire == 1 ? 'disabled' : '') 
                                    ~ 'onChange="ajaxRechercheTableau(\'' ~ path(pathPopup) ~ '\', \'genetableau\', \'formulaireListe\')"'
                            ) }}
							<input type="hidden" name="filter_GENRERIQUE" value="{{ post.filter_GENRERIQUE }}"/>
						</div>
					</div>
					<table class="table" id="tableau">
						<thead class="thead-dark">
							<tr>
								<th>{{ triTable('DESIGN',  post.tri_DESIGN, 'Libellé Article' | trad, 'genetableau', path(pathPopup), 'formulaireListe') }}</th>
								<th>{{ triTable('SI',  post.tri_SI, 'SI' | trad, 'genetableau', path(pathPopup), 'formulaireListe') }}</th>
								<th>{{ triTable('CDC',  post.tri_CDC, 'CDC' | trad, 'genetableau', path(pathPopup), 'formulaireListe') }}</th>
								<th>{{ triTable('SCA',  post.tri_SCA, 'SCA' | trad, 'genetableau', path(pathPopup), 'formulaireListe') }}</th>
							</tr>
						</thead>
						<tbody>
							<tr>
								<th>{{ filterTable('DESIGN'~spliter()~'CODE_ART', post['filter_DESIGN'~spliter()~'CODE_ART'], '', 'genetableau', path(pathPopup), 'formulaireListe') }}</th>
								<th>{{ filterTable('SI'~spliter()~'LIBELLE_SI', post['filter_SI'~spliter()~'LIBELLE_SI'], '', 'genetableau', path(pathPopup), 'formulaireListe') }}</th>
								<th>{{ filterTable('CDC'~spliter()~'LIBELLE_CDC', post['filter_CDC'~spliter()~'LIBELLE_CDC'], '', 'genetableau', path(pathPopup), 'formulaireListe') }}</th>
								<th>{{ filterTable('SCA'~spliter()~'LIBELLE_SCA', post['filter_SCA'~spliter()~'LIBELLE_SCA'], '', 'genetableau', path(pathPopup), 'formulaireListe') }}</th>
							</tr>
							{% for article in listeArticles %}
								{% set codeArticle = post.displayCode != 'false' ? ' ('~article.CODE_ART~')' : '' %}
								<tr onclick='changeCodeLibelle("{{ post.divCode }}","{{ article.CODE_ART | convert_encoding(' utf-8', ' iso-8859-1') }}", "{{ post.divLibelle }}", "{{ article.DESIGN ~ (codearticle ? (codearticle | convert_encoding(' utf-8', ' iso-8859-1')) : ' (' ~ article.CODE_ART | convert_encoding(' utf-8', ' iso-8859-1')) ~ ')'}}");desactivePopup ()'>
									<td>{{ article.DESIGN | convert_encoding('UTF-8', 'ISO-8859-1') ~ (article.CODE_ART ? " (" : "") ~ article.CODE_ART | convert_encoding('UTF-8', 'ISO-8859-1') ~ (article.CODE_ART ? ")" : "") }}</td>
									<td>{{ article.LIBELLE_SI | convert_encoding('UTF-8', 'ISO-8859-1') ~ (article.SI ? " (" : "") ~ article.SI | convert_encoding('UTF-8', 'ISO-8859-1') ~ (article.SI ? ")" : "")}}</td>
									<td>{{ article.LIBELLE_CDC | convert_encoding('UTF-8', 'ISO-8859-1') ~ (article.CDC ? " (" : "") ~ article.CDC | convert_encoding('UTF-8', 'ISO-8859-1') ~ (article.CDC ? ")" : "") }}</td>
									<td>{{ article.LIBELLE_SCA | convert_encoding('UTF-8', 'ISO-8859-1') ~ (article.SCA ? " (" : "") ~ article.SCA | convert_encoding('UTF-8', 'ISO-8859-1') ~ (article.SCA ? ")" : "") }}</td>
								</tr>
							{% endfor %}
						</tbody>
					</table>
					<input type="hidden" name="societe" value={{post.societe ?? ''}}>
				</form>
				{{ paginations(path(pathPopup),infoPagination.nombreDePage, infoPagination.page, infoPagination.post, 'modal-body') }}
			</div>
		</div>
	</center>
{# </div> #}
{% endblock %}
