Rev 30017 | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed
$(function () {$(document).on('click', "a.allocation_po", function () {currentFofoId = 0;counterSize = '';loadIndent('main-content');});$(document).on('click', ".partners_allocation",function () {doGetAjaxRequestHandler(context + "/getPartnerAllocation", function (response) {$('#' + 'main-content').html(response);});});$(document).on('click', ".partnerAllocation",function () {var fofoId = $('#fofo-users').val()console.log(fofoId)var url = "/indent/loadIndent?fofoId=" + fofoId + "&counterSize="+ "TEN_LAC";doAjaxRequestHandler(context + url, "GET", function (response) {{}$('.partner-indent-container').html(response);});});$(document).on('click', "button.mk_pause_button",function () {var clickedButton = $(this);var description = clickedButton.data("description");var catalogId = clickedButton.data("id");getColorsForItems(catalogId,0,"Active/pause " + description,function (itemIds) {console.log(itemIds);if (itemIds != null) {bootbox.confirm("Confirm Update "+ clickedButton.data("description")+ "?",function (result) {console.log(result)if (result) {coloredItems.forEach(function (item) {item.active = itemIds.indexOf(item.id+ "") >= 0;console.log(coloredItems)});doPostAjaxRequestWithJsonHandler(context+ "/indent/confirm-pause/",JSON.stringify(coloredItems),function (response) {if (response) {bootbox.alert("Item/s Updated Successfully");} else {bootbox.alert("Could not pause item");}});}});}});});$(document).on('click', "li.mk_counter_size", function () {if ($(this).hasClass('active')) {return;}currentFofoId = 0;counterSize = $(this).find('a').html();loadIndent('main-content');});$(document).on('click', "li.brandLi", function () {if (!$(this).hasClass('active')) {$("table.brandPerformance").toggle();$("li.brandLi").removeClass('active');$(this).addClass('active');}});$(document).on('click', ".previous-month", function () {currentFofoId = 0;counterSize = '';loadPreviousMonthIndent('main-content');});$(document).on('click', ".current-month", function () {currentFofoId = 0;counterSize = '';loadIndent('main-content');});$(document).on('click', 'a.create_indent', function () {currentFofoId = 0;counterSize = '';loadIndent("main-content");});$(document).on('click', "button.create_indent", function () {loadIndent("main-content");});$(document).on('click', "button.download_indent", function () {downloadIndent();});$(document).on('change', "#entire-catalog-table input",function () {var catalogId = parseInt($(this).data("catalog-id"));var sellingPrice = parseInt($(this).data("selling-price"));var quantity = parseInt($(this).val());if (quantity > 40) {alert("Quantity should not be above 40");if (catalogId in indentMap) {$(this).val(indentMap[catalogId].quantity);} else {$(this).val(0);}return;}brandName = $(this).data("brand-name");description = $(this).data("description");if (!(brandName in indentMap)) {indentMap[brandName] = {};}if (catalogId in indentMap[brandName]) {indentMap[brandName][catalogId]["quantity"] = quantity;indentMap[brandName][catalogId]["sellingPrice"] = sellingPrice;indentMap[brandName][catalogId]["description"] = description;indentMap[brandName][catalogId]["catalogId"] = catalogId;indentMap[brandName][catalogId]["diff"] = quantity- indentMap[brandName][catalogId]["initialQuantity"];} else {indentMap[brandName][catalogId] = {"quantity": quantity,"sellingPrice": sellingPrice,"description": description,"catalogId": catalogId,"initialQuantity": 0,"diff": quantity};}console.log(indentMap);console.log(currentFofoId)doPostAjaxRequestHandler(context+ "/open-indent/save?catalogId=" + catalogId + "&itemQty=" + quantity + "&fofoId=" + currentFofoId, function (response) {console.log(response);if (response == 'true') {}});populateIndentSummary();});/** $(document).on('click', "button.mk_submit_indent", function() {* confirmString =[]; confirmString .push('<table class="table* table-striped table-condensed table-bordered"* id="entire-catalog-table">'); confirmString.push('<tr>');* confirmString .push('<th style="width:100px">Catalog Id</th>');* confirmString .push('<th style="width:250px">Description</th>');* confirmString .push('<th style="width:150px">Unit Price</th>');* confirmString .push('<th style="width:150px">Quantity</th>');* confirmString .push('<th style="width:200px">Item total</th>');* confirmString.push('</tr>'); changedItemIds* .forEach(function(itemId) {** confirmString .push('<tr style="background-color:#9C7D7E">');* confirmString.push('<td>' + itemId + '</td>');* confirmString.push('<td>' +indentMap[itemId].description + '</td>');* confirmString .push('<td style="text-align:left">' +* numberToComma(indentMap[itemId].sellingPrice) + '</td>');* confirmString.push('<td style="text-align:left">' +* indentMap[itemId].quantity + '(' +(indentMap[itemId].diff > 0 ? '+' :* '-') + Math.abs(indentMap[itemId].diff) + ' pcs)</td>');* confirmString .push('<td style="text-align:left">'* +numberToComma(indentMap[itemId].quantity,* indentMap[itemId].sellingPrice) + '</td>'); confirmString.push('</tr>');* });**** for ( var itemId in indentMap) { if(itemId.indexOf(changedItemIds) >* 0) { continue; } if(indentMap[itemId].quantity > 0) {* confirmString.push('<tr>'); confirmString.push('<td>' + itemId + '</td>');* confirmString.push('<td>' +indentMap[itemId].description + '</td>');* confirmString .push('<td style="text-align:left">' +* numberToComma(indentMap[itemId].sellingPrice) + '</td>');* confirmString.push('<td style="text-align:left">' +* indentMap[itemId].quantity + '</td>'); confirmString .push('<td style="text-align:left">' +* numberToComma(indentMap[itemId].quantity* ,indentMap[itemId].sellingPrice) + '</td>'); confirmString.push('</tr>'); } }* confirmString.push('</table>');* $('#indent-container1').html(confirmString.join('')) .show();* $('#indent-container').hide(); $('button.mk_submit_indent').hide();* $('button.bk_toedit_indent').show();* $('button.confirm_indent').show();*//** $(document).on('click', "button.confirm_indent", function() { var* itemQtyList = []; for (catalogId in indentMap) { diff =* indentMap[catalogId]["quantity"] -* indentMap[catalogId]["initialQuantity"]; if (diff != 0) {* itemQtyList.push({ "quantity" : indentMap[catalogId]["quantity"],* "catalogId" : indentMap[catalogId]["catalogId"] }); } }* doPostAjaxRequestWithJsonHandler(context +* "/open-indent/save?fofoId=" + currentFofoId + "&counxterSize=" +* counterSize, JSON .stringify(itemQtyList), function(data) {* alert('Indent has been created Successfully!'); indentMap = {};* loadIndent('main-content'); }); });*/$(document).on('click', ".confirm_indent",function () {if (confirm("Are you sure to confirm the indent") == true) {doPostAjaxRequestHandler(context + "/open-indent/confirm?fofoId=" + currentFofoId,function (response) {console.log(response);if (response == 'true') {alert("successfully confirm");// loadIndent('main-content');}});}});/** $(document).on('click', "button.bk_toedit_indent", function() {* $('button.bk_toedit_indent').hide(); $('button.confirm_indent').hide();* $('button.mk_submit_indent').show(); $('#indent-container1').hide();* $('#indent-container').show();** });*/});function populateIndentSummary() {$planSummary = $("#plansummary");$planSummary.html('');changedItemIds = [];htmArr = [];$('button.confirm_indent').hide();for (var brandName in indentMap) {allZero = true;trArray = [];for (var itemId in indentMap[brandName]) {var description = indentMap[brandName][itemId]['description'];var itemQty = indentMap[brandName][itemId]['quantity'];var sellingPrice = indentMap [brandName][itemId]['sellingPrice'];var sellPrice = itemQty * sellingPrice;if (itemQty != 0) {allZero = false;trString = `<tr><td style = "width:80%">${description}</td><td>${itemQty}</td><td class ="currency" >${sellPrice}</td></tr>`trArray.push(trString);}}if (!allZero) {$('button.confirm_indent').show();htmArr.push('<div>');htmArr.push('<h4>' + brandName + '</h4>');htmArr.push('<table class="table table-condensed" id = "planning-table">');htmArr.push(trArray.join(' '));htmArr.push('</table>');htmArr.push('</div>');}}$planSummary.html(htmArr.join(""));var total = 0;$('#planning-table tr').each(function () {var value = parseInt($('td', this).eq(2).text());if (!isNaN(value)) {total += value;}console.log(total);});divString = `<div style ="float:right"><b>Total:-</b><span class="currency">${total}</span></div>`htmArr.push(divString);$planSummary.html(htmArr.join(""));// $('#planning-table tfoot td').eq(2).text('Total: ' + total);}function loadIndent(domId) {var url = "/indent/loadIndent?fofoId=" + currentFofoId + "&counterSize="+ counterSize;doAjaxRequestHandler(context + url, "GET", function (response) {{}$('#' + domId).html(response);});}function loadPreviousMonthIndent(domId) {let url = `${context}/indent/loadIndentPreviousMonth?fofoId=${currentFofoId}&counterSize=${counterSize}`;doAjaxRequestHandler(context + url, "GET", function (response) {$('#' + domId).html(response);});}function downloadIndent() {let url = `${context}/indent/download?fofoId=${currentFofoId}&counterSize=${counterSize}`;doAjaxGetDownload(url, "indent.csv");}