]> git.plutz.net Git - lobster/blobdiff - cards/widgets.sh
disabled timesheet
[lobster] / cards / widgets.sh
index d2ed32611932d5fd9bf7067b904679892f797e69..c0ecfb09e5bf78019189325443c320382ab57bca 100755 (executable)
@@ -135,13 +135,18 @@ card_item(){
       therapies)
         client="$(pdi_value "$card" UID)"
         printf '[h3 %s]' "$(l10n therapies)"
-        (cd "$_DATA/prescriptions/"; printf '%s\n' "${client}".*.mpx) \
-        | while read mpxfile; do
-          [ "$mpxfile" = "${client}.*.mpx" ] && break
-          mpx="${mpxfile%.mpx}";
-          printf '[a .item .therapy href="/therapies/%s" . Therapy - %s]' \
-            "${mpx%.*}/${mpx#*.}" "$(sed -E '/^date:.*/{s;^date:;;;q;};d;' "$_DATA/prescriptions/$mpxfile")"
-        done |sort -r
+        (cd "$_DATA/therapies/"; printf '%s\n' "${client}".*.tpy) \
+        | while read tpyfile; do
+          [ "$tpyfile" = "${client}.*.tpy" ] && break
+          tpy="${tpyfile%.tpy}";
+          tpydates="$(sed -En 's;^session[0-9]+_date:;;p;' "$_DATA/therapies/$tpyfile" \
+                      | sort \
+                      | sed -E ':X;N;$!bX; s;^[\n ]+;;; s;[\n ]+$;;; s;(\n.*\n|\n); - ;;'
+                     )"
+          printf '[a .item .therapy href="/therapies/%s" . %s] ' \
+                 "${tpy%.*}/${tpy#*.}" "$(HTML "${tpydates:--}")"
+        done |sort -n
+        printf '[a .item .therapy href="/therapies/%s/new" . +]' "${client}"
         ;;
       *)[ $cnt -gt 0 ] && printf '[h3 %s]' "$(l10n "$item")"
         shy="$(printf '\302\255')"