]> git.plutz.net Git - confetti/blobdiff - pages/therapy.sh
remove exec prop
[confetti] / pages / therapy.sh
index 571333ec7008d98720597bb42ea5f9c6020033ef..88855151a8fa27ea9b9f03c66694478fba47f043 100755 (executable)
@@ -18,6 +18,7 @@
 # along with Confetti.  If not, see <http://www.gnu.org/licenses/>. 
 
 declare -A tpy
+declare -A mpx
 
 BR='
 '
@@ -25,9 +26,31 @@ BR='
 id="$_GET[id]"
 
 tpyfile="$_DATA/therapies/$id"
+mpxfile="$_DATA/prescriptions/${id%.tpy}.mpx"
+client="$_DATA/vcard/${id%%.*}.vcf"
+
+identify "$_EXEC/static/therapy_background.png" \
+| sed -r 's;^.* ([0-9]+x[0-9]+) .*$;\1;' \
+| read bg_dim
+
+card_N="$(sed -nr 's:^(N)(;[^"\:]+|;"[^"]+")*\:(.*)$:\3:gp' "$client")"
+card_FN="$(sed -nr 's:^(FN)(;[^"\:]+|;"[^"]+")*\:(.*)$:\3:gp' "$client")"
+card_NICK="$(sed -nr 's:^(NICKNAME)(;[^"\:]+|;"[^"]+")*\:(.*)$:\3:gp' "$client")"
+
+n=$(printf %s "$card_N" \
+    | sed -rn 's:^([^;]*)(\;[^;]*)(\;[^;]*)?(\;[^;]*)?(\;[^;]*)?$:\4 \2 \3 \1 \5:gp' \
+    | sed -r 's:,: :;s:\;: :g;s: +: :g;s:^ $::;'
+   )
+client_name="${n:-${card_FN:-${card_NICK}}}"
 
 mpx=()
+cat "$mpxfile" |while read -r line; do
+  val="${line#*:}"
+  mpx[${line%%:*}]="$(htmlsafe "${val//\\n/$BR}")"
+done
+
+tpy=()
 cat "$tpyfile" |while read -r line; do
   val="${line#*:}"
-  tpy[${line%%:*}]="${val//\\n/$BR}"
+  tpy[${line%%:*}]="$(htmlsafe "${val//\\n/$BR}")"
 done