{{ define "content" }}

<div class="container">

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

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

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

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

    {{$options := ` { name: "Hours",id: "teacher_hours",label: "Numero di ore",placeholder: "",type: "number" } `}}
    {{template "input" dict "options" ($options|yaml) "value" (.Data|field "Hours") "update" $update}}

    {{$options := ` { name: "AltEmail",id: "teacher_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: "teacher_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: "teacher_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: "teacher_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: "teacher_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: "teacher_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: "teacher_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: "Teacher"} ` }}
    {{template "submit_cancel_buttons" dict "options" ($options|yaml) "id" (.Data|field "ID") "update" $update}}
  
  </form>
  
</div>

{{ end }}
