{% 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('CODE_ART',  post.tri_CODE_ART, 'Code Article' | trad, 'genetableau', path(pathPopup), 'formulaireListe') }}</th>
								<th>{{ triTable('DESIGN',  post.tri_DESIGN, 'Libellé Article' | trad, 'genetableau', path(pathPopup), 'formulaireListe') }}</th>
								<th>{{ triTable('CODE_FOU',  post.tri_CODE_FOU, 'Fournisseur' | trad, 'genetableau', path(pathPopup), 'formulaireListe') }}</th>
								<th>{{ triTable('CODE_FAM',  post.tri_CODE_FAM, 'Famille' | trad, 'genetableau', path(pathPopup), 'formulaireListe') }}</th>
								<th>{{ triTable('CODE_SFA',  post.tri_CODE_SFA, 'Sous Famille' | trad, 'genetableau', path(pathPopup), 'formulaireListe') }}</th>
							</tr>
						</thead>
						<tbody>
							<tr>
								<th>{{ filterTable('CODE_ART', post.filter_CODE_ART, '', 'genetableau', path(pathPopup), 'formulaireListe') }}</th>
								<th>{{ filterTable('DESIGN', post.filter_DESIGN, '', 'genetableau', path(pathPopup), 'formulaireListe') }}</th>
								<th>{{ filterTable('CODE_FOU'~spliter()~'LIBELLE_FOU', post['filter_CODE_FOU'~spliter()~'LIBELLE_FOU'], '', 'genetableau', path(pathPopup), 'formulaireListe') }}</th>
								<th>{{ filterTable('CODE_FAM'~spliter()~'LIBELLE_FAM', post['filter_CODE_FAM'~spliter()~'LIBELLE_FAM'], '', 'genetableau', path(pathPopup), 'formulaireListe') }}</th>
								<th>{{ filterTable('CODE_SFA'~spliter()~'LIBELLE_SFA', post['filter_CODE_SFA'~spliter()~'LIBELLE_SFA'], '', 'genetableau', path(pathPopup), 'formulaireListe') }}</th>
							</tr>
							{% for article in listeArticles %}
								{% if post.displayCodeOnly == 'true' %}
									<tr onclick='changeCodeLibelle("{{ post.divCode }}","{{ article.CODE_ART | convert_encoding(' utf-8', ' iso-8859-1') }}", "{{ post.divLibelle }}", "{{ article.CODE_ART }}");desactivePopup ()'>							
								{% else %}
									{% 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 ()'>							
								{% endif %}
									<td>{{ article.CODE_ART | convert_encoding('UTF-8', 'ISO-8859-1') }}</td>
									<td>{{ article.DESIGN | convert_encoding('UTF-8', 'ISO-8859-1') }}</td>
									<td>{{ article.LIBELLE_FOU | convert_encoding('UTF-8', 'ISO-8859-1') ~ (article.CODE_FOU ? " (" : "") ~ article.CODE_FOU | convert_encoding('UTF-8', 'ISO-8859-1') ~ (article.CODE_FOU ? ")" : "")}}</td>
									<td>{{ article.LIBELLE_FAM | convert_encoding('UTF-8', 'ISO-8859-1') ~ (article.CODE_FAM ? " (" : "") ~ article.CODE_FAM | convert_encoding('UTF-8', 'ISO-8859-1') ~ (article.CODE_FAM ? ")" : "") }}</td>
									<td>{{ article.LIBELLE_SFA | convert_encoding('UTF-8', 'ISO-8859-1') ~ (article.CODE_SFA ? " (" : "") ~ article.CODE_SFA | convert_encoding('UTF-8', 'ISO-8859-1') ~ (article.CODE_SFA ? ")" : "") }}</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 %}
