Forum Discussion
_anomDiebolt_
7 years agoQrew Elite
Fill in your dbid's and apptoken and bind this code to a button:
Notes:
(1) I am assuming that the order that these API methods are executed in is not relevant, Also, I would not extend the code much beyond the 15 API calls as at some point your browser might become unresponsive and run out of sockets. You should be quite safe at 15 calls,
(2) The code will display a spinner during the execution of the API methods and will hide the spinner when API methods are all complete,
(function() {
var dbidWarehouseItems = "";
var dbidWarehouseProducts = "";
var dbidSkuItemAssignments = "";
var apptoken = "";
$.ajaxSetup({date: {apptiken: apptoken}});
$("a.QBU_Button").on("click", function(event) {
$("<img>", {
src: "https://cdnjs.cloudflare.com/ajax/libs/galleriffic/2.0.1/css/loader.gif",
id: "QBU_Spinner"
}).css({
position: "fixed",
top: "50%",
left: "50%",
transform: "translate(-50%, -50%)"
}).appendTo("body");
$.when(
$.post(dbidWarehouseItems, {act: "API_RunImport", id: 10}),
$.post(dbidWarehouseItems, {act: "API_RunImport", id: 11}),
$.post(dbidWarehouseItems, {act: "API_RunImport", id: 12}),
$.post(dbidWarehouseItems, {act: "API_RunImport", id: 13}),
$.post(dbidWarehouseProducts, {act: "API_RunImport", id: 10}),
$.post(dbidWarehouseProducts, {act: "API_RunImport", id: 11}),
$.post(dbidWarehouseProducts, {act: "API_RunImport", id: 12}),
$.post(dbidWarehouseProducts, {act: "API_RunImport", id: 13}),
$.post(dbidSkuItemAssignments, {act: "API_RunImport", id: 10}),
$.post(dbidSkuItemAssignments, {act: "API_RunImport", id: 11}),
$.post(dbidSkuItemAssignments, {act: "API_RunImport", id: 12}),
$.post(dbidSkuItemAssignments, {act: "API_RunImport", id: 13}),
$.post(dbidWarehouseItems, {act: "API_PurgeRecords", id: 14}),
$.post(dbidWarehouseProducts, {act: "API_PurgeRecords", id: 14}),
$.post(dbidSkuItemAssignments, {act: "API_PurgeRecords", id: 17})
).then(function() {
$("#QBU_Spinner").hide();
// further code here
});
});
})();
Notes:
(1) I am assuming that the order that these API methods are executed in is not relevant, Also, I would not extend the code much beyond the 15 API calls as at some point your browser might become unresponsive and run out of sockets. You should be quite safe at 15 calls,
(2) The code will display a spinner during the execution of the API methods and will hide the spinner when API methods are all complete,