{% extends 'layout.twig' %}

{% block body %}

	<div class="contenu clearfix"  id="fournisseurs">
	<h1>
    	{{ 'Fournisseurs' | trad }}
    </h1>	
        {{ ariane() }}
        
    	{{ navBar_creationFourniss(modeFournisseur, code_fournisseur??id, ficheFourniss) }}

        <div class="tab-content">
	
			<div class="contenu clearfix"  id="fournisseurs">
					<div id="edi-routage" class="tab-pane fade in active clearfix">
						<form method="post" name="form_ediRoutage" id="form_ediRoutage" class="box-form clearfix">
							<div class="row">
								<div class="colonne2">
									<div class="row">
									    {{ inputSwitch('Bon de commande électronique ?' | trad, 'BDC_ELEC', post.BDC_ELEC, lockModif? 'disabled':'') }}
									</div>
								</div>
								<div class="colonne2 last">
									<div class="row">
									    {{ inputSelect('Routage d\'impression de Cde' | trad ,"ROUTAGECDE", {'':'Routage par défaut' | trad, 'P':'Préimprimé' | trad, 'B': 'Blanc' | trad , 'F': 'Fax' | trad, 'E':'Email' | trad}, post.ROUTAGECDE, ((post.BDC_ELEC==0 and lockModif==false)? '':'disabled'),'','','','','','', false ) }}
									</div>
								</div>
							</div>
							<fieldset class="scheduler-border">
								<legend class="scheduler-border">{{ 'Format' | trad }}</legend>
								<div class="colonne2">
									<div class="row">
    									{{ inputSelect('Type de format' | trad,"TYPE_FORM", {1:'PDF', 2:'XML', 3:'TXT', 4:'PDF/XML', 5:'PDF/TXT', 6:'cXML'}, post.TYPE_FORM, ((post.BDC_ELEC==1 and lockModif==false)? '':'disabled'), '','','','','','','', false ) }}
									</div>
								</div>
								<div class="colonne2 last">
									<div class="row">
                                    	{{ inputZoomAdvance('Format' | trad, "FORMAT", path('Ajax.liste.Format'), "", 
                                	     (post.FORMAT), 'convertLibelleGlobal', 
                                	     path('Ajax.validator.zoom'), "{'entity' : 'BceFexp','nomChamp' : '"~ 'Format' | trad ~"', 'null' : true}" , ((post.BDC_ELEC==1 and lockModif==false)? '':'disabled') , "",
                                	     path('Ajax.outil.convertLibelle'), "BceFexp","ID_FORMAT", "NOM_FORMAT", "", "") }}
									</div>
								</div>
							</fieldset>
							<fieldset class="scheduler-border">
								<legend class="scheduler-border">{{ 'Envoi' | trad }}</legend>
								<div class="colonne2">
									<div class="row">
                                        {{ inputSelect('Mode d\'envoi' | trad,"MODE_ENV", {1:'Email', 2:'Transfert FTP'}, post.MODE_ENV,  (post.BDC_ELEC==1? '':'disabled'), '','','','','','','', false ) }}
                                        {% if (post.MODE_ENV != 2 or post.BDC_ELEC==0) or lockModif %}
                                        	{% set disabledEnvoi='Disabled' %}                                    	
                                        {% endif %}
                                        {% if (post.MODE_ENV == 2 or post.BDC_ELEC==0) or lockModif %}
                                            {% set disabledMail='Disabled' %}                                    	
                                        {% endif %}
									</div>
								</div>
								<div class="colonne2 last">
									<div class="row">
									    {{ inputText('Email destinataire' | trad, 'MAIL_DEST', post.MAIL_DEST, '', path('Ajax.validator.adresseMail'), "{'sizeMin' : '0', 'sizeMax' : '100','type' : true}", '', '',  disabledMail ) }}
									</div>
								</div>
								<div class="full clearfix">
									<div class="row single">
    									{{ inputText('Adresse site FTP' | trad, 'ADR_FTP', post.ADR_FTP, '', path('Ajax.validator.isStringSansEspace'), "{'sizeMin' : '0', 'sizeMax' : '255'}", '', '', disabledEnvoi ) }}
									</div>
								</div>
								<div class="colonne2">
									<div class="row">
									    {{ inputText('Utilisateur FTP' | trad, 'USER_FTP', post.USER_FTP, '', path('Ajax.validator.isStringSansEspace'), "{'sizeMin' : '0', 'sizeMax' : '30'}", '', '', disabledEnvoi ) }}
									</div>
								</div>
								<div class="colonne2 last">
									<div class="row">
									    {{ inputPassword('Mot de passe FTP' | trad, 'PWD_FTP', post.PWD_FTP, '', path('Ajax.validator.isStringSansEspace'), "{'sizeMin' : '0', 'sizeMax' : '30'}", '', '', disabledEnvoi ) }}
									</div>
								</div>
								<div class="full clearfix">
									<div class="row single">
    									{{ inputText('Chemin de dépose' | trad, 'PATH_DEP', post.PATH_DEP , '', path('Ajax.validator.isStringSansEspace'), "{'sizeMin' : '0', 'sizeMax' : '255'}", '', '', disabledEnvoi ) }}
									</div>
								</div>
								
							</fieldset>
						</form>
					</div>	
				</div>
			</div>
		</div>
{% if lockModif==false %}
<script>
	
	$("#input_BDC_ELEC").change(function() {
		if($('#input_BDC_ELEC').is(':checked')) // bon de commande a oui 
		{
			$('#input_ROUTAGECDE').attr("disabled", true);
			$('#input_TYPE_FORM').removeAttr('disabled');
			$('#input_FORMAT').removeAttr('disabled');
			$('#text_FORMAT').removeAttr('disabled');
			$('#zoom_FORMAT').css('display', 'block');

			$('#input_MODE_ENV').removeAttr('disabled');
			$('#input_MAIL_DEST').removeAttr('disabled');

			if($('#input_MODE_ENV').val()==2)
			{
				$('#input_MAIL_DEST').attr("disabled", true);
				$('#input_ADR_FTP').removeAttr('disabled');
				$('#input_USER_FTP').removeAttr('disabled');
				$('#input_PWD_FTP').removeAttr('disabled');
				$('#input_PATH_DEP').removeAttr('disabled');
			}
			else
			{
				$('#input_MAIL_DEST').removeAttr('disabled');
				$('#input_ADR_FTP').attr("disabled", true);
				$('#input_USER_FTP').attr("disabled", true);
				$('#input_PWD_FTP').attr("disabled", true);
				$('#input_PATH_DEP').attr("disabled", true);
			}
		} // bon de commandea non
		else
		{
			$('#input_ROUTAGECDE').removeAttr('disabled');
			$('#input_TYPE_FORM').attr("disabled", true);
			$('#input_FORMAT').attr("disabled", true);
			$('#text_FORMAT').attr("disabled", true);
			$('#input_MODE_ENV').attr("disabled", true);
			$('#input_MAIL_DEST').attr("disabled", true);

			$('#input_ADR_FTP').attr("disabled", true);
			$('#input_USER_FTP').attr("disabled", true);
			$('#input_PWD_FTP').attr("disabled", true);
			$('#input_PATH_DEP').attr("disabled", true);

			$('#zoom_FORMAT').css('display', 'none');
		}
	});

	$("#input_MODE_ENV").change(function() {
		if($('#input_MODE_ENV').val()==2)
		{
			$('#input_MAIL_DEST').attr("disabled", true);
			$('#input_ADR_FTP').removeAttr('disabled');
			$('#input_USER_FTP').removeAttr('disabled');
			$('#input_PWD_FTP').removeAttr('disabled');
			$('#input_PATH_DEP').removeAttr('disabled');
		}
		else
		{
			$('#input_MAIL_DEST').removeAttr('disabled');
			$('#input_ADR_FTP').attr("disabled", true);
			$('#input_USER_FTP').attr("disabled", true);
			$('#input_PWD_FTP').attr("disabled", true);
			$('#input_PATH_DEP').attr("disabled", true);
		}
		
	});


	$( "input" ).change(function() {
		setSessionModule("{{path('Fournisseur.SessionCreationFournisseur.sessionEdiRoutage')}}", 'form_ediRoutage');
	});
	$( "select" ).change(function() {
		setSessionModule("{{path('Fournisseur.SessionCreationFournisseur.sessionEdiRoutage')}}", 'form_ediRoutage');
	});

	setSessionModule("{{path('Fournisseur.SessionCreationFournisseur.sessionEdiRoutage')}}", 'form_ediRoutage');

</script>
{% endif %}
{% endblock %}