mirror of
https://codeberg.org/metamuffin/abrechenbarkeit.git
synced 2024-12-29 16:14:36 +00:00
add some more localisation to products and log pages
This commit is contained in:
parent
3badf67851
commit
2fe75952b8
1 changed files with 41 additions and 26 deletions
|
@ -127,12 +127,21 @@ local function format(template, params)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function format_amount(amount, tag, classes)
|
local function format_amount(amount, tag, classes)
|
||||||
local s = string.format("%s%.02f%s", amount > 0 and "+" or "", amount / 100, config.unit or "€")
|
local s = format("{+price.amount}", {
|
||||||
|
sign = amount > 0 and "{+price.sign.pos}" or "{+price.sign.neg}",
|
||||||
|
amount = string.format("%.2f", math.abs(amount / 100)),
|
||||||
|
unit = config.unit or "€"
|
||||||
|
})
|
||||||
|
|
||||||
|
-- local s = string.format("%s%.02f%s", amount > 0 and "+" or "", amount / 100, )
|
||||||
if tag == nil then return s end
|
if tag == nil then return s end
|
||||||
return format(
|
return format(
|
||||||
[[<{tag} class="amount-{sign} {classes}">{content}</{tag}>]],
|
[[<{tag} class="amount-{sign} {classes}">{content}</{tag}>]], {
|
||||||
{ tag = tag, sign = amount >= 0 and "pos" or "neg", classes = classes or "", content = s }
|
tag = tag,
|
||||||
)
|
sign = amount >= 0 and "pos" or "neg",
|
||||||
|
classes = classes or "",
|
||||||
|
content = s
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
local function get_user_theme(username)
|
local function get_user_theme(username)
|
||||||
|
@ -483,7 +492,7 @@ local function r_log(filter)
|
||||||
<input type="text" name="pcode" value="{pcode}" hidden />
|
<input type="text" name="pcode" value="{pcode}" hidden />
|
||||||
<input type="number" name="pcount" value="{revert_pcount}" hidden />
|
<input type="number" name="pcount" value="{revert_pcount}" hidden />
|
||||||
<input type="text" name="comment" value="Revert {comment}" hidden />
|
<input type="text" name="comment" value="Revert {comment}" hidden />
|
||||||
<input type="submit" class="amount-ntr button" value="Revert" />
|
<input type="submit" class="amount-ntr button" value="{+log.actions.revert}" />
|
||||||
</form>
|
</form>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -496,8 +505,12 @@ local function r_log(filter)
|
||||||
user_dst_url = urlencode(user_dst),
|
user_dst_url = urlencode(user_dst),
|
||||||
amount = format_amount(amount, "td"),
|
amount = format_amount(amount, "td"),
|
||||||
pcode = escape(pcode),
|
pcode = escape(pcode),
|
||||||
pcount = (pcount and (pcount < 0 and "buy " or "stock ") or "") ..
|
pcount = (pcount
|
||||||
(pcount and tostring(math.abs(pcount)) or ""),
|
and (pcount < 0
|
||||||
|
and "{+log.count.purchase}"
|
||||||
|
or "{+log.count.stock}"
|
||||||
|
) or ""),
|
||||||
|
n = (pcount and tostring(math.abs(pcount)) or ""),
|
||||||
comment = escape(comment),
|
comment = escape(comment),
|
||||||
revert_amount = -amount,
|
revert_amount = -amount,
|
||||||
revert_pcount = -(pcount or 0),
|
revert_pcount = -(pcount or 0),
|
||||||
|
@ -595,38 +608,40 @@ local function r_products()
|
||||||
notif = r_products_post()
|
notif = r_products_post()
|
||||||
end
|
end
|
||||||
respond(200, "Abrechenbare Product List", function()
|
respond(200, "Abrechenbare Product List", function()
|
||||||
print("<h1>Product List</h1>")
|
print(format("<h1>{+products.title}</h1>"))
|
||||||
if notif then print(notif) end
|
if notif then print(notif) end
|
||||||
print([[
|
print(format([[
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<form action="/?products" method="POST" class="box backgroundbox">
|
<form action="/?products" method="POST" class="box backgroundbox">
|
||||||
<h3>Add Product</h3>
|
<h3>{+products.form.add}</h3>
|
||||||
<label for="name">Name: </label>
|
<label for="name">{+products.form.name}: </label>
|
||||||
<input type="text" name="name" id="name" />
|
<input type="text" name="name" id="name" />
|
||||||
<label for="price">Price (ct): </label>
|
<label for="price">{+products.form.price}: </label>
|
||||||
<input type="number" name="price" id="price" />
|
<input type="number" name="price" id="price" />
|
||||||
<label for="user">User: </label>
|
<label for="user">{+products.form.user}: </label>
|
||||||
<input type="text" name="user" id="user" />
|
<input type="text" name="user" id="user" />
|
||||||
<label for="barcode">Barcode: </label>
|
<label for="barcode">{+products.form.barcode}: </label>
|
||||||
<input type="text" name="barcode" id="barcode" />
|
<input type="text" name="barcode" id="barcode" />
|
||||||
<input type="submit" value="Add" class="amount-ntr button" />
|
<input type="submit" value="{+products.form.add.short}" class="amount-ntr button" />
|
||||||
</form>
|
</form>
|
||||||
<form action="/?products" method="POST" class="box backgroundbox">
|
<form action="/?products" method="POST" class="box backgroundbox">
|
||||||
<h3>Remove Product</h3>
|
<h3>{+products.form.remove}</h3>
|
||||||
<input type="text" name="delete" value="1" hidden />
|
<input type="text" name="delete" value="1" hidden />
|
||||||
<label for="barcode">Barcode: </label>
|
<label for="barcode">{+products.form.barcode}: </label>
|
||||||
<input type="text" name="barcode" id="barcode" />
|
<input type="text" name="barcode" id="barcode" />
|
||||||
<input type="submit" value="Remove"class="amount-ntr button" />
|
<input type="submit" value="{+products.form.remove.short}" class="amount-ntr button" />
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
]])
|
]], {
|
||||||
print([[<table class="productlist"><tr>
|
currency = config.unit or "€",
|
||||||
<th>Name</th>
|
}))
|
||||||
<th>Price</th>
|
print(format([[<table class="productlist"><tr>
|
||||||
<th>Barcode</th>
|
<th>{+products.list.name}</th>
|
||||||
<th>Count</th>
|
<th>{+products.list.price}</th>
|
||||||
<th>User</th>
|
<th>{+products.list.barcode}</th>
|
||||||
</tr>]])
|
<th>{+products.list.count}</th>
|
||||||
|
<th>{+products.list.user}</th>
|
||||||
|
</tr>]]))
|
||||||
local pbals = product_balances()
|
local pbals = product_balances()
|
||||||
for barcode, price, user, name in read_products() do
|
for barcode, price, user, name in read_products() do
|
||||||
print(format([[<tr>
|
print(format([[<tr>
|
||||||
|
|
Loading…
Reference in a new issue