]> git.plutz.net Git - confetti/blob - templates/edit_client.sh
simplified vcf parser, enabled field for health insurance
[confetti] / templates / edit_client.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_gen() {
19   [ "$values[GENDER]" = "$1" ] && echo 'selected="selected"'
20 }
21 check_a() {
22   egrep -q "^${1}.${id}$" "$_DATA/mappings/attendance" && echo 'checked="checked"'
23 }
24
25 n_last="$(printf %s "$values[N]" |sed -rn 's:^([^;]*;){0} *([^;]*).*$:\2:p')"
26 n_first="$(printf %s "$values[N]" |sed -rn 's:^([^;]*;){1} *([^;]*).*$:\2:p')"
27 n_middle="$(printf %s "$values[N]" |sed -rn 's:^([^;]*;){2} *([^;]*).*$:\2:p')"
28 n_pre="$(printf %s "$values[N]" |sed -rn 's:^([^;]*;){3} *([^;]*).*$:\2:p')"
29 n_post="$(printf %s "$values[N]" |sed -rn 's:^([^;]*;){4} *([^;]*)*$:\2:p')"
30
31 hi_number="${values[X-HEALTH-INSURANCE]%;*}"
32 hi_company="${values[X-HEALTH-INSURANCE]#*;}"
33
34 SUP_FIELDS=(N NICKNAME GENDER BDAY ADR TEL EMAIL X-HEALTH-INSURANCE X-HEALTH-INSURANCE-NOCONTRIB IMPP URL NOTE X-CLIENT-REFERRAL)
35
36 [ -z "$values[UID]" ] && values[UID]="$(uuidgenerator)"
37
38 cat <<END_HTML
39 <form id="$id" class="card" action="?action=update_card" method="POST">
40   <input type="hidden" name="card" value="${id}"/>
41   <div class="section basic">
42     <h3>$(l10n N)</h3>
43     <input class="item N" name="3N" placeholder="$(l10n n_pre)" value="$n_pre" />
44     <input class="item N" name="1N" placeholder="$(l10n n_first)" value="$n_first" />
45     <input class="item N" name="2N" placeholder="$(l10n n_middle)" value="$n_middle" />
46     <input class="item N" name="0N" placeholder="$(l10n n_last)" value="$n_last" />
47     <input class="item N" name="4N" placeholder="$(l10n n_post)" value="$n_post" />
48
49     <select class="item GENDER" name="GENDER">
50       <option value="" disabled="disabled">$(l10n GENDER)</option>
51       <option value="female" $(check_gen female)>$(l10n gender_female)</option>
52       <option value="male" $(check_gen male)>$(l10n gender_male)</option>
53       <option value="other" $(check_gen other)>$(l10n gender_other)</option>
54       <option value="none" $(check_gen none)>$(l10n gender_none)</option>
55     </select>
56
57     $(for n in NICKNAME NICKNAME{0..10}; do
58       echo "${values[$n]:+<input class="item NICKNAME" name="NICKNAME" placeholder="$(l10n NICKNAME)" value="$values[$n]" />}"
59     done)
60
61     <h3>$(l10n BDAY)</h3>
62     <input class="item BDAY" name="BDAY" value="$values[BDAY]" />
63
64     $(if [ -n "$values[SOUND]" ]; then
65       echo '    <audio controls="controls" class="item SOUND">'
66       echo '      <source type="audio/ogg" src="data:audio/ogg;base64,'$values[SOUND]'" />'
67       echo '    </audio>'
68     fi)
69     ${values[PHOTO]:+<img class="item PHOTO" src="data:image/$tags[PHOTO_TYPE];base64,$values[PHOTO]" />}
70     ${values[LOGO]:+<img class="item LOGO" src="data:image/$tags[LOGO_TYPE];base64,$values[LOGO]" />}
71   </div>
72
73   <div class="section address">
74     <h3>$(l10n ADR)</h3>
75     <textarea class="item ADR" name="ADR">$values[ADR]</textarea>
76     $(for n in ADR{0..10}; do
77       echo "${values[$n]:+<textarea class="item ADR" name="ADR">$values[$n]</textarea>}"
78     done)
79     ${values[URL]:+<h3>$(l10n URL)</h3>}
80     $(for n in URL URL{0..10}; do
81       echo "${values[$n]:+<input class="item URL" name="URL" value="$values[$n]" />}"
82     done)
83   </div>
84
85   <div class="section phone">
86     <h3>$(l10n TEL)</h3>
87     <input class="item TEL" name="TEL" value="$values[TEL]" />
88     $(for n in TEL{0..10}; do
89       echo "${values[$n]:+<input class="item TEL" name="TEL" value="'$values[$n]'" />}"
90     done)
91     ${values[EMAIL]:+<h3>$(l10n EMAIL)</h3>}
92     $(for n in EMAIL EMAIL{0..10}; do
93       echo "${values[$n]:+<input class="item EMAIL" name="EMAIL" value="$values[$n]" />}"
94     done)
95     ${values[IMPP]:+<h3>$(l10n IMPP)</h3>}
96     $(for n in IMPP IMPP{0..10}; do
97       echo "${values[$n]:+<input class="item IMPP" name="IMPP" value="$values[$n]" />}"
98     done)
99   </div>
100
101   <div class="section insurance">
102     <h3>$(l10n X-HEALTH-INSURANCE)</h3>
103     <select class="item" name="hi_company">
104       <option value="" disabled="disabled" selected="selected">$(l10n hi_company)</option>
105       $(list_hi_companies |while read f; do echo "<option value=\"$f\">$(l10n $f)</option>"; done)
106     </select>
107     <input class="item hi_number" name="hi_number" value="$hi_number" placeholder="$(l10n hi_number)" />
108
109   </div>
110
111   <div class="section note">
112     <h3>$(l10n NOTE)</h3>
113     <textarea class="item NOTE" name="NOTE">$values[NOTE]</textarea>
114     $(for n in NOTE{0..10}; do
115       echo "${values[$n]:+<textarea class="item NOTE" name="NOTE">$values[$n]</textarea>}"
116     done)
117     <h3>$(l10n X-CLIENT-REFERRAL)</h3>
118     <input class="item X-CLIENT-REFERRAL" name="X-CLIENT-REFERRAL" value="$values[X-CLIENT-REFERRAL]" />
119     $(for n in X-CLIENT-REFERRAL{0..10}; do
120       echo "${values[$n]:+<input class="item X-CLIENT-REFERRAL" name="X-CLIENT-REFERRAL" value="'$values[$n]'" />}"
121     done)
122   </div>
123
124   <div class="control">
125     <select class="item" name="newfield">
126       <option value="" disabled="disabled" selected="selected">$(l10n edit_addfieldtext)</option>
127       $(for f in $SUP_FIELDS; do echo "<option value=\"$f\">$(l10n $f)</option>"; done)
128     </select
129     ><button class="item" type="submit" name="action" value="addfield">$(l10n edit_addfield)</button>
130     <button class="item" type="submit" name="action" value="update">$(l10n edit_update)</button>
131     <button class="item" type="submit" name="action" value="delete">$(l10n edit_delete)</button>
132     <button class="item" type="submit" name="action" value="cancel">$(l10n edit_cancel)</button>
133   </div>
134   <input type="hidden" name="UID" value="$values[UID]"/>
135 </form>
136 END_HTML