]> git.plutz.net Git - invoices/blobdiff - clients.sh
use transaction id for all updates
[invoices] / clients.sh
index fc047a2447aad54669b64e3f927631785b7aa628..474f6258538189525f60dea9dff0d2eb40f96301 100755 (executable)
@@ -14,11 +14,12 @@ edit_client(){
 %s</textarea>
       [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]+')" \
+    "$(tid "clients/$id")"
 }
 
 list_clients(){
@@ -38,13 +39,15 @@ list_clients(){
 }
 
 update_client(){
-  id="$(POST id |checkid)"
-  if [ "$(POST update)" = update -a "$id" ]; then
+  local id="$(POST id |checkid)"
+  if [ "$(POST update)" = "$(tid "clients/$id")" ]; then
     mkdir -p clients
     printf 'address=%s hourly=%s' \
       "$(POST address |STRING)" "$(POST hourly |STRING)" \
       >"clients/$id"
+    REDIRECT "/clients/"
   else
-    echo Invalid Data "$(POST id)" "$(POST update)" >&2
+    error Invalid Data "$id" "$(POST update)"
+    REDIRECT "/clients/$1"
   fi
 }