X-Git-Url: https://git.plutz.net/?a=blobdiff_plain;f=therapies%2Fpage.sh;h=a38372f9e3443ebc5caec497cc391369d8aaa432;hb=1e1cb695a2a413f310c4538c0d3b951f4d4fe72f;hp=c3f3c5c40097dbb2da10d94246d1581cff97f553;hpb=531f71462dfbc0eeebd74c74c84323c14475f51a;p=lobster diff --git a/therapies/page.sh b/therapies/page.sh index c3f3c5c..a38372f 100755 --- a/therapies/page.sh +++ b/therapies/page.sh @@ -15,213 +15,211 @@ # You should have received a copy of the GNU Affero General Public License # along with Lobster. If not, see . -# t_session_note(){ -# session_n="$1" -# note_n="$2" -# -# color=session${session_n}_note${note_n}_color -# unset c0 c1 c2 c3 c4 c5 c6 c7 -# -# if [ "$note_n" -eq 1 -o -n "${tpy[session${session_n}_note${note_n}]}" ]; then -# printf '' -# else -# printf '' -# fi -# -# _checked="$(validate "$tpy[$color]" '#(888|00A|0A0|0AA|A00|A0A|AA0)' '#FFF')" -# cat <<-EOF -#
-# -# -# -# -# -# -# -# -# -#
-# EOF -# } -# -# t_session(){ -# session_n="$1" -# -# sid=session${session_n} -# -# if [ "$tpy[${sid}_sigset]" = pos ]; then -# sigcheck=checked -# else -# unset sigcheck -# fi -# -# cat <<-EOF -# -# -# -#
-# -# $(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 -# ) -# -# -#
-# EOF -# } -# -# therapy_sessions(){ -# n=1; while [ -n "${tpy[session${n}]}" ]; do -# t_session $n -# n=$(($n+1)) -# done -# -# sid=session$n -# -# cat <<-EOF -#
-# -# -#
-# EOF -# } +t_session_note(){ + session_n="$1" + note_n="$2" + + color=session${session_n}_note${note_n}_color + + if [ "$note_n" -eq 1 -o "$(TPY "session${session_n}_note${note_n}")" ]; then + printf '[input type="checkbox" .trailbtn checked="checked"]' + else + printf '[input type="checkbox" .trailbtn]' + fi + + check="$(TPY "$color" |grep -xE -m1 '#(888|00A|0A0|0AA|A00|A0A|AA0)' || printf '#FFF')" + cat <<-EOF + [fieldset .note .trailbox + [radio "$color" "#888" .color #${color}_000 $(checked "$check" '#888') ][label for=${color}_000] + [radio "$color" "#00A" .color #${color}_001 $(checked "$check" '#00A') ][label for=${color}_001] + [radio "$color" "#0A0" .color #${color}_010 $(checked "$check" '#0A0') ][label for=${color}_010] + [radio "$color" "#0AA" .color #${color}_011 $(checked "$check" '#0AA') ][label for=${color}_011] + [radio "$color" "#A00" .color #${color}_100 $(checked "$check" '#A00') ][label for=${color}_100] + [radio "$color" "#A0A" .color #${color}_101 $(checked "$check" '#A0A') ][label for=${color}_101] + [radio "$color" "#AA0" .color #${color}_110 $(checked "$check" '#AA0') ][label for=${color}_110] + [radio "$color" "#FFF" .color #${color}_111 $(checked "$check" '#FFF') ][label for=${color}_111] + [textarea name="session${session_n}_note${note_n}" . $(TPY "session${session_n}_note${note_n}" |HTML)] + ] + EOF +} + +therapy_sessions(){ + 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} + + cat <<-EOF + [hidden "$sid" "exists"] + [checkbox "${sid}_open" "checked" #${sid}_open .tab $(checked "$(TPY "${sid}_open")" checked)] + [label .tab for="${sid}_open" + [span .no ${session_n}.] + [span .date . $(TPY "${sid}_date" |HTML)] + [input .date name="${sid}_date" value="$(TPY "${sid}_date" |HTML)" placeholder="$(l10n date)"] + [span .therapist . $(TPY "${sid}_therapist" |HTML)] + [input .therapist name="${sid}_therapist" value="$(TPY "${sid}_therapist" |HTML)" placeholder="$(l10n therapist)"] + [span .signature [checkbox "${sid}_sigset" "pos" $(checked "$(TPY "${sid}_sigset")" "pos")]] + ] + [div .tab + [img .dotmark .ov src="/therapies/${id}_${sid}.png?${_DATE}" alt=""] + $(n=1; while TPY "session${session_n}_note${n}" >/dev/null; do + [ "$(TPY "session${session_n}_note${n}")" ] && x=$n + n=$(($n + 1)) + done + for n in $(seq 1 $((${x:-0} + 3)) ); do + t_session_note $session_n $n + done + ) + [button type="submit" .trailbtn $(l10n trailbtn)] + [button type="submit" name=delete_session value="$session_n" .delete $(l10n delete_session)] + ] + EOF + done +} cat <