Subversion Repositories SmartDukaan

Rev

Rev 27648 | Rev 27754 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
23343 ashik.ali 1
$(function() {
2
	$(".create-scheme").live('click', function() {
3
		loadScheme("main-content");
4
	});
23752 govind 5
 
6
	$("#schemes-paginated .next").live(
7
			'click',
8
			function() {
26802 tejbeer 9
				var category = $('#partner-category').val();
23752 govind 10
				var searchText = $("#scheme-item-search-text").val();
26802 tejbeer 11
 
26763 tejbeer 12
				var category = $('#partner-category').val();
23752 govind 13
				if (typeof (searchText) == "undefined" || !searchText) {
14
					searchText = "";
15
				}
26802 tejbeer 16
				if (typeof (category) == "undefined" || !category) {
17
					category = "";
18
				}
23752 govind 19
 
26802 tejbeer 20
				if ((searchText) && (category)) {
21
 
23752 govind 22
					var params = {};
26802 tejbeer 23
					params['searchItem'] = currentItem.itemId;
24
					params['partnerType'] = category
25
					loadPaginatedNextItems('/getPaginatedSchemes', params,
26
							'schemes-paginated', 'schemes-table',
23752 govind 27
							'scheme-details-container');
26763 tejbeer 28
 
26802 tejbeer 29
				} else if ((searchText)) {
26763 tejbeer 30
					var params = {};
26802 tejbeer 31
					params['searchItem'] = currentItem.itemId;
32
					loadPaginatedNextItems('/getPaginatedSchemes', params,
33
							'schemes-paginated', 'schemes-table',
26763 tejbeer 34
							'scheme-details-container');
26802 tejbeer 35
 
23752 govind 36
				} else {
26912 tejbeer 37
					var params = {};
38
					params['partnerType'] = category
39
					loadPaginatedNextItems('/getPaginatedSchemes', params,
23752 govind 40
							'schemes-paginated', 'schemes-table',
41
							'scheme-details-container');
42
				}
43
				$(this).blur();
44
			});
45
 
46
	$("#schemes-paginated .previous").live(
47
			'click',
48
			function() {
49
				var searchText = $("#scheme-item-search-text").val();
26763 tejbeer 50
				var category = $('#partner-category').val();
23752 govind 51
				// var searchTxt=$("#scheme-search-text").val();
52
				console.log(searchText);
53
				if (typeof (searchText) == "undefined" || !searchText) {
54
					searchText = "";
55
				}
26802 tejbeer 56
				if (typeof (category) == "undefined" || !category) {
57
					category = "";
58
				}
23752 govind 59
 
26802 tejbeer 60
				console.log(searchText)
61
 
62
				if ((searchText) && (category)) {
63
 
23752 govind 64
					var params = {};
26802 tejbeer 65
					params['searchItem'] = currentItem.itemId;
66
					params['partnerType'] = category
67
					loadPaginatedPreviousItems('/getPaginatedSchemes', params,
68
							'schemes-paginated', 'schemes-table',
23752 govind 69
							'scheme-details-container');
26763 tejbeer 70
 
26802 tejbeer 71
				} else if ((searchText)) {
26763 tejbeer 72
					var params = {};
26802 tejbeer 73
					params['searchItem'] = currentItem.itemId;
74
					loadPaginatedPreviousItems('/getPaginatedSchemes', params,
75
							'schemes-paginated', 'schemes-table',
26763 tejbeer 76
							'scheme-details-container');
77
 
26802 tejbeer 78
				} else {
26912 tejbeer 79
					var params = {};
80
					params['partnerType'] = category
81
					loadPaginatedPreviousItems('/getPaginatedSchemes', params,
23752 govind 82
							'schemes-paginated', 'schemes-table',
83
							'scheme-details-container');
84
				}
85
				$(this).blur();
86
			});
87
 
88
	$(".scheme-details").live('click', function() {
23343 ashik.ali 89
		var schemeId = $(this).attr('data');
23752 govind 90
		console.log("schemeId = " + schemeId);
23343 ashik.ali 91
		loadSchemeDetails(schemeId, "scheme-details-container");
92
	});
23752 govind 93
 
94
	$(".active-scheme").live('click', function() {
23343 ashik.ali 95
		var schemeId = $(this).attr('data');
23752 govind 96
		console.log("active-scheme id : " + schemeId);
97
		var start = $("#schemes-paginated .start").text();
98
		// var end = $( "#schemes-paginated .end" ).text();
23343 ashik.ali 99
		var offset = start - 1;
23752 govind 100
		if (confirm("Are you sure you want to Active Scheme!") == true) {
23343 ashik.ali 101
			activeScheme(schemeId, offset, "schemes-table");
102
		}
103
	});
23752 govind 104
 
105
	$(".expire-scheme").live('click', function() {
23343 ashik.ali 106
		var schemeId = $(this).attr('data');
25069 amit.gupta 107
		var expireDate = startDate;
23752 govind 108
		var start = $("#schemes-paginated .start").text();
109
		// var end = $( "#schemes-paginated .end" ).text();
23343 ashik.ali 110
		var offset = start - 1;
23752 govind 111
		if (confirm("Are you sure you want to Expire Scheme!") == true) {
25069 amit.gupta 112
			expireScheme(schemeId, expireDate, offset, "schemes-table");
23343 ashik.ali 113
		}
114
	});
23914 govind 115
	$("#extendDatetime-button")
116
			.live(
117
					'click',
118
					function() {
119
						console.log("extendAll button click");
120
						var extendDatetime = $('input[name="extendDatetime"]')
121
								.val();
122
						console.log("extendDatetime : " + extendDatetime);
123
						if (extendDatetime) {
124
							if (confirm("Are you sure you want to Extend expireDateTime for All Scheme!") == true) {
125
								extendAllScheme(extendDatetime, "schemes-table")
126
							}
127
						} else {
128
							alert("feild can't be blank");
129
						}
130
					});
131
	$("#extendScheme-button")
132
			.live(
133
					'click',
134
					function() {
135
						console.log("extend button click");
136
						var extendDatetime = $('input[name="extendScheme"]')
137
								.val();
138
						var schemeId = $('#schemeId').val()
139
						console.log("extendDatetime : " + extendDatetime);
140
						console.log(schemeId);
141
						if (extendDatetime) {
142
							if (confirm("Are you sure you want to Extend expireDateTime for Scheme!") == true) {
143
								extendSchemeById(schemeId)
144
							}
145
						} else {
146
							alert("feild can't be blank");
147
						}
148
					});
23752 govind 149
 
27654 tejbeer 150
	$(".schemes").live('click', function() {
23347 ashik.ali 151
		console.log("Active Schemes Button Clicked...")
27648 tejbeer 152
	  schemes("main-content");
23347 ashik.ali 153
	});
23752 govind 154
 
27648 tejbeer 155
    $(".margin-calculator").live('click', function() {
156
		console.log("Active Schemes Button Clicked...")
157
	   marginCalculator("main-content");
158
	});
159
 
23347 ashik.ali 160
	$(".schemes-download-page").live('click', function() {
161
		console.log("Schemes Download Clicked...")
162
		loadSchemesDownloadPage("main-content");
22860 ashik.ali 163
	});
23752 govind 164
 
23556 amit.gupta 165
	$(".schemes-update").live('click', function() {
166
		loadSchemeUpdatePage("main-content");
167
	});
23557 amit.gupta 168
 
23928 govind 169
	$(".add-item").live('click', function() {
170
 
171
		schemeIds = $("#schemeids").val();
172
		itemIds = $("#itemids").val();
173
		console.log(schemeIds);
174
		console.log(itemIds);
175
		if (confirm("Are you sure you want to Add Item to Scheme!") == true) {
26763 tejbeer 176
			if (itemIds.trim().length === 0 || schemeIds.trim().length === 0) {
177
				alert("fields shouldn't be blank");
178
				return;
179
			}
180
			updateSingleScheme(schemeIds, itemIds);
23928 govind 181
		}
182
	});
23557 amit.gupta 183
	$(".add-schemes").live('click', function() {
23752 govind 184
 
23557 amit.gupta 185
		schemeIds = $("#schemeids").val();
186
		itemIds = $("#itemids").val();
23914 govind 187
		console.log(schemeIds);
188
		console.log(itemIds);
189
		if (confirm("Are you sure you want to Add Item to Scheme!") == true) {
26763 tejbeer 190
			if (itemIds.trim().length === 0 || schemeIds.trim().length === 0) {
191
				alert("fields shouldn't be blank");
192
				return;
193
			}
194
			updateSchemes(schemeIds, itemIds);
23557 amit.gupta 195
		}
196
	});
23715 govind 197
	$(".delete-schemes").live('click', function() {
23819 govind 198
		if (confirm("Are you sure you want to delete Scheme!") == true) {
23914 govind 199
			schemeId = $(this).data('schemeid');
200
			itemId = $(this).data('itemid');
201
			console.log(schemeId);
202
			console.log(itemId);
203
			deleteScheme(schemeId, itemId);
23715 govind 204
		}
23752 govind 205
	});
206
 
26802 tejbeer 207
	$("#scheme-search-button").live(
208
			'click',
209
			function() {
210
				var searchText = $("#scheme-search-text").val();
211
				if (typeof (searchText) == "undefined" || !searchText) {
212
					searchText = "";
213
				}
214
				doGetAjaxRequestHandler(context + "/getSchemes/?searchTerm="
215
						+ searchText, function(response) {
216
					$('#' + "main-content").html(response);
217
				});
218
			});
219
 
23752 govind 220
	$("#scheme-search-text").live("keyup", function(e) {
221
		var keyCode = e.keyCode || e.which;
222
		if (keyCode == 13) {
223
			$("#scheme-search-button").click();
224
		}
225
	});
226
	$("#scheme-item-search-button").live('click', function() {
227
		var searchText = $("#scheme-item-search-text").val();
228
		if (typeof (searchText) == "undefined" || !searchText) {
229
			searchText = "";
26497 amit.gupta 230
			alert("please select item");
231
			return;
23752 govind 232
		}
27094 tejbeer 233
		if (typeof currentItem != "undefined") {
234
			console.log(currentItem);
235
			loadSchemeItemSearchInfo(currentItem);
236
		} else {
237
			console.log("reeffff")
238
			alert("Data No Found")
239
		}
240
 
23752 govind 241
	});
242
 
26763 tejbeer 243
	$(".categoryWiseSchemeHistory").live(
244
			'click',
245
			function() {
246
				var category = $('#partner-category').val();
247
				console.log(category);
248
 
26912 tejbeer 249
				doGetAjaxRequestHandler(context + "/getSchemes?partnerType="
26802 tejbeer 250
						+ category, function(response) {
251
					$('#' + "main-content").html(response);
252
					$('#partner-category').val(category);
253
					window.dispatchEvent(new Event('resize'));
254
				});
26763 tejbeer 255
 
256
			});
257
 
23752 govind 258
	$("#scheme-item-search-text").live("keyup", function(e) {
259
		var keyCode = e.keyCode || e.which;
260
		if (keyCode == 13) {
261
			$("#scheme-item-search-button").click();
262
		}
263
	});
22860 ashik.ali 264
});
265
 
