Subversion Repositories SmartDukaan

Rev

Rev 24107 | Rev 24833 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 24107 Rev 24171
Line 7... Line 7...
7
		console.log("upload target Button Clicked...")
7
		console.log("upload target Button Clicked...")
8
		uploadTarget("main-content");
8
		uploadTarget("main-content");
9
	});
9
	});
10
	$(".partner-target").live('click', function() {
10
	$(".partner-target").live('click', function() {
11
		console.log("partner target Button Clicked...")
11
		console.log("partner target Button Clicked...")
12
		partnerTarget("main-content", startDate);
12
		partnerTarget("main-content");
13
	});
13
	});
-
 
14
	$("#partner-target-details-paginated .next").live(
-
 
15
			'click',
-
 
16
			function() {
-
 
17
				loadPaginatedNextItems('/getAllPartnerTargetPaginated', null,
-
 
18
						'partner-target-details-paginated',
-
 
19
						'partner-target-details-table',
-
 
20
						'partner-target-details-container');
-
 
21
				$(this).blur();
-
 
22
			});
14
 
23
 
-
 
24
	$("#partner-target-details-paginated .previous").live(
-
 
25
			'click',
-
 
26
			function() {
-
 
27
				loadPaginatedPreviousItems('/getAllPartnerTargetPaginated',
-
 
28
						null, 'partner-target-details-paginated',
-
 
29
						'partner-target-details-table',
-
 
30
						'partner-target-details-container');
-
 
31
				$(this).blur();
-
 
32
			});
15
	$(".create-slab").live('click', function() {
33
	$(".partner-target-details").live('click', function() {
-
 
34
		var targetId = $(this).attr('data');
16
		console.log("create slab Button Clicked...");
35
		console.log("targetId = " + targetId);
17
		createSlab("main-content");
36
		loadPartnerTargetDetails(targetId, "partner-target-details-container");
18
	});
37
	});
19
	$(".deleteslab").live('click', function() {
38
	$(".deleteslab").live('click', function() {
20
		console.log("delete slab button clicked");
39
		console.log("delete slab button clicked");
21
		var index = $(this).data('index');
40
		var index = $(this).data('index');
22
		console.log(index);
41
		console.log(index);
23
		targetSlab.splice(-1, 1);
42
		targetSlab.splice(-1, 1);
24
		$(".div-" + index).remove();
43
		$(".div-" + index).remove();
25
		$("#index-" + (index - 1)).show();
44
		$("#index-" + (index - 1)).show();
26
		console.log(targetSlab);
45
		console.log(targetSlab);
-
 
46
		if (targetSlab.length == 0) {
-
 
47
			$("#uploadfile").prop('disabled', false);
-
 
48
			$("#targetName").prop('disabled', false);
-
 
49
			$("#targetDuration").prop('disabled', false);
-
 
50
			$('#target-brands').prop('disabled', false);
-
 
51
		}
27
 
52
 
28
	});
53
	});
29
 
54
 
30
	$("#saveSlab")
-
 
31
			.live(
-
 
32
					'click',
-
 
33
					function() {
-
 
34
						console.log("save slab Button Clicked...");
-
 
35
						console.log(targetSlab);
-
 
36
						var labelName = $("#label").val();
-
 
37
						var rewardPercentage = $("#rewardPercentage").val();
-
 
38
						if (rewardPercentage == "") {
-
 
39
							alert("Input field can't be empty");
-
 
40
							return;
-
 
41
						}
-
 
42
						slabInputs['minSlabPercentage'] = parseFloat(targetSlab[targetSlab.length - 1].maxSlabPercentage) + 1;
-
 
43
						slabInputs['maxSlabPercentage'] = -1;
-
 
44
						slabInputs['rewardPercentage'] = rewardPercentage;
-
 
45
						console.log(slabInputs);
-
 
46
						targetSlab.push(slabInputs);
-
 
47
						slabInputs = {};
-
 
48
						console.log(targetSlab);
-
 
49
						if (confirm("Are you sure you want to save slab!") == true) {
-
 
50
							doPostAjaxRequestWithJsonHandler(context
-
 
51
									+ "/createSlab?slabMonth=" + slabmonth,
-
 
52
									JSON.stringify(targetSlab), function(
-
 
53
											response) {
-
 
54
										if (response === 'true') {
-
 
55
											alert("Slab created successfully");
-
 
56
											targetSlab = [];
-
 
57
											createSlab("main-content");
-
 
58
 
-
 
59
										} else {
-
 
60
											alert("slab already created");
-
 
61
											targetSlab = [];
-
 
62
											createSlab("main-content");
-
 
63
 
-
 
64
										}
-
 
65
									});
-
 
66
						}
-
 
67
 
-
 
68
					});
