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"
26 [legend $(l10n filter_item):]
28 $(for field in any name street zip TEL BDAY CATEGORIES; do
29 printf '[input id="%s%i" type="radio" name="filter_type%i" value="%s" %s][label for="%s%i" %s ]' \
30 "$field" "$n" "$n" "$field" "$([ "$1" = "$field" ] && printf checked )" \
31 "$field" "$n" "$(l10n filter_$field)"
33 [input type="text" name="filter_text$n" value="$([ "$1" = CATEGORIES ] || HTML "$2")" placeholder="$(l10n filter_placeholder)"]
35 $(list_categories | while read cat; do
36 printf '[label [checkbox "filter_cat%i" "|%s" %s] %s ]' \
37 "$n" "$(HTML "$cat")" \
38 "$(printf %s "$cat" |grep -qxEe "$2" && printf checked )" \
41 [a href="/cards/categories.sh" $(l10n edit_categories)]
49 [form .filter action="/cards/filter_card.sh" method="POST"
50 [h1 $(l10n filter_label)]
51 [input type="hidden" name="page" value="cards"]
53 $(n=0; filter="${filter}^"
54 while [ "${filter#^}" ]; do
55 fil="${filter%%^*}" filter="${filter#*^}"
56 w_filter_item "${fil%%:*}" "${fil#*:}" $n
59 [ "$n" -eq 0 -o "$(GET newfilter)" ] && w_filter_item any '' $n
61 [button type="submit" name="choice" value="new_filter" $(l10n filter_more)]
62 [fieldset class="order"
63 [legend $(l10n filter_order):]
64 [label [radio "order" "firstname" $( [ "$order" = firstname ] && printf checked )] $(l10n filter_firstname)]
65 [label [radio "order" "lastname" $( [ "$order" = lastname ] && printf checked )] $(l10n filter_lastname)]
66 [label [radio "order" "bdate" $( [ "$order" = bdate ] && printf checked )] $(l10n filter_bdate)]
68 [button type="submit" name="choice" value="filter" $(l10n filter_apply)]
69 [button type="submit" name="choice" value="del_filter" $(l10n filter_cancel)]
74 # listcards |grep ${edit:+-v} "$edit" \
75 # | while read card; do
76 # "${_EXEC}"/cgilite/html-sh.sed <<-ENDCARD
78 # $(view_card "$card")[!--
80 # [a "?action=edit_card&card=${card}" .item $(l10n edit)]
81 # [a "?action=export_vcard&card=${card}".item $(l10n vcf_export)]
82 # ${profile_medical:+[a "?action=new_prescription&client=${card}" .item $(l10n new_prescription)]}
95 cnt="$(pdi_count "$card" "$item")"
98 FN) printf '[h2 .item .FN . %s]' "$(pdi_value "$card" FN |unescape |HTML)"
100 GENDER) printf '[span .item .GENDER . %s]' "$(pdi_value "$card" GENDER |l10n)"
102 NICKNAME) seq 1 $cnt |while read c; do
103 printf '[span .item .NICKNAME . aka. "%s"]' \
104 "$(pdi_value "$card" NICKNAME $c |unescape |HTML)"
107 X-ZACK-JOINDATE|X-ZACK-LEAVEDATE) if [ $cnt -gt 0 ]; then
108 printf '[span .item .%s [b %s:] %s]' \
109 "$item" "$(l10n "${item}_short")" \
110 "$(pdi_value "$card" "$item" |HTML)"
114 [ $cnt -gt 0 ] && printf '[span .item .BDAY [b *:] %s]' \
115 "$(pdi_value "$card" BDAY |grep -xE '[0-9-]+')"
118 [ $cnt -gt 0 ] && printf '[audio .item .SOUND controls="controls"
119 [source type="audio/ogg" src="data:audio/ogg;base64,%s"]
121 "$(pdi_value "$card" SOUND |grep -xE '[a-zA-Z0-9/+=]+')"
124 [ $cnt -gt 0 ] && printf '[img .item .%s src="data:image/%s;base64,%s"]' "$item" \
125 "$(pdi_attrib "$card" "$item" |sed -E 's;^(.*;)?TYPE="?(.+)"?(;.*)?$;\2;')" \
126 "$(pdi_value "$card" "$item" |grep -xE '[a-zA-Z0-9/+=]+')"
129 [ $cnt -gt 0 ] && printf '[h3 %s]' "$(l10n EMAIL)"
130 seq 1 $cnt |while read c; do
131 printf '[a .item .EMAIL href="mailto:%s" . %s]' \
132 "$(pdi_value "$card" EMAIL $c |unescape |HTML)" \
133 "$(pdi_value "$card" EMAIL $c |unescape |HTML)"
137 [ $cnt -gt 0 ] && printf '[h3 %s]' "$(l10n TEL)"
138 seq 1 $cnt |while read c; do
139 teltype="$(pdi_attrib "$card" TEL $c TYPE)"
141 && printf '[span .item .TEL [span .type . %s:] %s]' \
142 "$(l10n "TYPE=$teltype" |HTML)" \
143 "$(pdi_value "$card" TEL $c |unescape |HTML)" \
144 || printf '[span .item .TEL . %s]' \
145 "$(pdi_value "$card" TEL $c |unescape |HTML)"
148 *)[ $cnt -gt 0 ] && printf '[h3 %s]' "$(l10n "$item")"
149 seq 1 $cnt |while read c; do
150 printf '[span .item .%s . %s]' "$item" \
151 "$(pdi_value "$card" "$item" $c |unescape |HTML)"
164 cnt="$(pdi_count "$card" "$item")"
165 [ $cnt -lt 1 ] && cnt=1
168 N)N="$(pdi_value "$card" N)"
170 IFS=\; read n1 n2 n3 n4 n5 <<-EOF
174 N="$(pdi_value "$card" FN |unescape)"
175 n1="${N%%[a-z]*}" n1="${N#$n1}"
176 [ "$n1" ] || n1="${N##* }"
181 [input .item .N name="4N" placeholder="%s" value="%s"]
182 [input .item .N name="2N" placeholder="%s" value="%s"]
183 [input .item .N name="1N" placeholder="%s" value="%s"]
184 [input .item .N name="5N" placeholder="%s" value="%s"]
185 ' "$(l10n "$item")" \
186 "$(l10n n_pre)" "$(HTML "$n4")" \
187 "$(l10n n_first)" "$(HTML "$n2" "$n3")" \
188 "$(l10n n_last)" "$(HTML "$n1")" \
189 "$(l10n n_post)" "$(HTML "$n5")"
192 gender="$(pdi_value "$card" GENDER)"
194 [select .item .GENDER name="GENDER"
195 [option value="" disabled="disabled" %s %s]
196 [option value="female" %s %s]
197 [option value="male" %s %s]
198 [option value="other" %s %s]
199 [option value="none" %s %s]
201 "$([ "$gender" = '' ] && printf 'selected="selected"')" "$(l10n GENDER)" \
202 "$([ "$gender" = 'female' ] && printf 'selected="selected"')" "$(l10n gender_female)" \
203 "$([ "$gender" = 'male' ] && printf 'selected="selected"')" "$(l10n gender_male)" \
204 "$([ "$gender" = 'other' ] && printf 'selected="selected"')" "$(l10n gender_other)" \
205 "$([ "$gender" = 'none' ] && printf 'selected="selected"')" "$(l10n gender_none)"
207 BDAY|X-ZACK-JOINDATE|X-ZACK-LEAVEDATE)
209 [input .item .%s name="%s" value="%s" placeholder="YYYY-MM-DD"]' \
210 "$(l10n "$item")" "$item" "$item" "$(pdi_value "$card" "$item" |grep -xE '[0-9-]+')"
213 printf '[h3 %s]' "$(l10n "$item")"
214 seq 1 $cnt |while read c; do
215 printf '[checkbox "%s_delete_%i" "true" .delete #%s_delete_%i][label for="%s_delete_%i" %s]' \
216 "$item" $c "$item" $c "$item" $c "$(l10n delete)"
217 printf '<textarea class="item %s" name="%s">%s</textarea>' \
218 "$item" "$item" "$(pdi_value "$card" "$item" $c |unescape |HTML)"
220 printf '[button type="submit" name="action" value="addfield %s" %s ]' "$item" "$(l10n edit_addfield)"
222 TEL) printf '[h3 %s]' "$(l10n "$item")"
223 seq 1 $cnt |while read c; do
224 printf '[checkbox "%s_delete_%i" "true" .delete #%s_delete_%i][label for="%s_delete_%i" %s]' \
225 "$item" $c "$item" $c "$item" $c "$(l10n delete)"
226 teltype="$(pdi_attrib "$card" TEL $c TYPE)"
227 printf '[select .item .teltype name="teltype"
228 [option value="" disabled="disabled" %s %s]
229 [option value="HOME" %s %s]
230 [option value="WORK" %s %s]
231 [option value="CELL" %s %s]
232 [option value="FAX" %s %s]
234 "$([ "$teltype" = '' ] && printf 'selected="selected"')" "$(l10n teltype)" \
235 "$([ "$teltype" = 'HOME' ] && printf 'selected="selected"')" "$(l10n TYPE=HOME)" \
236 "$([ "$teltype" = 'WORK' ] && printf 'selected="selected"')" "$(l10n TYPE=WORK)" \
237 "$([ "$teltype" = 'CELL' ] && printf 'selected="selected"')" "$(l10n TYPE=CELL)" \
238 "$([ "$teltype" = 'FAX' ] && printf 'selected="selected"')" "$(l10n TYPE=FAX)"
240 printf '[input .item .%s name="%s" value="%s" placeholder="%s"]' \
241 "$item" "$item" "$(pdi_value "$card" "$item" $c |unescape |HTML)" "$(l10n "$item")"
243 printf '[button type="submit" name="action" value="addfield %s" %s ]' "$item" "$(l10n edit_addfield)"
245 *)printf '[h3 %s]' "$(l10n "$item")"
246 seq 1 $cnt |while read c; do
247 printf '[checkbox "%s_delete_%i" "true" .delete #%s_delete_%i][label for="%s_delete_%i" %s]' \
248 "$item" $c "$item" $c "$item" $c "$(l10n delete)"
249 printf '[input .item .%s name="%s" value="%s" placeholder="%s"]' \
250 "$item" "$item" "$(pdi_value "$card" "$item" $c |unescape |HTML)" "$(l10n "$item")"
252 printf '[button type="submit" name="action" value="addfield %s" %s ]' "$item" "$(l10n edit_addfield)"