23752 govind 266
function configureTagListingItemsDescriptionDropDown() {
23347 ashik.ali 267
	$(document).ready(function() {
23752 govind 268
		$('#tagListingItemsDescription').multiselect({
269
			includeSelectAllOption : true,
270
			maxHeight : 200,
271
			buttonWidth : '180px',
272
			numberDisplayed : 1,
273
			nonSelectedText : 'Items',
274
			nSelectedText : ' - Items Selected',
275
			allSelectedText : 'All Items Selected',
276
			enableFiltering : true,
277
			enableCaseInsensitiveFiltering : true
278
 
279
		});
280
	});
23343 ashik.ali 281
}
282
 
23752 govind 283
function schemesDownload() {
23343 ashik.ali 284
	console.log("downloadItemLedgerReport Button clicked")
23914 govind 285
	var startDateTime = $('input[name="startDateTime"]').val();
286
	console.log("startDateTime : " + startDateTime);
287
	var endDateTime = $('input[name="endDateTime"]').val();
288
	console.log("endDateTime : " + endDateTime);
23752 govind 289
	doAjaxGetDownload(context + "/schemes/download?startDateTime="
23914 govind 290
			+ startDateTime + "&endDateTime=" + endDateTime,
23347 ashik.ali 291
			"SchemesReport.xlsx");
23343 ashik.ali 292
}
23914 govind 293
function selectedbrand() {
294
	var brands = $('#tag-listing-brands').val();
295
	console.log(brands);
296
	if (brands) {
297
		loadTagListingItemsDescriptionByBrand(
298
				"tag-listing-items-description-container", brands);
299
	}
300
}
23752 govind 301
function loadSchemeDetails(schemeId, domId) {
302
	doGetAjaxRequestHandler(context + "/getSchemeById?schemeId=" + schemeId,
303
			function(response) {
304
				$('#' + domId).html(response);
305
				window.dispatchEvent(new Event('resize'));
306
			});
23343 ashik.ali 307
}
308
 
