]> git.plutz.net Git - confetti/blobdiff - templates/edit_client.sh
enable drawing via android-4, quicker drawing via lines
[confetti] / templates / edit_client.sh
index 049f251da7a56e804ffb32f9e0ba427aab308562..2b0c004bf07e0daeb5728f9c032c02b86a9c0320 100755 (executable)
 # 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"'
+}
+setselected() {
+  printf 'selected="selected"'
+}
 check_gen() {
-  [ "$values[GENDER]" = "$1" ] && echo 'selected="selected"'
+  [ "$values[GENDER]" = "$1" ] && setselected
 }
 check_a() {
-  egrep -q "^${1}.${id}$" "$_DATA/mappings/attendance" && echo 'checked="checked"'
+  egrep -q "^${1}.${id}$" "$_DATA/mappings/attendance" && setchecked
+}
+teltype() {
+  cat <<-EOF
+       <select class="item phonetype" name="phonetype">
+         <option value="" disabled="disabled" $([ -z "$1" ] && setselected )>$(l10n phone_typeselect)</option>
+         <option value=""></option>
+         <option value="HOME" $([ "$1" = HOME ] && setselected)>$(l10n phone_home)</option>
+         <option value="CELL" $([ "$1" = CELL ] && setselected)>$(l10n phone_cell)</option>
+         <option value="WORK" $([ "$1" = WORK ] && setselected)>$(l10n phone_work)</option>
+         <option value="FAX"  $([ "$1" = FAX  ] && setselected)>$(l10n phone_fax )</option>
+       </select>
+       EOF
 }
 
 n_last="$(printf %s "$values[N]" |sed -rn 's:^([^;]*;){0} *([^;]*).*$:\2:p')"
@@ -28,8 +46,9 @@ n_middle="$(printf %s "$values[N]" |sed -rn 's:^([^;]*;){2} *([^;]*).*$:\2:p')"
 n_pre="$(printf %s "$values[N]" |sed -rn 's:^([^;]*;){3} *([^;]*).*$:\2:p')"
 n_post="$(printf %s "$values[N]" |sed -rn 's:^([^;]*;){4} *([^;]*)*$:\2:p')"
 
-hi_number="${values[X-HEALTH-INSURANCE]%;*}"
-hi_company="${values[X-HEALTH-INSURANCE]#*;}"
+hi_company="$(printf %s "${values[X-HEALTH-INSURANCE]}" |cut -d\; -f1)"
+hi_number="$(printf %s "${values[X-HEALTH-INSURANCE]}" |cut -d\; -f2)"
+hi_status="$(printf %s "${values[X-HEALTH-INSURANCE]}" |cut -d\; -f3)"
 
 SUP_FIELDS=(N NICKNAME GENDER BDAY ADR TEL EMAIL X-HEALTH-INSURANCE X-HEALTH-INSURANCE-NOCONTRIB IMPP URL NOTE X-CLIENT-REFERRAL)
 
@@ -59,7 +78,7 @@ cat <<END_HTML
     done)
 
     <h3>$(l10n BDAY)</h3>
-    <input class="item BDAY" name="BDAY" value="$values[BDAY]" />
+    <input class="item BDAY" name="BDAY" value="$values[BDAY]" placeholder="YYYY-MM-DD" />
 
     $(if [ -n "$values[SOUND]" ]; then
       echo '    <audio controls="controls" class="item SOUND">'
@@ -84,13 +103,13 @@ cat <<END_HTML
 
   <div class="section phone">
     <h3>$(l10n TEL)</h3>
-    <input class="item TEL" name="TEL" value="$values[TEL]" />
+    $(teltype "${tags[TEL_TYPE]}")<input class="item TEL" name="TEL" value="$values[TEL]" />
     $(for n in TEL{0..10}; do
-      echo "${values[$n]:+<input class="item TEL" name="TEL" value="'$values[$n]'" />}"
+      printf "${values[$n]:+$(teltype "${tags[$n_TYPE]}")<input class="item TEL" name="TEL" value="'$values[$n]'" />}"
     done)
     ${values[EMAIL]:+<h3>$(l10n EMAIL)</h3>}
     $(for n in EMAIL EMAIL{0..10}; do
-      echo "${values[$n]:+<input class="item EMAIL" name="EMAIL" value="$values[$n]" />}"
+      printf "${values[$n]:+<input class="item EMAIL" name="EMAIL" value="$values[$n]" />}"
     done)
     ${values[IMPP]:+<h3>$(l10n IMPP)</h3>}
     $(for n in IMPP IMPP{0..10}; do
@@ -100,11 +119,19 @@ cat <<END_HTML
 
   <div class="section insurance">
     <h3>$(l10n X-HEALTH-INSURANCE)</h3>
+    <input type="radio" name="hi_select" value="list" id="hi_select_list" checked /><label for="hi_select_list">$(l10n hi_from_list)</label><!--
+    --><input type="radio" name="hi_select" value="other" id="hi_other"><label for="hi_other">$(l10n hi_other)</label>
     <select class="item" name="hi_company">
-      <option value="" disabled="disabled" selected="selected">$(l10n hi_company)</option>
-      $(list_hi_companies |while read f; do echo "<option value=\"$f\">$(l10n $f)</option>"; done)
+      <option value="" disabled="disabled" ${hi_company:-selected}>$(l10n hi_company)</option>
+      $(list_hi_companies |while read f; do
+        [ "$f" = "$hi_company" ] \
+        && printf '<option value="%s" selected>%s</option>' "$f" "$f" \
+        || printf '<option value="%s">%s</option>' "$f" "$f"
+      done)
     </select>
-    <input class="item hi_number" name="hi_number" value="$hi_number" placeholder="$(l10n hi_number)" />
+    <input type="text" name="hi_other" value="$hi_company" placeholder="$(l10n hi_company)" />
+    <input name="hi_number" value="$hi_number" placeholder="$(l10n hi_number)" />
+    <input name="hi_status" value="$hi_status" placeholder="$(l10n hi_status)" />
 
   </div>