<table class="table table-hover" id='tableauFacture'>
	<thead class="thead-dark">
		<tr>                                     
			<th scope="col" {% if nbLignesCde==0 %} width="15%"{% endif %}>
				<div class="ligne1">{{  'Code article' | trad }}</div>
			</th>                                
			<th scope="col" {% if nbLignesCde==0 %} width="15%"{% endif %}>
				<div class="ligne1">{{  'Désignation ligne' | trad }}</div>
			</th>                                    
			
				{# <div class="ligne2">{{  'Détail' | trad }}</div> #}
			<th scope="col" width="9%">
				<div class="ligne1">{{  'Sect Imp.' | trad }}</div>
			</th> 
			{% if params.IS_CG_ACTIVE %}                                  
			<th scope="col" width="9%">
				<div class="ligne2">{{  'Code Gest.' | trad }}</div>
			</th>       
			{% endif %}                              
			<th scope="col" width="9%">
				<div class="ligne1">{{  'CodeComp.' | trad }}</div>
			</th>                               
			<th scope="col" width="9%">
				<div class="ligne2">{{  'ScptAna' | trad }}</div>
			</th>                                  
			<th scope="col" width="12%">
				<div class="ligne2">{{  'Montant Facturé' | trad }}</div>
			</th>                                    
			<th scope="col" width="10%">
				{{  'Taux de TVA' | trad }}
			</th>                                    
			<th scope="col" width="10%">
				{{  'Montant de TVA' | trad }}
			</th>
			<th scope="col" width="2%" class="white-tooltip">
				<span class="infos_tooltip left">
					{{ 'Tout sélectionner' | trad}}
				</span>
				<input type="checkbox" name="allCde" id="allCde" onclick="checkout('checkbox', 'allCde');updateSelectAll('{{ path('Facture.ajax.ajaxModificationGroupe', {numFact:numFact}) }}', 'allCde');" class="form-control checkbox" checked />
			</th> 
			<th scope="col" width="2%" class="white-tooltip">
			</th>                                       
		</tr>
	</thead>
	<tbody>
		{% include '@facture/affectationEasyDemat/ligneTableauAffectation.twig' %}
	</tbody>
</table> 


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

    $("[id^=zoom_TAUX_TVA]").click(function(){
		id = $(this).attr('id');
		id_input = id.replace('zoom_', 'input_');
		$('#'+id_input).trigger('focus');
	});


	$('.calculQTE, .calculPU, .calculMTN, .calculTAUX_TVA, .calculMTN_TVA').focus(function(){
    
    	var id = $(this).attr('id');
    	var split_id = id.split('-');
    
    	if($('#SELECT_LIGNE-'+split_id[1]).is(':checked'))
    	{
        	HT_OLD_VALUE = $('#input_MONTANT-'+split_id[1]).val();
        	TVA_OLD_VALUE = $('#input_MT_TVA-'+split_id[1]).val();
        
        	HT_OLD_VALUE = HT_OLD_VALUE.replace(' ', '');
        	TVA_OLD_VALUE = TVA_OLD_VALUE.replace(' ', '');
    	}
    });
    
    $('.calculMTN, .calculMTN_TVA').change(function(){
    	var id = $(this).attr('id');
    	var split_id = id.split('-');
    
    	if($('#SELECT_LIGNE-'+split_id[1]).is(':checked'))
    	{
        	HT_NEW_VALUE = $('#input_MONTANT-'+split_id[1]).val();
        	TVA_NEW_VALUE = $('#input_MT_TVA-'+split_id[1]).val();
        
        	HT_NEW_VALUE = HT_NEW_VALUE.replace(' ', '');
        	TVA_NEW_VALUE = TVA_NEW_VALUE.replace(' ', '');
        
        	calculTotal(true);	
        
        	HT_OLD_VALUE = HT_NEW_VALUE;
        	TVA_OLD_VALUE = TVA_NEW_VALUE;
    	}
    });

	$(function() {
		$( ".datepicker" ).datepicker({
			showOn: "button",
			changeYear: true,
			changeMonth: true,
			buttonImage: "{{ baseUrl('IconeV2/Global/deadline-change.svg') }}",
			buttonImageOnly: true,
	/* 		minDate: "-3M",
			maxDate: "+1M", */
			showAnim: "fade",
			dateFormat: "{{ 'dd/mm/yy' | paramDateFormat }}"
			
		});

		/* TODO */ 
		
		{{ tradDatePickers() }}

		$.datepicker.setDefaults($.datepicker.regional['fr']);
		
		$("[id^=mail_CS_EXTENTION]").click(function(){
			id = $(this).attr('id');
			name_input = id.replace('mail_', '');
			if($('[name="'+name_input+'"]').val() != ""){
				document.location.href = "mailto:"+$('[name="'+name_input+'"]').val();
			}
		});
		$("[id^=url_CS_EXTENTION]").click(function(){
			id = $(this).attr('id');
			name_input = id.replace('url_', '');
			if($('[name="'+name_input+'"]').val() != ""){
				window.open($('[name="'+name_input+'"]').val(), "_blank");
			}
		});
	});
</script>
<!-- specifique twig -->
{% set data = i|specifiqueScript  %}

{% for object  in data  %}
    {% include object  %}
{% endfor %}

{% for cde in listeCde %} 
	<script>
		changeSousFamille('{{ numFact }}', '{{ cde.NO_LIGNE }}');
	</script>
{% endfor %}