23752 govind 309
function activeScheme(schemeId, offset, domId) {
310
	doPutAjaxRequestHandler(context + "/activeSchemeById?schemeId=" + schemeId
311
			+ "&offset=" + offset, function(response) {
23343 ashik.ali 312
		$('#' + domId).html(response);
313
		$('#scheme-details-container').html('');
314
	});
23752 govind 315
 
23343 ashik.ali 316
}
317
 
25069 amit.gupta 318
function expireScheme(schemeId, expireDate, offset, domId) {
23752 govind 319
	doPutAjaxRequestHandler(context + "/expireSchemeById?schemeId=" + schemeId
26763 tejbeer 320
			+ "&offset=" + offset + "&expireTimestamp=" + expireDate, function(
321
			response) {
322
		alert("Scheme - " + schemeId + " marked for expiry successfully!");
23343 ashik.ali 323
		$('#' + domId).html(response);
324
		$('#scheme-details-container').html('');
325
	});
326
}
23914 govind 327
function extendAllScheme(domId) {
26763 tejbeer 328
	doPostAjaxRequestWithJsonHandler(context + "/extendAllSchemes", JSON
329
			.stringify(startDate), function(response) {
23914 govind 330
		if (response == 'true') {
331
			alert("Scheme All Extended successfully");
332
			schemes("main-content");
333
		} else {
334
			alert("No scheme Activated Currently");
335
			schemes("main-content");
336
		}
337
	});
23343 ashik.ali 338
 
23914 govind 339
}
340
function extendSchemeById(schemeId) {
26763 tejbeer 341
	doPostAjaxRequestWithJsonHandler(context + "/extendSchemeById?schemeId="
342
			+ schemeId, JSON.stringify(startDate), function(response) {
23914 govind 343
		if (response == 'true') {
344
			alert("Scheme extended successfully");
345
			schemes("main-content");
346
		} else {
347
			alert("Scheme already Expired");
348
			schemes("main-content");
349
		}
350
	});
351
 
352
}
353
 
