X-Git-Url: https://git.plutz.net/?p=confetti;a=blobdiff_plain;f=templates%2Fview_attendee.sh;h=10cb06e764d9b2219665db638fd0c820fa20bf95;hp=01fb3f0383565c3f9baa56a26aac6b1eb2367705;hb=0dc31a9e7992c227b680180d3ceee031ac293169;hpb=e308373633b80056507ee9cedc5c9b7fc3a00dca diff --git a/templates/view_attendee.sh b/templates/view_attendee.sh index 01fb3f0..10cb06e 100755 --- a/templates/view_attendee.sh +++ b/templates/view_attendee.sh @@ -1,137 +1,133 @@ -declare -A item_name - -item_name[PHOTO]="Foto" -item_name[LOGO]="Logo" -item_name[FN]="Voller Name" -item_name[SOUND]="Aussprache" -item_name[GENDER]="Geschlecht" -item_name[KIND]="Typ" -item_name[TITLE]="Beruf" -item_name[ROLE]="Position" -item_name[ORG]="Organisation" -item_name[MEMBER]="Mitglied" -item_name[CATEGORIES]="Kategorien" -item_name[ANNIVERSARY]="Jubiläum" -item_name[BDAY]="Geburtstag" -item_name[EMAIL]="E-Mail" -item_name[TEL]="Telefon" -item_name[IMPP]="Chat" -item_name[ADR]="Anschrift" -item_name[URL]="Webseite" -item_name[LANG]="Sprache" -item_name[NOTE]="Notiz" - -item_name[RELATED]="Kontakte" - -item_name[BEGIN]="" -item_name[CALADRURI]="" -item_name[CALURI]="" -item_name[CLASS]="" -item_name[CLIENTPIDMAP]="" -item_name[END]="" -item_name[FBURL]="" -item_name[GEO]="" -item_name[MAILER]="" -item_name[NAME]="" -item_name[PRODID]="" -item_name[PROFILE]="" -item_name[REV]="" -item_name[SORT-STRING]="" -item_name[SOURCE]="" -item_name[TZ]="" -item_name[UID]="" -item_name[VERSION]="" -item_name[XML]="" - -l10n() { - [ -n "$item_name[$1]" ] && echo -n "$item_name[$1]" || echo -n "$1" -} +# Copyright 2014 - 2016 Paul Hänsch +# +# This file is part of Confetti. +# +# Confetti is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Confetti is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with Confetti. If not, see . -view_card_item() { - case "$key" in - BEGIN|VERSION|END);; - PHOTO) - echo "" - ;; - FN) - echo "

$value

" - ;; - *) - echo -n "$(l10n "$key")" - [ -n "$tag[TYPE]" ] && echo -n "($tag[TYPE])" - echo ":" - ;| - EMAIL) - echo "$value" - ;; - IMPP) - echo ""$(echo "$value" |cut -d: -f2-)"" - ;; - *) - echo "$value" - ;; - esac +list_items(){ + item="$1" + [ -n "${values[$item]+x}" ] && \ + printf '

%s

\n' "$(l10n $item)" + for n in "$item" "$item"{0..100}; do + [ -z "${values[$n]+x}" ] && break \ + || printf '%s\n' \ + "$item" "$(htmlsafe ${values[$n]})" + done } -edit_card_item() { - case "$key" in - BEGIN|VERSION|END);; - PHOTO) - echo "" - ;; - *) - echo -n "$(l10n "$key")" - [ -n "$tag[TYPE]" ] && echo -n "($tag[TYPE])" - echo ":" - ;| - *) - echo "" - ;; - esac +list_section(){ + printf '
' "$1" + shift 1 + for each in $@; do + list_items "$each" + done + printf '
' } -view_attendee() { #Parameter: Cardfile - cardfile="$1" - cachefile="cache/vcf_$(basename "$cardfile").cache" - unset key - [ "$cachefile" -nt "$cardfile" ] && cat "$cachefile" \ - || vcf_parse "$cardfile" |while read -r line; do - declare -A tag - case "$line" in - value*) eval "$line";; - tag*) eval "$line";; - key*) - if [ -z "$key" ]; then - eval "$line" - else - view_card_item - eval "$line" - unset value - unset tag - fi - ;; - esac - done |tee "$cachefile" -} +n=$(printf %s "$values[N+3] $values[N+1] $values[N+2] $values[N+0] $values[N+4]" \ + | sed -r ':X;$!{N;bX}; s;^[\n ]+;;; s;[\n ]+$;;; s;[\r\t\n ]+; ;g;' + ) +fullname="${n:-${values[FN]:-${values[NICKNAME]}}}" + +hi_company="${values[X-HEALTH-INSURANCE+0]}" + hi_number="${values[X-HEALTH-INSURANCE+1]}" + hi_status="${values[X-HEALTH-INSURANCE+2]}" + +printf '
+

