-. ${_EXEC}/templates/view_attendee.sh
+# Copyright 2014 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/>.
-check(){
+check_type(){
[ "$_GET[\"filtertype\"]" = "$1" ] && echo 'checked="checked"'
}
+check_order(){
+ [ "$_GET[\"order\"]" = "$1" ] && echo 'checked="checked"'
+}
+
+edit="$_GET[\"edit\"]"
+[ -z "$_GET[\"filtertype\"]" ] && _GET["filtertype"]="any"
+[ -z "$_GET[\"order\"]" ] && _GET["order"]="firstname"
cat <<EOF
-<div class="filter">
-<form action="/" method="GET">
- <div class="search">
- <span class="label">Filter:</span>
- <input type="hidden" name="page" value="attendees"/>
- <input type="text" name="filter" value="$_GET["filter"]"/><br/>
- <input type="radio" name="filtertype" value="any" $(check any)>Alles</input>
- <input type="radio" name="filtertype" value="name" $(check name)>Name</input>
- <input type="radio" name="filtertype" value="street" $(check street)>Straße</input>
- <input type="radio" name="filtertype" value="zip" $(check zip)>PLZ.</input>
- <input type="radio" name="filtertype" value="telephone" $(check telephone)>Telefon</input>
- <input type="radio" name="filtertype" value="birth" $(check birth)>Geburtsjahr</input>
- <input type="radio" name="filtertype" value="course" $(check course)>Kurs</input><br/>
- <button type="submit" name="action" value="new_filter">Filtern</button>
- <button type="submit" name="action" value="del_filter">Filter löschen</button>
- </div>
+<form class="filter" action="?action=filter_attendee" method="POST">
+ <h1>$(l10n filter_label)</h1>
+ <input type="hidden" name="page" value="attendees"/>
+ <input type="text" name="filter" value="$_GET["filter"]" placeholder="$(l10n filter_placeholder)"/>
+ <br />
+ <fieldset>
+ <legend>$(l10n filter_type):</legend>
+ <input type="radio" name="filtertype" value="any" id="ft_any" $(check_type any)
+ ><label for="ft_any" >$(l10n filter_all)</label>
+ <input type="radio" name="filtertype" value="name" id="ft_name" $(check_type name)
+ ><label for="ft_name" >$(l10n filter_name)</label>
+ <input type="radio" name="filtertype" value="street" id="ft_street" $(check_type street)
+ ><label for="ft_street">$(l10n filter_street)</label>
+ <input type="radio" name="filtertype" value="zip" id="ft_zip" $(check_type zip)
+ ><label for="ft_zip" >$(l10n filter_zip)</label>
+ <input type="radio" name="filtertype" value="telephone" id="ft_phone" $(check_type telephone)
+ ><label for="ft_phone" >$(l10n filter_phone)</label>
+ <input type="radio" name="filtertype" value="birth" id="ft_birth" $(check_type birth)
+ ><label for="ft_birth" >$(l10n filter_birthyear)</label>
+ <input type="radio" name="filtertype" value="course" id="ft_course" $(check_type course)
+ ><label for="ft_course">$(l10n filter_course)</label>
+ </fieldset>
+ <fieldset>
+ <legend>$(l10n filter_order):</legend>
+ <input type="radio" name="order" value="firstname" id="od_fname" $(check_order firstname)
+ ><label for="od_fname">$(l10n filter_firstname)</label>
+ <input type="radio" name="order" value="lastname" id="od_lname" $(check_order lastname)
+ ><label for="od_lname">$(l10n filter_lastname)</label>
+ <input type="radio" name="order" value="bdate" id="od_bdate" $(check_order bdate)
+ ><label for="od_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>
-</div>
-<div class="newcard">
-<h2>Neuer Eintrag</h2>
-<form action="actions/newcard.cgi" method="POST">
- <span class="label">Name:</span>
- <input type="text" name="name"/>
- <button type="submit">Anlegen</button>
+<form class="newcard" action="?action=new_attendee" method="POST">
+ <button type="submit">$(l10n newcard)</button>
</form>
-</div>
-
-<div class="cardlist">
- $(listcards |while read card; do
- id="vcf_$card"
- echo '<div id="'"$id"'" class="card">'
- if [ "$_GET[\"edit\"]" = "$id" ]; then
- debug "Edit: $card"
- edit_attendee "$card"
- else
- echo '<p class="control"><a href="?page=attendees&edit='"$id"'#'"$id"'">Bearbeiten</a></p>'
- view_attendee "$card"
- fi
- echo '</div>'
- done)
-</div>
+$(
+[ -f "vcard/$edit" -o -f "temp/$edit" ] && edit_attendee "$edit"
+if [ "$?" = 0 ]; then
+ listcards |grep -v "$edit"
+else
+ listcards
+fi |while read card; do
+ view_attendee "$card"
+done
+)
EOF
# vi:set filetype=html: