selectedCurrency = "USD"; selectedCountry = "USA"; formArray = new Array(); flag = 0; var customItemCount = 1; var finalCustomItemCountArray = [1]; var alreadySubscribedFlag = 0; var productPlanCurrency = null; var displayProductPlan = false; var subscriptionFrequency = 1; var subscriptionStartDate; var basicpackageCustomer = false; var trialAccount = false; var accountStatusId = "Payee"; currencyArray = { "EUR" : "€", "AUD" : "A$ ", "USD" : "$", "GBP" : "£", "INR" : "₹" }; var substringMatcher = function(strs) { return function findMatches(q, cb) { var matches, substringRegex; // an array that will be populated with substring matches matches = []; // regex used to determine if a string contains the substring `q` substrRegex = new RegExp(q, 'i'); // iterate through the pool of strings and for any string that // contains the substring `q`, add it to the `matches` array $.each(strs, function(i, str) { if (substrRegex.test(str)) { // the typeahead jQuery plugin expects suggestions to a // JavaScript object, refer to typeahead docs for more info matches.push({ value: str }); } }); cb(matches); }; }; //*These functions are init functions of various pages *// function initPricing(){ loadAllProductPlanData(); } function initCompare(){ loadAllProductPlanData(); } function initConfirm(){ loadAllCountryPrice(); } function initBuy(currency, plan, isAlreadySubscribed){ productPlanCurrency = currency; alreadySubscribedFlag = isAlreadySubscribed; addRemoveInboundDiv(); loadSMSPackData(currency); loadIncomingPriceData(currency); loadProductPlanData(currency, plan ,isAlreadySubscribed); if(accountStatusId == 'expired' || accountStatusId == 'trial') { displayCustomMessages(); } } function initSMSCost(){ loadTopCountryPrice(); getCurrencyConversionFactors(); loadTopIncomingPrice(); loadAllCountryPriceForSMSCostPage(); loadAllIncomingCountryPrice(); } function initTopup(){ getCurrencyConversionFactors(); loadAllCountryPrice(); // for outgoing price and auto complete dropdown loadAllIncomingCountryPrice(); loadSMSPackData("USD", 1); } /*This function is called on pricing and compare page on change of currency */ function updateProductPlanPrice(currency){ response = productPlanData[currency]; selectedCurrency = currency; if(selectedCurrency == "INR"){ var plan1Price = response[0].price * 12; var plan2Price = response[1].price * 12; var plan3Price = response[2].price * 12; }else{ var plan1Price = response[0].price; var plan2Price = response[1].price; var plan3Price = response[2].price; } $(".currencyButtons").removeClass("btn-primary"); $(".currencyButtons").addClass("btn-default"); $("#"+currency).addClass("btn-primary"); $(".currencyButtons").addClass("outlined"); $("#"+currency).removeClass("outlined"); var currencySign = currencyArray[currency]; $("#plan_1_currency").html(currencySign); $("#plan_1_price").html(numerToPrice(plan1Price)); $("#plan_2_currency").html(currencySign); $("#plan_2_price").html(numerToPrice(plan2Price)); $("#plan_3_currency").html(currencySign); $("#plan_3_price").html(numerToPrice(plan3Price)); if(selectedCurrency == "INR"){ //document.getElementById('selectCurrencyINRDiv').style.display="block"; $('.currencydiv').show(); $('.selectCurrencyOTHERDiv').hide(); }else{ $('.currencydiv').hide(); $('.selectCurrencyOTHERDiv').show(); } } /*This function is called on SMS Cost page on change of currency */ function convertPricingSMS(currency){ selectedCurrency = currency; var convFactor = factorArray[currency]; generateHtml("newTopCountryPriceDiv",topCountryList , convFactor,currency); generateHtml("allCountryPriceDiv",countryList , convFactor,currency); generateIncomingHtml("topIncomingCountryPriceDiv",topIncomingPriceData,1, convFactor , currency); generateIncomingHtml("allIncomingCountryPriceDiv",incomingPriceData,0, convFactor , currency); calculateCost( convFactor , currency); } /*This function is called on Topup page on change of currency */ function convertPricingTopup(currency){ selectedCurrency = currency; document.getElementById('selectCountry').disabled = false; if(currency == "INR"){ $('#selectCountry').val("India"); showCountryPrice("India" ,"INR"); var dropdown = $('select[name="selectCountry"]'); dropdown.prop('disabled', true); //disable IMEI select } generateSMSPackHtmlForTopupPage(smsPackPriceData, currency); showCountryPrice(selectedCountry ,currency); } /*This function is called on Inbound page on change of currency*/ function convertPricingInbound(currency){ selectedCurrency = currency; var inboundCountry = $( "#inboundCountry option:selected" ).text(); var params = { "currency" : currency, "countryName" : inboundCountry }; $.post("/pricingajaxapi/getInboundCountryPricing", params, function(data){ var responseData = eval('(' + data + ')'); var price = responseData['price']; var amount = price+" "+currencyArray[currency]+" "+"Per Month"; $('#priceInbound').html(amount); $('#csrfField').attr('name', csrfInputName); $("#csrfField").val(csrfTokenValue); $("#inboundCurrency").val(currency); loadIncomingPriceData(currency); var pricePerNumber = incomingCountryPriceArray[inboundCountry]; var dataArr = pricePerNumber.split( '-' ); $("#inboundNumberProductItemId").val(dataArr[1]); }); $(".currencyButtons").addClass("outlined"); $("#"+currency).removeClass("outlined"); $(".currencyButtons").removeClass("btn-primary"); $(".currencyButtons").addClass("btn-default"); $("#"+currency).addClass("btn-primary"); //generateSMSPackHtmlForTopupPage(smsPackPriceData, currency); } /* This function creates country Array, country price array and country flag array for incoming and price per sms cost */ function createCountryPriceArray(){ countryArray = new Array(); countryPriceArray = new Array(); countryFlagArray = new Array(); countryLocalPriceArray = new Array(); for(var i=0; i< countryList.length; i++){ var countryName = countryList[i].countryName; var price = countryList[i].price; var flagName = countryList[i].flagName; var localprice = countryList[i].localprice; countryArray.push(countryName); countryLocalPriceArray[countryName] = localprice; countryPriceArray[countryName] = price; countryFlagArray[countryName] = flagName; } } /* This function loads all countries to auto complete country dropdown. */ function loadAutoCompleteCountryList(){ var states = countryArray; $('#scrollable-dropdown-menu .typeahead').typeahead({ hint: true, highlight: true, minLength: 1 }, { name: 'states', displayKey: 'value', source: substringMatcher(states), updater:function (item) { } }); } /*This function adds and removes inbound number country-price row on buy page on click of add country and delete last item buttons. */ function addRemoveInboundDiv() { $("#addIncoming").click(function () { var countryName = $('select[name=incomingInboundCountry]').val(); var addIncomingNumber = false; if(accountStatusId == "Payee" || !accountStatusId) { addIncomingNumber = true; } var len = formArray.length; for (var i =0; i< len; i++) { if(formArray[i].productId == 2 || (formArray[i].productId == 4 && formArray[i].productItemId == 5)) { addIncomingNumber = true; break; } } if(addIncomingNumber == true) { if (countryName != "Select Country Name" || !countryName.trim()) { currencySign = currencyArray[selectedCurrency]; var pricePerNumber = incomingCountryPriceArray[countryName]; var dataArr = pricePerNumber.split( '-' ); pricePerNumber = dataArr[0]; var id = dataArr[1]; var incomingNumberId = id; // if(id > totalIncomingProducts) // { // incomingNumberId = parseInt(id % totalIncomingProducts); // } if(($('.incoming-group').length+1) > 10) { alert("Only 10 Numbers allowed"); return false; } var itemName = 'Inbound Number - '+ countryName; var in_id = ($('.incoming-group').length + 1).toString(); //alert("incomingNumberId:" +incomingNumberId); addItemToSummary(3,incomingNumberId , selectedCurrency ,pricePerNumber , itemName); } else { alert("Please Select Inbound Country"); return false; } } else { accountStatusId = 'trial'; displayCustomMessages(); } }); removeIncomingNumberCountryDiv(); } function displayCustomMessages() { var message; if(accountStatusId == 'expired') { message ="Your account is expired. Please buy Subscription Plan to activate account."; } else if(accountStatusId == 'trial') { message ="If you need an Incoming Number for testing, please contact : sales@screen-magic.com"; } if($("#displayCustomMessages").length > 0) { $( "#displayCustomMessages" ).remove(); } html = ''; $("#trialExpiry").after(html); } function removeSummaryItem(id, productId, productItemId) { if(formArray.length > 0) { for (var i = 0; i < formArray.length; i++) { if(i == id) { formArray.splice(i, 1); break; } } } loadItemsToSummary(selectedCurrency); loadCheckoutForm(selectedCurrency); } function removeIncomingNumberCountryDiv(){ $("#removeIncoming").click(function () { if ($('.incoming-group').length == 0) { return false; } var countryName = $(".incoming-group .country:last").html(); countryNameArr = countryName.split( '-' ); countryName = $.trim(countryNameArr[1]); var pricePerNumber = incomingCountryPriceArray[countryName]; var dataArr = pricePerNumber.split( '-' ); pricePerNumber = dataArr[0]; var id = dataArr[1]; var incomingNumberId = id; if(id > totalIncomingProducts){ incomingNumberId = parseInt(id % totalIncomingProducts); } $(".incoming-group:last").remove(); removeItemFromSummary(3,incomingNumberId ,selectedCurrency); }); } function incomingPricing(incomingPricingData ,currency){ var pricingData = incomingPricingData[currency]; for(var i=0; i< pricingData.length; i++){ var countryName = pricingData[i].countryName; var id = pricingData[i].id; var price = pricingData[i].price; incomingCountryPriceArray[countryName] = price+"-"+id; } } function loadAutoCompleteCountryListForIncoming(incomingPricingData ,currency){ incomingCountryArray = new Array(); incomingCountryPriceArray = new Array(); var pricingData = incomingPricingData[currency]; for(var i=0; i< pricingData.length; i++){ var countryName = pricingData[i].countryName; var id = pricingData[i].id; var price = pricingData[i].price; incomingCountryArray.push(countryName); } incomingPricing(incomingPricingData ,currency); var states = incomingCountryArray; $('#scrollable-dropdown-menu .typeahead').typeahead({ hint: true, highlight: true, minLength: 1 }, { name: 'states', displayKey: 'value', source: substringMatcher(states) }); } topupPricePerSMS = 0.0; function showCountryPrice(countryName ,currency){ selectedCountry = countryName; $("#typeahead").val(selectedCountry); currencySign = currencyArray[selectedCurrency]; var convFactor = factorArray[selectedCurrency]; if(typeof(convFactor)==='undefined') convFactor = 1; var pricePerSMS = countryPriceArray[countryName]; if(countryName == "India" && currency == "INR"){ var pricePerSMS = countryLocalPriceArray[countryName]; } if(convFactor != 1){ pricePerSMS = (pricePerSMS * convFactor).toFixed(4); } topupPricePerSMS = pricePerSMS; var flagName = countryFlagArray[countryName]; var incomingPrice = 0.0; var countryList = incomingPriceData[selectedCurrency]; for(var i=0; i< countryList.length; i++){ if(countryList[i].countryName == countryName){ incomingPrice = countryList[i].price; incomingPrice = incomingPrice +" "+ currencySign + " Per Month "; if(currency == "INR"){ incomingPrice = countryList[i].price * 12; incomingPrice = incomingPrice +" "+ currencySign + " Per Year "; } break; }else{ incomingPrice = ' Contact Sales';//"

Contact Sales

"; } } $("#priceInbound").html(incomingPrice); $("#pricePerSMS").html(pricePerSMS +" "+ currencySign); var html = ''+countryName+''; $("#countryFlagDiv").html(html); generateSMSPackHtmlForTopupPage(smsPackPriceData, selectedCurrency); } function showInboundCountryPrice(countryName ,currency){ selectedCountry = countryName; $("#typeahead").val(selectedCountry); currencySign = currencyArray[selectedCurrency]; var flagName = countryFlagArray[countryName]; var html = ''+countryName+''; $("#countryFlagDiv").html(html); convertPricingInbound(currency); } function calculateCost( convFactor , currency){ if(typeof(selectedCurrency)==='undefined') selectedCurrency = "EUR"; var convFactor = factorArray[selectedCurrency]; if(typeof(convFactor)==='undefined') convFactor = 1; var calculatedPrice = 0; var countryName = $('#typeahead').prop("value"); var pricePerSMS = countryPriceArray[countryName]; if(currency == "INR"){ var pricePerSMS = countryLocalPriceArray[countryName]; } if(convFactor != 1){ pricePerSMS = (pricePerSMS * convFactor).toFixed(4); } var number0fSMS = $('#number0fSMS').prop("value"); currencySign = currencyArray[selectedCurrency]; calculatedPrice = pricePerSMS * number0fSMS; calculatedPrice = calculatedPrice.toFixed(2); if(calculatedPrice == "NaN" || pricePerSMS == "NaN"){ calculatedPrice = 0; pricePerSMS = (0.0000).toFixed(4); } $("#calculatedAmount").html(" = "+calculatedPrice +" "+ currencySign); $("#pricePerSMS").html("   ( "+pricePerSMS +" "+ currencySign + " per sms )"); } /* This function gets pricing of top countries from database and store it to global variable for further use. */ function loadTopCountryPrice(){ $.get("/pricingajaxapi/getTopCountryPricing", null, function(data) { var responseData = eval('(' + data + ')'); topCountryList = responseData["topCountryList"]; generateHtml("newTopCountryPriceDiv",topCountryList,factorArray["USD"],"USD"); }); } function getCurrencyConversionFactors(){ factorArray ={}; $.ajax({ type: "GET", async: false, url: "/pricingajaxapi/getCurrencyConversionFactors", data: null, success: function(data) { var responseData = eval('(' + data + ')'); conversionFactors = responseData["conversionFactors"]; for(var i=0; i< conversionFactors.length; i++){ var toCurrency = conversionFactors[i].toCurrency; var convFactor = conversionFactors[i].convFactor; factorArray[toCurrency] = convFactor; } } }); } /* This function gets incoming number pricing of all countries from database and store it to global variable for further use. buy page */ function loadIncomingPriceData(currency){ $.ajax({ type: "GET", async: false, url: "/pricingajaxapi/getAllIncomingCountryPricing", data: null, success: function(data) { incomingPricingData = eval('(' + data + ')'); loadAutoCompleteCountryListForIncoming(incomingPricingData ,currency); } }); } /* This function gets pricing of all countries from database and store it to global variable for further use. * also it loads the country list to the auto complete drop down for topup page */ function loadAllCountryPrice(){ $.ajax({ type: "GET", async: false, url: "/pricingajaxapi/getAllCountryPricing", data: null, success: function(data) { var responseData = eval('(' + data + ')'); countryList = responseData["countryList"]; createCountryPriceArray(); loadAutoCompleteCountryList(); //generateHtml("allCountryPriceDiv",countryList,factorArray["USD"],"USD"); } }); } function loadAllCountryPriceForSMSCostPage(){ $.ajax({ type: "GET", async: false, url: "/pricingajaxapi/getAllCountryPricing", data: null, success: function(data) { var responseData = eval('(' + data + ')'); countryList = responseData["countryList"]; //loadAutoCompleteCountryList(); createCountryPriceArray(); generateHtml("allCountryPriceDiv",countryList,factorArray["USD"],"USD"); } }); } /* This function gets incoming number pricing of all countries from database and store it to global variable for further use. sms cost page */ function loadAllIncomingCountryPrice(){ $.ajax({ type: "GET", async: false, url: "/pricingajaxapi/getAllIncomingCountryPricing", data: null, success: function(data) { incomingPriceData = eval('(' + data + ')'); generateIncomingHtml("allIncomingCountryPriceDiv",incomingPriceData,0, factorArray["USD"],"USD"); } }); } /* This function gets incoming number pricing of top countries from database and store it to global variable for further use. */ function loadTopIncomingPrice(){ $.get("/pricingajaxapi/getTopIncomingNumberPricing", null, function(data) { topIncomingPriceData = eval('(' + data + ')'); generateIncomingHtml("topIncomingCountryPriceDiv",topIncomingPriceData ,1, factorArray["USD"],"USD"); }); } function generateHtml(divId,countryList , convFactor , currency){ if(typeof(convFactor)==='undefined') convFactor = 1; if(typeof(currency)==='undefined') currency = "EUR"; var priceDivHTML = ""; var html =""; var currencySign = currencyArray[currency]; for(var i=0; i< countryList.length; i++){ var countryName = countryList[i].countryName; var flagName = countryList[i].flagName; if((countryList[i].countryId == '80') && ( currency == "INR")){ var price = countryList[i].localprice; }else{ var price = countryList[i].price; } if(convFactor != 1){ price = (price * convFactor).toFixed(4); } priceDivHTML = "
"+ "
"+ "
"+ ""+ ""+countryName+""+ "
"+ "
"+ " "+price+" "+ currencySign ; if(divId == "incomingPriceDiv"){ priceDivHTML += " /mo "; } priceDivHTML += ""+ "
"+ "
"+ "
"; $(".currencyButtons").removeClass("btn-primary"); $(".currencyButtons").addClass("btn-default"); $("#"+currency).addClass("btn-primary"); $(".currencyButtons").addClass("outlined"); $("#"+currency).removeClass("outlined"); html += priceDivHTML; } $("#"+divId).html(html); } function generateIncomingHtml(divId,incomingPriceData ,isTopCountryList, convFactor , currency){ if(typeof(convFactor)==='undefined') convFactor = 1; if(typeof(currency)==='undefined') currency = "EUR"; if(typeof(isTopCountryList)==='undefined') isTopCountryList = 1; var countryList = incomingPriceData[currency];//+currency; var priceDivHTML = ""; var html =""; var length =0; var currencySign = currencyArray[currency]; if(isTopCountryList ==1){ length = countryList.length; divId = "topIncomingCountryPriceDiv"; }else{ length = countryList.length; divId = "allIncomingCountryPriceDiv"; } for(var i=0; i< length; i++){ var countryName = countryList[i].countryName; var flagName = countryList[i].flagName; var price = countryList[i].price; if(currency == "INR"){ price = price * 12; } priceDivHTML = "
"+ "
"+ "
"+ ""+ ""+countryName+""+ "
"+ "
"+ " "+price+" "+ currencySign ; if(currency == "INR") priceDivHTML += " /yr "; else priceDivHTML += " /mo "; priceDivHTML += ""+ "
"+ "
"+ "
"; $(".currencyButtons").removeClass("btn-primary"); $(".currencyButtons").addClass("btn-default"); $("#"+currency).addClass("btn-primary"); html += priceDivHTML; } $("#"+divId).html(html); } function askForCCInfo() { $("#ccinfo-div").show(); $("#active-card-div").hide(); } function hideCCInfo() { $("#active-card-div").show(); $("#ccinfo-div").hide(); } function isAcceptedTnCActiveCard() { var isCheckedTermsAndCondition = $('#termsAndCondition1').is(":checked"); if (!isCheckedTermsAndCondition) { $("#termsAndConditionMsg1").show(); return false; } else { $("#termsAndConditionMsg1").hide(); return true; } return false; } function isAcceptedTnCNoActiveCard() { var isCheckedTermsAndCondition = $('#termsAndCondition2').is(":checked"); if (!isCheckedTermsAndCondition) { $("#termsAndConditionMsg2").show(); return false; } else { $("#termsAndConditionMsg2").hide(); return true; } return false; } function initiatePaymentWithActiveCard(form) { var tnc = isAcceptedTnCActiveCard(); if (tnc == true) { // Disable the submit button to prevent repeated clicks $(form).find('button').prop('disabled', true); return true; } return false; } /* * This function get SMS pack data from database and generate the html and set it to sms pack div * */ function loadSMSPackData(currency , isTopupPage){ selectedCurrency = currency; $.ajax({ type: "GET", async: false, url: "/pricingajaxapi/getSMSPackPrice", data: null, success: function(data) { smsPackPriceData = eval('(' + data + ')'); if(isTopupPage == 1){ showCountryPrice(selectedCountry ,currency); generateSMSPackHtmlForTopupPage(smsPackPriceData, currency); }else{ generateSMSPackHtml(smsPackPriceData, currency); } } }); } function loadProductPlans(display, subscriptionFrequency) { if(subscriptionFrequency == null){ subscriptionFrequency = $("input[type='radio'][name='subscription_frequency']:checked").val(); } if(typeof(subscriptionFrequency)==='undefined') subscriptionFrequency = 1; if(selectedCurrency == "INR"){ subscriptionFrequency = 12; } if(display == 'show') { displayProductPlan = true; } $.ajax({ type: "GET", async: false, url: "/pricingajaxapi/getAllProductPlanPrice", data: null, success: function(data) { productPlanPriceData = eval('(' + data + ')'); generateProductPlanHtml(productPlanPriceData, selectedCurrency, subscriptionFrequency); } }); } //This function get called when curency is get changed it changes pricing of all product items according to currency function updatePriceAsPerCurrency(currency,plan){ if(currency == selectedCurrency) return; if(currency == "INR"){ subscriptionFrequency = 12; } selectedCurrency = currency; generateSMSPackHtml(smsPackPriceData , currency); generateHtmlForSelectedItems(currency, subscriptionFrequency); loadProductPlanData(currency,plan, isSubscribedForPlan); } function updatePriceAsPerSelectedCurrency(currency){ subscriptionFrequency = 1; $('input[name="subscription_frequency"][value="1"]').prop('checked', true); selectedCurrency = currency; if(currency == "INR"){ document.getElementById('changeCurrencyINR').style.display = "none"; subscriptionFrequency = 12; $('input[name="subscription_frequency"][value="12"]').prop('checked', true); loadProductPlans('hide', 12); changeSelectedPlan(selectedCurrency,1,12); }else{ document.getElementById('changeCurrencyINR').style.display = "block"; loadProductPlans('hide'); changeSelectedPlan(selectedCurrency,1); } generateSMSPackHtml(smsPackPriceData , currency); generateHtmlForSelectedItems(currency, subscriptionFrequency); clearSummaryItems(); } /* This function generate html for the selected items and load it to summary and list of inbound numbers */ function generateHtmlForSelectedItems(selectedCurrency, subscriptionFrequency){ incomingPricing(incomingPricingData ,selectedCurrency); if(typeof(subscriptionFrequency)==='undefined') subscriptionFrequency = 1; $('.incoming-group-all').html(""); for(var i=0; i< formArray.length; i++){ var productId = formArray[i].productId; var newPrice = 0; var itemName = formArray[i].itemName; var countryNameArr = itemName.split( '-' ); itemName = $.trim(countryNameArr[1]); if(productId == 1){ newPrice = smsPackPriceArray[itemName]; } else if(productId == 2){ var arr = changeSelectedPlan(selectedCurrency,0, subscriptionFrequency); newPrice = arr['price']; formArray[i].itemName = arr['itemName']; } else if(productId == 3){ newPrice = incomingCountryPriceArray[itemName]; var newPriceArr = newPrice.split( '-' ); newPrice = $.trim(newPriceArr[0]); if(subscriptionFrequency == 12){ newPrice = newPrice*12; } } formArray[i].price = newPrice; formArray[i].currency = selectedCurrency; var currencySign = currencyArray[selectedCurrency]; if(productId == 3){ itemName = 'Inbound Number - '+ itemName; var in_id = ($('.incoming-group').length + 1).toString(); $('.incoming-group-all').append( '
\
\
\

'+ itemName +'

\
\
\

'+ newPrice +' '+currencySign+' per month

\
\
\
'); } } loadItemsToSummary(selectedCurrency); loadCheckoutForm(selectedCurrency); } function generateHtmlForSelectedItemsforCustomer(selectedCurrency, subscriptionFrequency){ incomingPricing(incomingPricingData ,selectedCurrency); if(typeof(subscriptionFrequency)==='undefined') subscriptionFrequency = 1; for(var i= 0; i< formArray.length; i++){ var productId = formArray[i].productId; var newPrice = 0; var itemName = formArray[i].itemName; var countryNameArr = itemName.split( '-' ); itemName = $.trim(countryNameArr[1]); if(productId == 1){ newPrice = smsPackPriceArray[itemName]; } if(productId == 3){ newPrice = incomingCountryPriceArray[itemName]; var newPriceArr = newPrice.split( '-' ); newPrice = $.trim(newPriceArr[0]); if(subscriptionFrequency == 12){ newPrice = newPrice*12; } } formArray[i].price = newPrice; formArray[i].currency = selectedCurrency; var currencySign = currencyArray[selectedCurrency]; } loadItemsToSummary(selectedCurrency); loadCheckoutForm(selectedCurrency); } function addSMSPackHoverClass(id){ $("#"+id).addClass("sms_pack_hover"); } function removeSMSHoverClass(id){ $("#"+id).removeClass("sms_pack_hover"); } function addItemToSummary(productId, productItemId , currency ,price , itemName, itemId, cutomItemOriginalAmount){ $("#buyPageError").hide(); $(".sms_pack_name").removeClass("sms_pack_onclick"); $("#"+itemId).removeClass("sms_pack_hover"); $("#"+itemId).addClass("sms_pack_onclick"); var rowArray = new Array(); var frequencyText = "Per Month"; if(subscriptionFrequency == 12) { frequencyText = "Per Year"; } if(typeof(cutomItemOriginalAmount)==='undefined') cutomItemOriginalAmount = null; if(productId == 3) { price = price * subscriptionFrequency; } if(productId == 2) { $("#planDiv").html(itemName +" : "+price +" "+currency +" "+frequencyText); } rowArray = { "productId" : productId, "productItemId" : productItemId, "itemName" : itemName, "price" : price, "currency" : currency, "cutomItemOriginalAmount" : cutomItemOriginalAmount, "subscriptionFrequency" : subscriptionFrequency }; /* Product Id List * 1 - SMS Pack * 2 - Inbound Number * 3 - Standard Subscription Plan * 4 - Custom Subscription Plan (with Product Item Id 5) * 4 - Custom SMS pack (with Product Item Id 1) * 4 - Custom Inbound number (with Product Item id 2) */ if((productId == 1) && formArray.length > 0) { flag = 1; } else if(productId == 2 && formArray.length > 0) { var len = formArray.length; for (var i =0; i< len; i++) { if(formArray[i].productId == 2 || (formArray[i].productId == 4 && formArray[i].productItemId == 5)) { formArray[i] = rowArray; flag = 0; break; } else { flag = 1; } } } else if(productId == 4 && formArray.length > 0) { if(productItemId == 5) { var len = formArray.length; for (var i =0; i< len; i++) { if((formArray[i].productId == 4 && formArray[i].productItemId == 5) || formArray[i].productId == 2) { formArray[i] = rowArray; flag = 0; break; } else { flag = 1; } } } else if(productItemId == 1) { flag = 1; } else { flag = 1; } } else { flag = 1; } if(flag == 1) { formArray.push(rowArray); } loadItemsToSummary(currency); loadCheckoutForm(currency); } /* This funciton gets sms pack data according to provided currency,generate html and load data to sms pack div*/ function generateSMSPackHtml(smsPackPriceData, currency){ smsPackPriceArray ={}; if(typeof(currency)==='undefined') currency = "USD"; var html = ""; var smsPackPrice = smsPackPriceData[currency]; var currencySign = currencyArray[currency]; var msg = ""; var className = ""; for(var i=0; i< smsPackPrice.length; i++){ var packName = smsPackPrice[i].item_name; var id = smsPackPrice[i].id; var price = smsPackPrice[i].price; var validity = smsPackPrice[i].validity; var discountPercent = smsPackPrice[i].discountedPercent; var discountedPrice = smsPackPrice[i].discountedPrice; smsPackPriceArray[packName] = price; if(packName == "Trial" || packName == "Coral" ){ msg = " Validity : "+validity +" days "; var st_html = '' }else{ msg = " Pay "+discountPercent+" % less"; var st_html = ' '+ currencySign +' '+ price +' ' } var smsPackName = "SMS Pack -"+packName; var smsPackId = i+1; html += '
'+ '
'+ '
'+packName+'
'+ '
'+st_html+' '+ currencySign +' '+ discountedPrice +'
'+ '
'+ msg +'
'+ '
'+ '
'; } $("#smsPackDiv").html(html); $(".currencyButtons").removeClass("btn-primary"); $(".currencyButtons").addClass("btn-default"); $("#"+currency).addClass("btn-primary"); } function generateProductPlanHtml(productPlanPriceData, currency, subscriptionFrequency) { if(typeof(subscriptionFrequency)==='undefined') subscriptionFrequency = 1; if(alreadySubscribedFlag == 1) { //$('#subscriptionPlanDiv').show(); } productPlanPriceArray ={}; if(typeof(currency)==='undefined') { currency = "USD"; } var html = ""; var productPlanPrice = productPlanPriceData[currency]; var currencySign = currencyArray[currency]; var msg = ""; var className = ""; var frequencyText = "/ Month / Org"; for(var i=0; i< productPlanPrice.length; i++){ var productPlanName = productPlanPrice[i].item; var id = productPlanPrice[i].id; var price = productPlanPrice[i].price * subscriptionFrequency; productPlanPriceArray[productPlanName] = price; var smsPackName = "Plan - "+productPlanName; var id = i+1; if(subscriptionFrequency == 12) { var frequencyText = "/ Year / Org"; } html += '
'+ '
'+ '
'+productPlanName+'
'+ '
'+ currencySign +' '+price+'
'+ '
'+frequencyText+'
'+ '
'+ '
'; } $("#customerPlanDiv").hide(); $("#customerPlanDiv").html(html); if(alreadySubscribedFlag == 0 && basicpackageCustomer=="") { $("#customerPlanDiv").show(); } else if(alreadySubscribedFlag == 1 && basicpackageCustomer=="") { $("#customerPlanDiv").hide(); } else if(alreadySubscribedFlag == 1 && basicpackageCustomer== 1) { $("#customerPlanDiv").show(); } } function generateSMSPackHtmlForTopupPage(smsPackPriceData, currency){ smsPackPriceArray ={}; if(typeof(currency)==='undefined') currency = "USD"; var html = ""; var html1 = ""; var smsPackPrice = smsPackPriceData[currency]; var currencySign = currencyArray[currency]; var className = ""; for(var i=0; i< smsPackPrice.length; i++){ var packName = smsPackPrice[i].item_name; var id = smsPackPrice[i].id; var price = smsPackPrice[i].price; var validity = smsPackPrice[i].validity; var discountPercent = smsPackPrice[i].discountedPercent; var discountedPrice = smsPackPrice[i].discountedPrice; smsPackPriceArray[packName] = price; var noOfSMS = parseInt(price / topupPricePerSMS);//.toFixed(0); var discountMsg = ""; var validityMsg = ""; if(packName == "Trial" || packName == "Coral"){ validityMsg = " Validity : "+validity +" days "; className = ""; html1 = ' '+currencySign+''+ price+''+ ''+validityMsg+' '; }else if(packName == "Economy") { discountMsg = " ( "+discountPercent+" % OFF)"; className = ""; html1 = ''+currencySign+' '+ ' '+ price+' '+ ' '+currencySign+' '+ ' '+ discountedPrice+' '; }else{ discountMsg = " ( "+discountPercent+" % OFF)"; className = ""; html1 = ''+currencySign+' '+ ' '+ price+' '+ ' '+currencySign+' '+ ' '+ discountedPrice+' '; } var smsPackId = i+1; html +='
'+ '
'+ '
'+packName+' '+discountMsg+'
'+ '
'+html1+ '
'+ '
' + '
' + '' + '' + '' + '' + '
'+ '' + '
Approx '+noOfSMS+' SMS in '+ selectedCountry + '
'+ '
'+ '
'; } $("#smsPackDiv").html(html); $(".currencyButtons").addClass("outlined"); $("#"+currency).removeClass("outlined"); $(".currencyButtons").removeClass("btn-primary"); $(".currencyButtons").addClass("btn-default"); $("#"+currency).addClass("btn-primary"); } function removeItemFromSummary(productId ,id , currency){ if(productId == 3 && formArray.length >0){ for (var i =0; i"; } } else if(productId == 4 && productItemId == 5) { delitemhtml = ""; } else{ delitemhtml = ""; } html += ""+ itemName +""+parseFloat(price).toFixed(2)+ " "+currencySign+" "+freq+""+delitemhtml+""; $('#row-'+productId).remove(); } html += 'Total '+total.toFixed(2)+' '+ currencySign+''; $('#summaryDiv tr:last').after(html); $("#recurringTotal").html(recurringTotal +" "+ currencySign); if ( produt1Flag == 0 && produt3Flag == 0 ) { msg = "Don't forget to buy Incoming Numbers for receiving responses and SMS Packs for sending outbound messages"; } else if( produt1Flag == 0 ) { msg ="You can also purchase SMS Pack for sending outbound messages"; } else if ( produt3Flag == 0 ) { msg ="You can also buy Incoming Numbers for receiving responses"; } $("#errormessage").html(msg); $("#errormessage").show(); isMsgAlreadyShown = 1; } function loadCheckoutForm(selectedCurrency){ if(typeof(selectedCurrency)==='undefined' || selectedCurrency == "") selectedCurrency = "USD"; var formHtml = ''; subscriptionStartDate = $('#subscriptionStartDate').val(); for (var i =0; i'+ ''; if(productId == 4) { customProductItemName = formArray[i].itemName; customProductItemprice = formArray[i].price; customProductItemOriginalprice = formArray[i].cutomItemOriginalAmount; formHtml += ''+ ''+ ''; } } formHtml += ''; formHtml += ''; formHtml += ''; $("#checkoutForm").html(formHtml); } function loadProductPlanData(currency ,plan , isAlreadySubscribed){ isSubscribedForPlan = isAlreadySubscribed; var params = { "currency" : currency }; var planId = plan - 1; if(isAlreadySubscribed == 1 ) { if(plan > 3){ planId = parseInt(plan % 3); } } $.get("/pricingajaxapi/getProductPlanPrice", params, function(data){ var response = eval('(' + data + ')'); var price = response[planId].price; var item = response[planId].item; var currencySign = currencyArray[currency]; $("#planDiv").html(item +" : "+price +" "+currencySign +" Per Month"); if(isAlreadySubscribed == 0) { addItemToSummary(2, plan , currency ,price , item); } }); } function loadAllProductPlanData(){ $.get("/pricingajaxapi/getAllProductPlanPrice", null, function(data) { var response = eval('(' + data + ')'); productPlanData = response; }); } function addRows(){ var html = '
'+ '
'+ ''+ '
'+ '
'+ '
'+ ''+ '
'; $("#rowDiv").append(html); } function deleteRows(){ $("#rowDiv").append(html); } function showAllcountries(elm){ if(elm == 1){ $("#topCountryPriceDiv").hide(); $("#allCountryPriceDiv").show(); $("#hideAllCountryButton").show(); $("#showAllCountryButton").hide(); }else{ $("#topCountryPriceDiv").show(); $("#allCountryPriceDiv").hide(); $("#hideAllCountryButton").hide(); $("#showAllCountryButton").show(); } } function showAllIncomingCountries(elm){ if(elm == 1){ $("#topIncomingCountryPriceDiv").hide(); $("#allIncomingCountryPriceDiv").show(); $("#hideAllIncomingCountryButton").show(); $("#showAllIncomingCountryButton").hide(); }else{ $("#topIncomingCountryPriceDiv").show(); $("#allIncomingCountryPriceDiv").hide(); $("#hideAllIncomingCountryButton").hide(); $("#showAllIncomingCountryButton").show(); } } function redirectToPage(page,tag) { if(typeof (page) === "undefined") return; var hit_url = ''; if(page == 'sms'){ hit_url = "/pricing/sms/"; }else if(page == 'topup'){ hit_url = "/pricing/topup/"; }else if (page == 'compare'){ hit_url = "/pricing/compare/"; }else if(page == 'price'){ hit_url = "/pricing/"; }else if(page == 'purchase'){ hit_url = "/pricing/purchase"; }else if(page == 'salesCheckOut'){ hit_url = "/pricing/salesCheckOut"; }else if(page == 'buy'){ hit_url = "/pricing/buy/"; }else if(page == 'feedback'){ hit_url = "/customerportal/feedback/"; }else if(page == "dashboard"){ hit_url = "/customerportal/dashboard/"; }else if(page == "billing"){ hit_url = "/customerportal/invoicesHistory/"; }else if(page == "profile"){ hit_url = "/customerportal/profile"; }else if(page == "contactus"){ hit_url = "/contact/"; }else if(page == "main/cardInfo/?accountId"){ hit_url = "/main/cardInfo/?accountId"; }else if(page == "main/account/?accountId"){ hit_url = "/main/account/?accountId"; }else if(page == "invoiceHistory"){ hit_url = "/billingc/invoiceHistory"; }else if(page == "buyPlan"){ hit_url = "/pricing/buy?plan"; }else if(page == "buyInbound"){ hit_url = "/pricing/inbound"; } if(typeof tag !== "undefined" && typeof tag !== ""){ if(hit_url == "/main/cardInfo/?accountId" || hit_url == "/main/account/?accountId" || hit_url == "/pricing/buy?plan") { window.location = hit_url+"="+tag; } else { window.location = hit_url+"#"+tag; } }else{ window.location = hit_url; } } function buy(plan, type){ window.location = "/pricing/buy?plan="+plan+"&curr="+selectedCurrency+"&type="+type; } function redirectToTopup() { window.location = "/pricing/topup"; } function validateCustomerInfoFields() { var isInvalidField = true; $("#payment-form .smbilling-cust-info").each(function() { if (this.name && !$.trim(this.value)) { $('.payment-errors-div').show(); var fieldlabel = $('label[for="' + this.name + '"]').html(); $('.payment-errors').text(fieldlabel + " is mandatory"); isInvalidField = false; return false; } }); if (isInvalidField == true) { return true; } // Prevent the form from submitting with the default action return false; } function checkValidProducts() { var cartValue = $('#checkoutForm').children("#originalProductId").val(); if (typeof cartValue === "undefined") { $("#buyPageError").show(); return false; } else { return true; } } function addCustomSubscriptionItems(){ customItemCount = customItemCount + 1; finalCustomItemCountArray.push(customItemCount); var html = '
'+ '
'+ '
'+ '
'+ '
'+ ''+ '
'+ '
'+ '
'+ '
'+ ''+ '
'+ '
'+ ''+ '
'+ '
'+ '
'+ '
'+ ''+ '
'+ '
'+ ''+ '
'+ '
'+ '
 
'+ '
'+ '
'+ ''+ '
'+ '
'+ ''+ '
'+ '
'+ '
'+ '
'+ ''+ '
'+ '
'+ ''+ '
'+ '
'+ '
'+ '
'+ '
'; $("#customParentDiv").append(html); } function removeCustomItem(remmoveId) { removeA(finalCustomItemCountArray, remmoveId); var idName = "#section_"+remmoveId; $(idName ).remove(); } function addCustomItemToSummary() { var itemNumber = null; for(var i=0;i 1 && arr.length) { what = a[--L]; while ((ax = arr.indexOf(what)) !== -1) { arr.splice(ax, 1); } } return arr; } function customSubscriptionFormValidations() { $("#customSubscriptionForm").validate({ submitHandler: function(form) { addCustomItemToSummary(); $('#creditCardFormModal').modal('hide'); } }); } function customSubscriptionAmountComparison() { finalResult = []; for(var i = 0;i < finalCustomItemCountArray.length;i++) { amountFieldName = null; discountAmountFieldName = null; result = null; amount = 0; discountedAmount = 0; amountFieldName = 'amount_'+finalCustomItemCountArray[i]; discountAmountFieldName = 'discountedAmount_'+finalCustomItemCountArray[i]; amount = parseInt(document.getElementById(amountFieldName).value); discountedAmount = parseInt(document.getElementById(discountAmountFieldName).value); return discountedAmount <= amount; } } function changeSelectedPlanforcustomer(currency,price, subscriptionFrequency,itemName) { var frequencyText = " Per Month"; if(typeof(subscriptionFrequency)==='undefined') subscriptionFrequency = 1; var arr = new Array(); arr['itemName'] = itemName; arr['price'] = price; arr['currency'] = currency; if(subscriptionFrequency == 12) { frequencyText = " Per Year"; arr['price'] = price*12; price= price*12; } generateHtmlForSelectedItemsforCustomer(currency, subscriptionFrequency); formArray[0].price = price; $("#planDiv").html(itemName +" : "+ numerToPrice(price) +" "+currency +" "+frequencyText); return arr; } function changeSelectedPlan(currency,flag, subscriptionFrequency) { var data ={'currency':currency}; var frequencyText = " Per Month"; if(typeof(subscriptionFrequency)==='undefined') subscriptionFrequency = 1; $.ajax({ type: "GET", async: false, url: "/pricingajaxapi/getProductPlanDetails", data: data, success: function(data) { var responseData = eval('(' + data + ')'); productPlanData = responseData["productPlanData"]; itemName = productPlanData['item']; price = productPlanData['price'] * subscriptionFrequency; currency = productPlanData['currency']; } }); var arr = new Array(); arr['productPlanData'] = productPlanData; arr['itemName'] = itemName; arr['price'] = price; arr['currency'] = currency; if(subscriptionFrequency == 12) { frequencyText = " Per Year"; } if(flag == 1) { $("#planDiv").html(itemName +" : "+ numerToPrice(price) +" "+currency +" "+frequencyText); } return arr; } function numerToPrice(price){ strPrice = price.toString(); finalNumber = ""; strLen = strPrice.length; if(strLen <= 3){ finalNumber = strPrice; } else{ while(strLen > 3){ stringPrice = strPrice.substring(strLen-3, strLen); strPrice = strPrice.substring(0, strLen - 3); strLen = strPrice.length; if(finalNumber == "") finalNumber = stringPrice; else finalNumber = stringPrice + ',' + finalNumber; } if(strPrice != "") finalNumber = strPrice + ',' + finalNumber; } return finalNumber; } function isPendingInvoice(accountId){ var params = { "customerAccountId" : accountId }; $.get("/pricingajaxapi/isPendingInvoices", params, function(data) { var response = eval('(' + data + ')'); if(response.totalPendingInvoicesAmount != null){ $("#cancelSubscriptionModal").modal('hide'); $("#pendingInvoiceMessage").html("Can not cancel this subscription as this account has some pending invoice(s)"); $("#pendingInvoiceMessage").show(); }else{ $("#cancelSubscriptionModal").modal('show'); } }); } function isActiveIncomingNumber(subscriptionId,itemId, accountId, trialAccount){ $.get("/pricingajaxapi/getActiveIncominNumberSubscriptionData", {"accountId" : accountId}, function(data){ if(data == 1){ $("#cancelSubscriptionItemModal").modal('hide'); $("#pendingInvoiceMessage").html("Cannot cancel Subscription plan as this account has active incoming number(s)"); $("#pendingInvoiceMessage").show(); } else{ getSubscriptionById(subscriptionId, itemId, accountId, trialAccount); } }); } function getSubscriptionById(subscriptionId,itemId, accountId, trialAccount){ var params = { "customerAccountId" : accountId }; trialAccount = typeof trialAccount !== 'undefined' ? trialAccount : 0; $.get("/pricingajaxapi/isPendingInvoices", params, function(data) { var response = eval('(' + data + ')'); if(response.totalPendingInvoicesAmount != null){ $("#cancelSubscriptionItemModal").modal('hide'); $("#pendingInvoiceMessage").html("Can not cancel this subscription as this account has some pending invoice(s)"); $("#pendingInvoiceMessage").show(); }else{ var params = { "subscriptionId" : subscriptionId, "subscriptionItemId":itemId, "customerAccountId" : accountId }; $.get("/pricingajaxapi/getSubscriptionById", params, function(data) { var response = eval('(' + data + ')'); var name = response.description; var companyName = response.companyName; var amount = response.discountedAmount; var initialAmount = response.initialAmountDiscounted; var subscriptionItemId = response.subscriptionItemId; var subscriptionId = response.subscriptionId; var today = new Date(); var currency = response.currency; var subscriptionDate = response.subscriptionStartDate; var thisDateT = subscriptionDate.substr(0, 10); subscriptionDate = new Date(thisDateT); var subscriptionCheckDate = new Date(subscriptionDate.setDate(subscriptionDate.getDate() + 3)); var nextPaymentDate = response.nextPaymentDate; $(".subscriptionDiv").html(name); $("#customerName").html(companyName); $(".accountIdSpan").html(accountId); $("#customerAccountId").val(accountId); $("#subscriptionId").val(subscriptionId); $("#subscriptionItemId").val(subscriptionItemId); $("#subscriptionAmount").html(amount+" "+currencySignArray[currency]); $(".currency").html(currencySignArray[currency]); if(trialAccount == 0) { if(today <= subscriptionCheckDate){ $("#subscriptionAmount").html(initialAmount+" "+currencySignArray[currency]); sendCancelSubscriptionRefundEmail(params, amount, currency, initialAmount, false); }else{ var cancellationDate = new Date(today.getFullYear(), today.getMonth(), today.getDate()).toDateString(); var cancelllationCharge = amount; currencySignArray = { "USD" : "$", "AUD" : "A$", "EUR" : "€", "GBP" : "£", }; $("#subscriptionMessage").html("Your subscription will be terminated immediately"); $("#cancellationDate").html(cancellationDate); $("#cancellationCharge").val(cancelllationCharge); $("#cancellationChargeDiv").show(); $("#cancelSubscriptionConfirmBtn").hide(); $("#cancelSubscriptionSubmitBtn").show(); $("#reason").val(""); $("#cancelSubscriptionItemModal").modal('show'); } } else if(trialAccount == 1) { $("#subscriptionAmount").html(initialAmount+" "+currencySignArray[currency]); sendCancelSubscriptionRefundEmail(params, amount, currency, initialAmount, true); } }); } }); } function sendCancelSubscriptionRefundEmail(params, amount, currency, initialAmount, trialAccountStatus){ var finalrefundAmount = 0; var processingFees = 0; finalrefundAmount = Math.round(initialAmount * 95)/100; processingFees = Math.round(initialAmount * 5)/100; $("#cancellationChargeDiv").hide(); $("#cancelSubscriptionConfirmBtn").show(); $("#cancelSubscriptionSubmitBtn").hide(); trialAccount = trialAccountStatus; if(trialAccountStatus == 0) { $("#subscriptionMessage").html("This subscription will be terminated immediately.
Subscription Amount : "+ initialAmount +" "+ currencySignArray[currency] +"

Refund Amount : "+ initialAmount +" "+ currencySignArray[currency]); } else if(trialAccountStatus == 1) { $("#subscriptionMessage").html("This subscription will be terminated immediately."); } $("#cancelSubscriptionItemModal").modal('show'); } function getCancellationDate(){ var today = new Date(); var checkDate = 15; var todayDate = today.getDate(); if(todayDate > checkDate){ newDate = today.setMonth((today.getMonth()+1) + 3); }else{ newDate = today.setMonth((today.getMonth()+1) + 2); } newDate =new Date(newDate); newDate = new Date(newDate.getFullYear(), newDate.getMonth(),1) cancellationDate = newDate.toDateString(); return cancellationDate; } function calculateCancellationCharge(price, nextPaymentDate){ var today = new Date(); var todayDate = today.getDate(); var checkDate = 15; nextPaymentDate = new Date(nextPaymentDate); var firstDay = new Date(today.getFullYear(), today.getMonth(), 1); var isSameDate = (firstDay.getDate() == nextPaymentDate.getDate() && firstDay.getMonth() == nextPaymentDate.getMonth() && firstDay.getFullYear() == nextPaymentDate.getFullYear()) if (todayDate >= checkDate || isSameDate) { price = price * 3 ; }else{ price = price * 2 ; } var cancellationCharge = Math.round(price * 100) / 100; return cancellationCharge; } function cancelSubscriptionAndSendRefundEmail(){ var subscriptionId = $("#subscriptionId").val(); var subscriptionItemId = $("#subscriptionItemId").val(); var customerAccountId = $("#customerAccountId").val(); var reason = $("#reason").val(); var params = { "subscriptionId" : subscriptionId, "subscriptionItemId":subscriptionItemId, "customerAccountId": customerAccountId , "reason" : reason, "trialAccount" : trialAccount }; $.get("/pricing/cancelSubscriptionAndSendRefundEmail", params, function(data) { var response = eval('(' + data + ')'); $("#cancelSubscriptionConfirmationModal").modal('hide'); $("#cancelSubscriptionItemModal").modal('hide'); $('textarea').val(''); $("#sId-"+subscriptionItemId).find('td.nextPaymentDate').html(''); $("#sId-"+subscriptionItemId).find('#cancelSubscription').css({'display' :'none'}); $("#sId-"+subscriptionItemId).find('td.subscriptionStatus').html('Cancelled'); $("#sId-"+subscriptionItemId).find('td.action').html(''); $("#statusMessage").html(response["message"]); $("#statusMessage").show(); }); } function validateForm(){ var reason = $("#reason").val(); if(reason == "") { $("#invalidInputMessage").html("Reason is required."); $("#invalidInputMessage").show(); return false; }else{ $("#cancelSubscriptionConfirmationModal").modal('show'); } } function cancelIncomingService(){ var customerAccountId = $("#customerAccountId").val(); var reason = $("#reason").val(); var params = { "customerAccountId": customerAccountId, "reason" : reason }; $.post("/pricingajaxapi/cancelService", params, function(data) { var response = eval('(' + data + ')'); $("#cancelSubscriptionConfirmationModal").modal('hide'); $("#cancelSubscriptionModal").modal('hide'); $("#cancelSubscriptionStatusMessage").html(response["message"]); $("#cancelSubscriptionStatusMessage").show(); }); } function cancelSubscriptionFormValidations() { $("#cancelSubscriptionForm").validate({ submitHandler: function(form) { $('#cancelSubscriptionForm').submit(); } }); } function cancelSubscriptionItemFormValidations(onClick){ $("#cancelSubscriptionItemForm").validate({ submitHandler: function(form) { $('#cancelSubscriptionItemForm').submit(); } }); } function changeSubscriptionFrequencyforcustomer(freq, itemName, currency, price){ subscriptionFrequency = freq; subscriptionStartDate = getCurrentDate(); selectedCurrency = currency; changeSelectedPlanforcustomer(currency, price, subscriptionFrequency, itemName); loadItemsToSummary(currency); loadCheckoutForm(currency); clearSummaryItems(); } function changeSubscriptionFrequency(frequency, isAlreadySubscribed) { subscriptionFrequency = frequency; subscriptionStartDate = $('#subscriptionStartDate').val(); alreadySubscribedFlag = isAlreadySubscribed; loadProductPlans('show', subscriptionFrequency); changeSelectedPlan(selectedCurrency,1, subscriptionFrequency); generateHtmlForSelectedItems(selectedCurrency, subscriptionFrequency); clearSummaryItems(); } function getCurrentDate() { var today = new Date(); var dd = today.getDate(); var mm = today.getMonth()+1; //January is 0! var yyyy = today.getFullYear(); if(dd<10) { dd='0'+dd; } if(mm<10) { mm='0'+mm; } return today = mm+'/'+dd+'/'+yyyy; } function subscriptionTerminationChoice(flag) { var cancellationDate; if(flag == 0) { $('input[name="terminationChoice"][value="0"]').prop('checked', true); $("#terminationDateSelectionDiv").css("display", "none"); $("#terminationDate").css("display", "block"); cancellationDate = getCurrentDate(); } else { $("#terminationDateSelectionDiv").css("display", "block"); $('input[name="terminationChoice"][value="1"]').prop('checked', true); $("#terminationDate").css("display", "none"); cancellationDate = $('#terminationMonth').val()+"/"+$('#terminationDay').text()+"/"+$('#terminationYear').val(); } $('#cancellationDate').val(cancellationDate); }