_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'
[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
padding: .125em .5em;
background-color: #FFF;
text-align: left;
+ font-size: 12pt;
}
form input[type=number] {
width: 5em;
line-height: 2em;
}
+.invoice form input#date {
+ margin-right: .25em;
+}
+
.invoice form label::before {
white-space: pre;
content: '\0A';
.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;
+}