]> git.plutz.net Git - confetti/commitdiff
always show 22 lines in export, show line numbers, show years master
authorPaul Hänsch <paul@plutz.net>
Mon, 13 Oct 2025 11:19:15 +0000 (13:19 +0200)
committerPaul Hänsch <paul@plutz.net>
Mon, 13 Oct 2025 11:19:15 +0000 (13:19 +0200)
courses/export_pdf.sh

index 10230b89c8457281a09d8c0fba8549cb75986cd4..d9f423a6219297b0eb61e6cf281833d4b683e6a0 100755 (executable)
@@ -64,13 +64,14 @@ get_dates() {
 
   while [ "$dts_date" -lt "$today" ]; do dts_date="$(date -d "${dts_date} + ${rec}" +%Y%m%d)"; done
   for n in 1 2 3 4 5 6 7 8 9 10; do
-    LANG=de_DE.UTF-8 date -d "$dts_date" +"%d. %b."
+    LANG=de_DE.UTF-8 date -d "$dts_date" +"%Y  %d. %b."
     dts_date="$(date -d "${dts_date} + ${rec}" +%Y%m%d)"
   done
 }
 
 # some table styles need to be inline, because this is how libreoffice works
-style_td='style="border: 1pt solid; padding: 1mm 2mm; vertical-align: top;"'
+style_td='style="border: 0.5pt solid; padding: 0mm 1.5mm; vertical-align: top;"'
+linecnt="$(grep -F "${coursefile##*/}  " "$_DATA/mappings/attendance" |wc -l)"
 
 "$_EXEC/cgilite/html-sh.sed" <<-EOF >"$htmlfile"
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
@@ -83,7 +84,7 @@ style_td='style="border: 1pt solid; padding: 1mm 2mm; vertical-align: top;"'
   [style type="text/css"
     @page { size: 29.7cm 21cm; margin: 1.5cm; }
     * { background: inherit; }
-    body { background: transparent; font-family: Liberation Sans, Sans-Serif; }
+    body { background: transparent; font-family: Liberation Sans, Sans-Serif; font-size: 12pt; }
 
     th { white-space: pre; }
     th, td { text-align: left; }
@@ -111,19 +112,32 @@ style_td='style="border: 1pt solid; padding: 1mm 2mm; vertical-align: top;"'
       done |sort |while read -r line; do
         attno=$((${attno-0} + 1))
         printf '%s%2i%s\n' "${line%%@@No@@*}" $attno "${line#*@@No@@}"
+    done
+    seq $((linecnt + 1)) 22 |while read n; do
+      printf '[tr [td %s .No %i] [td %s .N] [td %s .BDAY] [td %s .TEL] [td %s .NOTE]]\n' \
+             "${style_td%\"} text-align: right;\"" "$n" "$style_td" "$style_td" "$style_td" "$style_td"
       done)]
   ]
+  [h2 style="text-align: center;" . Jahr $(get_dates |cut -f1 |uniq |sed '2,$i/')]
   [table width="100%"
-    [col width=30*] [col width=10*] [col width=10*] [col width=10*] [col width=10*] [col width=10*] [col width=10*] [col width=10*] [col width=10*] [col width=10*] [col width=10*]
+    [col width=5*] [col width=30*] [col width=10*] [col width=10*] [col width=10*] [col width=10*] [col width=10*] [col width=10*] [col width=10*] [col width=10*] [col width=10*] [col width=10*]
     [thead
-      [tr [th $style_td ] $(get_dates |xargs -d\\n printf "[th $style_td . %s]")]
+      [tr [th] [th] $(get_dates |cut -f2- |xargs -d\\n printf "[th $style_td . %s]")]
     ][tbody
     $(grep -F "${coursefile##*/}       " "$_DATA/mappings/attendance" |while read discard each; do
       vcf="$(pdi_load "$_DATA/vcard/$each")"
-      printf '[tr [td %s .N . %s] [td %s] [td %s] [td %s] [td %s] [td %s] [td %s] [td %s] [td %s] [td %s] [td %s]]\n' \
-             "$style_td" "$(pdi_value "$vcf" FN |unescape |HTML)" \
+      printf '[tr [td %s .No @@No@@] [td %s .N . %s] [td %s] [td %s] [td %s] [td %s] [td %s] [td %s] [td %s] [td %s] [td %s] [td %s]]\n' \
+             "${style_td%\"} text-align: right;\"" "$style_td" "$(pdi_value "$vcf" FN |unescape |HTML)" \
              "$style_td" "$style_td" "$style_td" "$style_td" "$style_td" "$style_td" "$style_td" "$style_td" "$style_td" "$style_td"
-    done |sort)]
+    done |sort |while read -r line; do
+      attno=$((${attno-0} + 1))
+      printf '%s%2i%s\n' "${line%%@@No@@*}" $attno "${line#*@@No@@}"
+    done
+    seq $((linecnt + 1)) 22 |while read n; do
+      printf '[tr [td %s .No %i] [td %s .N ] [td %s] [td %s] [td %s] [td %s] [td %s] [td %s] [td %s] [td %s] [td %s] [td %s]]\n' \
+             "${style_td%\"} text-align: right;\"" "$n" "$style_td" \
+             "$style_td" "$style_td" "$style_td" "$style_td" "$style_td" "$style_td" "$style_td" "$style_td" "$style_td" "$style_td"
+    done)]
   ]
 ]]
 EOF