23752 govind 354
function loadScheme(domId) {
355
	doGetAjaxRequestHandler(context + "/createScheme", function(response) {
23343 ashik.ali 356
		$('#' + domId).html(response);
357
	});
23752 govind 358
 
23343 ashik.ali 359
}
360
 
23914 govind 361
// function loadTagListingItemsDescriptionByBrand(domId, brand) {
362
// doGetAjaxRequestHandler(context + "/getTagListingItemsByBrand?brand="
363
// + brand, function(response) {
364
// $('#' + domId).html(response);
365
// configureTagListingItemsDescriptionDropDown();
366
// });
367
//
368
// }
369
function loadTagListingItemsDescriptionByBrand(domId, brands) {
370
	doPostAjaxRequestWithJsonHandler(context + '/getTagListingItemsByBrand',
371
			JSON.stringify(brands), function(response) {
372
				$('#' + domId).html(response);
373
				configureTagListingItemsDescriptionDropDown();
374
			});
23752 govind 375
 
23343 ashik.ali 376
}
377
 
23752 govind 378
function schemes(domId) {
379
	doGetAjaxRequestHandler(context + "/getSchemes", function(response) {
23343 ashik.ali 380
		$('#' + domId).html(response);
381
	});
382
}
27648 tejbeer 383
function marginCalculator(domId) {
384
	doGetAjaxRequestHandler(context + "/getMarginCalculator", function(response) {
385
		$('#' + domId).html(response);
386
	});
387
}
23343 ashik.ali 388
 
23752 govind 389
function loadSchemesDownloadPage(domId) {
390
	doGetAjaxRequestHandler(context + "/schemes/downloadPage", function(
391
			response) {
23343 ashik.ali 392
		$('#' + domId).html(response);
393
	});
23556 amit.gupta 394
}
395
 
