X-Git-Url: https://git.plutz.net/?p=confetti;a=blobdiff_plain;f=pages%2Fcards.sh;h=08b88b94e11b75e8eeeab786df667adb1912af3c;hp=c045b5bfd09cc3a0fbd7c1bbc58d8efbb5e6c2d5;hb=9d6e65a0055304b62e0b2c9502da3443fb82ad33;hpb=2805ee334bead55e2ab08b7c4dbdbf07dcebf8e9 diff --git a/pages/cards.sh b/pages/cards.sh index c045b5b..08b88b9 100755 --- a/pages/cards.sh +++ b/pages/cards.sh @@ -17,7 +17,28 @@ # You should have received a copy of the GNU Affero General Public License # along with Confetti. If not, see . -[ -z "${_GET[order]}" ] && _GET[order]="firstname" +BR=' +' + +case $PROFILE in +medical) + view_card="$_EXEC/templates/view_client.sh" + edit_card="$_EXEC/templates/edit_client.sh" + _GET[order]="${_GET[order]:-lastname}" + _GET[filtertype]="${_GET[filtertype]:-name}" + profile_medical=x +;; +circus) + view_card="$_EXEC/templates/view_attendee.sh" + edit_card="$_EXEC/templates/edit_attendee.sh" + _GET[order]="${_GET[order]:-firstname}" + _GET[filtertype]="${_GET[filtertype]:-any}" + profile_circus=x +;; +esac + +edit="${_GET[edit]}" +[ \! -f "vcard/$edit" -a \! -f "temp/$edit" ] && edit='' listcourses() { ls -1 ${_DATA}/ical/*ics |while read file; do @@ -26,6 +47,11 @@ listcourses() { done |sort |sed -r 's:^.*\t(.*/)([^/]+)$:\2:' } +list_hi_companies(){ + sed -rn 's;^X-HEALTH-INSURANCE:([^\;]+)\;.*$;\1;p' ${_DATA}/vcard/*vcf \ + | sort -u +} + listcards() { case "${_GET[filtertype]}" in any) @@ -111,12 +137,12 @@ vcf_parse() { case "$line" in key=*) printf %s\\n "$line" ;; - value=*) printf %s\\n "$line" + value=*) printf %s\\n "${line}" ;; tag=*) ot='' printf %s "$line" \ | sed -r 's:^tag=::;s:\;([A-Z+_-]+="[^"]+"|[A-Z+_-]+=[^\;]+):\n\1:g;' \ - | sed -r 's:([A-Z+_-]+)="?(.*)"?:tag\[\1\]="\2":g' \ + | sed -rn 's:([A-Z+_-]+)="?(.+)"?:tag\[\1\]="\2":gp' \ | sed -r '/^ *$/d' \ | sort |while read -r tag; do nt="$(printf %s "$tag" |sed -r 's:^tag\[([A-Z+_-]+)\]="(.*)"$:\1:')" @@ -150,7 +176,7 @@ view_card() { #Parameter: Cardfile if [ -z "$key" ]; then eval "$line" else - values[$key]="$value" + values[$key]="${value//\\r\\n/$BR}" for t in ${(k)tag}; do tags[${key}_$t]="$tag[$t]" done @@ -188,7 +214,7 @@ edit_card() { #Parameter: Cardfile if [ -z "$key" ]; then eval "$line" else - [ -n "$value" ] && values[$key]="$value" || values[$key]='\r' + [ -n "$value" ] && values[$key]="${value//\\r\\n/$BR}" || values[$key]='\r' for t in ${(k)tag}; do tags[${key}_$t]="$tag[$t]" done