--- /dev/null
+# Copyright 2014 - 2019 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 <http://www.gnu.org/licenses/>.
+
+w_filter_item() {
+cat <<EOF
+ [fieldset .item
+ [legend $(l10n filter_item):]
+ [input type="hidden" name="filter${n}" value="^"]
+
+ $(for field in any name street zip TEL BDAY CATEGORIES; do
+ printf '[input id="%s%i" type="radio" name="filter%i" value="%s" %s]
+ [label for="%s%i" %s]' \
+ "$field" "$n" "$((n + 1))" "$field" "$([ "$1" = "$field" ] && printf checked )" \
+ "$field" "$n" "$(l10n filter_$field)"
+ done)
+ [input type="text" name="filter$((n + 2))" value="$([ "$1" = CATEGORIES ] || HTML "$2")" placeholder="$(l10n filter_placeholder)"]
+ [fieldset .categories
+ $(m=3; list_categories | while read cat; do
+ printf '[label [checkbox "filter%i" "|%s" %s] %s ]' \
+ "$((n + m))" "$(HTML "$cat")" \
+ "$(printf %s "$cat" |grep -qEx "$2" && printf checked )" \
+ "$(HTML "$cat")"
+ m=$((m + 1))
+ done)
+ [a href="?p=categories" $(l10n edit_categories)]
+ ]
+ ]
+EOF
+}
+
+w_filter_diag(){
+ cat <<EOF
+ [form .filter action="?action=filter_card" method="POST"
+ [h1 $(l10n filter_label)]
+ [input type="hidden" name="page" value="cards"]
+
+ $(
+ n=0; m="$(list_categories |wc -l)"
+ printf '%s\n' "$filter" |tr '^' '\n' \
+ | while read filter; do
+ [ -n "$filter" ] && w_filter_item "${filter%%:*}" "${filter#*:}" "$n"
+ n=$((n + 3 + m))
+ done
+ w_filter_item any '' "$n"
+ )
+
+ [fieldset class="order"
+ [legend $(l10n filter_order):]
+ [label [radio "order" "firstname" $( [ "$order" = firstname ] && printf checked )] $(l10n filter_firstname)]
+ [label [radio "order" "lastname" $( [ "$order" = lastname ] && printf checked )] $(l10n filter_lastname)]
+ [label [radio "order" "bdate" $( [ "$order" = bdate ] && printf checked )] $(l10n filter_bdate)]
+ ]
+ [button type="submit" name="choice" value="new_filter" $(l10n filter_apply)]
+ [button type="submit" name="choice" value="del_filter" $(l10n filter_cancel)]
+ ]
+EOF
+}
+
+# listcards |grep ${edit:+-v} "$edit" \
+# | while read card; do
+# "${_EXEC}"/cgilite/html-sh.sed <<-ENDCARD
+# [div #${card} .card
+# $(view_card "$card")[!--
+# --][div .control
+# [a "?action=edit_card&card=${card}" .item $(l10n edit)]
+# [a "?action=export_vcard&card=${card}".item $(l10n vcf_export)]
+# ${profile_medical:+[a "?action=new_prescription&client=${card}" .item $(l10n new_prescription)]}
+# ]]
+# ENDCARD
+# done
+