{% extends 'layout.twig' %}

{% block body %}
	<div class="contenu clearfix"  id="fournisseurs">
	<h1>
    	{{ 'Fournisseurs' | trad }}
    </h1>
    {{ ariane() }}
    
    <div id="detail_fournisseur" class="clearfix titre_div">
        <h2>
            {{ 'Fournisseur :' | trad }} {{ libelle_fournisseur??libelle }} ({{ code_fournisseur??id }})
        </h2>
        
            {{ arianeSub() }}
					<div id="ajout-attestation" class="tab-pane pad-15 fade in active clearfix">
						<form method="post" name="form-ajout-attestation" id="form-ajout-attestation" class="box-form clearfix">
							<div class="colonne2">
								<div class="row">                                	 
                            	     {{ inputZoomAdvance("Société" | trad, "COD_SOC", path('Ajax.liste.societe'), "", 
                            	     attestation.COD_SOC, 'convertLibelleGlobal', 
                            	     path('Ajax.validator.zoom'), "{'entity' : 'Societe','nomChamp' : '"~ 'Société' | trad ~"', 'null' : true}" , "" , "",
                            	     path('Ajax.outil.convertLibelle'), "Societe","CODE_STE", "RAIS_SOC", '','','','Liste société' | trad,'',true) }}
								</div>
								<div class="row">
									{{ inputDate("Date attestation" | trad, 'DTE_ATT',attestation.DTE_ATT |dateTrad, '' , path('Ajax.validator.date'), '{}', '','','','',true) }}
								</div>
								<div class="row">
									{{ inputDate("Date d'achat" | trad, 'DTEACHAT',  attestation.DTEACHAT |dateTrad, '' , path('Ajax.validator.date'), '{}') }}
								</div>
								<div class="row">
									 {{ inputText('Réf. commande' | trad, 'REF_CDE', attestation.REF_CDE, '', path('Ajax.validator.isStringSansEspace'), "{'sizeMin' : '1', 'sizeMax' : '9'}" ) }}
								</div>
								<div class="row">
									{{ inputText('Réf. facture' | trad, 'REF_FFOU', attestation.REF_FFOU, '', path('Ajax.validator.isStringSansEspace'), "{'sizeMin' : '0', 'sizeMax' : '9'}" ) }}
								</div>
							</div>
							<div class="colonne2 last">
								<div class="row">
									{{ inputSelect("Type d'opération" | trad,"TYP_OPE", listeTypeOpe, attestation.TYP_OPE,'','','','','','','','','',true) }}
								</div>
								<div class="row">
									{{ inputText('Décision administrative' | trad, 'NODECADM', attestation.NODECADM, '', path('Ajax.validator.isStringSansEspace'), "{'sizeMin' : '1', 'sizeMax' : '30'}", '','','readonly', '','','','',true ) }}
								</div>
								<div class="row">
									{{ inputText('Description' | trad, 'DESCRIPT', attestation.DESCRIPT, '', path('Ajax.validator.isStringAvecEspace'), "{'sizeMin' : '1', 'sizeMax' : '60'}", '','','','','','','',true ) }}
								</div>
								<div class="row">
                                    {{ inputAdvance('DEVISE',{
									    'titre' : 'Montant' | trad,
									    'name' : 'MTDEVSTO',
									    'value' : attestation.MTDEVSTO,
									    'pathValidator' : path('Ajax.validator.float'),
									    'paramsValidator' : "{'format' : "~getConst('formatMontant')~"}"
									}) }}
								</div>
								<div class="row">									
                            	     {{ inputZoomAdvance("TVA" | trad, "MT_TVAST", path('Ajax.liste.TVA'), "", 
                            	     attestation.MT_TVAST??'0.0', 'convertLibelleGlobal', 
                            	     path('Ajax.validator.zoom'), "{'entity' : 'TVA','nomChamp' : '"~ 'TVA' | trad ~"', 'null' : true}" , "" , "",
                            	     path('Ajax.outil.convertLibelle'), "TVA","CODE_TVA", "LIBELLE") }}
								</div>
							</div>
							<div class="button_right full validation_modal">
                                 <button type="submit" class="button principal button_right" >{{ 'Enregistrer' | trad }}</button>
                                 <a href='{{ path('Fournisseur.AttestationsFournisseur.Attestations', {id:code_fournisseur}) }}' type="button" class="button secondaire button_right" >{{ 'Annuler' | trad }}</a>
                    		</div>
						</form>
					</div>	
				</div>
			</div>			
			<script>	
            	{% if post.ErreurValid or ErreurValid != '' %}
                    activePopupErreur("{{ path('Ajax.Erreur.popupErreurValid') }}", "{{'Erreur lors de la validation !' | trad }} ", "{{ErreurValid | raw}}");
    		    {% endif %} 

    		    $( "#input_COD_SOC" ).change(function() {
    		    	$.ajax({
    				  	dataType : 'html',
    				  	data: { 'societe' : $( "#input_COD_SOC" ).val()},
        				url: '{{ path('Fournisseur.AttestationsFournisseur.decisionAdmin') }}',
        				type: "POST",
        				success: function(result){
            				$('#input_NODECADM').val(result);
        				}
        			});
  		   		});
		    </script>	
{% endblock %}