From: Paul Hänsch Date: Mon, 19 Nov 2018 11:27:33 +0000 (+0100) Subject: start billing section in invoices, introduce sessions for securing transmissions X-Git-Url: https://git.plutz.net/?a=commitdiff_plain;h=c9bb4a41908f01e2e9698d17cf1027255b53a47b;p=invoices start billing section in invoices, introduce sessions for securing transmissions --- diff --git a/.gitignore b/.gitignore index 1d3e532..9c26be5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ clients/ invoices/ senders/ .*.swp +serverkey diff --git a/cgilite b/cgilite index 5c24129..3fe2a9c 160000 --- a/cgilite +++ b/cgilite @@ -1 +1 @@ -Subproject commit 5c24129a2347b2be54fedfec74acc156758e3533 +Subproject commit 3fe2a9ceb477adf245f6cc8f72fb61282e42c904 diff --git a/invoices.cgi b/invoices.cgi index e6a152f..cc505d4 100755 --- a/invoices.cgi +++ b/invoices.cgi @@ -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 diff --git a/invoices.css b/invoices.css index 8892892..482984d 100755 --- a/invoices.css +++ b/invoices.css @@ -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; +}