    <input type="hidden" value="{{ planning | length == 0? 1:(planning | length) }}" id="countPlanning" />
    <input type="hidden" name="calculPlanning" id="calculPlanning" value="{% if ligne.RECEP_AUTO %}0{% else %}1{% endif %}" />
    <table class="table table-hover" id="tablePlanning">
        <thead class="thead-dark">
            <tr>
                <td>{{ 'Quantité' | trad }}</td>
                <td>{{ 'Date' | trad }}</td>
                <td width='40px'>
                    {% if (ligne.NO_DA == '' or (ligne.NO_DA and param.LIMITACH_DEL == false) or droit.HA_CA_MCPR == true) %}
                        <a {% if lockPlanning == true or ligne.RECEP_AUTO | boolSql %}style="display:none;"{% endif %} id="addPlanning" class="ajouter_v2" onClick="addLignePlanning('{{ path('Commande.ModificationLigneCommande.ajaxAddLignePlanning') }}')" style="float: right;">
                        </a>
                    {% endif %}
                </td>
            </tr>
        </thead>
        <tbody class="tablePlanning">
            {% for date in planning %}
                <tr class="planningTR" id="planningTR{{loop.index}}">
                    <td align="right">
                        {{ inputAdvance('text', {
                            'name' : 'PLANNING-QTE_COMM-'~loop.index,
                            'pathValidator' : path('Ajax.validator.float'),
                            'value'	: qteByUnite(date.QTE_COMM, ligne.UNITE),
                            'paramsValidator' : "{'format':"~getConst('formatQTE')~"}",
                            'addClass' : 'planningQte',
                            'option' : ((ligne.NO_DA and param.LIMITACH_DEL) and droit.HA_CA_MCPR == false)? 'readOnly':'',
                        }) }}
                    </td>
                    <td>
                        {{ inputAdvance('date', {
                            'name' : 'PLANNING-DTE_LIV-'~loop.index,
                            'pathValidator' : path('Ajax.validator.date'),
                            'value'	: date.DTE_LIV |dateTrad,
                            'paramsValidator' : "{}",
                            'addStyle' : 'dte_planning',
                            'option' : (((ligne.NO_DA and param.LIMITACH_DEL) and droit.HA_CA_MCPR == false) or (lockPlanning == true or ligne.RECEP_AUTO | boolSql))? 'readOnly':'',
                        }) }}
                    </td>
                    <td>
                        {% if loop.index != 1 and ligne.RECEP_AUTO | boolSql == false %}
                            {{ hover_action('planningTR'~loop.index, 'Supprimer_v2 deletePlanning' , "deletePlanning("~loop.index~");", 'float: right;margin-right:5px;'~(lockPlanning == true? 'display:none;':'')~'') }}
                        {% endif %}
                    </td>
                </tr>
            {% else %}
                <tr id="planningTR1">
                    <td align="right">
                        {{ inputAdvance('text', {
                            'name' : 'PLANNING-QTE_COMM-1',
                            'pathValidator' : path('Ajax.validator.float'),
                            'paramsValidator' : "{'format':"~getConst('formatQTE')~"}",
                            'addClass' : 'planningQte',
                            'option' : ((ligne.NO_DA and param.LIMITACH_DEL) and droit.HA_CA_MCPR == false)? 'readOnly':'',
                        }) }}
                    </td>
                    <td>
                        {{ inputAdvance('date', {
                            'name' : 'PLANNING-DTE_LIV-1',
                            'pathValidator' : path('Ajax.validator.date'),
                            'paramsValidator' : "{}",
                            'option' : (((ligne.NO_DA and param.LIMITACH_DEL) and droit.HA_CA_MCPR == false) or (lockPlanning == true or ligne.RECEP_AUTO | boolSql))? 'readOnly':'',
                        }) }}
                    </td>
                    <td>
                    </td>
                </tr>
            {% endfor %}
        </tbody>
    </table>
    <script>
        function deletePlanning(noLignePlanning)
			{
				$('#planningTR'+noLignePlanning).remove();
				var countTR = $('.tablePlanning >tr').length;

				if (countTR == 1) {
					$('#input_ligne_DTELIVCON').attr("readOnly", false);
					$('#input_ligne_DTELIVCON').val($('#input_PLANNING-DTE_LIV-1').val());
                    showDatepicker('#input_ligne_DTELIVCON', '{{ baseUrl('IconeV2/Global/deadline-change.svg') }}', '{{ 'dd/mm/yy' | paramDateFormat }}');
				}
			}

			function addLignePlanning(path)
			{
				$('#input_ligne_DTELIVCON').val('');
				$('#input_ligne_DTELIVCON').attr("readOnly", true);
				var countTR = $('#countPlanning').val();
				countTR = parseInt(countTR);
				$.ajax({
					dataType : 'html',
					url: path,
					data: {'noLigne' : countTR + 1},
					type: "POST",
					success: function(result){
						$('#tablePlanning').find('tr:last').after(result);
						$('#countPlanning').val(countTR + 1 );
						desactiveLoader();
					}
				});

			}

			$('#input_ligne_DTELIVCON').change(function(){
				var countTR = $('.tablePlanning >tr').length;

				if (countTR == 1) {
					$('#input_PLANNING-DTE_LIV-1').val($(this).val());
				}
			});

			$('#input_PLANNING-DTE_LIV-1').change(function(){
				var countTR = $('.tablePlanning >tr').length;

				if (countTR == 1) {
					$('#input_ligne_DTELIVCON').val($(this).val());
				}
			});
    </script>