4 printf '%+04i\n' "$1" \
5 | sed -E 's;[0-9]{2}$;d&;; :0 s;([0-9])([0-9]{3}[dm]);\1m\2;; t0; y;dm;,.;'
8 if uid="$(POST uid)"; then
9 cfile="$(grep -lxF "UID;:${uid}" "${_DATA}/vcard/"*.vcf || grep -lxF "UID:${uid}" "${_DATA}/vcard/"*.vcf)"
10 REDIRECT "${_BASE}/ledgers/account.sh?card=${cfile##*/}"
13 . "${_EXEC}/cgilite/storage.sh"
14 . "${_EXEC}/pdiread.sh"
15 . "${_EXEC}/cards/l10n.sh"
16 . "${_EXEC}/cards/widgets.sh"
17 . "${_EXEC}/datetime.sh"
19 cardfile="$(GET card |PATH)" cardfile="${cardfile##*/}"
20 if [ ! -f "${_DATA}/vcard/$cardfile" ]; then
21 SET_COOKIE 0 message="Invalid account: $cardfile"
22 REDIRECT "${_BASE}/ledgers/"
25 cledger="${_DATA}/ledgers/vcf.${cardfile%.vcf}.account"
27 if tid="$(POST tid)"; then
28 if [ "$tid" != "$(transid "$cledger")" ]; then
29 SET_COOKIE 0 message="Ledger was changed since last edit"
30 REDIRECT "$REQUEST_URI"
32 tdate="$(isdate "$(POST tdate)")"
33 tref="$(POST tref |grep -m1 -xE '.+')"
34 tamount="$(POST tamount \
36 s;^([\+-]?[0-9]+)[\.,]([0-9][0-9])$;\1\2;;
37 s;^([\+-]?[0-9]+)$;&00;;
38 ' | grep -m1 -xE '[\+-]?[0-9]+')"
39 # debug "TDATE: $tdate TREF: $tref AMOUNT: $tamount"
40 if ! [ "$tdate" -a "$tref" -a "$tamount" ]; then
41 SET_COOKIE 0 message="Transaction info invalid"
42 REDIRECT "$REQUEST_URI"
44 tdtstamp="$(date -ud "$tdate" +%s)"
45 printf '%s %i %s \ %s %i\n' \
46 "${tdate}" "${tdtstamp}" "$(STRING "${cardfile%.vcf}")" \
47 "$(STRING "$tref")" "${tamount}" \
49 REDIRECT "$REQUEST_URI"
52 { card="$(pdi_load "${_DATA}/vcard/$cardfile")"
55 [div .card #${cardfile}
56 [div .section .basic . $(
57 card_item "$card" FN GENDER NICKNAME BDAY X-ZACK-JOINDATE X-ZACK-LEAVEDATE SOUND PHOTO LOGO
59 [div .section .phone . $(card_item "$card" TEL)]
60 [div .section .message . $(card_item "$card" EMAIL IMPP URL)]
61 [div .section .address . $(card_item "$card" ADR X-IBAN)]
62 [div .section .note . $(card_item "$card" NOTE)]
63 [div .section .attendance [h3 $(l10n course_attendance) ] [ul
64 $(grep -F " ${cardfile}" "$_DATA/mappings/attendance" |while read each discard; do
65 printf '[li [a .item .attendance href="%s/courses#%s" . %s]]' \
67 "$(pdi_value "$(pdi_load "$_DATA/ical/$each")" SUMMARY || l10n "(unnamed course)" |unescape |HTML)"
69 $(card_item "$card" CATEGORIES)
75 [hidden "tid" "$(transid "${cledger}")"]
78 [th .date . $(l10n Date)][th .orig . $(l10n Originator)]
79 [th .reference . $(l10n "Reference Text")]
80 [th .amount . $(l10n Amount)][th .balance . $(l10n Balance)]
84 cnt="$(pdi_count "$card" X-IBAN)"
85 { while [ "$cnt" -gt 0 ]; do
86 pdi_value "$card" X-IBAN "$cnt" |RXLITERAL
89 RXLITERAL "${cardfile%.vcf}"; echo
91 | while read -r iban; do
92 grep -hE "^[^\t]+ [^\t]+ ${iban} " "${_DATA}/ledgers/"*
96 while read -r date dtstamp iban accname reftext amount; do
97 total=$((total + amount))
98 if [ "$iban" = "${cardfile%.vcf}" ]; then
99 printf '[tr [td .date . %s][td .orig [span . %s][span . %s]][td .reference . %s]
100 [td .amount . %s][td .balance . %s]]' \
101 "$date" "$(l10n "Credit Account")" \
102 "$(UNSTRING "$accname" |HTML)" "$(UNSTRING "$reftext" |HTML)" \
103 "$(credit "$amount")" "$(credit "$total")"
105 printf '[tr [td .date . %s][td .orig [span . %s][span . %s]][td .reference . %s]
106 [td .amount . %s][td .balance . %s]]' \
107 "$date" "$(HTML "$iban")" \
108 "$(UNSTRING "$accname" |HTML)" "$(UNSTRING "$reftext" |HTML)" \
109 "$(credit "$amount")" "$(credit "$total")"
114 [tr [th colspan=5 . $(l10n 'Manual Record')]]
116 [input type=date placeholder="$(l10n Date)" name=tdate value="$(date +%F)"]
117 [input type=checkbox id=rr_month name=recur value=monthly]
118 [label for=rr_month $(l10n Recur Monthly)]
120 [td .reference . [textarea placeholder="$(l10n "Reference Text")" name=tref]]
121 [td .amount [input type=number placeholder="$(l10n Amount)" name=tamount value=0.00 step=.01]]
122 [td .balance [button type=submit . $(l10n Submit)]]