1 # Copyright 2014 - 2019, 2021 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/>.
19 grep -vxE '^[ ]*$' "${_DATA}/mappings/categories"
23 local file name cachefile="${_DATA}/cache/courses.ui.cache"
24 if [ $cachefile -nt "${_DATA}/ical" ]; then
27 for file in "$_DATA/ical"/*.ics; do
28 name="$(pdi_value "$(pdi_load "$file")" SUMMARY || l10n "(unnamed course)" |unescape |HTML)"
29 printf '%s/%s\n' "${file##*/}" "$name"
31 | sort -t/ -k2 |tee "$cachefile"
39 [legend $(l10n filter_item):]
41 $(for field in any name street zip TEL BDAY CATEGORIES course; do
42 printf '[input .tab id="%s%i" type="radio" name="filter_type%i" value="%s" %s][label for="%s%i" %s ]' \
43 "$field" "$n" "$n" "$field" "$([ "$1" = "$field" ] && printf checked )" \
44 "$field" "$n" "$(l10n filter_$field)"
46 [input .tab type="text" name="filter_text$n" value="$([ "$1" = CATEGORIES -o "$1" = course ] || HTML "$2")" placeholder="$(l10n filter_placeholder)"]
47 [fieldset .tab .categories
48 $(list_categories | while read cat; do
49 printf '[label [checkbox "filter_cat%i" "|%s" %s] %s ] ' \
50 "$n" "$(HTML "$cat")" \
51 "$(printf %s "$cat" |grep -qxEe "$2" && printf checked )" \
54 [a href="${_BASE}/categories/" $(l10n edit_categories)]
56 [fieldset .tab .courses
57 $(list_courses | while IFS=/ read course coursename; do
58 printf '[label [checkbox "filter_course%i" "|%s" %s] %s ] ' \
59 "$n" "$(HTML "${course##*/}")" \
60 "$(printf %s "${course##*/}" |grep -qxEe "$2" && printf checked )" \
70 [form .filter action="${_BASE}/cards/filter_card.sh" method="POST"
71 [h1 $(l10n filter_label)]
72 [input type="hidden" name="page" value="cards"]
74 $(n=0; filter="${filter}^"
75 while [ "${filter#^}" ]; do
76 fil="${filter%%^*}" filter="${filter#*^}"
77 w_filter_item "${fil%%:*}" "${fil#*:}" $n
80 [ "$n" -eq 0 -o "$(GET newfilter)" ] && w_filter_item any '' $n
82 [button type="submit" name="choice" value="new_filter" $(l10n filter_more)]
83 [fieldset class="order"
84 [legend $(l10n filter_order):]
85 [label [radio "order" "firstname" $( [ "$order" = firstname ] && printf checked )] $(l10n filter_firstname)]
86 [label [radio "order" "lastname" $( [ "$order" = lastname ] && printf checked )] $(l10n filter_lastname)]
87 [label [radio "order" "bdate" $( [ "$order" = bdate ] && printf checked )] $(l10n filter_bdate)]
89 [button type="submit" name="choice" value="filter" $(l10n filter_apply)]
90 [button type="submit" name="choice" value="del_filter" $(l10n filter_cancel)]
91 [button type="submit" name="choice" value="export_csv" $(l10n export_csv)]
96 # listcards |grep ${edit:+-v} "$edit" \
97 # | while read card; do
98 # "${_EXEC}"/cgilite/html-sh.sed <<-ENDCARD
100 # $(view_card "$card")[!--
102 # [a "?action=edit_card&card=${card}" .item $(l10n edit)]
103 # [a "?action=export_vcard&card=${card}".item $(l10n vcf_export)]
104 # ${profile_medical:+[a "?action=new_prescription&client=${card}" .item $(l10n new_prescription)]}
117 cnt="$(pdi_count "$card" "$item")"
120 FN) printf '[h2 .item .FN . %s]' "$(pdi_value "$card" FN |unescape |HTML)"
122 GENDER) printf '[span .item .GENDER . %s]' "$(pdi_value "$card" GENDER |l10n)"
124 NICKNAME) seq 1 $cnt |while read c; do
125 printf '[span .item .NICKNAME . aka. "%s"]' \
126 "$(pdi_value "$card" NICKNAME $c |unescape |HTML)"
129 X-ZACK-JOINDATE|X-ZACK-LEAVEDATE) if [ $cnt -gt 0 ]; then
130 printf '[span .item .%s [b %s:] %s]' \
131 "$item" "$(l10n "${item}_short")" \
132 "$(pdi_value "$card" "$item" |HTML)"
136 [ $cnt -gt 0 ] && printf '[span .item .BDAY [b *:] %s]' \
137 "$(pdi_value "$card" BDAY |grep -xE '[0-9-]+')"
140 [ $cnt -gt 0 ] && printf '[audio .item .SOUND controls="controls"
141 [source type="audio/ogg" src="data:audio/ogg;base64,%s"]
143 "$(pdi_value "$card" SOUND |grep -xE '[a-zA-Z0-9/+=]+')"
146 [ $cnt -gt 0 ] && printf '[img .item .%s src="data:image/%s;base64,%s"]' "$item" \
147 "$(pdi_attrib "$card" "$item" |sed -E 's;^(.*;)?TYPE="?(.+)"?(;.*)?$;\2;')" \
148 "$(pdi_value "$card" "$item" |grep -xE '[a-zA-Z0-9/+=]+')"
151 [ $cnt -gt 0 ] && printf '[h3 %s]' "$(l10n EMAIL)"
152 seq 1 $cnt |while read c; do
153 printf '[a .item .EMAIL href="mailto:%s" . %s]' \
154 "$(pdi_value "$card" EMAIL $c |unescape |HTML)" \
155 "$(pdi_value "$card" EMAIL $c |unescape |HTML)"
159 [ $cnt -gt 0 ] && printf '[h3 %s]' "$(l10n TEL)"
160 seq 1 $cnt |while read c; do
161 teltype="$(pdi_attrib "$card" TEL $c TYPE)"
163 && printf '[span .item .TEL [span .type . %s:] %s]' \
164 "$(l10n "TYPE=$teltype" |HTML)" \
165 "$(pdi_value "$card" TEL $c |unescape |HTML)" \
166 || printf '[span .item .TEL . %s]' \
167 "$(pdi_value "$card" TEL $c |unescape |HTML)"
170 ADR)[ $cnt -gt 0 ] && printf '[h3 %s]' "$(l10n "$item")"
171 shy="$(printf '\302\255')"
172 seq 1 $cnt |while read c; do
173 printf '[span .item .%s . %s]' "$item" \
174 "$(pdi_value "$card" "$item" $c |sed -r "s;(straße|weg|damm|allee|ufer);${shy}\1;g" |unescape |HTML)"
177 *)[ $cnt -gt 0 ] && printf '[h3 %s]' "$(l10n "$item")"
178 seq 1 $cnt |while read c; do
179 printf '[span .item .%s . %s]' "$item" \
180 "$(pdi_value "$card" "$item" $c |unescape |HTML)"
193 cnt="$(pdi_count "$card" "$item")"
194 [ $cnt -lt 1 ] && cnt=1
197 N)N="$(pdi_value "$card" N)"
199 IFS=\; read n1 n2 n3 n4 n5 <<-EOF
203 N="$(pdi_value "$card" FN |unescape)"
209 [input .item .N name="4N" placeholder="%s" value="%s"]
210 [input .item .N name="2N" placeholder="%s" value="%s"]
211 [input .item .N name="1N" placeholder="%s" value="%s"]
212 [input .item .N name="5N" placeholder="%s" value="%s"]
213 ' "$(l10n "$item")" \
214 "$(l10n n_pre)" "$(HTML "$n4")" \
215 "$(l10n n_first)" "$(HTML "${n2}$([ "$n2" -a "$n3" ] && printf ' ')${n3}")" \
216 "$(l10n n_last)" "$(HTML "$n1")" \
217 "$(l10n n_post)" "$(HTML "$n5")"
220 gender="$(pdi_value "$card" GENDER)"
222 [select .item .GENDER name="GENDER"
223 [option value="" disabled="disabled" %s %s]
224 [option value="female" %s %s]
225 [option value="male" %s %s]
226 [option value="other" %s %s]
227 [option value="none" %s %s]
229 "$([ "$gender" = '' ] && printf 'selected="selected"')" "$(l10n GENDER)" \
230 "$([ "$gender" = 'female' ] && printf 'selected="selected"')" "$(l10n gender_female)" \
231 "$([ "$gender" = 'male' ] && printf 'selected="selected"')" "$(l10n gender_male)" \
232 "$([ "$gender" = 'other' ] && printf 'selected="selected"')" "$(l10n gender_other)" \
233 "$([ "$gender" = 'none' ] && printf 'selected="selected"')" "$(l10n gender_none)"
235 BDAY|X-ZACK-JOINDATE|X-ZACK-LEAVEDATE)
237 [input .item .%s name="%s" value="%s" placeholder="YYYY-MM-DD"]' \
238 "$(l10n "$item")" "$item" "$item" "$(pdi_value "$card" "$item" |grep -xE '[0-9-]+')"
241 printf '[h3 %s]' "$(l10n "$item")"
242 seq 1 $cnt |while read c; do
243 printf '[checkbox "%s_delete_%i" "true" .delete #%s_delete_%i][label for="%s_delete_%i" %s]' \
244 "$item" $c "$item" $c "$item" $c "$(l10n delete)"
245 printf '<textarea class="item %s" name="%s">%s</textarea>' \
246 "$item" "$item" "$(pdi_value "$card" "$item" $c |unescape |HTML)"
248 printf '[button type="submit" name="action" value="addfield %s" %s ]' "$item" "$(l10n edit_addfield)"
250 TEL) printf '[h3 %s]' "$(l10n "$item")"
251 seq 1 $cnt |while read c; do
252 printf '[checkbox "%s_delete_%i" "true" .delete #%s_delete_%i][label for="%s_delete_%i" %s]' \
253 "$item" $c "$item" $c "$item" $c "$(l10n delete)"
254 teltype="$(pdi_attrib "$card" TEL $c TYPE)"
255 printf '[select .item .teltype name="teltype"
256 [option value="" disabled="disabled" %s %s]
257 [option value="HOME" %s %s]
258 [option value="WORK" %s %s]
259 [option value="CELL" %s %s]
260 [option value="FAX" %s %s]
262 "$([ "$teltype" = '' ] && printf 'selected="selected"')" "$(l10n teltype)" \
263 "$([ "$teltype" = 'HOME' ] && printf 'selected="selected"')" "$(l10n TYPE=HOME)" \
264 "$([ "$teltype" = 'WORK' ] && printf 'selected="selected"')" "$(l10n TYPE=WORK)" \
265 "$([ "$teltype" = 'CELL' ] && printf 'selected="selected"')" "$(l10n TYPE=CELL)" \
266 "$([ "$teltype" = 'FAX' ] && printf 'selected="selected"')" "$(l10n TYPE=FAX)"
268 printf '[input .item .%s name="%s" value="%s" placeholder="%s"]' \
269 "$item" "$item" "$(pdi_value "$card" "$item" $c |unescape |HTML)" "$(l10n "$item")"
271 printf '[button type="submit" name="action" value="addfield %s" %s ]' "$item" "$(l10n edit_addfield)"
273 *)printf '[h3 %s]' "$(l10n "$item")"
274 seq 1 $cnt |while read c; do
275 printf '[checkbox "%s_delete_%i" "true" .delete #%s_delete_%i][label for="%s_delete_%i" %s]' \
276 "$item" $c "$item" $c "$item" $c "$(l10n delete)"
277 printf '[input .item .%s name="%s" value="%s" placeholder="%s"]' \
278 "$item" "$item" "$(pdi_value "$card" "$item" $c |unescape |HTML)" "$(l10n "$item")"
280 printf '[button type="submit" name="action" value="addfield %s" %s ]' "$item" "$(l10n edit_addfield)"