aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRiley L. <riley@e926.de>2025-01-02 00:40:33 +0100
committerRiley L. <riley@e926.de>2025-01-02 00:40:33 +0100
commit0b975df3e498853a4dbf85cc197e0e147fbc1315 (patch)
treed22c9f875a3ca064d5e0bad293ce1f34bb0a31f8
parent5be820b181360f7c5fcf4ebd8b8159e4c07e4e5a (diff)
downloadabrechenbarkeit-0b975df3e498853a4dbf85cc197e0e147fbc1315.tar
abrechenbarkeit-0b975df3e498853a4dbf85cc197e0e147fbc1315.tar.bz2
abrechenbarkeit-0b975df3e498853a4dbf85cc197e0e147fbc1315.tar.zst
fix delete barcode functionality; fix styling of product menus
-rwxr-xr-xabrechenbarkeit.lua37
-rw-r--r--locale/en.ini1
-rw-r--r--style.css5
3 files changed, 27 insertions, 16 deletions
diff --git a/abrechenbarkeit.lua b/abrechenbarkeit.lua
index 2ebafc3..dee8b4d 100755
--- a/abrechenbarkeit.lua
+++ b/abrechenbarkeit.lua
@@ -698,6 +698,26 @@ end
local function r_products_post()
local data = form_data()
+
+ if data.deletebarcode then
+ local barcode = data.barcode
+
+ -- remove barcode
+ local new_barcodes = io.open("barcodes.new", "w+")
+ if new_barcodes == nil then
+ return error_box("{+error.open_new_barcodes}")
+ end
+ for name, a_barcode in read_barcodes() do
+ if barcode ~= a_barcode then
+ new_barcodes:write(string.format("%s,%s\n", name, a_barcode))
+ end
+ end
+ new_barcodes:flush()
+ new_barcodes:close()
+ os.rename("barcodes.new", "barcodes")
+ return
+ end
+
local name = data.name
if name == nil or name:match("^[%w_-]*$") == nil then
return error_box("{+error.invalid_name}")
@@ -710,7 +730,7 @@ local function r_products_post()
end
for price, user, a_name in read_products() do
if name ~= a_name then
- new_products:write(string.format("%d,%s,%s\n", price, user, name))
+ new_products:write(string.format("%d,%s,%s\n", price, user, a_name))
end
end
new_products:flush()
@@ -785,7 +805,7 @@ local function r_products()
currency = config.unit or "€",
}))
for _, _, name in read_products() do
- print(format([[<option name="{name}">{name}</option>]], {
+ print(format([[<option value="{name}">{name}</option>]], {
name = name,
}))
end
@@ -804,7 +824,7 @@ local function r_products()
currency = config.unit or "€",
}))
for _, _, name in read_products() do
- print(format([[<option name="{name}">{!name}</option>]], {
+ print(format([[<option value="{name}">{!name}</option>]], {
name = name,
}))
end
@@ -814,7 +834,7 @@ local function r_products()
<!-- remove barcode -->
<form action="/?products" method="POST" class="box backgroundbox">
<h3>{+products.form.removebarcode}</h3>
- <input type="text" name="delete" value="1" hidden />
+ <input type="text" name="deletebarcode" value="1" hidden />
<label for="barcode">{+field.barcode}: </label>
<select type="text" name="barcode" id="barcode">
]], {
@@ -823,7 +843,7 @@ local function r_products()
local barcodes = {}
for name, barcode in read_barcodes() do
- print(format([[<option name="{barcode}">{!barcode} ({!name})</option>]], {
+ print(format([[<option value="{barcode}">{!barcode} ({!name})</option>]], {
name = name,
barcode = barcode,
}))
@@ -835,13 +855,6 @@ local function r_products()
end
end
- for a, b in pairs(barcodes) do
- print("name: " .. a)
- for _, c in pairs(b) do
- print("\t"..c)
- end
- end
-
print(format([[</select>
<input type="submit" value="{+products.form.remove.submit}" class="amount-ntr button" />
</form>
diff --git a/locale/en.ini b/locale/en.ini
index d051b50..9d210ba 100644
--- a/locale/en.ini
+++ b/locale/en.ini
@@ -67,6 +67,7 @@ error.invalid_user=Username invalid
error.open_log=Failed to open log file
error.invalid_barcode=Barcode invalid
error.open_new_products=Failed to open new products file
+error.open_new_barcodes=Failed to open new barcodes file
error.invalid_price=Price invalid
error.invalid_name=Name invalid
error.open_products=Failed to open products file
diff --git a/style.css b/style.css
index 9599c84..3082d31 100644
--- a/style.css
+++ b/style.css
@@ -31,10 +31,7 @@ body>* {
}
.container {
- display: grid;
- flex-direction: column;
- justify-content: left;
- grid-template-columns: auto auto;
+ display: ruby;
list-style-type: none;
}