23752 govind 396
function loadSchemeUpdatePage(domId) {
397
	doGetAjaxRequestHandler(context + "/schemes/update-schemes-page", function(
398
			response) {
23556 amit.gupta 399
		$('#' + domId).html(response);
400
	});
23557 amit.gupta 401
}
402
 
23928 govind 403
function updateSingleScheme(shcemeIds, itemIds) {
404
	doPostAjaxRequestWithJsonHandler(context + '/addItemToScheme', JSON
23752 govind 405
			.stringify({
406
				"itemIds" : itemIds.split(",").map(Number),
407
				"schemeIds" : schemeIds.split(",").map(Number)
408
			}), function(response) {
26763 tejbeer 409
		if (response == 'true') {
23914 govind 410
			alert("Item Added to scheme successfully");
411
			// $('#newItemToSchemeModal').modal('hide');
412
			loadSchemeDetails(shcemeIds, "scheme-details-container");
413
		} else {
414
			alert("Item already present");
415
			loadSchemeDetails(shcemeIds, "scheme-details-container");
23557 amit.gupta 416
		}
417
	});
23715 govind 418
}
23928 govind 419
function updateSchemes(shcemeIds, itemIds) {
420
	doPostAjaxRequestWithJsonHandler(context + '/schemes/update', JSON
421
			.stringify({
422
				"itemIds" : itemIds.split(",").map(Number),
423
				"schemeIds" : schemeIds.split(",").map(Number)
424
			}), function(response) {
425
		if (response == 'true') {
426
			alert("Item Added to scheme successfully");
427
			// $('#newItemToSchemeModal').modal('hide');
428
			loadSchemeUpdatePage("main-content");
26763 tejbeer 429
		}
23928 govind 430
	});
431
}
23914 govind 432
function deleteScheme(shcemeId, itemId) {
433
	doDeleteAjaxRequestHandler(context + "/schemes/delete?schemeId=" + shcemeId
434
			+ "&itemId=" + itemId, function(response) {
23752 govind 435
		if (response == 'true') {
23914 govind 436
			alert("ItemId Deleted successfully from Scheme");
437
			loadSchemeDetails(shcemeId, "scheme-details-container");
23715 govind 438
		}
439
	});
23752 govind 440
}
441
function loadSearchScheme(domId, search_text) {
442
	doGetAjaxRequestHandler(context + "/searchScheme/?searchTerm="
443
			+ search_text, function(response) {
444
		$('#' + domId).html(response);
445
	});
446
}
26497 amit.gupta 447
function loadSearchItemScheme(domId, selected_item) {
26802 tejbeer 448
	var category = $('#partner-category').val();
449
	var searchText = $("#scheme-item-search-text").val();
26763 tejbeer 450
 
26802 tejbeer 451
	var category = $('#partner-category').val();
26912 tejbeer 452
 
453
	console.log(category)
454
 
26802 tejbeer 455
	if (typeof (searchText) == "undefined" || !searchText) {
456
		searchText = "";
457
	}
458
	if (typeof (category) == "undefined" || !category) {
459
		category = "";
460
	}
461
	if ((searchText) && (category)) {
462
		doGetAjaxRequestHandler(context + "/getSchemes/?searchItem="
463
				+ selected_item.itemId + "&partnerType=" + category, function(
464
				response) {
465
			$('#' + domId).html(response);
466
			$('#partner-category').val(category);
467
			$('#scheme-item-search-text').val(selected_item.itemDescription);
468
 
469
		});
26912 tejbeer 470
	} else if ((searchText)) {
26802 tejbeer 471
		doGetAjaxRequestHandler(context + "/getSchemes/?searchItem="
472
				+ selected_item.itemId, function(response) {
473
			$('#' + domId).html(response);
474
			$('#scheme-item-search-text').val(selected_item.itemDescription);
475
 
476
		});
26912 tejbeer 477
 
478
	}
479
 
23752 govind 480
}
481
function loadSchemeSearchInfo(search_text) {
482
	loadSearchScheme("main-content", search_text);
483
}
26497 amit.gupta 484
function loadSchemeItemSearchInfo(selectedItem) {
485
	loadSearchItemScheme("main-content", selectedItem);
23914 govind 486
}