{{ define "content" }}

<div class="container">

  {{if .Options.Get "update"}}
  <nav aria-label="breadcrumb">
    <ol class="breadcrumb">
      <li class="breadcrumb-item"><a href="/administratives?{{query "tpl_layout" "base" "tpl_content" "administratives"}}">Amministrativi</a></li>
      <li class="breadcrumb-item active"><a href="#">Aggiorna amministrativo</a></li>
    </ol>
  </nav>
  {{else}}
  <nav aria-label="breadcrumb">
    <ol class="breadcrumb">
      <li class="breadcrumb-item"><a href="/administratives?{{query "tpl_layout" "base" "tpl_content" "administratives"}}">Amministrativi</a></li>
      <li class="breadcrumb-item active"><a href="#">Aggiungi</a></li>
    </ol>
  </nav>
  {{end}}

 {{if .Options.Get "update"}}
  <div class="karmen-info-header">
    <div class="row">
      <div class="col-md-8">
	<h1>Aggiorna amministrativo</h1>
      </div>
    </div>
  </div>
  
  {{else}}
  <h1 class="karmen-info-header">Crea nuovo amministrativo</h1>
  {{end}}

  {{if .Options.Get "update"}}
  <form id="form_administratives_add_update" action="/administratives/{{.Data.Administrative.ID}}/update" method="POST" role="form" class="needs-validation">
  {{else}}
  <form id="form_administratives_add_update" action="/administratives/add/" method="POST" role="form" class="needs-validation">
  {{end}}

    <div class="form-group">
      <label class="control-label" for="administrative_name">Nome</label>
      <input type="text" name="Name" class="form-control" id="administrative_name" placeholder="Nome" {{if .Options.Get "update"}} value="{{.Data.Administrative.Name}}" {{end}} required>
    </div>

    <div class="form-group">
      <label class="control-label" for="administrative_surname">Cognome</label>
      <input type="text" name="Surname" class="form-control" id="administrative_surname" placeholder="Cognome" {{if .Options.Get "update"}} value="{{.Data.Administrative.Surname}}" {{end}} required>
    </div>

    <div class="form-group">
      <label class="control-label" for="administrative_internal_telephone">Telefono (interno)</label>
      <input type="text" name="InternalTelephoneNumber" class="form-control" id="administrative_internal_telephone_number" placeholder="Numero di telefono (interno)" {{if .Options.Get "update"}} value="{{.Data.Administrative.InternalTelephoneNumber}}" {{end}}>
    </div>

    <div class="form-row">
      <div class="col">
	<input type="email" name="AltEmail" class="form-control" id="administrative_altemail" placeholder="Email alternativa" {{if .Options.Get "update"}} value="{{.Data.Administrative.AltEmail}}" {{end}}>
      </div>
      <div class="col">
	<div class="form-check">
	  <input type="checkbox" name="Regenerate" class="form-check-input" id="administrative_regenerate" {{if .Options.Get "update"}}{{if .Data.Administrative.Regenerate}}checked{{end}}{{end}}>
	  <label class="form-check-label has-feedback" for="administrative_regenerate">Rigenerare/inviare le credenziali</label>
	</div>
      </div>
      <div class="col">
	<div class="form-check">
	  <input type="checkbox" name="Exclude" class="form-check-input" id="administrative_exclude" {{if .Options.Get "update"}}{{if .Data.Administrative.Exclude}}checked{{end}}{{end}}>
	  <label class="form-check-label has-feedback" for="administrative_exclude">Escludere dalle utenze</label>
	</div>
      </div>
    </div>
    <div class="col">
      <div class="form-check">
	<input type="checkbox" name="NotInvited" class="form-check-input" id="administrative_not_invited" {{if .Options.Get "update"}}{{if .Data.Administrative.NotInvited}}checked{{end}}{{end}}>
	<label class="form-check-label has-feedback" for="administrative_not_invited">Escludere dagli inviti</label>
      </div>
    </div>

    
    <div class="form-row">
      <div class="col">
	<label class="control-label" for="administrative_date_from">In servizio dal</label>
	<input type="date" name="DateFrom" class="form-control" id="administrative_date_from" {{if .Options.Get "update"}} value="{{convertDate .Data.Administrative.DateFrom}}" {{end}}>
      </div>
      <div class="col">
	<label class="control-label" for="administrative_date_to">In servizio fino al</label>
	<input type="date" name="DateTo" class="form-control" id="administrative_date_to" {{if .Options.Get "update"}} value="{{convertDate .Data.Administrative.DateTo}}" {{end}}>
      </div>
    </div>

    <div class="form-group">
      <label class="control-label" for="office_id">Associato all'ufficio</label>
      <select name="office_id" class="form-control selectpicker" id="office_id" placeholder="Seleziona l'ufficio" data-live-search="true" form="form_administratives_add_update" title="Seleziona l'ufficio" data-dropup-auto="false">
    	<option value="0"></option>
    	{{range $office := .Data.AllOffices}}
    	{{if $.Options.Get "update"}}
    	<option
    	  value="{{$office.ID}}"
    	  {{index $.Data.SelectedOffice $office.ID}}>{{$office.Name}}
    	</option>
    	{{else}}
    	<option value="{{$office.ID}}">{{$office.Name}}</option>
    	{{end}}
    	{{end}}
      </select>
    </div>

    <div class="form-group">
      <label class="control-label has-feedback" for="administrative_ldapdnfmt">Stringa DN per LDAP</label>
      <input type="text" name="LdapDNFmt" class="form-control" id="administrative_ldapdnfmt" placeholder="cn=%s %s,ou=People,dc=foo,dc=org" {{if .Options.Get "update"}}value="{{.Data.Administrative.LdapDNFmt}}"{{end}}>
    </div>

    <div class="form-group">
      <button type="submit" class="btn btn-primary">Salva</button>
      {{if .Options.Get "update"}}
      <a href="/administratives/{{.Data.Administrative.ID}}?{{query "tpl_layout" "base" "tpl_content" "administratives_show"}}" class="btn btn-default">Annulla</a>
      {{else}}
      <a href="/administratives?{{query "tpl_layout" "base" "tpl_content" "administratives"}}" class="btn btn-default">Annulla</a>
      {{end}}
    </div>
    
  </form>

</div>

{{ end }}
