Subversion Repositories SmartDukaan

Rev

Rev 25587 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
25496 tejbeer 1
$(function() {
2
 
3
	$(".refferal").live('click', function() {
4
 
5
		loadRefferals("main-content");
6
	});
7
 
8
	$(".refferal-approve").live('click', function() {
9
 
10
		loadApproveRefferals("main-content");
11
	});
12
 
13
	$(".refferal-transferred").live('click', function() {
14
		loadTransferredRefferals("main-content");
15
	});
16
 
17
	$("#refferal-paginated .next").live(
18
			'click',
19
			function() {
20
				var url = $('#url').val();
21
				console.log(url);
22
				if (url == "/getPaginatedRefferalsRequest") {
23
					loadPaginatedNextItems('/getPaginatedRefferalsRequest',
24
							null, 'refferal-paginated', 'refferal-table',
25
							'refferal-container');
26
				} else if (url == "/getPaginatedTransferredRefferals") {
27
					loadPaginatedNextItems('/getPaginatedTransferredRefferals',
28
							null, 'refferal-paginated', 'refferal-table',
29
							'refferal-container');
30
				}
31
				$(this).blur();
32
			});
33
 
34
	$("#refferal-paginated .previous").live(
35
			'click',
36
			function() {
37
				var url = $('#url').val();
38
				if (url == "/getPaginatedRefferalsRequest") {
39
					loadPaginatedPreviousItems('/getPaginatedRefferalsRequest',
40
							null, 'refferal-paginated', 'refferal-table',
41
							'refferal-container');
42
				} else if (url == "/getPaginatedTransferredRefferals") {
43
					loadPaginatedNextItems('/getPaginatedTransferredRefferals',
44
							null, 'refferal-paginated', 'refferal-table',
45
							'refferal-container');
46
				}
47
				$(this).blur();
48
			});
49
 
50
	$(".refferal-reject")
51
			.live(
52
					'click',
53
					function() {
54
						if (confirm("Are you sure you want to Reject the refferal") == true) {
55
 
56
							refferalId = $(this).data('requestid');
57
							console.log(refferalId);
58
							doPutAjaxRequestHandler(context
59
									+ "/rejectRefferal?refferalId="
60
									+ refferalId, function(response) {
61
								if (response == 'true') {
62
									alert("successfully Rejected");
63
									loadRefferals("main-content");
64
								}
65
 
66
							});
67
						}
68
					});
69
 
70
	$(".reffral-approve")
71
			.live(
72
					'click',
73
					function() {
74
						if (confirm("Are you sure you want to approve the refferal") == true) {
75
 
76
							refferalId = $(this).data('requestid');
77
							console.log(refferalId);
78
							doPutAjaxRequestHandler(context
79
									+ "/approveRefferal?refferalId="
80
									+ refferalId, function(response) {
81
								if (response == 'true') {
82
									alert("successfully Approved");
83
									loadRefferals("main-content");
84
								}
85
 
86
							});
87
						}
88
					});
89
 
90
	$(".fetchApproveRefferals").live(
91
			'click',
92
			function() {
93
				currentFofoId = currentFofoId;
94
				currentFofoEmail = currentFofoEmail;
95
 
96
				console.log(currentFofoId);
97
				console.log(currentFofoEmail);
98
 
99
				doGetAjaxRequestHandler(context
100
						+ "/getApprovedRefferals?refereeEmail="
101
						+ currentFofoEmail, function(response) {
102
					$('.refferal-approve-info-container').html(response);
103
				});
104
 
105
			});
106
 
107
	$(".refferalAmountSubmit").live(
108
			'click',
109
			function() {
110
				currentFofoId = currentFofoId;
111
				currentFofoEmail = currentFofoEmail;
112
				var count = $('#count').val();
113
				var refferalAmount = $('#refferalAmount').val();
114
				var month = $('#previousMonth').val();
115
				$('#count').attr('readonly', true);
116
				$('#refferalAmount').attr('readonly', true);
117
				$('#previousMonth').attr('readonly', true);
118
 
119
				if (confirm("Are you sure you want add money!") == true) {
120
					doPostAjaxRequestHandler(context
121
							+ "/addMoneyToWallet?amount=" + refferalAmount
122
							+ "&count=" + count + "&refereeEmail="
123
							+ currentFofoEmail + "&month=" + month,
124
							function(response) {
125
								if (response == 'true') {
126
									alert("successfully submit");
127
 
128
									loadApproveRefferals("main-content");
129
								}
130
 
131
								return false;
132
							});
133
				}
134
 
135
			});
136
 
137
	$(".oldRefferalAmountSubmit").live(
138
			'click',
139
			function() {
140
				currentFofoId = currentFofoId;
141
				currentFofoEmail = currentFofoEmail;
142
				var count = $('#oldMonthCount').val();
143
				var refferalAmount = $('#oldMonthrefferalAmount').val();
144
				var month = $('#oldMonth').val();
145
				$('#oldMonthCount').attr('readonly', true);
146
				$('#oldMonthrefferalAmount').attr('readonly', true);
147
				$('#oldMonth').attr('readonly', true);
148
 
149
				if (confirm("Are you sure you want add money!") == true) {
150
					doPostAjaxRequestHandler(context
151
							+ "/addMoneyToWalletPreviousMonth?amount="
152
							+ refferalAmount + "&count=" + count
153
							+ "&refereeEmail=" + currentFofoEmail + "&month="
154
							+ month, function(response) {
155
						if (response == 'true') {
156
							alert("successfully submit");
157
 
158
							loadApproveRefferals("main-content");
159
						}
160
 
161
						return false;
162
					});
163
				}
164
 
165
			});
166
 
167
});
168
 
169
function loadRefferals(domId) {
170
	doGetAjaxRequestHandler(context + "/getRefferalsRequest",
171
			function(response) {
172
				$('#' + domId).html(response);
173
			});
174
 
175
}
176
 
177
function loadTransferredRefferals(domId) {
178
	doGetAjaxRequestHandler(context + "/getTransferredRefferals", function(
179
			response) {
180
		$('#' + domId).html(response);
181
	});
182
}
183
 
184
function loadApproveRefferals(domId) {
185
	doGetAjaxRequestHandler(context + "/approvedRefferals", function(response) {
186
		$('#' + domId).html(response);
187
	});
188
 
189
}