{% extends 'base.html' %}

{% block top %}
      <p>
      utente che sta effettuando aggiornamenti: {{ utenteautorizzato.mail }}@{{ utenteautorizzato.domain.nome }}
      </p>
{% endblock %}

{% block body %}

<div>Gestione data sql</div>

<div><p></div>

<div></div>

<form name='sqldataedit' method='post'>
  {% csrf_token %}

  <div class='form-group'>
    <div class='row'>
      <div class='col'>
	<label for='nome'>Nome Database</label>
	<input type='text' id='nome' name='nome' value='{{ formsqldatabase.nome.value }}' {% if not nuovorecord %} readonly {% endif %}/>
      </div>
      <div class='col'>
	<label for='dominio'> Dominio</label>
	<input type='text' id='dominio' name='dominio' value='{{ sqldatabase.dominio.nome }}' disabled>
      </div>
    </div>
  </div>

  <div class='form-group'>
    <div class='row'>
      <div class='col'>
	<label for='server'>Server Assegnato</label>
	<select name='server' id='server' class='form-control'>
        {% for s in sqlserver %}
          <option value='{{ s.id }}' {% if s.id|stringformat:'s' == formsqldatabase.server.value|stringformat:'s'  %}selected{% endif %}>{{s.id}}: {{ s.nome }}</option>
        {% endfor %}
      </select>

      </div>
    </div>
  </div>
  <div class='form-group'>
    <div class='row'>
      <div class='col'>
	<label for='nome'>Nome Utente</label>
	<input type='text' id='username' name='username' value='{{ formsqldatabase.username.value }}'/ {% if formsqldatabase.locked.value %} readonly {% endif %}>
      </div>
       <div class='col'>
	<label for='password'>Password Operativa</label>
	<input type='text' id='password' name='password' value='{{ formsqldatabase.password.value }}'/ {% if formsqldatabase.locked.value %} readonly {% endif %}>
      </div>
    </div>
  </div>

  <div class='form-group'>
    <div class='row'>
      <div class='col'>
        <label class='form-check-label' for='enabled'>Abilitato</label>
	<input type='checkbox' class='form-check-input' id='enabled' name='enabled' {% if formsqldatabase.enabled.value %} checked {% endif %} {% if formsqldatabase.locked.value %} {% endif %}>
      </div>
      <div class='col'>
        <label class='form-check-label' for='tobedeleted'>Da cancellare</label>
	<input type='checkbox' class='form-check-input' id='tobedeleted' name='tobedeleted' {% if formsqldatabase.tobedeleted.value %} checked {% endif %}>
      </div>
      <div class='col'>
        <label class='form-check-label' for='locked'>Bloccato (Informazioni non modificabili)</label>
	<input type='checkbox' class='form-check-input' id='locked' name='locked' {% if formsqldatabase.locked.value %} checked {% endif %}>
      </div>
      <div class='col'>
        <label class='form-check-label' for='locked'>Non Eseguire</label>
	<input type='checkbox' class='form-check-input' id='noneseguire' name='locked' {% if formsqldatabase.noneseguire.value %} checked {% endif %}>
      </div>
    </div>
  </div>

  <div class='form-group'>
    <div class='row'>
      <div class='col'>
        <label class='form-check-label' for='mail_send'>Invia Credenziali</label>:
	<input type='checkbox' class='form-check-input' id='mail_send' name='mail_send' {% if formsqldatabase.mail_send.value %} checked {% endif %}>
      </div>
      <div class='col'>
	      <label class='form-check-label' for='mail'>Destinatario Credenziali</label>
	<input type='text' class='form-control' id='mail' name='mail' value='{{ formsqldatabase.mail.value }}'>
      </div>
    </div>
  </div>

  <div class='form-group'>
    <div class='row'>
      <div class='col'>
        <label for='nota'>Nota</label>
        <textarea name='nota' class='form-control' rows='5'>{{ formsqldatabase.nota.value }}</textarea>
      </div>
    </div>
  </div>

  <div>
  <div class='form-group'>
    <div class='col'>
      {% if formsqldatabase.errors %}
         <div class='row'>
           Rilevati Errori, impossibile proseguire.
	   {{ formdatabase.errors }}
	 </div>
	 <div class='row'>
           {% for f in formsqldatabase %}
             {% for e in f.errors %}
               <div class="alter alter-danger">
                 <strong>{{f.label|escape }}: {{ e|escape }}</strong>
               </div>
             {% endfor %}
           {% endfor %}
         </div>

         <div class='row'>
         {% for e in formsqldatabase.non_field_errors %}
           <div class="alter alter-danger">
      	     <strong>{{ e|escape }}</strong><br>
           </div>
         {% endfor %}
         </div>

       {% endif %}
     </div>
  </div>

  <hr>
  <div class='btn-group' role='group' aria-label='conferme'>
    <button type='submit' class='btn btn-primary'>Conferma</button>
    <button type='reset' class='btn btn-secondary'>Reset</button>
    <button type 'submit' class='btn btn-secondary' name='AggiornaDbConf'>Aggiorna db.conf</button>
    <button type='submit' class='btn btn-secondary' name='Ritorna'>Ritorna (Senza Salvare)</button>
  </div>
</form>

{% endblock %}
