]> git.plutz.net Git - confetti/commitdiff
form submit for IBAN Assignments
authorPaul Hänsch <paul@plutz.net>
Sat, 11 May 2024 15:05:49 +0000 (17:05 +0200)
committerPaul Hänsch <paul@plutz.net>
Sat, 11 May 2024 15:05:49 +0000 (17:05 +0200)
ledgers/iban_assign.sh [new file with mode: 0755]
ledgers/index.cgi
style.css

diff --git a/ledgers/iban_assign.sh b/ledgers/iban_assign.sh
new file mode 100755 (executable)
index 0000000..cabeae7
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+printf '%s\r\n' "Content-Type: text/plain" ""
+
+for key in $(POST_KEYS); do case $key in
+  use_*)
+    use_iban="${use_iban} ${key#use_} "
+    ;;
+esac; done
+echo Use IBANS:
+echo "$use_iban"
+echo
+
+[ "$use_iban" ] && for key in $(POST_KEYS); do case $key in
+  check_*_*)
+    iban="${key#check_}" iban="${iban%_*}"
+    [ ! "${use_iban##* "${iban}" *}" ] && check="${check} ${key#check_} "
+    ;;
+esac; done
+echo Checked:
+echo "$check"
+echo
+
+for use in $check; do
+  iban="${use%_*}"
+  fn="$(POST "fn_${use}")"
+  echo Assign $iban to $fn
+done
index dbf8ee892a2b3c99454ce4a8632bf93feb131a17..685ee8516a88d449f06d8ca629f937a53cc618d2 100755 (executable)
@@ -61,21 +61,24 @@ credit() {
       amount="${record#*       *       *       *       *       }" amount="${amount%%   *}"
       printf '[p .principal . %s][p .date %s][p .amount %s][p .subject . %s]' \
              "$(UNSTRING "$principal" |HTML)" "$date" "$(credit "$amount")" "$(UNSTRING "$subject" |HTML)"
+      printf '[input type=checkbox id="use_%s" name="use_%s" value=true]' "$iban" "$iban"
       n=0; for card in $cards; do
         n=$((n+1)); uid="${card%%/*}" name="$(UNSTRING "${card#*/}")"
         cat <<-EOF
          [input type=checkbox id="check_${iban}_$n" name="check_${iban}_$n" value=true checked=checked]
-         [input .card name="fn_${iban}_$n" value="$(HTML "$name")" disabled=disabled]
+         [input .card name="fn_${iban}_$n" value="$(HTML "$name")" .disabled tabindex="-1"]
          [label .del for="check_${iban}_$n" . -]
        EOF
       done
       for m in 1 2 3 4 5 6 7 8; do
         cat <<-EOF
-         [input type=checkbox id="check_${iban}_$((n+m))" name="check_${iban}_$((n+m))" value=false]
+         [input type=checkbox id="check_${iban}_$((n+m))" name="check_${iban}_$((n+m))" value=true]
          [input .card name="fn_${iban}_$((n+m))" value="" placeholder="${l10n_attendant}" list="lattendants"]
          [label .add for="check_${iban}_$((n+m))" . +]
        EOF
       done
+      printf '[label for="use_%s" . %s]' "$iban" "$(l10n Accept Suggestions)"
+      printf '[label for="use_%s" . %s]' "$iban" "$(l10n Ignore Suggestions)"
     elif [ $state = unknown ]; then
       date="${data%%   *}"
       principal="${data#*      *       *       }" principal="${principal%%     *}"
@@ -94,5 +97,6 @@ credit() {
     fi
   printf ']'
   done
+  printf '[button type=submit . %s]' "$(l10n Submit Changes)"
   printf '  ]'
 } | yield_page ledgers
index 742163ba21d5ce1857d6af966e7b7a92f11091e0..13d41a0dd4962eb3805f17fe752002371ee897ff 100644 (file)
--- a/style.css
+++ b/style.css
@@ -403,6 +403,9 @@ form.ledgers {
   font-weight: bold;
 }
 
+.ibanassign fieldset.iban input[name^="fn_"].disabled {
+  pointer-events: none;
+}
 .ibanassign fieldset.iban input[name^="check_"],
 .ibanassign fieldset.iban input[name^="check_"] + input,
 .ibanassign fieldset.iban input[name^="check_"] + input + label {
@@ -435,3 +438,36 @@ form.ledgers {
   background-color: #FDD;
   border-radius: 0 2pt 2pt 0;
 }
+
+.ibanassign fieldset.iban input[name^="use_"] {
+  display: none;
+}
+.ibanassign fieldset.iban input[name^="use_"]:checked ~ input {
+  background-color: #DFD;
+  pointer-events: none;
+  border-color: #888;
+}
+.ibanassign fieldset.iban input[name^="use_"]:checked ~ label.del,
+.ibanassign fieldset.iban input[name^="use_"]:checked ~ label.add {
+  display: none !important;
+}
+
+.ibanassign fieldset.iban label[for^="use_"] {
+  display: block;
+  float: right;
+  padding: .25em .5em;
+  background-color: #AAF;
+  border: 1pt solid;
+}
+
+.ibanassign fieldset.iban input[name^="use_"] ~ label[for^="use_"] { display: block; }
+.ibanassign fieldset.iban input[name^="use_"] ~ label[for^="use_"] + label[for^="use_"] { display: none; }
+.ibanassign fieldset.iban input[name^="use_"]:checked ~ label[for^="use_"] { display: none; }
+.ibanassign fieldset.iban input[name^="use_"]:checked ~ label[for^="use_"] + label[for^="use_"] { display: block; }
+
+.ibanassign > button {
+  position: sticky;
+  bottom: 0;
+  margin: auto;
+  display: block;
+}