{{ define "content" }}

<div class="container">

  {{$update := .Options.Get "update"}}

  {{if $update}}
  {{template "breadcrumb" toSlice "Personale ATA" (all "Administrative") (.Data|string) (.Data.ID|show "Administrative") "Aggiorna" "current"}}
  {{else}}
  {{template "breadcrumb" toSlice "Personale ATA" (all "Administrative") "Aggiungi" "current"}}
  {{end}}
  
  {{template "add_update_header" dict "update" $update "addTitle" "Crea nuovo ATA" "updateTitle" (printf "Aggiorna ATA %s" (.Data|string))}}

  <form
    class="needs-validation"
    action="{{if $update}}{{.Data.ID|update "Administrative"}}{{else}}{{create "Administrative"}}{{end}}" method="POST" role="form">

    {{$options := ` { name: "Name",id: "administrative_name",label: "Nome",placeholder: "Nome",type: "text" } `}}
    {{template "input" dict "options" ($options|yaml) "value" (.Data|field "Name") "update" $update}}
    
    {{$options := ` { name: "Surname",id: "administrative_surname",label: "Cognome",placeholder: "Cognome",type: "text" } `}}
    {{template "input" dict "options" ($options|yaml) "value" (.Data|field "Surname") "update" $update}}

    {{$options := ` { name: "InternalTelephoneNumber",id: "administrative_internal_telephone_number",label: "Numero di telefono interno",placeholder: "",type: "text" } `}}
    {{template "input" dict "options" ($options|yaml) "value" (.Data|field "InternalTelephoneNumber") "update" $update}}

    {{$options := ` { name: "AltEmail",id: "administrative_altemail",label: "Email alternativa",placeholder: "Inserire indirizzo email",type: "email" } `}}
    {{template "input" dict "options" ($options|yaml) "value" (.Data|field "AltEmail") "update" $update}}

    <div class="form-row">
      <div class="col">
        {{$options := ` { name: "Regenerate",id: "administrative_regenerate",label: "Rigenerare/inviare le credenziali",formClass: "form-check form-check-inline" } `}}
        {{template "checkbox" dict "options" ($options|yaml) "value" (.Data|field "Regenerate") "update" $update}}
      </div>
      <div class="col">
        {{$options := ` { name: "Exclude",id: "administrative_exclude",label: "Escludere dalle utenze",formClass: "form-check form-check-inline" } `}}
        {{template "checkbox" dict "options" ($options|yaml) "value" (.Data|field "Exclude") "update" $update}}
      </div>
      <div class="col">
        {{$options := ` { name: "NotInvited",id: "administrative_not_invited",label: "Escludere dagli inviti",formClass: "form-check form-check-inline" } `}}
        {{template "checkbox" dict "options" ($options|yaml) "value" (.Data|field "NotInvited") "update" $update}}
      </div>
    </div>

    <div class="form-row">
      <div class="col">
        {{$options := ` { name: "DateFrom",id: "administrative_date_from",label: "In servizio dal",type: "date" } `}}
        {{template "input" dict "options" ($options|yaml) "value" (.Data|field "DateFrom"|convertDate) "update" $update}}
      </div>
      <div class="col">
        {{$options := ` { name: "DateTo",id: "administrative_date_to",label: "In servizio fino al",type: "date" } `}}
        {{template "input" dict "options" ($options|yaml) "value" (.Data|field "DateTo"|convertDate) "update" $update}}
      </div>
    </div>
    
    {{$options := ` { name: "LdapDNFmt",id: "administrative_ldapfnfmt",label: "Stringa DN per LDAP",placeholder: "cn=%s %s,ou=People,dc=foo,dc=org",type: "text" } `}}
    {{template "input" dict "options" ($options|yaml) "value" (.Data|field "LdapDNFmt") "update" $update}}

    {{ $options := ` { cancelTitle: "Annulla", saveTitle: "Salva", model: "Administrative"} ` }}
    {{template "submit_cancel_buttons" dict "options" ($options|yaml) "id" (.Data|field "ID") "update" $update}}
  
  </form>
  
</div>

{{ end }}
