]> git.plutz.net Git - invoices/commitdiff
document list display
authorPaul Hänsch <paul@plutz.net>
Wed, 29 Nov 2023 21:46:58 +0000 (22:46 +0100)
committerPaul Hänsch <paul@plutz.net>
Wed, 29 Nov 2023 21:46:58 +0000 (22:46 +0100)
doclist.css [new file with mode: 0644]
doclist.sh [new file with mode: 0644]

diff --git a/doclist.css b/doclist.css
new file mode 100644 (file)
index 0000000..6a5d50c
--- /dev/null
@@ -0,0 +1,52 @@
+body {
+  text-align: center;
+}
+
+section#open, section#sent, section#resent,
+section#paid, section#cancelled {
+  display: block;
+  border-top: 1pt solid #AAF;
+  padding-left: 1em;
+  padding-right: 1em;
+  vertical-align: top;
+  text-align: left;
+  width: 100%;
+  max-width: 720pt;
+  margin: auto;
+  margin-top: 2em;
+}
+
+section h2 {
+  text-align: center;
+}
+
+section form.invoice {
+  display: inline-block;
+  width: 216pt;
+  background-color: #FFF;
+  padding: 0 .5em .375em .5em;
+  box-shadow: .25em .25em .5em #888;
+}
+section form.invoice span {
+  display: block;
+}
+
+section form.invoice.new {
+  padding-top: .5em;
+}
+section form.invoice.new label[for=new_type] {
+  display: none;
+}
+
+@media(min-width: 720pt) {
+  section#open, section#sent, section#resent {
+    display: inline-block;
+    width: 240pt;
+    max-width: 33%;
+    border-top: none;
+    border-left: 1pt solid #AAF;
+  }
+  section#resent {
+    border-right: 1pt solid #AAF;
+  }
+}
diff --git a/doclist.sh b/doclist.sh
new file mode 100644 (file)
index 0000000..d31619d
--- /dev/null
@@ -0,0 +1,64 @@
+#!/bin/sh
+
+printf '%s\r\n' "Content-Type: text/html; charset=utf-8" ""
+
+list_status() {
+  local status=$1
+
+  grep -lxF "status    ${status}" "$_DATA"/*.kvd \
+  | while read file; do
+    id="${file##*/}" id="${id%.kvd}"
+    DB3 open "$file" || continue
+    cat <<-EOF
+       [form .invoice method=POST
+         [h3 [a href="/doc/${id}" . $(DB3 get number || printf ????)]]
+         [span .date . $(DB3 get date || printf ????-??-??)]
+         [span .rcpt . $(DB3 get rcpt || printf ?)]
+         [span .total . $(DB3 get total || printf '?') €]
+         [select name=status
+           [option value=open   $([ "$status" = open   ] && printf selected=selected) . $(_ Open)]
+           [option value=sent   $([ "$status" = sent   ] && printf selected=selected) . $(_ Sent)]
+           [option value=resent $([ "$status" = resent ] && printf selected=selected) . $(_ Reminded)]
+           [option value=paid   $([ "$status" = paid   ] && printf selected=selected) . $(_ Paid)]
+           [option value=cancelled $([ "$status" = cancelled ] && printf selected=selected) . $(_ Cancelled)]
+         ]
+         [input type=hidden name=id value="$id"]
+         [input type=hidden name=tid value="$(transid "$file")"]
+         [input type=hidden name=session_key value="$SESSION_KEY"]
+         [button type=submit name=action value=update_invoice . $(_ Update)]
+       ]
+       EOF
+  done
+}
+
+"$_EXEC/cgilite/html-sh.sed" <<EOF
+[html [head
+  [meta name="viewport" content="width=device-width"]
+  [link rel="stylesheet" type="text/css" href="/cgilite/common.css"]
+  [link rel="stylesheet" type="text/css" href="/doclist.css"]
+  [title $(_ Invoices)]
+] [body
+  [section #open   [h2 . $(_ Open)]
+    [form .invoice .new method=POST
+      [label for=new_type . $(_ Type):]
+      [select #new_type name=type
+        [option selected=selected]
+        $(for tmpl in "$_EXEC"/tmpl_*/; do
+          tmpl="${tmpl%/}" tmpl="${tmpl##*/}"
+          printf '[option value=%s . %s]' "$tmpl" "$(_ "$tmpl")"
+        done)
+      ]
+      [button type=submit name=action value=new_invoice . $(_ New)]
+    ]
+    $(list_status open)
+  ][section #sent   [h2 . $(_ Sent)]
+    $(list_status sent)
+  ][section #resent [h2 . $(_ Reminded)]
+    $(list_status resent)
+  ][section #paid   [h2 . $(_ Paid)]
+    $(list_status paid)
+  ][section #cancelled [h2 . $(_ Cancelled)]
+    $(list_status cancelled)
+  ]
+] ]
+EOF