enable support for phone number types
[confetti] / templates / edit_client.sh
index 586fa69..2b0c004 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')"
@@ -85,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