Rev 33715 | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed
$(function() {$(document).on('click', ".partner-po", function() {loadCreatePo("main-content");});$(document).on('click', ".partner-item-detail",function() {var fofoId = $('#fofo-users').val();var url = "/getPartnerloadContent?fofoId=" + fofoId+ "&counterSize=" + "TEN_LAC";doAjaxRequestHandler(context + url, "GET", function(response) {{}$('.partner-po-container').html(response);});});$(document).on("click", ".selectItemQty",function() {var catalogId = parseInt($(this).data("catalog-id"));doGetAjaxRequestHandler(context + "/selectItemColor?catalogId="+ catalogId, function(response) {$('.select-item-container .modal-content').html(response);$('#select-item-table').find('tr').each(function() {var selectRow = $(this);var selectCurrentRow = $(this).closest("tr");var itemId = selectCurrentRow.find("td:eq(1)").html();console.log(itemId)if (itemId != undefined) {$('#po-table').find('tr').each(function() {var row = $(this);var currentRow = $(this).closest("tr");var item = currentRow.find("td:eq(0)").html();if (item != undefined) {console.log(item)if (item == itemId) {selectCurrentRow.remove();}}});}});});});$(document).on('click', ".btnDelete", function() {console.log("Hello");$(this).closest("tr").remove();});$(document).on("click", ".submit-item", function (e) {var seletedIds;var seletedIdsJson = [];// Get the current total price from the header and convert it to a numbervar totalPoPrice = parseFloat($(".totalPoPrice").text().replace(/[^0-9.-]+/g, "")) || 0;$('#select-item-table').find('tr').each(function () {var row = $(this);if (row.find('input[type="checkbox"]').is(':checked')) {var currentRow = $(this).closest("tr");var itemId = currentRow.find("td:eq(1)").html();var name = currentRow.find("td:eq(2)").html();var quantity = currentRow.find("td:eq(3) input").val();var itemPrice = parseFloat(currentRow.find("td:eq(4)").html());if (quantity == "") {alert("Select the Quantity");return false;}// Calculate total item pricevar totalItemPrice = itemPrice * quantity;// Add to the total PO pricetotalPoPrice += totalItemPrice;seletedIds = {"itemId": itemId,"name": name,"qty": quantity,"itemPrice": itemPrice}seletedIdsJson.push(seletedIds);}});console.log(seletedIdsJson);for (let i = 0; i < seletedIdsJson.length; i++) {let markup = "<tr><td>" +seletedIdsJson[i].itemId + "</td><td>" +seletedIdsJson[i].name + "</td><td>" +seletedIdsJson[i].qty + "</td><td>" +seletedIdsJson[i].itemPrice + "</td><td>" +"<button type='button' class='btnDelete'>Delete</button></td></tr>";$('#po-table > tbody:last-child').append(markup);}// Update the total price in the headerupdateTotalPoPrice(totalPoPrice);$("#selectItem").modal("hide");});// Function to update the total price in the headerfunction updateTotalPoPrice(newPrice) {$('.totalPoPrice').text('Total Price: ' + newPrice.toFixed(2));}$(document).on('click', ".confirm_po",function() {var jsonObject = {};var poIdsJSon = [];var poIds;var fofoId = $('#fofo-users').val();$('#po-table').find('tr').each(function() {var row = $(this);console.log(row);var currentRow = $(this).closest("tr");var itemId = currentRow.find("td:eq(0)").html();var qty = currentRow.find("td:eq(2)").html();console.log(itemId);if (itemId != undefined) {poIds = {"itemId" : itemId,"qty" : qty}console.log(poIds);poIdsJSon.push(poIds);}});console.log(poIdsJSon)console.log(fofoId)if (fofoId == null) {alert("Partner ID is required");return false;}if (poIdsJSon.length === 0) {alert("Atleast one Item selected");return false;}jsonObject['poIds'] = poIdsJSon;jsonObject['fofoId'] = fofoId;console.log(jsonObject)if (confirm("Are you sure you want to create po") == true) {doPostAjaxRequestWithJsonHandler(context + "/createPo",JSON.stringify(jsonObject), function(response) {if (response == 'true') {alert("successfully create");loadCreatePo("main-content");}});}});});function loadCreatePo(domId) {doGetAjaxRequestHandler(context + "/partnerPendingOrder",function(response) {$('#' + domId).html(response);});}