{{ define "content" }}

<div class="container">

  {{if .Update}}
  <ol class="breadcrumb">
    <li><a href="/activities">Attività</a></li>
    <li class="active"><a href="#">Aggiorna l'attività</a></li>
  </ol>  
  {{else}}  
  <ol class="breadcrumb">
    <li><a href="/activities">Attività</a></li>
    <li class="active"><a href="#">Aggiungi</a></li>
  </ol>
  {{end}}

  {{if .Update}}
  <div class="karmen-info-header">
    <div class="row">
      <div class="col-md-8">
	<h1>Aggiorna l'attività</h1>
      </div>
      <div class="col-md-4">
	<a href="/activities/{{.Activity.ID}}/delete"
	   data-url="/activities/{{.Activity.ID}}/delete"
	   class="btn btn-danger karmen-ajax-delete pull-right">
	  <span class="glyphicon glyphicon-trash" aria-hidden="true"></span>
	  Elimina
	</a>
      </div>
    </div>
  </div>
  
  {{else}}
  <h1 class="karmen-info-header">Crea una nuova attività</h1>
  {{end}}
  
  <form id="form_activities_add_update" action="{{.SubmitUrl}}" method="POST" role="form" data-toggle="validator">

    <div class="form-group">
      <label class="control-label" for="subject_id">Materia</label>
      <select name="subject_id" class="form-control selectpicker" id="subject_id" placeholder="Materia" data-live-search="true" form="form_activities_add_update" title="Seleziona il nome della materia" data-dropup-auto="false" required>
	<option value="0"></option>
  	{{range $subject := .AllSubjects}}
	{{if $.Update}}
  	<option
	   value="{{$subject.ID}}"
	   {{index $.SelectedSubject $subject.ID}}>{{$subject.Name}}
	</option>
	{{else}}
  	<option value="{{$subject.ID}}">{{$subject.Name}}</option>
	{{end}}
  	{{end}}
      </select>
    </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="Materia" data-live-search="true" form="form_activities_add_update" title="Seleziona il nome della materia" data-dropup-auto="false" required>
	<option value="0"></option>
  	{{range $class := .AllClasses}}
	{{if $.Update}}
  	<option
	   value="{{$class.ID}}"
	   {{index $.SelectedClass $class.ID}}>{{$class.Name}}
	</option>
	{{else}}
  	<option value="{{$class.ID}}">{{$class.Name}}</option>
	{{end}}
  	{{end}}
      </select>
    </div>

    <div class="form-group">
      <label class="control-label" for="hours">Numero di ore</label>
      <input class="form-control" min="0" type="number" name="hours" id="hours" {{if .Update}}value="{{.Activity.Hours}}"{{end}} required>
    </div>

    <div class="form-group">
      <label class="control-label" for="teacher_id">Docente</label>
      <select name="teacher_id" class="form-control selectpicker" id="teacher_id" placeholder="Docente" data-live-search="true" form="form_activities_add_update" title="Seleziona il nome del docente" data-dropup-auto="false">
	<option value="0"></option>
  	{{range $teacher := .AllTeachers}}
	{{if $.Update}}
  	<option
	   value="{{$teacher.ID}}"
	   {{index $.SelectedTeacher $teacher.ID}}>{{$teacher.Name}} {{$teacher.Surname}}
	</option>
	{{else}}
  	<option value="{{$teacher.ID}}">{{$teacher.Name}} {{$teacher.Surname}}</option>
	{{end}}
  	{{end}}
      </select>
    </div>

    <div class="form-group">
      <button type="submit" class="btn btn-primary">Salva</button>
      {{if .Update}}
      <a href="/activities" class="btn btn-default">Annulla</a>
      {{else}}
      <a href="/activities" class="btn btn-default">Annulla</a>
      {{end}}
    </div>
    
  </form>

</div>

{{ end }}
