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