]> git.plutz.net Git - lobster/commitdiff
reverse session list - newest first
authorPaul Hänsch <paul@plutz.net>
Wed, 22 Jan 2020 17:17:29 +0000 (18:17 +0100)
committerPaul Hänsch <paul@plutz.net>
Wed, 22 Jan 2020 17:17:29 +0000 (18:17 +0100)
therapies/page.sh

index 571f9bb360054d8c9c3c05498ed11387ab5f9762..a38372f9e3443ebc5caec497cc391369d8aaa432 100755 (executable)
@@ -44,7 +44,20 @@ t_session_note(){
 }
 
 therapy_sessions(){
-  n=1; while [ "$(TPY session$n)" ]; do
+  n=1; while [ "$(TPY session$n)" ]; do n=$((n + 1)); done
+
+  sid=session$n
+  cat <<-EOF
+       [fieldset .tab
+         [submit "new_session" "$sid" .no . +]
+         [input .date name="${sid}_date" value="" placeholder=$(l10n date)]
+         [input .therapist name="${sid}_therapist" value="" placeholder=$(l10n therapist)]
+         [span .signature]
+         [hidden "${sid}_note1" ""]
+       ]
+       EOF
+
+  seq $((n - 1)) -1 1 | while read n; do
     session_n="$n"
     sid=session${session_n}
 
@@ -73,20 +86,7 @@ therapy_sessions(){
          [button type="submit" name=delete_session value="$session_n" .delete $(l10n delete_session)]
        ]
        EOF
-    n=$(($n+1))
   done
-
-  sid=session$n
-
-  cat <<-EOF
-       [fieldset .tab
-         [submit "new_session" "$sid" .no . +]
-         [input .date name="${sid}_date" value="" placeholder=$(l10n date)]
-         [input .therapist name="${sid}_therapist" value="" placeholder=$(l10n therapist)]
-         [span .signature]
-         [hidden "${sid}_note1" ""]
-       ]
-       EOF
 }
 
 cat <<EOF