-cat <<EOF
- <input type=hidden name=$sid value=exists>
- <input class="tab" type="checkbox" id=${sid}_open name="${sid}_open" value="checked" ${tpy[${sid}_open]}>
- <label class="tab" for="${sid}_open">
- <span class=no>${session_n}.</span><!--
- --><span class=date>${tpy[${sid}_date]}</span><!--
- --><input class="date" name="${sid}_date" value="${tpy[${sid}_date]}" placeholder="$(l10n date)"><!--
- --><span class=therapist>${tpy[${sid}_therapist]}</span><!--
- --><input class="therapist" name="${sid}_therapist" value="${tpy[${sid}_therapist]}" placeholder="$(l10n therapist)"><!--
- --><span class=signature><input type="checkbox" name="${sid}_sigset" value="pos" $sigcheck></span>
- </label>
- <div class=tab>
- <img class="dotmark ov" src="/therapies/${id%.tpy}_${sid}.png" alt="">
- $( for n in {1..10}; do t_session_note $session_n $n; done )
-
- <button class=delete type=submit name=delete_session value=${session_n}>$(l10n delete_session)</button>
- </div>
-EOF
+ cat <<-EOF
+ <input type=hidden name=$sid value=exists>
+ <input class="tab" type="checkbox" id=${sid}_open name="${sid}_open" value="checked" ${tpy[${sid}_open]}>
+ <label class="tab" for="${sid}_open">
+ <span class=no>${session_n}.</span><!--
+ --><span class=date>${tpy[${sid}_date]}</span><!--
+ --><input class="date" name="${sid}_date" value="${tpy[${sid}_date]}" placeholder="$(l10n date)"><!--
+ --><span class=therapist>${tpy[${sid}_therapist]}</span><!--
+ --><input class="therapist" name="${sid}_therapist" value="${tpy[${sid}_therapist]}" placeholder="$(l10n therapist)"><!--
+ --><span class=signature><input type="checkbox" name="${sid}_sigset" value="pos" $sigcheck></span>
+ </label>
+ <div class=tab>
+ <img class="dotmark ov" src="/therapies/${id%.tpy}_${sid}.png" alt="">
+ $(n=1;
+ while [ -n "${tpy[session${session_n}_note${n}]+x}" ]; do
+ if [ -n "${tpy[session${session_n}_note${n}]}" ]; then
+ x=$n
+ fi
+ n=$(($n + 1))
+ done
+ for n in $(seq 1 $((${x:-0} + 3)) ); do t_session_note $session_n $n; done
+ )
+ <button class="trailbtn" type="submit">$(l10n trailsave)</button>
+ <button class=delete type=submit name=delete_session value=${session_n}>$(l10n delete_session)</button>
+ </div>
+ EOF