Rev 33261 | Blame | Compare with Previous | Last modification | View Log | RSS feed
$(function () {$(document).on('click', ".billed-invoice", function () {getAuthorisedWarehouseList(function (warehouseId) {loadAllInvoice(warehouseId, "main-content");});});$(document).on('change', "#WarehouseList", function () {var warehouseId = $(this).val();loadAllInvoice(warehouseId, "main-content");});$(document).on('click', ".invoice-orders", function () {var invoiceNumber = $(this).data("invoice");loadInvoiceDetail(invoiceNumber, "invoice-detail-container");});$(document).on('click', ".invoice-download", function () {var invoiceNumber = $(this).data("invoice");window.open(`${context}/om/downloadInvoice/${invoiceNumber}`, "_blank");});});function loadAllInvoice(warehouseId, domId) {doGetAjaxRequestHandler(context + "/om/billedInvoice/?warehouseId=" + warehouseId, function (response) {$('#' + domId).html(response);var invoiceNumber = $("#firstInvoiceNumber").val();$("#selectedWarehouse").val(warehouseId);console.log("invoiceNumber:", invoiceNumber);var selectOptions = '';authorisedWarehouses.forEach(function (warehouse) {var selected = (warehouse.id == warehouseId) ? 'selected' : '';selectOptions += `<option value="${warehouse.id}" ${selected}>${warehouse.name}</option>`;});$('#authWarehousesList').html(`<select class="form-control" id="WarehouseList">${selectOptions}</select>`);loadInvoiceDetail(invoiceNumber, "invoice-detail-container");});}function loadInvoiceDetail(invoiceNumber, detailContainer) {var url = context + "/om/billed-invoice-orders/?invoiceNumber=" + invoiceNumber;doGetAjaxRequestHandler(url, function (response) {$('#' + detailContainer).html(response);$("#selectedInvoiceNumber").text(invoiceNumber);});}function getAuthorisedWarehousesList(callback) {bootBoxObj = {size: "small",title: "Choose Warehouse",callback: callback,inputType: 'select',inputOptions: typeof inputOptions == "undefined" ? undefined: inputOptions}if (typeof inputOptions == "undefined") {doGetAjaxRequestHandler(context + "/authorisedWarehouses", function (response) {console.log("response warehouse", response);response = JSON.parse(response);inputOptions = [];response.forEach(function (warehouse) {inputOptions.push({text: warehouse.name,value: warehouse.id,});});bootBoxObj['inputOptions'] = inputOptions;bootbox.prompt(bootBoxObj);});} else if (inputOptions.length == 1) {callback(inputOptions[0].warehouse.id);} else {bootbox.prompt(bootBoxObj);}}