X-Git-Url: http://git.plutz.net/?p=invoices;a=blobdiff_plain;f=clients.sh;h=052a0c84c897f82a38bbe4b82ad7b86f285442be;hp=fc047a2447aad54669b64e3f927631785b7aa628;hb=HEAD;hpb=de8eaf901067d4e0c72e5b0ca05f6dc12553fd79 diff --git a/clients.sh b/clients.sh index fc047a2..052a0c8 100755 --- a/clients.sh +++ b/clients.sh @@ -14,11 +14,12 @@ edit_client(){ %s [label for=hourly Hourly Rate:] [input #hourly type=number name=hourly value="%s"] - [submit "update" "update" Update] + [submit "update" "%s" Update] ]' \ "$(HTML $id)" \ "$(UNSTRING "${address#address=}" |HTML)" \ - "$(UNSTRING "${hourly#hourly=}" |grep -xE '[0-9]+')" + "$(UNSTRING "${hourly#hourly=}" |grep -xE '[0-9]+')" \ + "$(transid "clients/$id")" } list_clients(){ @@ -38,13 +39,21 @@ list_clients(){ } update_client(){ - id="$(POST id |checkid)" - if [ "$(POST update)" = update -a "$id" ]; then + local id="$(POST id |checkid)" + if [ "$(POST update)" = "$(transid "clients/$id")" ]; then mkdir -p clients printf 'address=%s hourly=%s' \ "$(POST address |STRING)" "$(POST hourly |STRING)" \ >"clients/$id" + + [ -d .git ] && { + git add "clients/$id" + git commit -m 'Update client info for "'"$(POST address |sed 1q)"'"' -- "clients/$id" + } >/dev/null + + REDIRECT "/clients/" else - echo Invalid Data "$(POST id)" "$(POST update)" >&2 + error Invalid Data "$id" "$(POST update)" + REDIRECT "/clients/$1" fi }