diff --git a/application/receipts/__pycache__/receipts_api.cpython-313.pyc b/application/receipts/__pycache__/receipts_api.cpython-313.pyc index e57363d..710b213 100644 Binary files a/application/receipts/__pycache__/receipts_api.cpython-313.pyc and b/application/receipts/__pycache__/receipts_api.cpython-313.pyc differ diff --git a/application/receipts/receipts_api.py b/application/receipts/receipts_api.py index f51f2cf..2bf2c03 100644 --- a/application/receipts/receipts_api.py +++ b/application/receipts/receipts_api.py @@ -43,8 +43,9 @@ def getItems(): limit = int(request.args.get('limit', 10)) site_name = session['selected_site'] offset = (page - 1) * limit - sort_order = "ID ASC" - payload = ("%%", limit, offset, sort_order) + search_string = f"%{str(request.args.get('search_string', ""))}%" + sort_order = "item_name ASC" + payload = (search_string, limit, offset, sort_order) recordset, count = receipts_database.getItemsWithQOH(site_name, payload) return jsonify({"items":recordset, "end":math.ceil(count['count']/limit), "error":False, "message":"items fetched succesfully!"}) return jsonify({"items":recordset, "end":math.ceil(count['count']/limit), "error":True, "message":"There was an error with this GET statement"}) diff --git a/application/receipts/static/js/receiptHandler.js b/application/receipts/static/js/receiptHandler.js index 9358f71..1810335 100644 --- a/application/receipts/static/js/receiptHandler.js +++ b/application/receipts/static/js/receiptHandler.js @@ -36,32 +36,6 @@ async function replenishFields(receipt) { } } -async function checkAPI(line_id, barcode) { - console.log(barcode) - const response = await fetch(`/receipts/api/checkAPI`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - line_id: line_id, - barcode: barcode - }), - }); - data = await response.json() - message_type = "primary" - if(data.error){ - message_type = "danger" - } - UIkit.notification({ - message: data.message, - status: message_type, - pos: 'top-right', - timeout: 5000 - }); - await refreshReceipt() -} - async function replenishLinesTable(receipt_items) { let linesTableBody = document.getElementById("linesTableBody") linesTableBody.innerHTML = "" @@ -102,16 +76,6 @@ async function replenishLinesTable(receipt_items) { let operationsCell = document.createElement('td') - let apiOp = document.createElement('a') - - if(receipt_items[i].type === "new sku"){ - apiOp.style = "margin-right: 5px;" - apiOp.setAttribute('class', 'uk-button uk-button-small uk-button-default') - apiOp.setAttribute('uk-icon', 'icon: pull') - apiOp.onclick = async function () { - await checkAPI(receipt_items[i].id, receipt_items[i].barcode) - } - } let linkOp = document.createElement('a') linkOp.style = "margin-right: 5px;" @@ -154,11 +118,6 @@ async function replenishLinesTable(receipt_items) { if (receipt_items[i].type === "new sku"){ - operationsCell.append(apiOp) - operationsCell.append(linkOp) - } - - if (receipt_items[i].type === "api"){ operationsCell.append(linkOp) } @@ -183,29 +142,6 @@ async function replenishLinesTable(receipt_items) { } } -async function replenishItemsTable(items) { - let itemsTableBody = document.getElementById("itemsTableBody") - itemsTableBody.innerHTML = "" - - for(let i = 0; i < items.length; i++){ - let tableRow = document.createElement('tr') - - let idCell = document.createElement('td') - idCell.innerHTML = items[i].id - let barcodeCell = document.createElement('td') - barcodeCell.innerHTML = items[i].barcode - let nameCell = document.createElement('td') - nameCell.innerHTML = items[i].item_name - - tableRow.onclick = async function() { - await addSKULine(items[i].id) - } - - tableRow.append(idCell, barcodeCell, nameCell) - itemsTableBody.append(tableRow) - } -} - async function replenishFilesCards(files) { let fileCards = document.getElementById('fileCards') fileCards.innerHTML = "" @@ -264,15 +200,6 @@ async function openCustomModal() { } -async function openSKUModal() { - pagination_current = 1 - let items = await getItems() - await replenishItemsTable(items) - await updateItemsPaginationElement() - UIkit.dropdown(document.getElementById("addLineDropDown")).hide(false); - UIkit.modal(document.getElementById("itemsModal")).show(); -} - async function openLineEditModal(line_data) { console.log(line_data) document.getElementById('lineName').value = line_data.name @@ -437,6 +364,7 @@ async function getReceipt(id) { return receipt; } +// SKU Modal functions let items_limit = 50; async function getItems() { console.log("getting items") @@ -533,7 +461,39 @@ async function updateItemsPaginationElement() { paginationElement.append(nextElement) } -// Select Vedor functions +async function openSKUModal() { + pagination_current = 1 + let items = await getItems() + await replenishItemsTable(items) + await updateItemsPaginationElement() + UIkit.dropdown(document.getElementById("addLineDropDown")).hide(false); + UIkit.modal(document.getElementById("itemsModal")).show(); +} + +async function replenishItemsTable(items) { + let itemsTableBody = document.getElementById("itemsTableBody") + itemsTableBody.innerHTML = "" + + for(let i = 0; i < items.length; i++){ + let tableRow = document.createElement('tr') + + let idCell = document.createElement('td') + idCell.innerHTML = items[i].id + let barcodeCell = document.createElement('td') + barcodeCell.innerHTML = items[i].barcode + let nameCell = document.createElement('td') + nameCell.innerHTML = items[i].item_name + + tableRow.onclick = async function() { + await addSKULine(items[i].id) + } + + tableRow.append(idCell, barcodeCell, nameCell) + itemsTableBody.append(tableRow) + } +} + +// Select Vendor functions let vendor_limit = 25 let vendor_current_page = 1 let vendor_end_page = 10 @@ -693,193 +653,19 @@ async function updateVendorsPaginationElement() { paginationElement.append(nextElement) } -// Select Vedor functions -let links_limit = 25 -let links_current_page = 1 -let links_end_page = 10 -async function getLinkedLists() { - const url = new URL('/receipts/api/getLinkedLists', window.location.origin); - url.searchParams.append('page', vendor_current_page); - url.searchParams.append('limit', vendor_limit); - const response = await fetch(url); - data = await response.json(); - links_end_page = data.end - return data.items; -} - -async function postLinkedItem(receipt_item_id, link_list_id, conv_factor) { - const response = await fetch(`/receipts/api/postLinkedItem`, { - method: 'POST', - headers: { - 'Content-Type': 'application/json', - }, - body: JSON.stringify({ - receipt_item_id: receipt_item_id, - link_list_id: link_list_id, - conv_factor: conv_factor - }), - }); - data = await response.json() - message_type = "primary" - if(data.error){ - message_type = "danger" - } - UIkit.notification({ - message: data.message, - status: message_type, - pos: 'top-right', - timeout: 5000 - }); - await refreshReceipt() - UIkit.modal(document.getElementById("linksModal")).hide(); -} - -async function openLinksSelectModal(receipt_item_id) { - let links = await getLinkedLists(); - await replenishLinksTableBody(links, receipt_item_id); - await updateLinksPaginationElement() - UIkit.modal(document.getElementById("linksModal")).show(); -} - -async function replenishLinksTableBody(links, receipt_item_id) { - let linksTableBody = document.getElementById('linksTableBody') - linksTableBody.innerHTML = "" - - for(let i=0; i < links.length; i++){ - let tableRow = document.createElement('tr') - - let idCell = document.createElement('td') - idCell.innerHTML = links[i].id - - let barcodeCell = document.createElement('td') - barcodeCell.innerHTML = links[i].barcode - - let nameCell = document.createElement('td') - nameCell.innerHTML = links[i].item_name - - let convFactorCell = document.createElement('td') - - let conv_factor_input = document.createElement('input') - conv_factor_input.setAttribute('class', 'uk-input') - conv_factor_input.setAttribute('id', `${links[i].id}_conv_factor`) - - convFactorCell.append(conv_factor_input) - - let addCell = document.createElement('td') - - let addbutton = document.createElement('button') - addbutton.setAttribute('class', 'uk-button') - addbutton.innerHTML = "Select" - addbutton.onclick = async function() { - let conv = document.getElementById(`${links[i].id}_conv_factor`) - if (!conv.value == ""){ - conv.classList.remove('uk-form-danger') - let conv_factor = parseFloat(conv.value) - await postLinkedItem(receipt_item_id, links[i].id, conv_factor) - } else { - conv.classList.add('uk-form-danger') - } - } - - addCell.append(addbutton) - - tableRow.append(idCell, barcodeCell, nameCell, convFactorCell, addCell) - linksTableBody.append(tableRow) - } - -} - -async function setLinksPage(pageNumber) { - links_current_page = pageNumber; - let links = await getLinkedLists() - await updateLinksPaginationElement() - await replenishLinksTableBody(links) -} - -async function updateLinksPaginationElement() { - let paginationElement = document.getElementById("linksPage"); - paginationElement.innerHTML = ""; - // previous - let previousElement = document.createElement('li') - if(links_current_page<=1){ - previousElement.innerHTML = ``; - previousElement.classList.add('uk-disabled'); - }else { - previousElement.innerHTML = ``; - } - paginationElement.append(previousElement) - - //first - let firstElement = document.createElement('li') - if(links_current_page<=1){ - firstElement.innerHTML = `1`; - firstElement.classList.add('uk-disabled'); - }else { - firstElement.innerHTML = `1`; - } - paginationElement.append(firstElement) - - // ... - if(links_current_page-2>1){ - let firstDotElement = document.createElement('li') - firstDotElement.classList.add('uk-disabled') - firstDotElement.innerHTML = `…`; - paginationElement.append(firstDotElement) - } - // last - if(links_current_page-2>0){ - let lastElement = document.createElement('li') - lastElement.innerHTML = `${links_current_page-1}` - paginationElement.append(lastElement) - } - // current - if(links_current_page!=1 && links_current_page != links_end_page){ - let currentElement = document.createElement('li') - currentElement.innerHTML = `
Select an Item from the system...
+Select an Item from the system that you would like to associate this unknown barcode to...
+Select an Linked List from the system...
- -| ID | -Barcode | -Name | -Conversion Factor | -Operations | -
|---|