X-Git-Url: https://git.plutz.net/?p=confetti;a=blobdiff_plain;f=templates%2Fedit_attendee.sh;h=820bce8334e54fae795bb50304092e476c15b3ff;hp=d79553f284cc7576bd3adb4317375b419a149326;hb=5736fc8f634020a8a32635e955c3a0d823499f42;hpb=9da739230659371a860e93dcaf3765b977e30de7 diff --git a/templates/edit_attendee.sh b/templates/edit_attendee.sh index d79553f..820bce8 100755 --- a/templates/edit_attendee.sh +++ b/templates/edit_attendee.sh @@ -1,42 +1,184 @@ -edit_card_item() { - case "$key" in - BEGIN|VERSION|END);; - PHOTO) - echo "" - ;; - *) - echo -n "$(l10n "$key")" - [ -n "$tag[TYPE]" ] && echo -n "($tag[TYPE])" - echo ":" - ;| - *) - echo "" - echo "" - ;; - esac +# 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 . + +setchecked() { + printf 'checked="checked"' +} +setselected() { + printf 'selected="selected"' +} +check_gen() { + [ "$values[GENDER]" = "$1" ] && setselected +} +check_a() { + egrep -q "^${1}.${id}$" "$_DATA/mappings/attendance" && setchecked +} +teltype() { + cat <<-EOF + + EOF } -edit_attendee() { - cardfile="vcard/$1" - tempfile="temp/$1" - [ -f "$tempfile" ] && cardfile="$tempfile" - debug Using card: $cardfile - unset key - vcf_parse "$cardfile" |debug |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 +list_items(){ + item="$1" + placeholder="$2" + [ -n "${values[$item]+x}" ] && printf '

%s

\n' "$(l10n $item)" + for n in "$item" "$item"{0..100}; do + if [ -n "${values[$n]+x}" ]; then + case "$item" in + (ADR|NOTE) + printf '\n' \ + "$item" "$item" "$(htmlsafe ${values[$n]})" + ;; + (TEL) + teltype "${values[${n}_TYPE]}" + printf '\n' \ + "$item" "$item" "$(attribsafe ${values[$n]})" + ;; + (*) + printf '\n' \ + "$item" "$item" "$(attribsafe ${values[$n]})" "$placeholder" + ;; + esac + else + break + fi done } + +list_section(){ + printf '
' "$1" + shift 1 + for each in $@; do + list_items "$each" + done + printf '
' +} + +hi_company="${values[X-HEALTH-INSURANCE+1]}" + hi_number="${values[X-HEALTH-INSURANCE+2]}" + hi_status="${values[X-HEALTH-INSURANCE+3]}" + +[ -z "$values[UID]" ] && values[UID]="$(uuidgenerator)" + +cat < + +
+

$(l10n N)

+ + + + + + + +END_HTML + + for n in NICKNAME NICKNAME{0..100}; do + [ -z "${values[$n]+x}" ] && break \ + || printf ' + + ' "$(attribsafe ${values[$n]})" "$(l10n NICKNAME)" + done + + list_items BDAY YYYY-MM-DD + list_items X-ZACK-JOINDATE YYYY-MM-DD + list_items X-ZACK-LEAVEDATE YYYY-MM-DD + + [ -n "$values[SOUND]" ] && printf ' + ' "$values[SOUND]" + + [ -n "$values[PHOTO]" ] && printf ' + + ' "${values[PHOTO_TYPE]}" "${values[PHOTO]}" + + [ -n "$values[LOGO]" ] && printf ' + + ' "${values[LOGO_TYPE]}" "${values[LOGO]}" + +printf '
' + +if [ "$PROFILE" = circus ]; then + list_section phone TEL + list_section message EMAIL IMPP URL + list_section address ADR + list_section note NOTE X-CLIENT-REFERRAL + cat <<-END_HTML +
+

$(l10n course_attendance)

+ $(listcourses |while read each; do + cname="$(sed -rn 's:^SUMMARY\:(.*)$:\1:p' "$_DATA/ical/$each")" + printf '' \ + "$(attribsafe "$each")" "$(check_a "$each")" "$(htmlsafe "$cname")" + done) +
+ END_HTML +elif [ "$PROFILE" = medical ]; then + list_section address ADR + list_section phone TEL EMAIL IMPP URL + cat <<-END_HTML +
+

$(l10n X-HEALTH-INSURANCE)

+ + + + + +
+ END_HTML + list_section note NOTE X-CLIENT-REFERRAL +fi + + +cat < + + + + + + + + +END_HTML