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

{% block body %}
<div class="liste" id="genetableau">
	<center>
	<div>
		<form method="POST" id='form'>
			{% if post.valide_obligatoire != 1 %}
			<div class="colonne">
				<div class="row">
					{% if post.cdc_valide == '0' or post.cdc_valide == '' %}
						{{ inputSwitch(labelValide, 'cdc_valide', (post.valide_obligatoire==1?'on':post.cdc_valide), (post.valide_obligatoire==1?'disabled ':'')~'onChange="ajaxRechercheTableau(\''~path('Ajax.liste.cdc')~'\', \'genetableau\', \'form\')"') }}
					{% else %}
						{{ inputSwitch(labelValide, 'cdc_valide', (post.cdc_valide==1?'on':post.cdc_valide), (post.valide_obligatoire==1?'disabled ':'')~'onChange="ajaxRechercheTableau(\''~path('Ajax.liste.cdc')~'\', \'genetableau\', \'form\')"') }}
					{% endif %}
				</div>
			</div>
			{% endif %}
			{% if post.showFiltreDate == 1 %}
			<div class="colonne2">
				<div class="row">
					<input type="hidden" name="showFiltreDate" value="1" />
					{{ inputAdvance('DATE', { 
						'titre' : 'Validité sur la période du' | trad,
						'name'  : 'DATE_DEB',
						'value' : post.DATE_DEB | dateTrad,
						'pathValidator' : path('Ajax.validator.date'),
						'paramsValidator' : '{}',
						'option' : 'onChange="ajaxRechercheTableau(\''~path('Ajax.liste.cdc')~'\', \'genetableau\', \'form\')"'
					}) }}      	    
				</div>
			</div>
			<div class="colonne2 last">
				<div class="row">
					{{ inputAdvance('DATE', { 
						'titre' : 'au' | trad,
						'name'  : 'DATE_FIN',
						'value' : post.DATE_FIN | dateTrad,
						'pathValidator' : path('Ajax.validator.date'),
						'paramsValidator' : '{}',
						'option' : 'onChange="ajaxRechercheTableau(\''~path('Ajax.liste.cdc')~'\', \'genetableau\', \'form\')"'
					}) }}      	    
				</div>
			</div>
			{% endif %}
			<input type="hidden" name="divCode" value="{{ post.divCode }}" />
			<input type="hidden" name="divLibelle" value="{{ post.divLibelle }}" />
			<input type="hidden" name="CODE_STE" value="{{ post.CODE_STE }}" />
			<table class="table" id="tableau">
    			<thead class="thead-dark">
    				<tr>
    					<th>{{ triTable('CODE_CDC',  infoPagination.filter.tri_CODE_CDC, 'Code CDC' | trad,'genetableau', path('Ajax.liste.cdc'), 'form') }}</th>
    					<th>{{ triTable('LIBELLE',  infoPagination.filter.tri_LIBELLE, 'Libellé CDC' | trad,'genetableau', path('Ajax.liste.cdc'), 'form') }}</th>
    					<th>{{ triTable('CODE_STE',  infoPagination.filter.tri_CODE_STE, 'Société' | trad,'genetableau', path('Ajax.liste.cdc'), 'form') }}</th>
    					<th>{{ triTable('CODNAN',  infoPagination.filter.tri_CODNAN, 'Nature d\'analyse' | trad,'genetableau', path('Ajax.liste.cdc'), 'form') }}</th>
    					<th>{{ triTable('BUDGET',  infoPagination.filter.tri_BUDGET, 'Budget' | trad,'genetableau', path('Ajax.liste.cdc'), 'form') }}</th>
    					<th>{{ triTable('DEVISE',  infoPagination.filter.tri_DEVISE, 'Devise' | trad,'genetableau', path('Ajax.liste.cdc'), 'form') }}</th>
						<th>{{ triTable('DATE_DEB',  infoPagination.filter.tri_DATE_DEB, 'Validité début' | trad,'genetableau', path('Ajax.liste.cdc'), 'form') }}</th>
						<th>{{ triTable('DATE_FIN',  infoPagination.filter.tri_DATE_FIN, 'Validité fin' | trad,'genetableau', path('Ajax.liste.cdc'), 'form') }}</th>
    				</tr>
    			</thead>
    			<tbody>
    				<tr>
    					<th>{{ filterTable('CODE_CDC', infoPagination.filter.filter_CODE_CDC, '','genetableau', path('Ajax.liste.cdc'), 'form') }}</th>
    					<th>{{ filterTable('LIBELLE', infoPagination.filter.filter_LIBELLE, '','genetableau', path('Ajax.liste.cdc'), 'form') }}</th>
    					<th>{{ filterTable('CODE_STE', infoPagination.filter.filter_CODE_STE, '','genetableau', path('Ajax.liste.cdc'), 'form') }}</th>
    					<th>{{ filterTable('CODNAN', infoPagination.filter.filter_CODNAN, '','genetableau', path('Ajax.liste.cdc'), 'form') }}</th>
    					<th>{{ filterTable('BUDGET', infoPagination.filter.filter_BUDGET, '', 'genetableau', path('Ajax.liste.cdc'), 'form') }}</th>
    					<th>{{ filterTable('DEVISE', infoPagination.filter.filter_DEVISE, '','genetableau', path('Ajax.liste.cdc'), 'form') }}</th>
						<th>{{ filterTable('date_DATE_DEB',post.filter_date_DATE_DEB, '','genetableau', path('Ajax.liste.cdc'), 'form') }}</th>
						<th>{{ filterTable('date_DATE_FIN', post.filter_date_DATE_FIN, '','genetableau', path('Ajax.liste.cdc'), 'form') }}</th>
    				</tr>
    				{% for cdc in cdcs %}
    				
    				<tr onclick='changeCodeLibelle("{{ post.divCode }}","{{ cdc.CODE_CDC }}", "{{ post.divLibelle }}", "{{ cdc.libelleCdc~' ('~cdc.CODE_CDC~')' | convert_encoding('UTF-8', 'ISO-8859-1') }}");desactivePopup();'>
    					<td id ="{{cdc.CODE_CDC}}">{{ cdc.CODE_CDC}}</td>
    					<td>{{ cdc.libelleCdc | convert_encoding('UTF-8', 'ISO-8859-1') }}</td>
    					<td>{% if cdc.CODE_STE != '' and cdc.CODE_STE != ' ' %}{{ cdc.RAIS_SOC~' ('~cdc.CODE_STE~')' }}{% endif %}</td>
    					<td>{% if cdc.CODNAN != '' and cdc.CODNAN != ' ' %}{{ cdc.libelleNature~' ('~cdc.CODNAN~')' }}{% endif %}</td>
    					<td class="montant">{{ cdc.BUDGET | number_format(2, '.', ' ') }}</td>
    					<td>{{ cdc.DEVISE }}</td>
						<td>{{ cdc.DATE_DEB | dateTrad }}</td>
						<td>{{ cdc.DATE_FIN | dateTrad }}</td>
    				</tr>
    				{% endfor %}
    			</tbody>
			</table>
		    {{ paginations(path('Ajax.liste.cdc'),infoPagination.nombreDePage, infoPagination.page, infoPagination.post, 'modal-body') }}
		</form>
		
	</div>

	</center>
	</div>
{% endblock %}