-
 
69
 
-
 
70
	$("#addSlab")
55
	$("#addSlab")
71
			.live(
56
			.live(
72
					'click',
57
					'click',
73
					function() {
58
					function() {
74
						console.log("Add slab Button Clicked...");
59
						console.log("Add slab Button Clicked...");
75
						var labelName = $("#label").val();
60
						var labelName = $("#label").val();
76
						var slabpercentage = $("#slabpercentage").val();
61
						var slabpercentage = $("#slabpercentage").val();
77
						var rewardPercentage = $("#rewardPercentage").val();
62
						var rewardPercentage = $("#rewardPercentage").val();
78
 
-
 
-
 
63
						var slabName = $("#slabNameId").val();
-
 
64
						$("#uploadfile").prop('disabled', true);
-
 
65
						$("#targetName").prop('disabled', true);
-
 
66
						$("#targetDuration").prop('disabled', true);
-
 
67
						$('#target-brands').prop('disabled', true);
79
						if (slabpercentage == "" || rewardPercentage == "") {
68
						if (slabpercentage == "" || rewardPercentage == ""
-
 
69
								|| slabName === "") {
80
							alert("Input field can't be empty");
70
							alert("Input field can't be empty");
81
							return;
71
							return;
82
						}
72
						}
83
						console.log(targetSlab.length);
73
						console.log(targetSlab.length);
84
 
74
 
Line 90... Line 80...
90
								$("#index-" + parseFloat(targetSlab.length - 1))
80
								$("#index-" + parseFloat(targetSlab.length - 1))
91
										.hide();
81
										.hide();
92
								slabInputs['minSlabPercentage'] = parseFloat(targetSlab[targetSlab.length - 1].maxSlabPercentage) + 1;
82
								slabInputs['minSlabPercentage'] = parseFloat(targetSlab[targetSlab.length - 1].maxSlabPercentage) + 1;
93
								slabInputs['maxSlabPercentage'] = slabpercentage;
83
								slabInputs['maxSlabPercentage'] = slabpercentage;
94
								slabInputs['rewardPercentage'] = rewardPercentage;
84
								slabInputs['rewardPercentage'] = rewardPercentage;
-
 
85
								slabInputs['slabName'] = slabName;
95
								console.log(slabInputs);
86
								console.log(slabInputs);
96
								targetSlab.push(slabInputs);
87
								targetSlab.push(slabInputs);
97
								console.log(slabInputs)
88
								console.log(slabInputs)
98
								$("#slab-input")
89
								$("#slab-input")
99
										.html(
90
										.html(
100
												"	<input type=number class=\"form-control input-sm\" id=slabpercentage placeholder=\"Enter upto percentage\">&nbsp&nbsp"
91
												"	<input type=number class=\"form-control input-sm\" id=slabpercentage placeholder=\"Enter upto percentage\">  "
101
														+ "<input type=number class=\"form-control input-sm\" id=rewardPercentage placeholder=\"Enter Reward Percentage\">&nbsp&nbsp"
92
														+ "<input type=number class=\"form-control input-sm\" id=rewardPercentage placeholder=\"Enter Reward Percentage\">  "
-
 
93
														+ "<input type=text class=\"form-control input-sm\" id=slabNameId placeholder=\"Enter Slab Name\">  "
102
														+ "<input type=button class=btn-primary  value=+ id=addSlab>"
94
														+ "<input type=button class=btn-primary  value=+ id=addSlab>"
103
 
95
 
104
										);
96
										);
105
 
97
 
106
								var htmlString = $("<div class=div-"
98
								var htmlString = $("<div class=div-"
107
										+ parseFloat(targetSlab.length - 1)
99
										+ parseFloat(targetSlab.length - 1)
108
										+ ">"
100
										+ ">"
109
										+ "<label class=\"control-label col-sm-2\" for=\"upto\" style=\"left:10%\">Upto:</label>"
101
										+ "<label class=\"control-label col-sm-2\" for=\"upto\" style=\"left:10%\">Upto:</label>"
110
										+ "<div><input disabled type=number class=\"form-control input-sm\" id=slabpercentage placeholder=\"Enter upto percentage\" value="
102
										+ "<div><input disabled type=number class=\"form-control input-sm\" id=slabpercentage placeholder=\"Enter upto percentage\" value="
111
										+ slabpercentage
103
										+ slabpercentage
112
										+ ">&nbsp&nbsp"
104
										+ ">  "
113
										+ "<input disabled type=number class=\"form-control input-sm\" id=rewardPercentage placeholder=\"Enter Reward Percentage\" value="
105
										+ "<input disabled type=number class=\"form-control input-sm\" id=rewardPercentage placeholder=\"Enter Reward Percentage\" value="
114
										+ rewardPercentage
106
										+ rewardPercentage
115
										+ ">&nbsp;&nbsp;"
107
										+ ">  "
-
 
108
										+ "<input disabled type=text class=\"form-control input-sm\" id=slabNameId placeholder=\"Enter Slab Name\" value="
-
 
109
										+ slabName
-
 
110
										+ ">"
116
										+ "<input type=button value=x  class=\"btn btn-primary deleteslab\"  data-index=\""
111
										+ "<input type=button value=x  class=\"btn btn-primary deleteslab\"  data-index=\""
117
										+ parseFloat(targetSlab.length - 1)
112
										+ parseFloat(targetSlab.length - 1)
118
										+ "\"id=index-"
113
										+ "\"id=index-"
119
										+ parseFloat(targetSlab.length - 1)
114
										+ parseFloat(targetSlab.length - 1)
120
										+ ">" + "&nbsp&nbsp<div><br>");
115
										+ ">" + "  <div><br>");
121
								$("#slab-order").append(htmlString);
116
								$("#slab-order").append(htmlString);
122
 
-
 
123
								$("#slabdate").prop('disabled', true);
-
 
124
								slabInputs = {};
117
								slabInputs = {};
125
							} else {
118
							} else {
126
								alert("Slab Percentage is not less than previous Slab Percentage");
119
								alert("Slab Percentage is not less than previous Slab Percentage");
127
								return false;
120
								return false;
128
							}
121
							}
129
						} else {
122
						} else {
130
							slabInputs['minSlabPercentage'] = 0;
123
							slabInputs['minSlabPercentage'] = 0;
131
							slabInputs['maxSlabPercentage'] = slabpercentage;
124
							slabInputs['maxSlabPercentage'] = slabpercentage;
132
							slabInputs['rewardPercentage'] = rewardPercentage;
125
							slabInputs['rewardPercentage'] = rewardPercentage;
-
 
126
							slabInputs['slabName'] = slabName;
133
							console.log(slabInputs);
127
							console.log(slabInputs);
134
							targetSlab.push(slabInputs);
128
							targetSlab.push(slabInputs);
135
							console.log(slabInputs)
129
							console.log(slabInputs)
136
							$("#slab-input")
130
							$("#slab-input")
137
									.html(
131
									.html(
138
											"	<input type=number class=\"form-control input-sm\" id=slabpercentage placeholder=\"Enter upto percentage\">&nbsp&nbsp"
132
											"	<input type=number class=\"form-control input-sm\" id=slabpercentage placeholder=\"Enter upto percentage\">  "
139
													+ "<input type=number class=\"form-control input-sm\" id=rewardPercentage placeholder=\"Enter Reward Percentage\">&nbsp&nbsp"
133
													+ "<input type=number class=\"form-control input-sm\" id=rewardPercentage placeholder=\"Enter Reward Percentage\">  "
-
 
134
													+ "<input type=text class=\"form-control input-sm\" id=slabNameId placeholder=\"Enter Slab Name\">  "
140
													+ "<input type=button class=btn-primary  value=+ id=addSlab>"
135
													+ "<input type=button class=btn-primary  value=+ id=addSlab>"
141
 
136
 
142
									);
137
									);
143
 
138
 
144
							var htmlString = $("<div class=div-"
139
							var htmlString = $("<div class=div-"
145
									+ parseFloat(targetSlab.length - 1)
140
									+ parseFloat(targetSlab.length - 1)
146
									+ ">"
141
									+ ">"
147
									+ "<label class=\"control-label col-sm-2\" for=\"upto\" style=\"left:10%\">Upto:</label>"
142
									+ "<label class=\"control-label col-sm-2\" for=\"upto\" style=\"left:10%\">Upto:</label>"
148
									+ "<div><input disabled type=number class=\"form-control input-sm\" id=slabpercentage placeholder=\"Enter upto percentage\" value="
143
									+ "<div><input disabled type=number class=\"form-control input-sm\" id=slabpercentage placeholder=\"Enter upto percentage\" value="
149
									+ slabpercentage
144
									+ slabpercentage
150
									+ ">&nbsp&nbsp"
145
									+ ">  "
151
									+ "<input disabled type=number class=\"form-control input-sm\" id=rewardPercentage placeholder=\"Enter Reward Percentage\" value="
146
									+ "<input disabled type=number class=\"form-control input-sm\" id=rewardPercentage placeholder=\"Enter Reward Percentage\" value="
152
									+ rewardPercentage
147
									+ rewardPercentage
153
									+ ">&nbsp;&nbsp;"
148
									+ ">  "
-
 
149
									+ "<input disabled type=text class=\"form-control input-sm\" id=slabNameId placeholder=\"Enter Slab Name\" value="
-
 
150
									+ slabName
-
 
151
									+ ">"
154
									+ "<input type=button value=x  class=\"btn btn-primary deleteslab\"  data-index=\""
152
									+ "<input type=button value=x  class=\"btn btn-primary deleteslab\"  data-index=\""
155
									+ parseFloat(targetSlab.length - 1)
153
									+ parseFloat(targetSlab.length - 1)
156
									+ "\" id=index-"
154
									+ "\" id=index-"
157
									+ parseFloat(targetSlab.length - 1) + ">"
155
									+ parseFloat(targetSlab.length - 1) + ">"
158
									+ "&nbsp&nbsp<div><br><div>");
156
									+ "  <div><br><div>");
159
							$("#slab-order").append(htmlString);
157
							$("#slab-order").append(htmlString);
160
							$("#slabdate").prop('disabled', true);
158
							$("#slabdate").prop('disabled', true);
161
							slabInputs = {};
159
							slabInputs = {};
162
						}
160
						}
163
 
161
 
Line 166... Line 164...
166
	$("#uploadExcel")
164
	$("#uploadExcel")
167
			.live(
165
			.live(
168
					'click',
166
					'click',
169
					function() {
167
					function() {
170
						var excelfile = $('#uploadfile')[0].files[0];
168
						var excelfile = $('#uploadfile')[0].files[0];
171
						var targetdate = $('#targetDateTime').val();
169
						var targetName = $('#targetName').val();
-
 
170
						var slabName = $("#slabNameId").val();
-
 
171
						console.log(excelfile);
-
 
172
						console.log(targetName);
-
 
173
						if (!excelfile) {
-
 
174
							alert("choose excel file for upload");
-
 
175
							return;
-
 
176
						}
-
 
177
						var ext = $('#uploadfile').val().split('.').pop()
-
 
178
								.toLowerCase();
-
 
179
						if ($.inArray(ext, [ 'xlsx' ]) == -1) {
-
 
180
							alert('invalid extension!');
-
 
181
							return;
-
 
182
						}
-
 
183
						if (targetName === null ||targetName ==="") {
-
 
184
							alert("targetName Field is not empty");
-
 
185
							return;
-
 
186
						}
-
 
187
						if (slabName === null ||slabName === "") {
-
 
188
							alert("slabName Field is not empty");
-
 
189
							return;
-
 
190
						}
-
 
191
						var brandName = $('#target-brands').val();
-
 
192
						console.log(brandName);
-
 
193
						if (brandName == "") {
-
 
194
							brandName = null;
-
 
195
						}
172
						console.log("excelfile" + excelfile);
196
						console.log("excelfile" + excelfile);
-
 
197
						var labelName = $("#label").val();
-
 
198
						var rewardPercentage = $("#rewardPercentage").val();
-
 
199
						if (rewardPercentage == "" || slabName === "") {
-
 
200
							alert("Input field can't be empty");
-
 
201
							return;
-
 
202
						}
-
 
203
						slabInputs['minSlabPercentage'] = parseFloat(targetSlab[targetSlab.length - 1].maxSlabPercentage) + 1;
-
 
204
						slabInputs['maxSlabPercentage'] = -1;
-
 
205
						slabInputs['rewardPercentage'] = rewardPercentage;
-
 
206
						slabInputs['slabName'] = slabName;
-
 
207
						console.log(slabInputs);
-
 
208
						targetSlab.push(slabInputs);
-
 
209
						slabInputs = {};
-
 
210
						console.log(targetSlab);
173
						if (confirm("Are you sure you want to upload excel file!") == true) {
211
						if (confirm("Are you sure you want to upload excel file!") == true) {
174
							if (!excelfile) {
-
 
175
								alert("choose excel file for upload");
-
 
176
								return;
212
							var data = {
177
							}
-
 
178
							var ext = $('#uploadfile').val().split('.').pop()
-
 
179
									.toLowerCase();
213
								targetName : targetName,
180
							if ($.inArray(ext, [ 'xlsx' ]) == -1) {
-
 
181
								alert('invalid extension!');
214
								startDate : startDate,
182
								return;
215
								endDate : endDate,
183
							}
-
 
184
							if (targetdate === null) {
216
								brandName : brandName,
185
								alert("Target Month Field is not empty");
217
								targetSlabs : targetSlab
186
								return;
-
 
187
							}
218
							}
188
 
219
 
189
							console.log(targetdate);
-
 
190
							doAjaxUploadRequestHandler(context
220
							doAjaxUploadRequestJsonHandler(context
191
									+ "/uploadPartnersTarget?targetDate="
221
									+ "/uploadPartnersTarget", 'POST',
192
									+ targetdate, 'POST', excelfile, function(
222
									excelfile, JSON.stringify(data), function(
193
									response) {
223
											response) {
194
								if (response == true) {
224
										if (response == "true") {
195
									alert("successfully uploaded");
225
											alert("successfully uploaded");
196
									doGetAjaxRequestHandler(context
-
 
197
											+ "/uploadPartnerTargetPage",
-
 
198
											function(response) {
226
											targetSlab = [];
199
												$('#' + "main-content").html(
227
											uploadTarget("main-content");
200
														response);
-
 
201
											});
228
										}
202
								}
229
										targetSlab = [];
-
 
230
 
203
							});
231
									});
204
						}
232
						}
205
					});
233
					});
206
 
234
 
207
});
235
});
208
 
236
 
209
function labelChange() {
237
function labelChange() {
210
	var labelName = $("#label").val();
238
	var labelName = $("#label").val();
211
	console.log(labelName);
239
	console.log(labelName);
212
	var month = $("#slabdate").val();
-
 
213
	console.log(month);
-
 
214
	if (month) {
-
 
215
		slabmonth = month;
-
 
216
		console.log(slabmonth);
-
 
217
		if (labelName == "upto") {
240
	if (labelName == "upto") {
218
 
241
 
219
			$("#slab-input")
242
		$("#slab-input")
220
					.html(
243
				.html(
221
							"	<input type=number class=\"form-control input-sm\" id=slabpercentage placeholder=\"Enter upto percentage\">&nbsp&nbsp"
244
						"	<input type=number class=\"form-control input-sm\" id=slabpercentage placeholder=\"Enter upto percentage\">  "
222
									+ "<input type=number class=\"form-control input-sm\" id=rewardPercentage placeholder=\"Enter Reward Percentage\">&nbsp&nbsp"
245
								+ "<input type=number class=\"form-control input-sm\" id=rewardPercentage placeholder=\"Enter Reward Percentage\">  "
-
 
246
								+ "<input type=text class=\"form-control input-sm\" id=slabNameId placeholder=\"Enter Slab Name\">  "
223
									+ "<input type=button class=btn-primary  value=+ id=addSlab>"
247
								+ "<input type=button class=btn-primary  value=+ id=addSlab>"
224
 
248
 
225
					);
249
				);
226
 
-
 
227
		} else {
-
 
228
			$("#slab-input")
-
 
229
					.html(
-
 
230
 
250
 
231
							"<input type=number class=\"form-control input-sm\" id=rewardPercentage placeholder=\"Enter Reward Percentage\">&nbsp&nbsp"
-
 
232
									+ "<button type=button class=\"btn btn-primary\"  value=\"save slab\" id=saveSlab>save</button>");
-
 
233
		}
-
 
234
	} else {
251
	} else {
235
		alert("Month field can't be empty");
252
		$("#slab-input")
236
		return;
253
				.html(
-
 
254
 
-
 
255
						"<input type=number class=\"form-control input-sm\" id=rewardPercentage placeholder=\"Enter Reward Percentage\">"
-
 
256
								+ "<input type=text class=\"form-control input-sm\" id=slabNameId placeholder=\"Enter Slab Name\">  "+
-
 
257
								"<input class=\"btn btn-primary\" type=button value=upload id=uploadExcel>");
237
	}
258
	}
238
}
259
}
239
 
260
 
240
function uploadTarget(domId) {
261
function uploadTarget(domId) {
241
	doGetAjaxRequestHandler(context + "/uploadPartnerTargetPage", function(
262
	doGetAjaxRequestHandler(context + "/uploadPartnerTargetPage", function(
242
			response) {
263
			response) {
243
		$('#' + domId).html(response);
264
		$('#' + domId).html(response);
244
	});
265
	});
245
}
266
}
246
function createSlab(domId) {
267
function partnerTarget(domId) {
247
	doGetAjaxRequestHandler(context + "/createTargetSlab", function(response) {
268
	doGetAjaxRequestHandler(context + "/getAllPartnerTarget",
-
 
269
			function(response) {
248
		$('#' + domId).html(response);
270
				$('#' + domId).html(response);
249
	});
271
			});
250
}
272
}
251
 
-
 
252
function partnerTarget(domId, slabMonth) {
273
function loadPartnerTargetDetails(targetId, domId) {
253
	console.log(slabMonth);
-
 
254
	doGetAjaxRequestHandler(context + "/getPartnerTarget?slabMonth="
274
	doGetAjaxRequestHandler(context + "/getPartnerTarget?targetId=" + targetId,
255
			+ slabMonth, function(response) {
275
			function(response) {
256
		$('#' + domId).html(response);
276
				$('#' + domId).html(response);
-
 
277
				window.dispatchEvent(new Event('resize'));
257
	});
278
			});
258
}
279
}
259
function getSlabTarget() {
-
 
260
	var slabMonth = $("#partnerTargetDatetime").val();
-
 
261
	console.log(slabMonth);
-
 
262
	doGetAjaxRequestHandler(context + "/getPartnerTarget?slabMonth="
-
 
263
			+ slabMonth, function(response) {
-
 
264
		$('#main-content').html(response);
-
 
265
	});
-
 
266
}
-
 
267
280