| 7068 |
anupam.sin |
1 |
$(function() {
|
| 7125 |
amit.gupta |
2 |
oldValue = "";
|
|
|
3 |
$('.rechargetype').click(function (){
|
|
|
4 |
$('div.mk_amount_row .input-div').html('<input type="text" name="amount" class="inputbox rupee padding48">');
|
|
|
5 |
$('#discountText').remove();
|
| 7068 |
anupam.sin |
6 |
var rechargeType = $('input.rechargetype:checked').val();
|
|
|
7 |
//1 is for Normal
|
|
|
8 |
//2 for New Connection(FRC)
|
|
|
9 |
if(rechargeType == 1) {
|
|
|
10 |
$('#frc-div').slideUp(100);
|
|
|
11 |
}
|
|
|
12 |
if(rechargeType == 2) {
|
| 7096 |
anupam.sin |
13 |
if($('input.devicetype:checked').val() == 2) {
|
|
|
14 |
$('input.rechargetype:unchecked').attr('checked', 'checked');
|
|
|
15 |
alert('New DTH Connections are not supported');
|
|
|
16 |
return false;
|
|
|
17 |
} else {
|
|
|
18 |
$('#frc-div').slideDown(100);
|
|
|
19 |
}
|
| 7068 |
anupam.sin |
20 |
}
|
|
|
21 |
});
|
|
|
22 |
|
|
|
23 |
$('.devicetype').change(function (){
|
|
|
24 |
var devicetype = $('input.devicetype:checked').val();
|
|
|
25 |
//1 is for Mobile
|
|
|
26 |
//2 for DTH
|
|
|
27 |
if(devicetype == 1) {
|
|
|
28 |
var deviceNumberInput = $('.inputbox[name=number]')
|
|
|
29 |
deviceNumberInput.removeClass('padding15');
|
|
|
30 |
deviceNumberInput.addClass('num-prefix padding48');
|
| 7073 |
anupam.sin |
31 |
$('#dthSelector').hide();
|
|
|
32 |
$('#mobileSelector').show();
|
| 7068 |
anupam.sin |
33 |
}
|
|
|
34 |
if(devicetype == 2) {
|
| 7096 |
anupam.sin |
35 |
if($('input.rechargetype:checked').val() == 2) {
|
|
|
36 |
$('input.devicetype:unchecked').attr('checked', 'checked');
|
|
|
37 |
alert('New DTH Connections are not supported');
|
|
|
38 |
return false;
|
|
|
39 |
}
|
| 7068 |
anupam.sin |
40 |
var deviceNumberInput = $('.inputbox[name=number]')
|
|
|
41 |
deviceNumberInput.removeClass('num-prefix padding48');
|
|
|
42 |
deviceNumberInput.addClass('padding15');
|
| 7073 |
anupam.sin |
43 |
$('#mobileSelector').hide();
|
|
|
44 |
$('#dthSelector').show();
|
| 7068 |
anupam.sin |
45 |
}
|
|
|
46 |
});
|
| 7073 |
anupam.sin |
47 |
|
| 7080 |
anupam.sin |
48 |
$('#recharge-button').click(function() {
|
| 7096 |
anupam.sin |
49 |
$('#confirmForm').attr('action', '/rch/confirm!createRecharge');
|
| 7080 |
anupam.sin |
50 |
$('#confirmForm').submit();
|
|
|
51 |
});
|
|
|
52 |
|
| 7151 |
amit.gupta |
53 |
/*$('#edit-button').click(function() {
|
| 7096 |
anupam.sin |
54 |
$('#confirmForm').attr('action', '/rch/home!editRecharge');
|
| 7080 |
anupam.sin |
55 |
$('#confirmForm').submit();
|
| 7151 |
amit.gupta |
56 |
});*/
|
| 7080 |
anupam.sin |
57 |
|
| 7073 |
anupam.sin |
58 |
$('#rechargeDetailsForm input[name="number"]').unbind('keyup blur').bind('keyup blur', function(){
|
|
|
59 |
var numvalue = $(this).val().substring(0,4);
|
|
|
60 |
var count = $(this).val().length;
|
|
|
61 |
if(count==10 && oldValue != numvalue){
|
|
|
62 |
getRechargeProvider(numvalue, 1);
|
|
|
63 |
//$(this).unbind('keyup');
|
|
|
64 |
}
|
|
|
65 |
});
|
| 7125 |
amit.gupta |
66 |
$('#mobileSelector').change(function(){
|
|
|
67 |
var selectedOperator = $('#mobileSelector').val();
|
|
|
68 |
if($('input.rechargetype:checked').val() == "2") {
|
|
|
69 |
if(selectedOperator != 0) {
|
|
|
70 |
return $.ajax({
|
|
|
71 |
type: "POST",
|
|
|
72 |
dataType:"json",
|
|
|
73 |
url: "/rch/home!getFRC?operatorId=" + selectedOperator,
|
|
|
74 |
success:function(msg) {
|
|
|
75 |
if(msg.length != 0) {
|
| 7140 |
amit.gupta |
76 |
$('div.mk_amount_row .input-div').html('<select id="newConDis" style="height:30px;font-size:18px;"><option>Custom</option></select>' +
|
| 7125 |
amit.gupta |
77 |
'<input type="text" name="amount" class="inputbox rupee padding48" style="width:120px">');
|
|
|
78 |
$.each(msg,function(index,obj){
|
|
|
79 |
$("#newConDis").append('<option disc="' + obj.maxDiscount + '" >' + obj.denomination +'</option>');
|
|
|
80 |
});
|
| 7176 |
anupam.sin |
81 |
$('div.mk_discount_row').append('<div id="discountText" style="text-align: left;font-size: 15px;width: 340px;color: blue;" class="text"></div>');
|
|
|
82 |
$("#newConDis").change(function(){
|
|
|
83 |
if(this.selectedIndex == 0){
|
|
|
84 |
$('div.mk_discount_row :last').html('');
|
|
|
85 |
$('#rechargeDetailsForm [name="amount"]').show().val('');
|
|
|
86 |
}else {
|
|
|
87 |
var discount = $(this).find(":selected").attr("disc");
|
|
|
88 |
$('#rechargeDetailsForm [name="amount"]').val($(this).val()).hide();
|
|
|
89 |
$('div.mk_discount_row :last').html('Discount more than rupees ' + discount + ' is not allowed');
|
|
|
90 |
}
|
|
|
91 |
});
|
| 7125 |
amit.gupta |
92 |
} else {
|
|
|
93 |
$('div.mk_amount_row .input-div').html('<input type="text" name="amount" class="inputbox rupee padding48">');
|
|
|
94 |
$('#discountText').remove();
|
|
|
95 |
}
|
|
|
96 |
}
|
|
|
97 |
});
|
|
|
98 |
}
|
|
|
99 |
}
|
|
|
100 |
});
|
| 7073 |
anupam.sin |
101 |
|
| 7151 |
amit.gupta |
102 |
|
| 7176 |
anupam.sin |
103 |
|
| 7151 |
amit.gupta |
104 |
$("#dateselector").change(function() {
|
|
|
105 |
if($(this).val()=="3"){
|
|
|
106 |
$("#daterange").show();
|
|
|
107 |
}else {
|
|
|
108 |
$("#daterange").hide();
|
|
|
109 |
}
|
|
|
110 |
});
|
|
|
111 |
|
| 7073 |
anupam.sin |
112 |
function getRechargeProvider(deviceNumber, deviceType){
|
|
|
113 |
return $.ajax({
|
|
|
114 |
type: "POST",
|
| 7096 |
anupam.sin |
115 |
url: "/rch/home!getServiceProvider?deviceNumber=" + deviceNumber + "&deviceType=" + deviceType,
|
| 7073 |
anupam.sin |
116 |
success:function(msg){
|
|
|
117 |
if(msg != ""){
|
|
|
118 |
var deviceNumberInfo = msg.split(":");
|
| 7125 |
amit.gupta |
119 |
if($.trim(deviceNumberInfo[0]) == -1) {
|
|
|
120 |
alert ("Service not reachable or invalid number");
|
|
|
121 |
}
|
|
|
122 |
if($('input.rechargetype:checked').val() == "2"){
|
|
|
123 |
if(storeCircleCode != $.trim(deviceNumberInfo[1])){
|
|
|
124 |
$('input[name="number"]').val("");
|
|
|
125 |
alert('This number does not belong to your circle');
|
|
|
126 |
return false;
|
|
|
127 |
}
|
|
|
128 |
}
|
| 7073 |
anupam.sin |
129 |
$('#rechargeDetailsForm select[name="mobileOperator"]').val($.trim(deviceNumberInfo[0]));
|
| 7096 |
anupam.sin |
130 |
$('#circlecode').val($.trim(deviceNumberInfo[1]));
|
| 7073 |
anupam.sin |
131 |
$('#mobileSelector').trigger('change');
|
| 7125 |
amit.gupta |
132 |
oldValue = deviceNumber;
|
| 7073 |
anupam.sin |
133 |
}
|
| 7125 |
amit.gupta |
134 |
},
|
|
|
135 |
complete : function(){
|
|
|
136 |
$('#rechargeDetailsForm input[name="number"]').bind('keyup blur', function(){
|
|
|
137 |
var numvalue = $(this).val().substring(0,4);
|
|
|
138 |
var count = $(this).val().length;
|
|
|
139 |
if(count==10 && oldValue != numvalue){
|
|
|
140 |
getRechargeProvider(numvalue, 1);
|
|
|
141 |
}
|
|
|
142 |
});
|
|
|
143 |
},
|
|
|
144 |
beforeSend : function(){
|
|
|
145 |
$('#rechargeDetailsForm input[name="number"]').unbind('keyup blur');
|
| 7073 |
anupam.sin |
146 |
}
|
|
|
147 |
});
|
|
|
148 |
}
|
| 7176 |
anupam.sin |
149 |
|
|
|
150 |
$(document).ready(function(){
|
|
|
151 |
var rechargeType = $('input.rechargetype:checked').val();
|
|
|
152 |
if(rechargeType == 2) {
|
|
|
153 |
$('#frc-div').show();
|
|
|
154 |
$('#mobileSelector').trigger('change');
|
|
|
155 |
//$('#rechargeDetailsForm input[name="number"]').keyup();
|
|
|
156 |
}
|
|
|
157 |
});
|
|
|
158 |
|
| 7096 |
anupam.sin |
159 |
});
|
|
|
160 |
|
| 7189 |
anupam.sin |
161 |
function isNumber(n) {
|
|
|
162 |
/****
|
|
|
163 |
* http://stackoverflow.com/questions/18082/validate-numbers-in-javascript-isnumeric/1830844#1830844
|
|
|
164 |
****/
|
|
|
165 |
var result = n.match(/^\d*$/);
|
|
|
166 |
if(result == null || result.length == 0) {
|
|
|
167 |
return false;
|
|
|
168 |
}
|
|
|
169 |
return true;
|
|
|
170 |
|
|
|
171 |
//return !isNaN(parseFloat(n)) && isFinite(n);
|
|
|
172 |
}
|
|
|
173 |
|
|
|
174 |
//$('input[name=repeat]').bind('contextmenu', function(e){
|
|
|
175 |
// e.preventDefault();
|
|
|
176 |
// alert('Right click disabled');
|
|
|
177 |
// return false;
|
|
|
178 |
//});
|
|
|
179 |
|
|
|
180 |
$(document).ready(function(){
|
|
|
181 |
$('input[name=number]').bind("cut copy paste",function(e) {
|
|
|
182 |
e.preventDefault();
|
|
|
183 |
});
|
|
|
184 |
});
|
|
|
185 |
|
| 7096 |
anupam.sin |
186 |
function validateAllFields() {
|
|
|
187 |
var rechargeType = $('input.rechargetype:checked').val();
|
|
|
188 |
//1 is for Normal
|
|
|
189 |
//2 for New Connection(FRC)
|
|
|
190 |
var devicetype = $('input.devicetype:checked').val();
|
|
|
191 |
//1 is for Mobile
|
|
|
192 |
//2 for DTH
|
| 7189 |
anupam.sin |
193 |
|
| 7096 |
anupam.sin |
194 |
if($('input[name=number]').val() === ""){
|
|
|
195 |
alert('Please enter device number');
|
|
|
196 |
return false;
|
|
|
197 |
}
|
| 7189 |
anupam.sin |
198 |
|
|
|
199 |
if(devicetype == 1) {
|
|
|
200 |
if($('input[name=number]').val().length != 10) {
|
|
|
201 |
alert('Please enter a 10 digit number');
|
|
|
202 |
return false;
|
|
|
203 |
}
|
|
|
204 |
|
|
|
205 |
if(!isNumber($('input[name=number]').val())) {
|
|
|
206 |
alert('Please enter a valid number');
|
|
|
207 |
return false;
|
|
|
208 |
}
|
|
|
209 |
}
|
|
|
210 |
|
| 7096 |
anupam.sin |
211 |
if($('input[name=name]').val() === ""){
|
|
|
212 |
alert('Please enter customer name');
|
|
|
213 |
return false;
|
|
|
214 |
}
|
| 7151 |
amit.gupta |
215 |
if($('input[name=number]').val() != $('input[name=repeat]').val()){
|
| 7189 |
anupam.sin |
216 |
alert('Device number and confirmation number do not match.');
|
| 7151 |
amit.gupta |
217 |
return false;
|
|
|
218 |
}
|
| 7096 |
anupam.sin |
219 |
if($('input[name=amount]').val() === ""){
|
|
|
220 |
alert('Please enter amount');
|
|
|
221 |
return false;
|
|
|
222 |
}
|
| 7073 |
anupam.sin |
223 |
|
| 7189 |
anupam.sin |
224 |
if(devicetype == 1 && $('#mobileSelector').val() === 0) {
|
| 7096 |
anupam.sin |
225 |
alert('Please select operator');
|
|
|
226 |
return false;
|
|
|
227 |
}
|
|
|
228 |
|
| 7189 |
anupam.sin |
229 |
if(devicetype == 2 && $('#dthSelector').val() === 0) {
|
| 7096 |
anupam.sin |
230 |
alert('Please select operator');
|
|
|
231 |
return false;
|
|
|
232 |
}
|
|
|
233 |
|
|
|
234 |
if(rechargeType == 2) {
|
| 7189 |
anupam.sin |
235 |
if($('input[name=simNum]').val() === ""){
|
| 7096 |
anupam.sin |
236 |
alert('Please enter SIM number');
|
| 7073 |
anupam.sin |
237 |
return false;
|
|
|
238 |
}
|
| 7189 |
anupam.sin |
239 |
|
|
|
240 |
if($('input[name=simNum]').val().length != 5) {
|
|
|
241 |
alert('Please enter the last 5 digits of SIM');
|
| 7073 |
anupam.sin |
242 |
return false;
|
|
|
243 |
}
|
| 7189 |
anupam.sin |
244 |
|
|
|
245 |
if(!isNumber($('input[name=simNum]').val())) {
|
|
|
246 |
alert('Please enter the last 5 digits of SIM');
|
| 7073 |
anupam.sin |
247 |
return false;
|
|
|
248 |
}
|
| 7189 |
anupam.sin |
249 |
|
|
|
250 |
if($('input[name=cafNum]').val() === ""){
|
|
|
251 |
alert('Please enter CAF number');
|
|
|
252 |
return false;
|
|
|
253 |
}
|
| 7073 |
anupam.sin |
254 |
}
|
| 7096 |
anupam.sin |
255 |
}
|