1 # Copyright 2014 - 2017 Paul Hänsch
3 # This file is part of Confetti.
5 # Confetti is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU Affero General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # Confetti is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU Affero General Public License for more details.
15 # You should have received a copy of the GNU Affero General Public License
16 # along with Confetti. If not, see <http://www.gnu.org/licenses/>.
20 [ -n "${values[$item]+x}" ] && \
21 printf '<h3>%s</h3>\n' "$(l10n $item)"
22 for n in "$item" "$item"{0..100}; do
23 if [ -z "${values[$n]+x}" ]; then
27 printf '<a class="item EMAIL" href="mailto:%s">%s</a>\n' \
28 "$(attribsafe "${values[$n]}")" "$(htmlsafe "${values[$n]}")"
31 printf '<span class="item %s">%s</span>\n' \
32 "$item" "$(htmlsafe ${values[$n]})"
39 printf '<div class="section %s">' "$1"
47 n=$(printf %s "$values[N+3] $values[N+1] $values[N+2] $values[N+0] $values[N+4]" \
48 | sed -r ':X;$!{N;bX}; s;^[\n ]+;;; s;[\n ]+$;;; s;[\r\t\n ]+; ;g;'
50 fullname="${n:-${values[FN]:-${values[NICKNAME]}}}"
52 hi_company="${values[X-HEALTH-INSURANCE+0]}"
53 hi_number="${values[X-HEALTH-INSURANCE+1]}"
54 hi_status="${values[X-HEALTH-INSURANCE+2]}"
56 printf '<div class="section basic">
57 <h2 class="item FN">%s</h2>
59 [ -n "$values[GENDER]" ] && printf '
60 <span class="item GENDER">%s</span>
61 ' "$(l10n "$values[GENDER]")"
63 for n in NICKNAME NICKNAME{0..100}; do
64 [ -z "${values[$n]+x}" ] && break \
66 <span class="item NICKNAME">aka. %s</span>
67 ' "$(htmlsafe ${values[$n]})"
70 [ -n "$values[BDAY]" ] && printf '
71 <span class="item BDAY"><b>*:</b> %s</span>
72 ' "$(htmlsafe "$values[BDAY]")"
73 [ -n "$values[X-ZACK-JOINDATE]" ] && printf '
74 <span class="item X-ZACK-JOINDATE"><b>%s:</b> %s</span>
75 ' "$(l10n label_join)" "$(htmlsafe "$values[X-ZACK-JOINDATE]")"
76 [ -n "$values[X-ZACK-LEAVEDATE]" ] && printf '
77 <span class="item X-ZACK-LEAVEDATE"><b>%s:</b >%s</span>
78 ' "$(l10n label_leave)" "$(htmlsafe "$values[X-ZACK-LEAVEDATE]")"
80 [ -n "$values[SOUND]" ] && printf '
81 <audio controls="controls" class="item SOUND">
82 <source type="audio/ogg" src="data:audio/ogg;base64,%s" />
83 </audio>' "$values[SOUND]"
85 [ -n "$values[PHOTO]" ] && printf '
86 <img class="item PHOTO" src="data:image/%s;base64,%s" />
87 ' "${values[PHOTO_TYPE]}" "${values[PHOTO]}"
89 [ -n "$values[LOGO]" ] && printf '
90 <img class="item PHOTO" src="data:image/%s;base64,%s" />
91 ' "${values[LOGO_TYPE]}" "${values[LOGO]}"
93 if [ "$PROFILE" = circus ]; then
96 list_section phone TEL
97 list_section message EMAIL IMPP URL
98 list_section address ADR
99 list_section note NOTE
101 printf '<div class="section attendance"><h3>%s</h3><ul>' "$(l10n course_attendance)"
102 sed -rn 's:(.*)\t'"$id"'$:\1:p' "$_DATA/mappings/attendance" |while read each; do
103 cname="$(sed -rn 's:^SUMMARY\:(.*)$:\1:p' "$_DATA/ical/$each")"
104 printf ' <li><a class="item attendance" href="?p=courses#%s">%s</a></li>' "$each" "$(htmlsafe $cname)"
107 list_items CATEGORIES
110 elif [ "$PROFILE" = medical ]; then
115 list_section phone TEL EMAIL IMPP
117 printf '<div class="section insurance"><h3>%s</h3>' "$(l10n X-HEALTH-INSURANCE)"
118 [ -n "$hi_company" ] && printf '<span class="item hi_comapany">%s</span>' \
119 "$(htmlsafe "$hi_company")"
120 [ -n "$hi_number" ] && printf '<span class="item hi_number"><label>%s:</label> %s</span>' \
121 "$(l10n hi_number)" "$(htmlsafe "$hi_number")"
122 [ -n "$hi_status" ] && printf '<span class="item hi_status"><label>%s:</label> %s</span>' \
123 "$(l10n hi_status)" "$(htmlsafe "$hi_status")"
126 list_section note NOTE X-CLIENT-REFERRAL
128 printf '<div class="section prescriptions"><h3>%s</h3><ul>' "$(l10n prescriptions)"
130 find "$_DATA/prescriptions/" -name "${id%.vcf}.*.mpx" \
131 | while read pfile; do
132 mpx=(); cat "$pfile" |while read -r line; do
134 mpx[${line%%:*}]="$(htmlsafe "${val//\\n/$BR}")"
136 printf '<li><a href="?p=prescriptions&client=%s#%s" >%s: %s - %s</a></li>' \
137 "${id}" "${pfile##*/}" "${mpx[date]}" "${mpx[indicator]}" \
138 "$([ -n "${mpx[remidy]}" ] && printf '%s %s' "${mpx[quantity]}" "${mpx[remidy]}"
140 [ -n "${mpx[remidy${n}]}" ] && printf ', %s %s' "${mpx[quantity${n}]}" "${mpx[remidy${n}]}"