]> git.plutz.net Git - confetti/blobdiff - templates/cards.html.sh
mailto: function in card listing
[confetti] / templates / cards.html.sh
index f1f039a77d81829af470451e327d759e0905f09d..e486317117b908fd90fab8ace14555924bc8fa85 100755 (executable)
@@ -1,9 +1,134 @@
-case $PROFILE in
-medical)
-;;
-circus)
-  view_card=${0%/*}/view_attendee.sh
-  edit_card=${0%/*}/edit_attendee.sh
-  . ${0%/*}/attendees.html.sh
-;;
-esac
+# Copyright 2014 - 2017 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/>. 
+
+setchecked() {
+  printf 'checked="checked"'
+}
+check_type(){
+  [ "${_GET[filter]%%:*}" = "$1" ] && setchecked
+}
+check_order(){
+  [ "${_GET[order]}" = "$1" ] && setchecked
+}
+
+filter_item() {
+cat <<EOF
+  <fieldset class="item">
+    <legend>$(l10n filter_item):</legend>
+    <input type="hidden" name="filter${n}" value="^"/>
+
+    <input  id="any$n" type="radio" name="filter$((n + 1))" value="any:" $([ "$1" = any ] && setchecked)>
+    <label for="any$n" >$(l10n filter_all)</label>
+
+    <input  id="name$n" type="radio" name="filter$((n + 1))" value="name:" $([ "$1" = name ] && setchecked)>
+    <label for="name$n">$(l10n filter_name)</label>
+
+    <!--
+    <input  id="adr$n" type="radio" name="filter$((n + 1))" value="ADR:" $([ "$1" = ADR ] && setchecked)>
+    <label for="adr$n">$(l10n ADR)</label>
+    -->
+
+    <input  id="street$n" type="radio" name="filter$((n + 1))" value="street:" $([ "$1" = street ] && setchecked)>
+    <label for="street$n">$(l10n filter_street)</label>
+
+    <input  id="zip$n" type="radio" name="filter$((n + 1))" value="zip:" $([ "$1" = zip ] && setchecked)>
+    <label for="zip$n">$(l10n filter_zip)</label>
+
+    <input  id="telephone$n" type="radio" name="filter$((n + 1))" value="TEL:" $([ "$1" = TEL ] && setchecked)>
+    <label for="telephone$n">$(l10n filter_phone)</label>
+
+    <input  id="birth$n" type="radio" name="filter$((n + 1))" value="BDAY:" $([ "$1" = BDAY ] && setchecked)>
+    <label for="birth$n">$(l10n filter_birthyear)</label>
+
+    <input  id="cat$n" type="radio" name="filter$((n + 1))" value="CATEGORIES:" $([ "$1" = CATEGORIES ] && setchecked)>
+    <label for="cat$n">$(l10n CATEGORIES)</label>
+    <input type="text" name="filter$((n + 2))" value="$([ "$1" = CATEGORIES ] || attribsafe "$2")" placeholder="$(l10n filter_placeholder)"/>
+    <fieldset class="categories">
+      $(m=3
+        list_categories \
+        | while read cat; do
+          printf '<label><input type="checkbox" name="filter%i" value="|%s" %s/>%s</label>' \
+                 "$((n + m))" "$(attribsafe "$cat")" "$(printf %s "$cat" |grep -qEx "$2" && setchecked)" "$(htmlsafe "$cat")"
+          m=$((m + 1))
+        done
+      )
+      <a href="?p=categories">$(l10n edit_categories)</a>
+    </fieldset>
+
+    <!--
+    ${profile_circus:+
+    <input  id="course" type="radio" name="filtertype" value="course" $(check_type course)>
+    <label for="course">$(l10n filter_course)</label>
+    }
+    -->
+  </fieldset>
+EOF
+}
+
+cat <<EOF
+<form class="filter" action="?action=filter_card" method="POST">
+  <h1>$(l10n filter_label)</h1>
+  <input type="hidden" name="page" value="cards"/>
+
+  $(
+  n=0; m="$(list_categories |wc -l)"
+  printf '%s\n' "${_GET[filter]}" |tr '^' '\n' \
+  | while read filter; do
+    [ -n "$filter" ] && filter_item "${filter%%:*}" "${filter#*:}" "$n"
+    n=$((n + 3 + m))
+  done
+  filter_item any '' "$n"
+  )
+
+  <fieldset class="order">
+    <legend>$(l10n filter_order):</legend>
+    <label><input type="radio" name="order" value="firstname" $(check_order firstname)>$(l10n filter_firstname)</label>
+    <label><input type="radio" name="order" value="lastname"  $(check_order lastname) >$(l10n filter_lastname)</label>
+    <label><input type="radio" name="order" value="bdate"     $(check_order bdate)    >$(l10n filter_bdate)</label>
+  </fieldset>
+  <button type="submit" name="choice" value="new_filter">$(l10n filter_apply)</button>
+  <button type="submit" name="choice" value="del_filter">$(l10n filter_cancel)</button>
+</form>
+
+<form class="newcard" action="?action=new_card" method="POST">
+  <button type="submit">$(l10n newcard)</button>
+</form>
+
+${edit:+$(edit_card "$edit")}
+
+<div class="dash">
+  <a href="mailto:zack@vuesch.org?bcc=$(attribsafe $(listcards_mail))">$(l10n mail_all)</a>
+</div>
+EOF
+
+listcards |grep ${edit:+-v} "$edit" \
+| while read card; do
+  cat <<-ENDCARD
+       <div id="${card}" class="card">
+         $(view_card "$card")<!--
+         --><div class="control">
+           <a class="item" href="?action=edit_card&card=${card}">$(l10n edit)</a>
+           <a class="item" href="?action=export_vcard&card=${card}">$(l10n vcf_export)</a>
+            ${profile_medical:+
+           <a class="item" href="?action=new_prescription&client=${card}">$(l10n new_prescription)</a>
+           }
+         </div>
+       </div>
+       ENDCARD
+done
+
+# vi:set filetype=html: