mirror of
https://codeberg.org/metamuffin/abrechenbarkeit.git
synced 2025-01-15 05:24:35 +00:00
fix delete barcode functionality; fix styling of product menus
This commit is contained in:
parent
5be820b181
commit
0b975df3e4
3 changed files with 27 additions and 16 deletions
|
@ -698,6 +698,26 @@ end
|
||||||
|
|
||||||
local function r_products_post()
|
local function r_products_post()
|
||||||
local data = form_data()
|
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
|
local name = data.name
|
||||||
if name == nil or name:match("^[%w_-]*$") == nil then
|
if name == nil or name:match("^[%w_-]*$") == nil then
|
||||||
return error_box("{+error.invalid_name}")
|
return error_box("{+error.invalid_name}")
|
||||||
|
@ -710,7 +730,7 @@ local function r_products_post()
|
||||||
end
|
end
|
||||||
for price, user, a_name in read_products() do
|
for price, user, a_name in read_products() do
|
||||||
if name ~= a_name then
|
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
|
||||||
end
|
end
|
||||||
new_products:flush()
|
new_products:flush()
|
||||||
|
@ -785,7 +805,7 @@ local function r_products()
|
||||||
currency = config.unit or "€",
|
currency = config.unit or "€",
|
||||||
}))
|
}))
|
||||||
for _, _, name in read_products() do
|
for _, _, name in read_products() do
|
||||||
print(format([[<option name="{name}">{name}</option>]], {
|
print(format([[<option value="{name}">{name}</option>]], {
|
||||||
name = name,
|
name = name,
|
||||||
}))
|
}))
|
||||||
end
|
end
|
||||||
|
@ -804,7 +824,7 @@ local function r_products()
|
||||||
currency = config.unit or "€",
|
currency = config.unit or "€",
|
||||||
}))
|
}))
|
||||||
for _, _, name in read_products() do
|
for _, _, name in read_products() do
|
||||||
print(format([[<option name="{name}">{!name}</option>]], {
|
print(format([[<option value="{name}">{!name}</option>]], {
|
||||||
name = name,
|
name = name,
|
||||||
}))
|
}))
|
||||||
end
|
end
|
||||||
|
@ -814,7 +834,7 @@ local function r_products()
|
||||||
<!-- remove barcode -->
|
<!-- remove barcode -->
|
||||||
<form action="/?products" method="POST" class="box backgroundbox">
|
<form action="/?products" method="POST" class="box backgroundbox">
|
||||||
<h3>{+products.form.removebarcode}</h3>
|
<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>
|
<label for="barcode">{+field.barcode}: </label>
|
||||||
<select type="text" name="barcode" id="barcode">
|
<select type="text" name="barcode" id="barcode">
|
||||||
]], {
|
]], {
|
||||||
|
@ -823,7 +843,7 @@ local function r_products()
|
||||||
|
|
||||||
local barcodes = {}
|
local barcodes = {}
|
||||||
for name, barcode in read_barcodes() do
|
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,
|
name = name,
|
||||||
barcode = barcode,
|
barcode = barcode,
|
||||||
}))
|
}))
|
||||||
|
@ -835,13 +855,6 @@ local function r_products()
|
||||||
end
|
end
|
||||||
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>
|
print(format([[</select>
|
||||||
<input type="submit" value="{+products.form.remove.submit}" class="amount-ntr button" />
|
<input type="submit" value="{+products.form.remove.submit}" class="amount-ntr button" />
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -67,6 +67,7 @@ error.invalid_user=Username invalid
|
||||||
error.open_log=Failed to open log file
|
error.open_log=Failed to open log file
|
||||||
error.invalid_barcode=Barcode invalid
|
error.invalid_barcode=Barcode invalid
|
||||||
error.open_new_products=Failed to open new products file
|
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_price=Price invalid
|
||||||
error.invalid_name=Name invalid
|
error.invalid_name=Name invalid
|
||||||
error.open_products=Failed to open products file
|
error.open_products=Failed to open products file
|
||||||
|
|
|
@ -31,10 +31,7 @@ body>* {
|
||||||
}
|
}
|
||||||
|
|
||||||
.container {
|
.container {
|
||||||
display: grid;
|
display: ruby;
|
||||||
flex-direction: column;
|
|
||||||
justify-content: left;
|
|
||||||
grid-template-columns: auto auto;
|
|
||||||
list-style-type: none;
|
list-style-type: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue