Rev 27071 | Rev 28893 | Go to most recent revision | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed
$(document).on('click', "button.processPayout", function() {if($(".mk_pending")) {}});$(document).on('click', "button.add-pricing", 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");}});}});}});});$(document).on('click', "button.addPriceDrop", 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");}});}});$(document).on('click', 'input.downloadtotalIMEI', function (){var priceDropId=$(this).closest('tr').data('pricedropid');doAjaxGetDownload(context+"/downloadtotalPriceDropIMEI/"+priceDropId,"totalPriceDropIMEI"+priceDropId+".csv");});$(document).on('click', 'button.download-imeis', function(){doAjaxGetDownload(context+"/price-drop/imes/download/?affectedDate="+startDate +"&itemId=" + currentItem.itemId, "pricedrop.csv")});$(document).on('click', 'button.mk_download_pricing', function(){doAjaxGetDownload(context+"/tagListing/download/4", "pricing.xlsx")});$(document).on('click', '.mk_auto_process', function (){var trElement=$(this).closest('tr');var payout = trElement.find('input.partner-payout').val();if(isNaN(parseInt(payout)) || parseInt(payout) <=0) {alert("Invalid payout amount");}if (confirm("Are you sure you want to Process Payout?")) {clickedPriceDrop = $(this);var priceDropId = trElement.data('pricedropid');autoProcess({priceDropId:priceDropId, partnerPayout:payout, activatedOnly:$(this).data('activatedonly')})}});$(document).on('click', '.mk_view_imeis', 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 disabled>' + val + '</option>')});$('select.mk_pending').html(pendingArr.join('')).find('option');$('span.mk_pending_count').html(pendingArr.length);approvedArr=[];response.approvedImeis.forEach(function(val,index){approvedArr.push('<option>' + val + '</option>')});$('select.mk_approved').html(approvedArr.join(''));$('span.mk_approved_count').html(approvedArr.length);rejectedArr=[];response.rejectedImeis.forEach(function(val,index){rejectedArr.push('<option>' + val + '</option>')});$('span.mk_rejected_count').html(rejectedArr.length);$('select.mk_rejected').html(rejectedArr.join(''));//if(rejected) {}});});$(document).on('click', '.mk_add_payout', 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 autoProcess(priceDropObj){doPostAjaxRequestWithJsonHandler(context+"/processPriceDrop", JSON.stringify(priceDropObj), 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());}});if(status=='rejected') {if($("#statusForm .mk_rejection_reason").val().trim()=="") {alert("Please enter rejection reason");return;}imeis = imeis.concat($('select.mk_approved').val());} else {if($("#statusForm .mk_rejection_reason").val().trim()!="") {alert("Rejection reason should be empty during approval.");return;}imeis = imeis.concat($('select.mk_rejected').val());}if(imeis.length == 0) {alert('Please choose imeis');return;}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.");}});}