]> git.plutz.net Git - confetti/blob - templates/edit_client.sh
reduce number of pre filled text fields, show more prescription info in therapy
[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 setchecked() {
19   printf 'checked="checked"'
20 }
21 setselected() {
22   printf 'selected="selected"'
23 }
24 check_gen() {
25   [ "$values[GENDER]" = "$1" ] && setselected
26 }
27 check_a() {
28   egrep -q "^${1}.${id}$" "$_DATA/mappings/attendance" && setchecked
29 }
30 teltype() {
31   cat <<-EOF
32         <select class="item phonetype" name="phonetype">
33           <option value="" disabled="disabled" $([ -z "$1" ] && setselected )>$(l10n phone_typeselect)</option>
34           <option value=""></option>
35           <option value="HOME" $([ "$1" = HOME ] && setselected)>$(l10n phone_home)</option>
36           <option value="CELL" $([ "$1" = CELL ] && setselected)>$(l10n phone_cell)</option>
37           <option value="WORK" $([ "$1" = WORK ] && setselected)>$(l10n phone_work)</option>
38           <option value="FAX"  $([ "$1" = FAX  ] && setselected)>$(l10n phone_fax )</option>
39         </select>
40         EOF
41 }
42
43 n_last="$(printf %s "$values[N]" |sed -rn 's:^([^;]*;){0} *([^;]*).*$:\2:p')"
44 n_first="$(printf %s "$values[N]" |sed -rn 's:^([^;]*;){1} *([^;]*).*$:\2:p')"
45 n_middle="$(printf %s "$values[N]" |sed -rn 's:^([^;]*;){2} *([^;]*).*$:\2:p')"
46 n_pre="$(printf %s "$values[N]" |sed -rn 's:^([^;]*;){3} *([^;]*).*$:\2:p')"
47 n_post="$(printf %s "$values[N]" |sed -rn 's:^([^;]*;){4} *([^;]*)*$:\2:p')"
48
49 hi_company="$(printf %s "${values[X-HEALTH-INSURANCE]}" |cut -d\; -f1)"
50 hi_number="$(printf %s "${values[X-HEALTH-INSURANCE]}" |cut -d\; -f2)"
51 hi_status="$(printf %s "${values[X-HEALTH-INSURANCE]}" |cut -d\; -f3)"
52
53 SUP_FIELDS=(N NICKNAME GENDER BDAY ADR TEL EMAIL X-HEALTH-INSURANCE X-HEALTH-INSURANCE-NOCONTRIB IMPP URL NOTE X-CLIENT-REFERRAL)
54
55 [ -z "$values[UID]" ] && values[UID]="$(uuidgenerator)"
56
57 cat <<END_HTML
58 <form id="$id" class="card" action="?action=update_card" method="POST">
59   <input type="hidden" name="card" value="${id}"/>
60   <div class="section basic">
61     <h3>$(l10n N)</h3>
62     <input class="item N" name="3N" placeholder="$(l10n n_pre)" value="$n_pre" />
63     <input class="item N" name="1N" placeholder="$(l10n n_first)" value="$n_first" />
64     <input class="item N" name="2N" placeholder="$(l10n n_middle)" value="$n_middle" />
65     <input class="item N" name="0N" placeholder="$(l10n n_last)" value="$n_last" />
66     <input class="item N" name="4N" placeholder="$(l10n n_post)" value="$n_post" />
67
68     <select class="item GENDER" name="GENDER">
69       <option value="" disabled="disabled">$(l10n GENDER)</option>
70       <option value="female" $(check_gen female)>$(l10n gender_female)</option>
71       <option value="male" $(check_gen male)>$(l10n gender_male)</option>
72       <option value="other" $(check_gen other)>$(l10n gender_other)</option>
73       <option value="none" $(check_gen none)>$(l10n gender_none)</option>
74     </select>
75
76     $(for n in NICKNAME NICKNAME{0..10}; do
77       echo "${values[$n]:+<input class="item NICKNAME" name="NICKNAME" placeholder="$(l10n NICKNAME)" value="$values[$n]" />}"
78     done)
79
80     <h3>$(l10n BDAY)</h3>
81     <input class="item BDAY" name="BDAY" value="$values[BDAY]" placeholder="YYYY-MM-DD" />
82
83     $(if [ -n "$values[SOUND]" ]; then
84       echo '    <audio controls="controls" class="item SOUND">'
85       echo '      <source type="audio/ogg" src="data:audio/ogg;base64,'$values[SOUND]'" />'
86       echo '    </audio>'
87     fi)
88     ${values[PHOTO]:+<img class="item PHOTO" src="data:image/$tags[PHOTO_TYPE];base64,$values[PHOTO]" />}
89     ${values[LOGO]:+<img class="item LOGO" src="data:image/$tags[LOGO_TYPE];base64,$values[LOGO]" />}
90   </div>
91
92   <div class="section address">
93     <h3>$(l10n ADR)</h3>
94     <textarea class="item ADR" name="ADR">$values[ADR]</textarea>
95     $(for n in ADR{0..10}; do
96       echo "${values[$n]:+<textarea class="item ADR" name="ADR">$values[$n]</textarea>}"
97     done)
98     ${values[URL]:+<h3>$(l10n URL)</h3>}
99     $(for n in URL URL{0..10}; do
100       echo "${values[$n]:+<input class="item URL" name="URL" value="$values[$n]" />}"
101     done)
102   </div>
103
104   <div class="section phone">
105     <h3>$(l10n TEL)</h3>
106     $(teltype "${tags[TEL_TYPE]}")<input class="item TEL" name="TEL" value="$values[TEL]" />
107     $(for n in TEL{0..10}; do
108       printf "${values[$n]:+$(teltype "${tags[$n_TYPE]}")<input class="item TEL" name="TEL" value="'$values[$n]'" />}"
109     done)
110     ${values[EMAIL]:+<h3>$(l10n EMAIL)</h3>}
111     $(for n in EMAIL EMAIL{0..10}; do
112       printf "${values[$n]:+<input class="item EMAIL" name="EMAIL" value="$values[$n]" />}"
113     done)
114     ${values[IMPP]:+<h3>$(l10n IMPP)</h3>}
115     $(for n in IMPP IMPP{0..10}; do
116       echo "${values[$n]:+<input class="item IMPP" name="IMPP" value="$values[$n]" />}"
117     done)
118   </div>
119
120   <div class="section insurance">
121     <h3>$(l10n X-HEALTH-INSURANCE)</h3>
122     <input type="radio" name="hi_select" value="list" id="hi_select_list" checked /><label for="hi_select_list">$(l10n hi_from_list)</label><!--
123     --><input type="radio" name="hi_select" value="other" id="hi_other"><label for="hi_other">$(l10n hi_other)</label>
124     <select class="item" name="hi_company">
125       <option value="" disabled="disabled" ${hi_company:-selected}>$(l10n hi_company)</option>
126       $(list_hi_companies |while read f; do
127         [ "$f" = "$hi_company" ] \
128         && printf '<option value="%s" selected>%s</option>' "$f" "$f" \
129         || printf '<option value="%s">%s</option>' "$f" "$f"
130       done)
131     </select>
132     <input type="text" name="hi_other" value="$hi_company" placeholder="$(l10n hi_company)" />
133     <input name="hi_number" value="$hi_number" placeholder="$(l10n hi_number)" />
134     <input name="hi_status" value="$hi_status" placeholder="$(l10n hi_status)" />
135
136   </div>
137
138   <div class="section note">
139     <h3>$(l10n NOTE)</h3>
140     <textarea class="item NOTE" name="NOTE">$values[NOTE]</textarea>
141     $(for n in NOTE{0..10}; do
142       echo "${values[$n]:+<textarea class="item NOTE" name="NOTE">$values[$n]</textarea>}"
143     done)
144     <h3>$(l10n X-CLIENT-REFERRAL)</h3>
145     <input class="item X-CLIENT-REFERRAL" name="X-CLIENT-REFERRAL" value="$values[X-CLIENT-REFERRAL]" />
146     $(for n in X-CLIENT-REFERRAL{0..10}; do
147       echo "${values[$n]:+<input class="item X-CLIENT-REFERRAL" name="X-CLIENT-REFERRAL" value="'$values[$n]'" />}"
148     done)
149   </div>
150
151   <div class="control">
152     <select class="item" name="newfield">
153       <option value="" disabled="disabled" selected="selected">$(l10n edit_addfieldtext)</option>
154       $(for f in $SUP_FIELDS; do echo "<option value=\"$f\">$(l10n $f)</option>"; done)
155     </select
156     ><button class="item" type="submit" name="action" value="addfield">$(l10n edit_addfield)</button>
157     <button class="item" type="submit" name="action" value="update">$(l10n edit_update)</button>
158     <button class="item" type="submit" name="action" value="delete">$(l10n edit_delete)</button>
159     <button class="item" type="submit" name="action" value="cancel">$(l10n edit_cancel)</button>
160   </div>
161   <input type="hidden" name="UID" value="$values[UID]"/>
162 </form>
163 END_HTML