provide info about health insurance in card view
authorpaul <paul@plutz.net>
Sun, 14 Feb 2016 19:19:52 +0000 (19:19 +0000)
committerpaul <paul@plutz.net>
Sun, 14 Feb 2016 19:19:52 +0000 (19:19 +0000)
svn path=/trunk/; revision=79

actions/update_card.sh
pages/cards.sh
templates/attendees.css.sh
templates/edit_client.sh
templates/view_client.sh

index 1be1676..a810476 100755 (executable)
@@ -34,8 +34,10 @@ _POST[1N]="${_POST[1N]//;/,}"
 _POST[2N]="${_POST[2N]//;/,}"
 _POST[3N]="${_POST[3N]//;/,}"
 _POST[4N]="${_POST[4N]//;/,}"
-[ -n "${_POST[hi_number]}" -o -n "${_POST[hi_company]}" ] \
-&& _POST[X-HEALTH-INSURANCE]="${_POST[hi_number]//;/,};${_POST[hi_company]//;/,}"
+
+[ "$_POST[hi_select]" = "list" ] && hi_company="${_POST[hi_company]}" || hi_company="${_POST[hi_other]}"
+[ -n "${_POST[hi_company]}${_POST[hi_number]}${_POST[hi_status]}" ] \
+&& _POST[X-HEALTH-INSURANCE]="${hi_company//;/,};${_POST[hi_number]//;/,};${_POST[hi_status]//;/,}"
 
 sed -r 's;$;\r;' >"$tempfile" <<EOF
 BEGIN:VCARD
index c045b5b..d1170b0 100755 (executable)
@@ -26,6 +26,10 @@ listcourses() {
   done |sort |sed -r 's:^.*\t(.*/)([^/]+)$:\2:'
 }
 
+list_hi_companies(){
+  sed -rn 's;^X-HEALTH-INSURANCE:([^\;]+)\;.*$;\1;p' ${_DATA}/vcard/*vcf
+}
+
 listcards() {
   case "${_GET[filtertype]}" in
     any)
index 58896fa..1544d86 100755 (executable)
@@ -143,6 +143,11 @@ cat <<EOF
   word-wrap: break-word;
 }
 
+form.card .section input[type=text],
+form.card .section input:not([type]),
+form.card .section textarea,
+form.card .section select {width: 100%;}
+
 form.card .attendance {
   min-width: 66%;
 }
@@ -157,6 +162,32 @@ form.card .attendance label input[type=checkbox] {
   margin-left: -3ex;
 }
 
+form.card .insurance input[type=radio] {display: none;}
+form.card .insurance input[type=radio] + label {
+  display: inline-block;
+  width: 50%;
+  padding: .25ex 0;
+  text-align: center;
+  border: 1px solid black;
+  
+}
+form.card .insurance input[type=radio]:checked + label {
+  font-weight: bold;
+  background-color: #FFF;
+  border-width: 1px 1px 0 1px;
+}
+form.card .insurance input[type=radio] + label + input + label + select,
+form.card .insurance input[type=radio] + label + select + input {display: none;}
+form.card .insurance input[type=radio]:checked + label + input + label + select,
+form.card .insurance input[type=radio]:checked + label + select + input {
+  display: block;
+  border: 1px solid black;
+  border-width: 0 1px 1px 1px;
+  padding: .25ex 0;
+  margin-top: -1px;
+  background-color: #FFF;
+}
+
 .card .section .item {
   display: block;
   max-width: 100%;
@@ -178,7 +209,6 @@ form.card .attendance label input[type=checkbox] {
   max-height: 10em;
 }
 
-
 EOF
 
 # vi:set filetype=css:
index 049f251..586fa69 100755 (executable)
@@ -28,8 +28,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 +60,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">'
@@ -100,11 +101,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>
 
index 47d6d21..4860e85 100755 (executable)
@@ -21,8 +21,10 @@ n=$(printf %s "$values[N]" \
    )
 fullname="${n:-${values[FN]:-${values[NICKNAME]}}}"
 
-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)"
+
 
 cat <<END_HTML
   <div class="section basic">
@@ -71,6 +73,7 @@ cat <<END_HTML
     <h3>$(l10n X-HEALTH-INSURANCE)</h3>
     ${hi_company:+<span class="item hi_comapany">${hi_company}</span>}
     ${hi_number:+<span class="item hi_number"><label>$(l10n hi_number):</label> ${hi_number}</span>}
+    ${hi_status:+<span class="item hi_status"><label>$(l10n hi_status):</label> ${hi_status}</span>}
   </div><!--
 
   --><div class="section note">