aboutsummaryrefslogtreecommitdiff
path: root/abrechenbarkeit.lua
diff options
context:
space:
mode:
Diffstat (limited to 'abrechenbarkeit.lua')
-rwxr-xr-xabrechenbarkeit.lua56
1 files changed, 31 insertions, 25 deletions
diff --git a/abrechenbarkeit.lua b/abrechenbarkeit.lua
index 8eedccd..ae1b38a 100755
--- a/abrechenbarkeit.lua
+++ b/abrechenbarkeit.lua
@@ -60,7 +60,7 @@ local function get_user_theme(username)
if username == "_jeb" then
c = "html { animation: 2s jeb infinite; }"
c = c .. "@keyframes jeb {\n"
- for i=0,100 do
+ for i = 0, 100 do
c = c .. string.format("%.02f%% { --hue: %.02f; } \n", i, i / 100 * 360)
end
c = c .. "\n}"
@@ -71,7 +71,7 @@ local function get_user_theme(username)
end
local function respond(status, title, body)
- local themecss, themejs = get_user_theme(path and path:sub(2))
+ local themecss, themejs = get_user_theme(path and path:sub(2))
print(string.format("Status: %d", status))
print("Content-Type: text/html")
@@ -101,14 +101,14 @@ local function respond(status, title, body)
]],
escape(title),
stylesheet, -- style.css
- themecss, -- theme for user
- script, -- script.js
+ themecss, -- theme for user
+ script, -- script.js
config.head_extra or ""
))
body()
print(string.format(
- "<script>%s</script></body></html>",
- themejs
+ "<script>%s</script></body></html>",
+ themejs
))
end
@@ -227,20 +227,20 @@ local function r_user_post(username)
if data.pcode then
for p_barcode, p_amount, p_name, p_owner in read_products() do
if p_barcode == data.pcode then
- powner = p_owner
+ powner = p_owner
pcount = (tonumber(data.pcount) or 1) * (data.negate_pcount ~= nil and -1 or 1)
pcode = p_barcode
if amount == nil then amount = pcount * p_amount end
if comment == nil then
- comment = string.format("%s %d %s", pcount < 0 and "Buy" or "Restock",
+ comment = string.format("%s %d %s", pcount < 0 and "Buy" or "Restock",
math.abs(pcount), p_name)
-
- powner_comment = string.format("%s %d %s %s %s",
- pcount < 0 and "Sell" or "Restock",
- math.abs(pcount), p_name,
- pcount < 0 and "to" or "by",
- username)
- end
+
+ powner_comment = string.format("%s %d %s %s %s",
+ pcount < 0 and "Sell" or "Restock",
+ math.abs(pcount), p_name,
+ pcount < 0 and "to" or "by",
+ username)
+ end
end
end
if amount == nil then
@@ -258,12 +258,12 @@ local function r_user_post(username)
return error_box("failed to open log")
end
local time = os.time()
- -- subtract from buyer
+ -- subtract from buyer
log:write(string.format("%d,%s,%d,%s,%s,%s\n", time, username, amount, pcode or "", pcount or "", comment))
-- add to owner
if powner then
- -- count is always zero as doesn't affect stock
- log:write(string.format("%d,%s,%d,%s,%s,%s\n", time, powner, -amount, pcode or "", "", powner_comment))
+ -- count is always zero as doesn't affect stock
+ log:write(string.format("%d,%s,%d,%s,%s,%s\n", time, powner, -amount, pcode or "", "", powner_comment))
end
log:flush()
log:close()
@@ -294,14 +294,14 @@ local function r_user(username)
<div class="notif"><p><i>This user account does not exist yet. It will only be created after the first transaction.</i></p></div>
]])
else
- print([[<div class="backgroundbox userinfo">]])
+ print([[<div class="backgroundbox userinfo">]])
print(string.format([[
Current balance:<br><span class="amount-%s balance-value">%.02f€</span><br>
]], balance >= 0 and "pos" or "neg", balance / 100))
print(string.format([[
Last transaction added %s ago. <a href="/%s?log">View user log</a>
]], format_duration(os.time() - last_txn), username))
- print([[</div>]])
+ print([[</div>]])
end
print([[<div class="transactions container firstchildlarge">]])
print([[<div class="amount-presets backgroundbox">]])
@@ -403,7 +403,7 @@ end
local function r_index()
return respond(200, "Abrechenbarkeit", function()
print([[
- <form action="/" method="GET" class="creation">
+ <form action="/" method="GET" id="user_creation">
<h3>User Creation</h3>
<label for="username">Username: </label>
<input type="text" name="create_user" id="username" />
@@ -426,9 +426,9 @@ local function r_index()
end
local function validate_username(username)
- -- disallow leading or traling whitespace
- return username ~= nil
- and username:match("^([%w_ -]+)$") ~= nil
+ -- disallow leading or traling whitespace
+ return username ~= nil
+ and username:match("^([%w_ -]+)$") ~= nil
and username:match("^%s") == nil
and username:match("%s$") == nil
end
@@ -517,7 +517,13 @@ local function r_products()
</form>
</div>
]])
- print([[<table class="productlist"><tr><th>Name</th><th>Price</th><th>Barcode</th><th>Count</th><th>Owner</th></tr>]])
+ print([[<table class="productlist"><tr>
+ <th>Name</th>
+ <th>Price</th>
+ <th>Barcode</th>
+ <th>Count</th>
+ <th>Owner</th>
+ </tr>]])
local pbals = product_balances()
for barcode, price, name, owner in read_products() do
print(string.format([[