allow additional remedies to be prescribed
[confetti] / templates / edit_prescription.sh
index 8ac9bb7..285739a 100755 (executable)
@@ -113,16 +113,28 @@ cat <<END_HTML
 <label for="quantity">$(l10n quantity)</label>
 <label for="remidy">$(l10n remidy)</label>
 <label for="quantity_weekly">$(l10n quantity_weekly)</label>
+<p>
 <input id="quantity" name="quantity" value="${mpx[quantity]}" placeholder="$(l10n quantity)">
 <textarea id="remidy" name="remidy" placeholder="$(l10n remidy)">${mpx[remidy]}</textarea>
 <input id="quantity_weekly" name="quantity_weekly" value="${mpx[quantity_weekly]}" placeholder="$(l10n quantity_weekly)">
+</p>
+
+$( for n in {0..10}; do
+  if [ "$n" -eq 0 -o -n "${mpx[quantity$n]}" -o -n "${mpx[remidy$n]}" -o -n "${mpx[quantity_weekly$n]}" ]; then
+    printf '<input type="checkbox" checked="checked">'
+  else
+    printf '<input type="checkbox">'
+  fi
+  printf '<p>
+    <input class="quantity" name="quantity" placeholder="%s" value="%s">
+    <textarea class="remidy" name="remidy" placeholder="%s">%s</textarea>
+    <input class="quantity_weekly" name="quantity_weekly" placeholder="%s" value="%s">
+    </p>
+  ' "$(l10n quantity)" "${mpx[quantity$n]}" \
+    "$(l10n remidy)" "${mpx[remidy$n]}" \
+    "$(l10n quantity_weekly)" "${mpx[quantity_weekly$n]}"
+done )
 
-<label for="quantity1">$(l10n quantity)</label>
-<label for="remidy1">$(l10n remidy)</label>
-<label for="quantity_weekly1">$(l10n quantity_weekly)</label>
-<input id="quantity1" name="quantity1" value="${mpx[quantity1]}" placeholder="$(l10n quantity)">
-<textarea id="remidy1" name="remidy1" placeholder="$(l10n remidy)">${mpx[remidy1]}</textarea>
-<input id="quantity_weekly1" name="quantity_weekly1" value="${mpx[quantity_weekly1]}" placeholder="$(l10n quantity_weekly)">
 
 <br>
 <p class="indicator_codes">