{{define "session_form"}}
<h2>{{if .Session}}Edit session{{else}}Add manual session{{end}}</h2>
<form hx-post="{{if .Session}}/sessions/{{.SessionID}}{{else}}/sessions/manual{{end}}" hx-target="#main">
  <input type="hidden" name="company_id" value="{{.CompanyID}}">
  <input type="hidden" name="assignment_id" value="{{.AssignmentID}}">
  <p><label>Task<br>
    <select name="task_id">
      {{range .Tasks}}
        <option value="{{.ID}}" {{if and $.Session (eq .ID $.Session.TaskID)}}selected{{end}}>{{.Number}} - {{.Name}}</option>
      {{end}}
      <option value="new">+ new task…</option>
    </select></label></p>
  <p><label>New task name <span class="muted">(only if “+ new task” selected)</span><br>
    <input name="new_task_name"></label></p>
  <p><label>Date (DD-MM-YYYY)<br>
    <input name="date" value="{{if .Session}}{{dateInput .Session.StartTime}}{{else}}{{today}}{{end}}" required></label></p>
  <p><label>Start (HH:MM)<br>
    <input name="start" value="{{if .Session}}{{hm .Session.StartTime}}{{else}}09:00{{end}}" required></label></p>
  <p><label>End (HH:MM)<br>
    <input name="end" value="{{if .Session}}{{hmp .Session.EndTime}}{{else}}17:00{{end}}" required></label></p>
  <p>
    <button type="submit">Save</button>
    <button type="button"
            hx-get="/main?company_id={{.CompanyID}}&assignment_id={{.AssignmentID}}"
            hx-target="#main">Cancel</button>
  </p>
</form>
{{end}}
