simplify distinction between attendees and clients
[confetti] / templates / cards.html.sh
1 # Copyright 2014 - 2016 Paul Hänsch
2 #
3 # This file is part of Confetti.
4
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.
9
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.
14
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/>. 
17
18 check_type(){
19   [ "${_GET[filtertype]}" = "$1" ] && echo 'checked="checked"'
20 }
21 check_order(){
22   [ "${_GET[order]}" = "$1" ] && echo 'checked="checked"'
23 }
24
25 edit="${_GET[edit]}"
26 [ \! -f "vcard/$edit" -a \! -f "temp/$edit" ] && edit=''
27 [ -z "${_GET[filtertype]}" ] && _GET[filtertype]="any"
28
29 case $PROFILE in
30 medical)
31   view_card=${0%/*}/view_client.sh
32   edit_card=${0%/*}/edit_client.sh
33   _GET[order]="${_GET[order]:-lastname}"
34   profile_medical=x
35 ;;
36 circus)
37   view_card=${0%/*}/view_attendee.sh
38   edit_card=${0%/*}/edit_attendee.sh
39   _GET[order]="${_GET[order]:-firstname}"
40   profile_circus=x
41 ;;
42 esac
43
44 cat <<EOF
45 <form class="filter" action="?action=filter_card" method="POST">
46   <h1>$(l10n filter_label)</h1>
47   <input type="hidden" name="page" value="cards"/>
48   <input type="text" name="filter" value="$_GET["filter"]" placeholder="$(l10n filter_placeholder)"/>
49   <br />
50   <fieldset>
51   <legend>$(l10n filter_type):</legend>
52     <label><input type="radio" name="filtertype" value="any"       $(check_type any)      >$(l10n filter_all)</label>
53     <label><input type="radio" name="filtertype" value="name"      $(check_type name)     >$(l10n filter_name)</label>
54     <label><input type="radio" name="filtertype" value="street"    $(check_type street)   >$(l10n filter_street)</label>
55     <label><input type="radio" name="filtertype" value="zip"       $(check_type zip)      >$(l10n filter_zip)</label>
56     <label><input type="radio" name="filtertype" value="telephone" $(check_type telephone)>$(l10n filter_phone)</label>
57     <label><input type="radio" name="filtertype" value="birth"     $(check_type birth)    >$(l10n filter_birthyear)</label>
58     ${profile_circus:+
59     <label><input type="radio" name="filtertype" value="course"    $(check_type course)   >$(l10n filter_course)</label>
60     }
61   </fieldset>
62   <fieldset>
63     <legend>$(l10n filter_order):</legend>
64     <label><input type="radio" name="order" value="firstname" $(check_order firstname)>$(l10n filter_firstname)</label>
65     <label><input type="radio" name="order" value="lastname"  $(check_order lastname) >$(l10n filter_lastname)</label>
66     <label><input type="radio" name="order" value="bdate"     $(check_order bdate)    >$(l10n filter_bdate)</label>
67   </fieldset>
68   <button type="submit" name="choice" value="new_filter">$(l10n filter_apply)</button>
69   <button type="submit" name="choice" value="del_filter">$(l10n filter_cancel)</button>
70 </form>
71
72 <form class="newcard" action="?action=new_card" method="POST">
73   <button type="submit">$(l10n newcard)</button>
74 </form>
75
76 ${edit:+$(edit_card "$edit")}
77 EOF
78
79 listcards |grep ${edit:+-v} "$edit" \
80 | while read card; do
81   cat <<-ENDCARD
82         <div id="${card}" class="card">
83           $(view_card "$card")<!--
84           --><div class="control">
85             <a class="item" href="?action=edit_card&card=${card}">$(l10n edit)</a>
86             <a class="item" href="?action=export_vcard&card=${card}">$(l10n vcf_export)</a>
87             ${profile_medical:+
88             <a class="item" href="?action=new_prescription&client=${card}">$(l10n new_prescription)</a>
89             }
90           </div>
91         </div>
92         ENDCARD
93 done
94
95 # vi:set filetype=html: