
{% 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.sca_valide == '0' or post.sca_valide == '' %}
						{{ inputSwitch(labelValide, 'sca_valide', (post.valide_obligatoire==1?'on':post.sca_valide), (post.valide_obligatoire==1?'disabled ':'')~'onChange="ajaxRechercheTableau(\''~path('Ajax.liste.sca')~'\', \'genetableau\', \'form\')"') }}
					{% else %}
						{{ inputSwitch(labelValide, 'sca_valide', (post.sca_valide==1?'on':post.sca_valide), (post.valide_obligatoire==1?'disabled ':'')~'onChange="ajaxRechercheTableau(\''~path('Ajax.liste.sca')~'\', \'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_MINI',
						'value' : post.DATE_MINI | dateTrad,
						'pathValidator' : path('Ajax.validator.date'),
						'paramsValidator' : '{}',
						'option' : 'onChange="ajaxRechercheTableau(\''~path('Ajax.liste.sca')~'\', \'genetableau\', \'form\')"'
					}) }}      	    
				</div>
			</div>
			<div class="colonne2 last">
				<div class="row">
					{{ inputAdvance('DATE', { 
						'titre' : 'au' | trad,
						'name'  : 'DATE_MAXI',
						'value' : post.DATE_MAXI | dateTrad,
						'pathValidator' : path('Ajax.validator.date'),
						'paramsValidator' : '{}',
						'option' : 'onChange="ajaxRechercheTableau(\''~path('Ajax.liste.sca')~'\', \'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_SCA',  infoPagination.filter.tri_CODE_SCA, 'Code SCA' | trad,'genetableau', path('Ajax.liste.sca'), 'form') }}</th>
    					<th>{{ triTable('LIBELLE',  infoPagination.filter.tri_LIBELLE, 'Libellé SCA' | trad,'genetableau', path('Ajax.liste.sca'), 'form') }}</th>
    					<th>{{ triTable('CODE_STE',  infoPagination.filter.tri_CODE_STE, 'Société' | trad,'genetableau', path('Ajax.liste.sca'), 'form') }}</th>
    					<th>{{ triTable('CODE_CTA',  infoPagination.filter.tri_CODE_CTA, 'Centre d\'analyse' | trad,'genetableau', path('Ajax.liste.sca'), 'form') }}</th>
    					<th>{{ triTable('BUDGET',  infoPagination.filter.tri_BUDGET, 'Budget' | trad,'genetableau', path('Ajax.liste.sca'), 'form') }}</th>
    					<th>{{ triTable('DEVISE',  infoPagination.filter.tri_DEVISE, 'Devise' | trad,'genetableau', path('Ajax.liste.sca'), 'form') }}</th>
						<th>{{ triTable('DATE_MINI',  infoPagination.filter.tri_DATE_MINI, 'Validité début' | trad,'genetableau', path('Ajax.liste.sca'), 'form') }}</th>
						<th>{{ triTable('DATE_MAXI',  infoPagination.filter.tri_DATE_MAXI, 'Validité fin' | trad,'genetableau', path('Ajax.liste.sca'), 'form') }}</th>
    				</tr>
    			</thead>
    			<tbody>
    				<tr>
    					<th>{{ filterTable('CODE_SCA', infoPagination.filter.filter_CODE_SCA, '','genetableau', path('Ajax.liste.sca'), 'form') }}</th>
    					<th>{{ filterTable('LIBELLE', infoPagination.filter.filter_LIBELLE, '','genetableau', path('Ajax.liste.sca'), 'form') }}</th>
    					<th>{{ filterTable('CODE_STE', infoPagination.filter.filter_CODE_STE, '','genetableau', path('Ajax.liste.sca'), 'form') }}</th>
    					<th>{{ filterTable('CODE_CTA', infoPagination.filter.filter_CODE_CTA, '','genetableau', path('Ajax.liste.sca'), 'form') }}</th>
    					<th>{{ filterTable('BUDGET', infoPagination.filter.filter_BUDGET, '', 'genetableau', path('Ajax.liste.sca'), 'form') }}</th>
    					<th>{{ filterTable('DEVISE', infoPagination.filter.filter_DEVISE, '','genetableau', path('Ajax.liste.sca'), 'form') }}</th>
							<th>{{ filterTable('date_DATE_MINI', post.filter_date_DATE_MINI, '','genetableau', path('Ajax.liste.sca'), 'form') }}</th>
							<th>{{ filterTable('date_DATE_MAXI', post.filter_date_DATE_MAXI, '','genetableau', path('Ajax.liste.sca'), 'form') }}</th>
        		    </tr>
    				{% for sca in scas %}
    				<tr onclick='changeCodeLibelle("{{ post.divCode }}","{{ sca.CODE_SCA }}", "{{ post.divLibelle }}","{{ sca.libelleSca~' ('~sca.CODE_SCA~')' | convert_encoding('UTF-8', 'ISO-8859-1') }}");desactivePopup();'>
    					<td>{{ sca.CODE_SCA}}</td>
    					<td>{{ sca.libelleSca   | convert_encoding('UTF-8', 'ISO-8859-1') }}</td>
    					<td>{% if sca.CODE_STE != '' and sca.CODE_STE != ' ' %}{{ sca.RAIS_SOC~' ('~sca.CODE_STE~')' }}{% endif %}</td>
    					<td>{% if sca.CODE_CTA != '' and sca.CODE_CTA != ' ' %}{{ sca.libelleCentreAnalyse~' ('~sca.CODE_CTA~')' }}{% endif %}</td>
    					<td align="right">{{ sca.BUDGET | number_format(2, '.', ' ') }}</td>
    					<td>{{ sca.DEVISE }}</td>
							<td>{{ sca.DATE_MINI | dateTrad }}</td>
							<td>{{ sca.DATE_MAXI | dateTrad }}</td>
    				</tr>
    				{% endfor %}
    			</tbody>
			</table>
	    {{ paginations(path('Ajax.liste.sca'),infoPagination.nombreDePage, infoPagination.page, infoPagination.post, 'modal-body') }}
		</form>
	</div>
	</center>
</div>

<script type="text/javascript" src="{{ baseUrl('js/parametre.js') }}"></script>
<script>


$(function() {
	  
	{{ tradDatePickers() }}
	$.datepicker.setDefaults($.datepicker.regional['fr']);

});
</script>	
{% endblock %}