| 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 |
|
|
|
53 |
$('#edit-button').click(function() {
|
| 7096 |
anupam.sin |
54 |
$('#confirmForm').attr('action', '/rch/home!editRecharge');
|
| 7080 |
anupam.sin |
55 |
$('#confirmForm').submit();
|
|
|
56 |
});
|
|
|
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) {
|
|
|
76 |
$('div.mk_amount_row .input-div').html('<select id="newConDis"><option>Custom</option></select>' +
|
|
|
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 |
});
|
|
|
81 |
console.log($('div.mk_discount_row').append('<div id="discountText" style="text-align: left;font-size: 15px;width: 340px;color: blue;" class="text"></div>'));
|
|
|
82 |
} else {
|
|
|
83 |
$('div.mk_amount_row .input-div').html('<input type="text" name="amount" class="inputbox rupee padding48">');
|
|
|
84 |
$('#discountText').remove();
|
|
|
85 |
}
|
|
|
86 |
}
|
|
|
87 |
});
|
|
|
88 |
}
|
|
|
89 |
}
|
|
|
90 |
});
|
| 7073 |
anupam.sin |
91 |
|
| 7125 |
amit.gupta |
92 |
$("#newConDis").live('change', function(){
|
|
|
93 |
if(this.selectedIndex == 0){
|
|
|
94 |
$('div.mk_discount_row :last').html('');
|
|
|
95 |
$('#rechargeDetailsForm [name="amount"]').show().val('');
|
|
|
96 |
}else {
|
|
|
97 |
var discount = $(this).find(":selected").attr("disc");
|
|
|
98 |
$('#rechargeDetailsForm [name="amount"]').val($(this).val()).hide();
|
| 7139 |
amit.gupta |
99 |
$('div.mk_discount_row :last').html('Not more than Rs.' + discount);
|
| 7125 |
amit.gupta |
100 |
}
|
|
|
101 |
});
|
| 7073 |
anupam.sin |
102 |
function getRechargeProvider(deviceNumber, deviceType){
|
|
|
103 |
return $.ajax({
|
|
|
104 |
type: "POST",
|
| 7096 |
anupam.sin |
105 |
url: "/rch/home!getServiceProvider?deviceNumber=" + deviceNumber + "&deviceType=" + deviceType,
|
| 7073 |
anupam.sin |
106 |
success:function(msg){
|
|
|
107 |
if(msg != ""){
|
|
|
108 |
var deviceNumberInfo = msg.split(":");
|
| 7125 |
amit.gupta |
109 |
if($.trim(deviceNumberInfo[0]) == -1) {
|
|
|
110 |
alert ("Service not reachable or invalid number");
|
|
|
111 |
}
|
|
|
112 |
if($('input.rechargetype:checked').val() == "2"){
|
|
|
113 |
if(storeCircleCode != $.trim(deviceNumberInfo[1])){
|
|
|
114 |
$('input[name="number"]').val("");
|
|
|
115 |
alert('This number does not belong to your circle');
|
|
|
116 |
return false;
|
|
|
117 |
}
|
|
|
118 |
}
|
| 7073 |
anupam.sin |
119 |
$('#rechargeDetailsForm select[name="mobileOperator"]').val($.trim(deviceNumberInfo[0]));
|
| 7096 |
anupam.sin |
120 |
$('#circlecode').val($.trim(deviceNumberInfo[1]));
|
| 7073 |
anupam.sin |
121 |
$('#mobileSelector').trigger('change');
|
| 7125 |
amit.gupta |
122 |
oldValue = deviceNumber;
|
| 7073 |
anupam.sin |
123 |
}
|
| 7125 |
amit.gupta |
124 |
},
|
|
|
125 |
complete : function(){
|
|
|
126 |
$('#rechargeDetailsForm input[name="number"]').bind('keyup blur', function(){
|
|
|
127 |
var numvalue = $(this).val().substring(0,4);
|
|
|
128 |
var count = $(this).val().length;
|
|
|
129 |
if(count==10 && oldValue != numvalue){
|
|
|
130 |
getRechargeProvider(numvalue, 1);
|
|
|
131 |
}
|
|
|
132 |
});
|
|
|
133 |
},
|
|
|
134 |
beforeSend : function(){
|
|
|
135 |
$('#rechargeDetailsForm input[name="number"]').unbind('keyup blur');
|
| 7073 |
anupam.sin |
136 |
}
|
|
|
137 |
});
|
| 7139 |
amit.gupta |
138 |
|
|
|
139 |
$("#print-invoice").click(function(){
|
|
|
140 |
$()
|
|
|
141 |
});
|
| 7073 |
anupam.sin |
142 |
}
|
| 7096 |
anupam.sin |
143 |
});
|
|
|
144 |
|
|
|
145 |
function validateAllFields() {
|
|
|
146 |
var rechargeType = $('input.rechargetype:checked').val();
|
|
|
147 |
//1 is for Normal
|
|
|
148 |
//2 for New Connection(FRC)
|
|
|
149 |
var devicetype = $('input.devicetype:checked').val();
|
|
|
150 |
//1 is for Mobile
|
|
|
151 |
//2 for DTH
|
|
|
152 |
if($('input[name=number]').val() === ""){
|
|
|
153 |
alert('Please enter device number');
|
|
|
154 |
return false;
|
|
|
155 |
}
|
|
|
156 |
if($('input[name=name]').val() === ""){
|
|
|
157 |
alert('Please enter customer name');
|
|
|
158 |
return false;
|
|
|
159 |
}
|
|
|
160 |
if($('input[name=amount]').val() === ""){
|
|
|
161 |
alert('Please enter amount');
|
|
|
162 |
return false;
|
|
|
163 |
}
|
| 7073 |
anupam.sin |
164 |
|
| 7096 |
anupam.sin |
165 |
if(deviceType == 1 && $('#mobileSelector').val() === 0) {
|
|
|
166 |
alert('Please select operator');
|
|
|
167 |
return false;
|
|
|
168 |
}
|
|
|
169 |
|
|
|
170 |
if(deviceType == 2 && $('#dthSelector').val() === 0) {
|
|
|
171 |
alert('Please select operator');
|
|
|
172 |
return false;
|
|
|
173 |
}
|
|
|
174 |
|
|
|
175 |
if(rechargeType == 2) {
|
|
|
176 |
if($('input[name=sim]').val() === ""){
|
|
|
177 |
alert('Please enter SIM number');
|
| 7073 |
anupam.sin |
178 |
return false;
|
|
|
179 |
}
|
| 7096 |
anupam.sin |
180 |
if($('input[name=caf]').val() === ""){
|
|
|
181 |
alert('Please enter CAF number');
|
| 7073 |
anupam.sin |
182 |
return false;
|
|
|
183 |
}
|
| 7096 |
anupam.sin |
184 |
if($('input[name=alternate]').val() === ""){
|
|
|
185 |
alert('Please enter alternate number');
|
| 7073 |
anupam.sin |
186 |
return false;
|
|
|
187 |
}
|
|
|
188 |
}
|
| 7096 |
anupam.sin |
189 |
}
|