Rev 33257 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
$(function () {$(document).on('click', ".warehouse-management", function () {getAuthorisedWarehousesList(function (warehouseId) {loadAllTransaction(warehouseId, "main-content");});});$(document).on('click', ".order_by_transaction", function () {var transactionId = $(this).data("transaction");var warehouseId = $("#selectedWarehouse").val();loadTransactionDetail(transactionId, warehouseId, "transaction-detail-container");});$(document).on('click', ".order_accepted", function () {var transactionId = $("#selectedTransactionId").text();var warehouseId = $("#selectedWarehouseId").val();var orderBillingModels = []; // Array to store OrderBillingModel objects$("#wareHouseTransactionTable > tbody > tr").each(function (rowIndex) {if ($(this).hasClass('main-tr')) {var orderId = parseInt($(this).find(".orderId").text().trim());var fillQuantityInput = $(this).find(".filledQty");var fillQuantity = fillQuantityInput.length ? parseInt(fillQuantityInput.val().trim()) : 0; // Get fill quantity from input field if it existsvar serialNumbers = [];var imeiInputAvailability = $(this).find(".imeis-to-grn");if (imeiInputAvailability.length) {var imeiInput = ($(this).find(".imeis-to-grn")).tagsinput('items'); // Get selected serial numbersif (imeiInput.length) {imeiInput.forEach((imei) => {serialNumbers.push(imei);});}}// Determine the quantity to bill based on serial numbers and fill quantityvar quantityToBill;if (serialNumbers.length) {quantityToBill = serialNumbers.length;} else {quantityToBill = fillQuantity;}// Create OrderBillingModel objectvar orderBillingModel = {orderId: orderId,serialNumbersToBill: serialNumbers,quantityToBill: quantityToBill};// Add OrderBillingModel object to the arrayorderBillingModels.push(orderBillingModel);}});// Convert orderBillingModels array to JSON stringvar requestBody = JSON.stringify(orderBillingModels);// Perform further actions with the requestBody, such as sending it in an AJAX requestconsole.log('Request Body:', requestBody);doPostAjaxRequestWithJsonHandler(`${context}/om/addBillingDetailsForGrouppedOrders/?warehouseId=${warehouseId}&transactionId=${transactionId}`, requestBody, function (response) {if (response) {alert("bill generated successfully");} else {alert("something went wrong");}});});});function loadAllTransaction(warehouseId, domId) {doGetAjaxRequestHandler(context + "/om/transactions/?warehouseId=" + warehouseId + "&orderStatus=SUBMITTED_FOR_PROCESSING", function (response) {$('#' + domId).html(response);var transactionId = $("#firstTxnId").val();$("#selectedWarehouse").val(warehouseId);console.log("Transaction ID:", transactionId);loadTransactionDetail(transactionId, warehouseId, "transaction-detail-container");});}function loadTransactionDetail(transactionId, warehouseId, detailContainer) {var url = context + "/om/orderByTransaction/?transactionId=" + transactionId + "&warehouseId=" + warehouseId;doGetAjaxRequestHandler(url, function (response) {$('#' + detailContainer).html(response);$("#selectedTransactionId").text(transactionId);$("#selectedWarehouseId").val(warehouseId);});}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);}}