Rev 24410 | Rev 24414 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed
$("button.processPayout").live('click', function() {if($(".mk_pending")) {}});$("button.add-pricing").live('click', function() {if($("#typeaheaditem1").val().trim().length == 0){alert("Please choose Item");return;}var mop = $("#mop").val();var dp = $("#dp").val();var mrp = $("#mrp").val();var tp = $("#tp").val();if(isNaN(dp) || isNaN(mop) || isNaN(mrp)) {alert("DP/MOP/MRP should be a number");return;}mop = parseFloat(mop),dp = parseFloat(dp),mrp = parseFloat(mrp)if(mrp !=0 && (mrp < mop || mrp < dp || mrp < tp)) {bootbox.alert("DP/MOP/TP should be lower than MRP");return;}getColorsForItems(0, currentItem.itemId, "Update prices for " + currentItem.itemDescription, function(itemIds){console.log(itemIds);if(itemIds!=null) {dataList = [];coloredItems.forEach(function(item){console.log(item);console.log(itemIds.indexOf(String(item.id)));if(itemIds.indexOf(String(item.id)) >= 0) {dataList.push({id:item.id,mop:mop,dp:dp,mrp:mrp,tp:tp});}});bootbox.confirm("Confirm Update " + currentItem.itemDescription + "?", function(result){if(result) {doPostAjaxRequestWithJsonHandler(context+"/add-pricing", JSON.stringify(dataList),function(response) {if (response == 'true') {bootbox.alert("Prices Successfully Updated" );} else {bootbox.alert("Something went wrong pls try after sometime");}});}});}});});$("button.addPriceDrop").live('click', function() {if($("#typeaheaditem").val().trim().length == 0){alert("Please choose Item");return;}var newDp = $("#newDp").val();var newTp = $("#newTp").val();var newMop = $("#newMop").val();var affectedOn = $("#affectedDate").val();var allColors = $("#allColors").prop('checked');if(newDp.length == 0 || parseFloat(newDp) == 0) {alert("New Tp should not be empty");return;}if(newTp.length == 0 || parseFloat(newTp) == 0) {alert("New Tp should not be empty");return;}if(newMop.length == 0 || parseFloat(newMop) == 0) {alert("New Mop should not be empty");return;}if(affectedOn.length == 0) {alert("Affected Date Should not be empty");return;}//as of now allColors is set to true. This means that all colors are eligible for price dropif(confirm("Are you sure?")) {var obj = {itemId:currentItem.itemId,dp:parseFloat(newDp),tp:parseFloat(newTp),mop:parseFloat(newMop),allColors:true,affectedDate:startDate}doPostAjaxRequestWithJsonHandler(context+"/priceDrop", JSON.stringify(obj),function(response) {if (response == 'true') {$('#newPriceDropModal').find('button.close').trigger('click');setTimeout(() => {alert("PriceDrop added successfully from " + $("#typeaheaditem").val());loadPriceDrop("main-content");}, 500);} else {alert("Invalid values provided could not update");}});}});$('input.downloadtotalIMEI').live('click', function (){var priceDropId=$(this).closest('tr').data('pricedropid');doAjaxGetDownload(context+"/downloadtotalPriceDropIMEI/"+priceDropId,"totalPriceDropIMEI"+priceDropId+".csv");});$('button.download-imeis').live('click', function(){doAjaxGetDownload(context+"/price-drop/imes/download/?affectedDate="+startDate +"&itemId=" + currentItem.itemId, "pricedrop.csv")});$('button.mk_download_pricing').live('click', function(){doAjaxGetDownload(context+"/tagListing/download/4", "pricing.xlsx")});$('.mk_view_imeis').live('click', function (){clickedPriceDrop = $(this);var trElement=$(this).closest('tr');var priceDropId = trElement.data('pricedropid');doAjaxRequestWithJsonHandler(context+"/priceDropImeis/"+ priceDropId, 'GET', null, function(response) {response = JSON.parse(response);pendingArr=[];response.pendingImeis.forEach(function(val,index){pendingArr.push('<option>' + val + '</option>')});$('select.mk_pending').html(pendingArr.join(''));approvedArr=[];response.approvedImeis.forEach(function(val,index){approvedArr.push('<option disabled>' + val + '</option>')});$('select.mk_approved').html(approvedArr.join(''));rejectedArr=[];response.rejectedImeis.forEach(function(val,index){rejectedArr.push('<option>' + val + '</option>')});$('select.mk_rejected').html(rejectedArr.join(''));if(rejected) {}});});$('.mk_process_price_drop').live('click', function (){if (confirm("Are you sure you want to Update Payout?")) {processPayout(priceDropProcessObj)}});$('.mk_add_payout').live('click', function (){if (confirm("Are you sure you want to add price Drop?")) {var trElement=$(this).closest('tr');var priceDropId = trElement.data('pricedropid');var partnerPayout = trElement.find('.partner-payout').val();var priceDropIn = trElement.find('.price-drop-in').val();if(isNaN(partnerPayout) || partnerPayout == 0) {alert("Partner Payout can't be 0");return false;} else if (isNaN(priceDropIn) || priceDropIn == 0) {alert("Price Drop can't be 0");return false;}else {let priceDropObj = {priceDropIn:parseFloat(priceDropIn),partnerPayout: parseFloat(partnerPayout),priceDropId:parseInt(priceDropId)};addPayout(priceDropObj);}}else {return false;}});function addPayout(priceDropProcessObj){doPostAjaxRequestWithJsonHandler(context+"/price-drop/addPayout", JSON.stringify(priceDropProcessObj), function(response) {if (response == 'true') {alert("Payout added");loadPriceDrop("main-content");}else {alert("Some error occurred while adding payout.");}});}function processPayout(priceDropProcessObj){doPostAjaxRequestWithJsonHandler(context+"/processPriceDrop", JSON.stringify(priceDropProcessObj), function(response) {if (response == 'true') {alert("PriceDrop sends successfully");loadPriceDrop("main-content");}else {alert("No IMEI is Eligible for PriceDrop");loadPriceDrop("main-content");}});}function updatePriceDropImeis(status){var imeis1 = $('input.mk_imeis_text').val().trim().split(',');var imeis = [];imeis1.forEach(function(imei,i) {if(imei.trim()!='') {imeis.push(imei.trim());}});imeis = imeis.concat($('select.mk_pending').val()).concat($('select.mk_approved').val()).concat($('select.mk_rejected').val());if(imeis.length < 0) {alert('Please choose imeis');}if(!confirm("Move selected imeis to " + status + "?")) {return;}var trElement=clickedPriceDrop.closest('tr');var priceDropId = trElement.data('pricedropid');priceDropImeisObj = {priceDropId: priceDropId,updatedStatus : status,updatedImeis : imeis};doPostAjaxRequestWithJsonHandler(context+"/updatePriceDropImeis", JSON.stringify(priceDropImeisObj), function(response) {if (response == 'true') {alert('Imeis updated and processed successfully');clickedPriceDrop.click();}else {alert("Error occurred while updating.");}});}