Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // JavaScript for formatted purchase order
- // by John Rogers 11/12/18
- // updated 11/12/18
- // contact JRogers22717@gmail.com
- // get rid of source record from url
- var queryString = location.search;
- queryString = queryString.split("=");
- var rid = queryString.pop();
- //This currently just pulls all records from the Replenishment table and displays them in a table.
- //Need to add a row at the beginning to be able to input amount to add
- //Then a button at button submit, which will execute the amounts input
- //The amounts input will be subtracted from the related record in replenishment table and added to the purchase order products table
- $(document).ready(function(){
- var urlRoot = "https://adirponiachik.quickbase.com"
- var urlDB = "/db/"
- var apptoken = "kx4cuqbcvtpdsdxukghwchp4zzy"
- // second request is for related products (Purchase Order Products table)
- var queryUrl = urlRoot;
- queryUrl += urlDB;
- queryUrl += "bng5k8grf";
- queryUrl += "?a=API_GenResultsTable";
- queryUrl += "&apptoken=" + apptoken;
- //queryUrl += "&query={'14'.EX.'" + rid + "'}; // Filter that is not working currently.
- queryUrl += "&clist=17.19.30.18.23.10.14"; // Product Name, Part #, Notes, SKU, QTY, SubTotal, Vendor Name
- queryUrl += "&jsa=1";
- // this query returns javascript array qdb_data
- var data = [];
- $.getScript(queryUrl, function(){
- data = qdb_data;
- console.log(data);
- //add table headers (don't want default)
- var thead = ["Product Name", "Vendor Part #", "Notes", "Maco's Sku", "Qty", "Total", "Vendor Name"];
- data.unshift(thead);
- // generate table
- function makeTable(container, data) {
- var table = $("<table/>").addClass('table-bordered').css('width','100%');
- $.each(data, function(rowIndex, r) {
- var row = $("<tr/>");
- $.each(r, function(colIndex, c) {
- row.append($("<t"+(rowIndex == 0 ? "h" : "d")+"/>").text(c));
- });
- table.append(row);
- });
- return container.append(table);
- }
- makeTable($("#products"), data);
- $("#products").css("width","100%");
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement