display inventory
This commit is contained in:
parent
99ae0e0f72
commit
a5b294b708
|
@ -30,6 +30,8 @@
|
|||
<div class="name">family:</div><div class="justify"><input class="full" type="text" id="part_family"></div>
|
||||
<div class="name"><a id="url_datasheet">datasheet</a>:</div><div class="justify"><input class="full" type="text" id="part_datasheet"></div>
|
||||
<div class="name"><a id="url_page">page</a>:</div><div class="justify"><input class="full" type="text" id="part_page"></div>
|
||||
<div class="name">location:</div><div class="justify"><input class="full" type="text" id="part_location"></div>
|
||||
<div class="name">stock:</div><div class="justify"><input class="full" type="number" min="0" step="1" id="part_stock"></div>
|
||||
<table>
|
||||
<thead><tr><th>distributor</th><th>sku</th><th>page</th></tr></thead>
|
||||
<tbody id="distributors"></tbody>
|
||||
|
|
|
@ -49,7 +49,7 @@ function select()
|
|||
if (part.id == part_selected) {
|
||||
console.log(part);
|
||||
// populate part fields
|
||||
const fields = ["name", "description", "details", "package", "pincount", "manufacturer", "family", "datasheet", "page"];
|
||||
const fields = ["name", "description", "details", "package", "pincount", "manufacturer", "family", "datasheet", "page", "location", "stock"];
|
||||
for (const field of fields) {
|
||||
const input = document.getElementById('part_' + field);
|
||||
if (input.tagName == "INPUT") {
|
||||
|
|
|
@ -92,6 +92,13 @@ def get_part_by_id(id)
|
|||
distributor.delete("product_page")
|
||||
end
|
||||
part["distributors"] = distributors
|
||||
# add inventory
|
||||
statement = @db.prepare("SELECT location.name AS location, inventory.quantity AS stock FROM inventory LEFT JOIN location ON location.id = inventory.location WHERE inventory.part = ? ORDER BY inventory.quantity DESC LIMIT 1")
|
||||
inventory = statement.execute(id).to_a[0]
|
||||
if inventory then
|
||||
part["location"] = inventory["location"]
|
||||
part["stock"] = inventory["stock"]
|
||||
end
|
||||
# clean up
|
||||
delete = ["parent"]
|
||||
delete.each do |k|
|
||||
|
|
Loading…
Reference in New Issue