%s

+' "$fullname" +[ -n "$values[GENDER]" ] && printf ' + %s + ' "$(l10n "$values[GENDER]")" + +for n in NICKNAME NICKNAME{0..100}; do + [ -z "${values[$n]+x}" ] && break \ + || printf ' + aka. %s + ' "$(htmlsafe ${values[$n]})" +done + +[ -n "$values[BDAY]" ] && printf ' + *:%s + ' "$(htmlsafe "$values[BDAY]")" +[ -n "$values[X-ZACK-JOINDATE]" ] && printf ' + %s:%s + ' "$(l10n label_join)" "$(htmlsafe "$values[X-ZACK-JOINDATE]")" +[ -n "$values[X-ZACK-LEAVEDATE]" ] && printf ' + %s:%s + ' "$(l10n label_leave)" "$(htmlsafe "$values[X-ZACK-LEAVEDATE]")" + +[ -n "$values[SOUND]" ] && printf ' + ' "$values[SOUND]" -edit_attendee() { - cardfile="$1" - unset key - vcf_parse "$cardfile" |while read -r line; do - declare -A tag - case "$line" in - value*) eval "$line";; - tag*) eval "$line";; - key*) - if [ -z "$key" ]; then - eval "$line" - else - edit_card_item - eval "$line" - unset value - unset tag - fi - ;; - esac +[ -n "$values[PHOTO]" ] && printf ' + + ' "${values[PHOTO_TYPE]}" "${values[PHOTO]}" + +[ -n "$values[LOGO]" ] && printf ' + + ' "${values[LOGO_TYPE]}" "${values[LOGO]}" + +if [ "$PROFILE" = circus ]; then + printf '
' + + list_section phone TEL + list_section message EMAIL IMPP URL + list_section address ADR + list_section note NOTE + + printf '

%s

    ' "$(l10n course_attendance)" + sed -rn 's:(.*)\t'"$id"'$:\1:p' "$_DATA/mappings/attendance" |while read each; do + cname="$(sed -rn 's:^SUMMARY\:(.*)$:\1:p' "$_DATA/ical/$each")" + printf '
  • %s
  • ' "$each" "$(htmlsafe $cname)" done -} + printf '
' +elif [ "$PROFILE" = medical ]; then + list_items ADR + list_items URL + printf '' + + list_section phone TEL EMAIL IMPP + + printf '

%s

' "$(l10n X-HEALTH-INSURANCE)" + [ -n "$hi_company" ] && printf '%s' \ + "$(htmlsafe "$hi_company")" + [ -n "$hi_number" ] && printf '%s' \ + "$(l10n hi_number)" "$(htmlsafe "$hi_number")" + [ -n "$hi_status" ] && printf '%s' \ + "$(l10n hi_status)" "$(htmlsafe "$hi_status")" + printf '
' + + list_section note NOTE X-CLIENT-REFERRAL + + printf '

%s

    ' "$(l10n prescriptions)" + declare -A mpx + find "$_DATA/prescriptions/" -name "${id%.vcf}.*.mpx" \ + | while read pfile; do + mpx=(); cat "$pfile" |while read -r line; do + val="${line#*:}" + mpx[${line%%:*}]="$(htmlsafe "${val//\\n/$BR}")" + done + printf '
  • %s: %s - %s
  • ' \ + "${id}" "${pfile##*/}" "${mpx[date]}" "${mpx[indicator]}" \ + "$([ -n "${mpx[remidy]}" ] && printf '%s %s' "${mpx[quantity]}" "${mpx[remidy]}" + for n in {0..10}; do + [ -n "${mpx[remidy${n}]}" ] && printf ', %s %s' "${mpx[quantity${n}]}" "${mpx[remidy${n}]}" + done + )" + done |sort -r + printf '
' +fi