]> git.plutz.net Git - invoices/commitdiff
start billing section in invoices, introduce sessions for securing transmissions
authorPaul Hänsch <paul@plutz.net>
Mon, 19 Nov 2018 11:27:33 +0000 (12:27 +0100)
committerPaul Hänsch <paul@plutz.net>
Mon, 19 Nov 2018 11:27:33 +0000 (12:27 +0100)
.gitignore
cgilite
invoices.cgi
invoices.css

index 1d3e53259c8f7cf16904014080506199258f6f14..9c26be5e3c768910a3475f0c99afe66cb3c2f788 100644 (file)
@@ -2,3 +2,4 @@ clients/
 invoices/
 senders/
 .*.swp
+serverkey
diff --git a/cgilite b/cgilite
index 5c24129a2347b2be54fedfec74acc156758e3533..3fe2a9ceb477adf245f6cc8f72fb61282e42c904 160000 (submodule)
--- a/cgilite
+++ b/cgilite
@@ -1 +1 @@
-Subproject commit 5c24129a2347b2be54fedfec74acc156758e3533
+Subproject commit 3fe2a9ceb477adf245f6cc8f72fb61282e42c904
index e6a152f73b4b6a98f7e4366d44474e13850f9439..cc505d4c52f3f09f7b9296811405f4b58906d551 100755 (executable)
@@ -2,35 +2,9 @@
 
 _EXEC="$(realpath "${0%/*}")"
 . "$_EXEC/cgilite/cgilite.sh"
+. "$_EXEC/cgilite/logging.sh"
 . "$_EXEC/cgilite/storage.sh"
-
-debug(){
-  if [ $# = 0 ]; then
-    tee /dev/stderr
-  else
-    printf %s\\n "$*" >/dev/stderr
-  fi
-}
-
-timeid(){
-  # generate time based ID
-  # Fixme: Unix time stamps assumed to be 32bit always
-  d=$(date +%s)
-  { printf $(
-      while [ "$d" -gt 0 ]; do
-        printf \\%o\\n $((d % 256))
-        d=$((d / 256))
-      done |tac |tr -d \\n
-    )
-    head -c5 /dev/urandom
-  } \
-  | uuencode -m - \
-  | sed -n '2{y;+/;:_;;p}'
-}
-
-checkid(){
-  grep -m 1 -xE '[0-9a-zA-Z:_]{12}';
-}
+. "$_EXEC/cgilite/session.sh"
 
 yield_page(){
 printf 'Content-Type: text/html; charset=utf-8\r\n\r\n'
@@ -207,11 +181,29 @@ edit_invoice(){
           [radio "vat" "smallbusiness" #vatsb $([ "${vat#vat=}" = smallbusiness ] && printf checked) ]
           [label for=vatsb Small business exemption from VAT]
           [radio "vat" "nett" #vatnett $([ "${vat#vat=}" = nett ] && printf checked)]
-          [label for=vatnett Nett]<!--
-       -->[radio "vat" "gross" #vatgross $([ "${vat#vat=}" = gross ] && printf checked)]<!--
-       -->[label for=vatgross Gross]
+          [label for=vatnett Nett]
+          [radio "vat" "gross" #vatgross $([ "${vat#vat=}" = gross ] && printf checked)]
+          [label for=vatgross Gross]
           [label for=vatrate VAT Rate: [input type=number name="vatrate" value="${vatrate#vatrate=}"]% ]
 
+          [table
+            [tr [th Date] [th Work] [th Hours] [th Price] ]
+$({ sed 1d "invoices/$id"; printf 'time= work= hours=\n'; } \
+    | while read -r time work hours; do
+      hours="$(UNSTRING "${hours#hours=}" |grep -m1 -xE '[0-9]+' || printf 0)"
+      printf '[tr
+              [td [textarea name=date
+%s] ]
+              [td [textarea name=work
+%s] ]
+              [td [input type=number name=hours value="%s"] ]
+              [td %s]
+     ]' "$(UNSTRING "${time#time=}" |HTML)" \
+        "$(UNSTRING "${work#work=}" |HTML)" \
+        "$hours" "$((hours * hourly)) €"
+    done
+)
+          ]
          [submit "update" "update" Update]
        ]
        EOF
index 8892892180f68983eeecc334340634e9711fb4ea..482984d8857804a43c8751115c354be3c36fe8db 100755 (executable)
@@ -88,6 +88,7 @@ form input {
   padding: .125em .5em;
   background-color: #FFF;
   text-align: left;
+  font-size: 12pt;
 }
 form input[type=number] {
   width: 5em;
@@ -142,6 +143,10 @@ form input[type=number] {
   line-height: 2em;
 }
 
+.invoice form input#date {
+  margin-right: .25em;
+}
+
 .invoice form label::before {
   white-space: pre;
   content: '\0A';
@@ -168,3 +173,31 @@ form input[type=number] {
 .invoice form input:checked + label[for^=vat]::before {
   content: '(x) ';
 }
+
+.invoice form table {
+  width: 30em;
+  margin-top: 1em;
+  border-spacing: 0;
+}
+.invoice form table tr > th {
+  text-align: left;
+  padding-left: .5em;
+  font-weight: bold;
+}
+.invoice form table tr > th:nth-child(3),
+.invoice form table tr > td:nth-child(4),
+.invoice form table tr > th:nth-child(4) {
+  text-align: right;
+}
+.invoice form table tr > :nth-child(1) { width: 6em; }
+.invoice form table tr > :nth-child(2) { width: 12em; }
+.invoice form table tr > :nth-child(3) { width: 6em; }
+.invoice form table tr > :nth-child(4) { width: 6em; }
+.invoice form table tr > * textarea,
+.invoice form table tr > * input[type=number],
+.invoice form table tr > * input {
+  display: block;
+  font-size: 12pt;
+  width: 100%; height: 100%;
+  height: 4em;
+}