Advertisement
Guest User

Untitled

a guest
Nov 13th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. // JavaScript for formatted purchase order
  2. // by John Rogers 11/12/18
  3. // updated 11/12/18
  4. // contact JRogers22717@gmail.com
  5.  
  6. // get rid of source record from url
  7. var queryString = location.search;
  8. queryString = queryString.split("=");
  9. var rid = queryString.pop();
  10.  
  11. //This currently just pulls all records from the Replenishment table and displays them in a table.
  12. //Need to add a row at the beginning to be able to input amount to add
  13. //Then a button at button submit, which will execute the amounts input
  14.  
  15. //The amounts input will be subtracted from the related record in replenishment table and added to the purchase order products table
  16.  
  17. $(document).ready(function(){
  18.  
  19. var urlRoot = "https://adirponiachik.quickbase.com"
  20. var urlDB = "/db/"
  21. var apptoken = "kx4cuqbcvtpdsdxukghwchp4zzy"
  22.  
  23.  
  24. // second request is for related products (Purchase Order Products table)
  25. var queryUrl = urlRoot;
  26. queryUrl += urlDB;
  27. queryUrl += "bng5k8grf";
  28. queryUrl += "?a=API_GenResultsTable";
  29. queryUrl += "&apptoken=" + apptoken;
  30. //queryUrl += "&query={'14'.EX.'" + rid + "'}; // Filter that is not working currently.
  31. queryUrl += "&clist=17.19.30.18.23.10.14"; // Product Name, Part #, Notes, SKU, QTY, SubTotal, Vendor Name
  32. queryUrl += "&jsa=1";
  33.  
  34. // this query returns javascript array qdb_data
  35. var data = [];
  36. $.getScript(queryUrl, function(){
  37. data = qdb_data;
  38. console.log(data);
  39.  
  40. //add table headers (don't want default)
  41. var thead = ["Product Name", "Vendor Part #", "Notes", "Maco's Sku", "Qty", "Total", "Vendor Name"];
  42. data.unshift(thead);
  43.  
  44.  
  45. // generate table
  46. function makeTable(container, data) {
  47. var table = $("<table/>").addClass('table-bordered').css('width','100%');
  48. $.each(data, function(rowIndex, r) {
  49. var row = $("<tr/>");
  50. $.each(r, function(colIndex, c) {
  51. row.append($("<t"+(rowIndex == 0 ? "h" : "d")+"/>").text(c));
  52. });
  53. table.append(row);
  54. });
  55. return container.append(table);
  56. }
  57.  
  58. makeTable($("#products"), data);
  59. $("#products").css("width","100%");
  60.  
  61. });
  62.  
  63.  
  64. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement