mirror of
https://codeberg.org/metamuffin/abrechenbarkeit.git
synced 2025-05-23 06:44:45 +00:00
Add print button
This commit is contained in:
parent
ee7987599e
commit
3b5948682a
2 changed files with 154 additions and 146 deletions
|
@ -114,6 +114,8 @@ local translations = load_translations({ "en", config.language })
|
||||||
local stylesheet = io.open("style.css"):read("a")
|
local stylesheet = io.open("style.css"):read("a")
|
||||||
local script = io.open("script.js"):read("a")
|
local script = io.open("script.js"):read("a")
|
||||||
|
|
||||||
|
local can_print = false
|
||||||
|
|
||||||
local function format(template, params)
|
local function format(template, params)
|
||||||
params = params or {}
|
params = params or {}
|
||||||
if template == nil then return "NIL TEMPLATE" end
|
if template == nil then return "NIL TEMPLATE" end
|
||||||
|
@ -225,6 +227,7 @@ local function respond(status, title, body)
|
||||||
<a href="/?spus">{+spus}</a>
|
<a href="/?spus">{+spus}</a>
|
||||||
<a href="/?products">{+products}</a>
|
<a href="/?products">{+products}</a>
|
||||||
<a href="/?log">{+log}</a>
|
<a href="/?log">{+log}</a>
|
||||||
|
{print_button}
|
||||||
<a href="/?about">{+about}</a>
|
<a href="/?about">{+about}</a>
|
||||||
</nav>
|
</nav>
|
||||||
]], {
|
]], {
|
||||||
|
@ -232,7 +235,9 @@ local function respond(status, title, body)
|
||||||
style = stylesheet,
|
style = stylesheet,
|
||||||
user_style = get_user_theme(path and path:sub(2)),
|
user_style = get_user_theme(path and path:sub(2)),
|
||||||
script = script,
|
script = script,
|
||||||
head_extra = config.head_extra or ""
|
head_extra = config.head_extra or "",
|
||||||
|
print_button = can_print and
|
||||||
|
[[<script>document.write('<a href="javascript:print()" style="float:right;">{+print}</a>')</script>]] or ""
|
||||||
}))
|
}))
|
||||||
if config.header ~= nil then
|
if config.header ~= nil then
|
||||||
print(config.header)
|
print(config.header)
|
||||||
|
@ -403,7 +408,7 @@ local function r_transaction_post()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not exists then
|
if not exists then
|
||||||
return error_box("{+error.unknown_product}: "..pname)
|
return error_box("{+error.unknown_product}: " .. pname)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -591,6 +596,7 @@ local function r_log(filter)
|
||||||
if method == "POST" then
|
if method == "POST" then
|
||||||
notif = r_transaction_post()
|
notif = r_transaction_post()
|
||||||
end
|
end
|
||||||
|
can_print = true
|
||||||
return respond(200, "Abrechnungen", function()
|
return respond(200, "Abrechnungen", function()
|
||||||
if notif then print(notif) end
|
if notif then print(notif) end
|
||||||
print([[<table class="log"]])
|
print([[<table class="log"]])
|
||||||
|
@ -728,7 +734,7 @@ local function r_users(show_special, filter_negative)
|
||||||
if filter_negative or user.time > inactive_cutoff then
|
if filter_negative or user.time > inactive_cutoff then
|
||||||
show_user(user)
|
show_user(user)
|
||||||
|
|
||||||
if user.name:sub(1,1) ~= "@" then
|
if user.name:sub(1, 1) ~= "@" then
|
||||||
if user.balance < 0 then embezzlement = embezzlement - user.balance end
|
if user.balance < 0 then embezzlement = embezzlement - user.balance end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -874,6 +880,7 @@ local function r_products()
|
||||||
if method == "POST" then
|
if method == "POST" then
|
||||||
notif = r_products_post()
|
notif = r_products_post()
|
||||||
end
|
end
|
||||||
|
can_print = true
|
||||||
respond(200, "Abrechenbare Product List", function()
|
respond(200, "Abrechenbare Product List", function()
|
||||||
print(format("<h1>{+products.title}</h1>"))
|
print(format("<h1>{+products.title}</h1>"))
|
||||||
if notif then print(notif) end
|
if notif then print(notif) end
|
||||||
|
|
|
@ -79,3 +79,4 @@ error.open_barcodes=Failed to open barcodes file
|
||||||
error.no_path=No path
|
error.no_path=No path
|
||||||
users.inactive_list=Inactive Users
|
users.inactive_list=Inactive Users
|
||||||
users.embezzlement=A total of {amount} are currently under embezzlement.
|
users.embezzlement=A total of {amount} are currently under embezzlement.
|
||||||
|
print=Print
|
Loading…
Add table
Reference in a new issue