{{ define "content" }}

<div class="container">

  {{if .Options.Get "update"}}
  <ol class="breadcrumb">
    <li><a href="/students?{{query "tpl_layout" "base" "tpl_content" "students"}}">Studente</a></li>
    <li class="active"><a href="#">Aggiorna studente</a></li>
  </ol>  
  {{else}}
  <ol class="breadcrumb">
    <li><a href="/students?{{query "tpl_layout" "base" "tpl_content" "students"}}">Studente</a></li>
    <li class="active"><a href="#">Aggiungi</a></li>
  </ol>
  {{end}}

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

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

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

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

    <div class="form-group">
      <label class="control-label" for="class_id">Classe</label>
      <select name="class_id" class="form-control selectpicker" id="class_id" placeholder="Classe" data-live-search="true" form="form_students_add_update" title="Seleziona la classe" data-dropup-auto="false" required>
    	<option value="0"></option>
    	{{range $class := .Data.AllClasses}}
    	{{if $.Options.Get "update"}}
    	<option
    	   value="{{$class.ID}}"
    	   {{index $.Data.SelectedClass $class.ID}}>{{$class.Name}}
    	</option>
    	{{else}}
    	<option value="{{$class.ID}}">{{$class.Name}}</option>
    	{{end}}
    	{{end}}
      </select>
    </div>

    <div class="form-group form-check">
      <input type="checkbox" name="Handicap" class="form-check-input" id="student_handicap" {{if .Options.Get "update"}}{{if .Data.Student.Handicap}}checked{{end}}{{end}}>
      <label class="form-check-label has-feedback" for="student_handicap">Handicap (L. 104/92)</label>
    </div>

    <div class="form-group form-check">
      <input type="checkbox" name="DSA" class="form-check-input" id="student_dsa" {{if .Options.Get "update"}}{{if .Data.Student.DSA}}checked{{end}}{{end}}>
      <label class="form-check-label has-feedback" for="student_dsa">DSA (L. 170/10)</label>
    </div>

    <div class="form-group form-check">
      <input type="checkbox" name="BES" class="form-check-input" id="student_bes" {{if .Options.Get "update"}}{{if .Data.Student.BES}}checked{{end}}{{end}}>
      <label class="form-check-label has-feedback" for="student_bes">BES (L. 170/10)</label>
    </div>

    <div class="form-group">
      <label class="control-label" for="class_id">Docente tutor</label>
      <select name="tutor_id" class="form-control selectpicker" id="tutor_id" placeholder="Docente tutor" data-live-search="true" form="form_students_add_update" title="Seleziona il docente tutor" data-dropup-auto="false">
    	<option value="0"></option>
    	{{range $teacher := .Data.AllTeachers}}
    	{{if $.Options.Get "update"}}
    	<option
    	   value="{{$teacher.ID}}"
    	   {{index $.Data.SelectedTeacher $teacher.ID}}>{{$teacher.Surname}} {{$teacher.Name}}
    	</option>
    	{{else}}
    	<option value="{{$teacher.ID}}">{{$teacher.Surname}} {{$teacher.Name}}</option>
    	{{end}}
    	{{end}}
      </select>
    </div>

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

</div>

{{ end }}
