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

{% block body %}
    <div id="nouveau-type-achat">
    <div id="genetableau" class="clearfix">
    	<form method="post" name="formulaireListeTypeAchat" id="formulaireListeTypeAchat">
    	
    		<table class="table sans_actions table-hover" id="tableau">
            	<thead class="thead-dark">
                	<tr>
                        <th scope="col" width="12%" >{{ 'Code' | trad }}</th>
                        <th scope="col" >{{ 'Libellé Type d\'Achat' | trad }}</th>
                        <th scope="col" class="align-center">{{ 'Sous-Traitance ?' | trad }}</th>
                        <th scope="col" class="align-center">{{ 'Pour invest ?' | trad }}</th>
                    </tr>
                </thead>
                <tbody>
                	<tr>
                    	<td>{{ filterTable('CODE', infoPagination.filter.filter_CODE, '', 'genetableau', path('Fournisseur.TypeAchat.popupAjoutTypeAchat',{'type' : type}),'formulaireListeTypeAchat') }}</td>
                    	<td>{{ filterTable('LIBELLE', infoPagination.filter.filter_LIBELLE, '', 'genetableau', path('Fournisseur.TypeAchat.popupAjoutTypeAchat',{'type' : type}),'formulaireListeTypeAchat') }}</td>
                    	<td>{{ filterSelect('ST', infoPagination.filter.filter_ST, { oui : 'Oui' | trad, non : 'Non' | trad}, 'formulaireListeTypeAchat' , '', 'nouveau-type-achat', path('Fournisseur.TypeAchat.popupAjoutTypeAchat',{'type' : type})) }}</td>
                    	<td>{{ filterSelect('INVEST', infoPagination.filter.filter_INVEST, { oui : 'Oui' | trad, non : 'Non' | trad}, 'formulaireListeTypeAchat' , '', 'nouveau-type-achat', path('Fournisseur.TypeAchat.popupAjoutTypeAchat',{'type' : type})) }}</td>
                    </tr>
                        {% for TypeAchat in listeTypeAchat %}
                            <tr onClick="ajouterEntity('{{ path('Fournisseur.TypeAchat.ajaxAjoutTypeAchat',{'type' : type}) }}', '{{ TypeAchat.TYP_ACH }}',
                             '{% if type %}content_tableauTypeAchat{% else %}content_tableau{% endif %}');" style="cursor:pointer;">
                            	<td>{{ TypeAchat.TYP_ACH }}</td>
                            	<td>{{ TypeAchat.LIB_TAC }}</td>
                            	<td class="align-center">{{ (TypeAchat.STRAIT | boolSql) | boolTrad }}</td>
                            	<td class="align-center">{{ (TypeAchat.INVEST | boolSql) | boolTrad }}</td>
                            </tr>
                        {% endfor %}
                </tbody>
            </table>
            {{ paginations(path('Fournisseur.TypeAchat.popupAjoutTypeAchat',{'type' : type}),infoPagination.nombreDePage, infoPagination.page, infoPagination.post, 'modal-body') }}
             <div class="validation_modal modal-footer">
                 <button type="button" class="button secondaire button_right" onClick='desactivePopup();'>{{ 'Fermer' | trad }}</button>
    		</div>
		</form>
		</div>
    </div>
    {% if type %}
    <script>

        function ajouterEntity(path, entity, div)
        {
            $.ajax({
                dataType : 'html',
                url: path,
                data: {'entity' : entity},
                type: "POST",
                success: function(result){  
                    refrechDiv('{{ path('Fournisseur.TypeAchat.ajaxTypeAchatTableau', {'type':type}) }}', div);
                    desactivePopup();
                }
            });
        }

    </script>  
{% endif %}
{% endblock %}