X-Git-Url: http://git.plutz.net/?p=invoices;a=blobdiff_plain;f=senders.sh;h=8c98737a39b4195ad681172777eb734753fffb87;hp=4d1f6121661d56c79f81ec5e1d563dc470d5cb94;hb=b037f9960718351b0470ab7ea67271b291bebb0e;hpb=363a64cdc01d34e8b1e9ba3bf4b1a68ae2dfeb1c diff --git a/senders.sh b/senders.sh index 4d1f612..8c98737 100755 --- a/senders.sh +++ b/senders.sh @@ -1,11 +1,16 @@ #!/bin/sh edit_sender(){ - id="$1" - if [ -f "senders/$id" ]; then - address="$(cat "senders/$id")" - fi - [ "$address" ] || address="Name + local id="$1" address iban bic + [ -f "senders/$id" ] \ + && read -r address iban bic <"senders/$id" + + iban="$(UNSTRING "${iban#iban=}")" + bic="$(UNSTRING "${bic#bic=}")" + + [ "${address#address=}" ] \ + && address="$(UNSTRING "${address#address=}")" \ + || address="Name Street City @@ -19,17 +24,23 @@ xxx / 000 / ### [form method="POST" action="/update_sender" [hidden "id" "%s"] + [label IBAN:][input name=iban value="%s" placeholder=IBAN] + [label BIC:][input name=bic value="%s" placeholder=BIC] [submit "update" "%s" Update] ]' \ - "$(HTML $id)" \ - "$(HTML "${address}")" \ + "$(HTML $id)" "$(HTML "${address}")" \ + "$(HTML "${iban}")" "$(HTML "${bic}")" \ "$(tid "senders/$id")" } list_senders(){ [ -d senders/ ] && for s in senders/*; do - address=$(cat "$s") - [ "$address" ] || address="(no address)" + read -r address iban bic <"$s" + + [ "${address#address=}" ] \ + && address="$(UNSTRING "${address#address=}")" \ + || address="(no address)" + printf '[div .sender .address %s[a href="/senders/%s" Edit]] ' "$(HTML "$address")" "$(HTML "${s#senders/}")" @@ -40,7 +51,9 @@ update_sender(){ id="$(POST id |checkid)" if [ "$(POST update)" = "$(tid "senders/$id")" ]; then mkdir -p senders - POST address >"senders/$id" + printf 'address=%s iban=%s bic=%s\n' \ + $(POST address |STRING) $(POST iban |STRING) \ + $(POST bic |STRING) >"senders/$id" REDIRECT "/senders/" else REDIRECT "/senders/$id"