Rev 7151 | Rev 7161 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
$(function() {$(document).ready(function(){var rechargeType = $('input.rechargetype:checked').val();if(rechargeType == 2) {if($('input.devicetype:checked').val() == 2) {$('input.rechargetype:unchecked').attr('checked', 'checked');alert('New DTH Connections are not supported');return false;} else {$('#frc-div').slideDown(100);}}});oldValue = "";$('.rechargetype').click(function (){$('div.mk_amount_row .input-div').html('<input type="text" name="amount" class="inputbox rupee padding48">');$('#discountText').remove();var rechargeType = $('input.rechargetype:checked').val();//1 is for Normal//2 for New Connection(FRC)if(rechargeType == 1) {$('#frc-div').slideUp(100);}if(rechargeType == 2) {if($('input.devicetype:checked').val() == 2) {$('input.rechargetype:unchecked').attr('checked', 'checked');alert('New DTH Connections are not supported');return false;} else {$('#frc-div').slideDown(100);}}});$('.devicetype').change(function (){var devicetype = $('input.devicetype:checked').val();//1 is for Mobile//2 for DTHif(devicetype == 1) {var deviceNumberInput = $('.inputbox[name=number]')deviceNumberInput.removeClass('padding15');deviceNumberInput.addClass('num-prefix padding48');$('#dthSelector').hide();$('#mobileSelector').show();}if(devicetype == 2) {if($('input.rechargetype:checked').val() == 2) {$('input.devicetype:unchecked').attr('checked', 'checked');alert('New DTH Connections are not supported');return false;}var deviceNumberInput = $('.inputbox[name=number]')deviceNumberInput.removeClass('num-prefix padding48');deviceNumberInput.addClass('padding15');$('#mobileSelector').hide();$('#dthSelector').show();}});$('#recharge-button').click(function() {$('#confirmForm').attr('action', '/rch/confirm!createRecharge');$('#confirmForm').submit();});/*$('#edit-button').click(function() {$('#confirmForm').attr('action', '/rch/home!editRecharge');$('#confirmForm').submit();});*/$('#rechargeDetailsForm input[name="number"]').unbind('keyup blur').bind('keyup blur', function(){var numvalue = $(this).val().substring(0,4);var count = $(this).val().length;if(count==10 && oldValue != numvalue){getRechargeProvider(numvalue, 1);//$(this).unbind('keyup');}});$('#mobileSelector').change(function(){var selectedOperator = $('#mobileSelector').val();if($('input.rechargetype:checked').val() == "2") {if(selectedOperator != 0) {return $.ajax({type: "POST",dataType:"json",url: "/rch/home!getFRC?operatorId=" + selectedOperator,success:function(msg) {if(msg.length != 0) {$('div.mk_amount_row .input-div').html('<select id="newConDis" style="height:30px;font-size:18px;"><option>Custom</option></select>' +'<input type="text" name="amount" class="inputbox rupee padding48" style="width:120px">');$.each(msg,function(index,obj){$("#newConDis").append('<option disc="' + obj.maxDiscount + '" >' + obj.denomination +'</option>');});console.log($('div.mk_discount_row').append('<div id="discountText" style="text-align: left;font-size: 15px;width: 340px;color: blue;" class="text"></div>'));} else {$('div.mk_amount_row .input-div').html('<input type="text" name="amount" class="inputbox rupee padding48">');$('#discountText').remove();}}});}}});$("#newConDis").live('change', function(){if(this.selectedIndex == 0){$('div.mk_discount_row :last').html('');$('#rechargeDetailsForm [name="amount"]').show().val('');}else {var discount = $(this).find(":selected").attr("disc");$('#rechargeDetailsForm [name="amount"]').val($(this).val()).hide();$('div.mk_discount_row :last').html('Discount more than rupees' + discount + ' is not allowed');}});$("#dateselector").change(function() {if($(this).val()=="3"){$("#daterange").show();}else {$("#daterange").hide();}});function getRechargeProvider(deviceNumber, deviceType){return $.ajax({type: "POST",url: "/rch/home!getServiceProvider?deviceNumber=" + deviceNumber + "&deviceType=" + deviceType,success:function(msg){if(msg != ""){var deviceNumberInfo = msg.split(":");if($.trim(deviceNumberInfo[0]) == -1) {alert ("Service not reachable or invalid number");}if($('input.rechargetype:checked').val() == "2"){if(storeCircleCode != $.trim(deviceNumberInfo[1])){$('input[name="number"]').val("");alert('This number does not belong to your circle');return false;}}$('#rechargeDetailsForm select[name="mobileOperator"]').val($.trim(deviceNumberInfo[0]));$('#circlecode').val($.trim(deviceNumberInfo[1]));$('#mobileSelector').trigger('change');oldValue = deviceNumber;}},complete : function(){$('#rechargeDetailsForm input[name="number"]').bind('keyup blur', function(){var numvalue = $(this).val().substring(0,4);var count = $(this).val().length;if(count==10 && oldValue != numvalue){getRechargeProvider(numvalue, 1);}});},beforeSend : function(){$('#rechargeDetailsForm input[name="number"]').unbind('keyup blur');}});}});function validateAllFields() {var rechargeType = $('input.rechargetype:checked').val();//1 is for Normal//2 for New Connection(FRC)var devicetype = $('input.devicetype:checked').val();//1 is for Mobile//2 for DTHif($('input[name=number]').val() === ""){alert('Please enter device number');return false;}if($('input[name=name]').val() === ""){alert('Please enter customer name');return false;}if($('input[name=number]').val() != $('input[name=repeat]').val()){alert('Please confirm the device number.');return false;}if($('input[name=amount]').val() === ""){alert('Please enter amount');return false;}if(deviceType == 1 && $('#mobileSelector').val() === 0) {alert('Please select operator');return false;}if(deviceType == 2 && $('#dthSelector').val() === 0) {alert('Please select operator');return false;}if(rechargeType == 2) {if($('input[name=sim]').val() === ""){alert('Please enter SIM number');return false;}if($('input[name=caf]').val() === ""){alert('Please enter CAF number');return false;}if($('input[name=alternate]').val() === ""){alert('Please enter alternate number');return false;}}}