revert txn from log

This commit is contained in:
metamuffin 2024-10-31 00:19:10 +01:00
parent 82e7646230
commit efd2e6c80e
No known key found for this signature in database
GPG key ID: 718F9749DCDBD654

View file

@ -204,7 +204,7 @@ local function r_user_post(username)
log:flush()
log:close()
return string.format([[
<div class=\"notif\"><p>Transaction successful: <strong class=\"amount-%s\">%.02f€</strong> (%s)</p></div>
<div class="notif"><p>Transaction successful: <strong class="amount-%s">%.02f</strong> (%s)</p></div>
<audio src="%s" autoplay></audio>
]],
amount >= 0 and "pos" or "neg", amount / 100,
@ -277,11 +277,27 @@ local function r_log(filter)
print("<tr><th>Time</th><th>Username</th><th>Amount</th><th>Comment</th></tr>")
for time, username, amount, comment in read_log() do
if filter == nil or filter == username then
print(string.format(
"<tr><td>%d (%s ago)</td><td>%s</td><td class=\"amount-%s\">%.02f€</td><td>%s</td></tr>",
print(string.format([[
<tr>
<td>%d (%s ago)</td>
<td>%s</td>
<td class=\"amount-%s\">%.02f€</td>
<td>%s</td>
<td>
<form action="/%s" method="POST">
<input type="number" name="amount" id="amount" value="%d" hidden />
<input type="text" name="comment" id="comment" value="Revert %s" hidden />
<input type="submit" value="Revert" />
</form>
</td>
</tr>
]],
time, format_duration(os.time() - time),
escape(username),
amount >= 0 and "pos" or "neg", amount / 100,
escape(comment),
escape(username),
-amount,
escape(comment)
))
end