Subversion Repositories SmartDukaan

Rev

Rev 23752 | Rev 23886 | 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
	$('#tag-listing-brands li a').live(
7
			'click',
8
			function() {
9
				$('#tag-listing-brand-value').text($(this).text());
10
				loadTagListingItemsDescriptionByBrand(
11
						"tag-listing-items-description-container", $(this)
12
								.text());
13
				console.log($(this).text());
14
			});
15
 
16
	$("#schemes-paginated .next").live(
17
			'click',
18
			function() {
19
				var searchText = $("#scheme-item-search-text").val();
20
				// var searchTxt=$("#scheme-search-text").val();
21
				console.log(searchText);
22
				if (typeof (searchText) == "undefined" || !searchText) {
23
					searchText = "";
24
				}
25
 
26
				if ((searchText)) {
27
					var params = {};
28
					params['searchItem'] = searchText;
29
					loadPaginatedNextItems('/searchItemSchemePanigated',
30
							params, 'schemes-paginated', 'schemes-table',
31
							'scheme-details-container');
32
				} else {
33
					loadPaginatedNextItems('/getPaginatedSchemes', null,
34
							'schemes-paginated', 'schemes-table',
35
							'scheme-details-container');
36
				}
37
				$(this).blur();
38
			});
39
 
40
	$("#schemes-paginated .previous").live(
41
			'click',
42
			function() {
43
				var searchText = $("#scheme-item-search-text").val();
44
				// var searchTxt=$("#scheme-search-text").val();
45
				console.log(searchText);
46
				if (typeof (searchText) == "undefined" || !searchText) {
47
					searchText = "";
48
				}
49
 
50
				if ((searchText)) {
51
					var params = {};
52
					params['searchItem'] = searchText;
53
					loadPaginatedPreviousItems('/searchItemSchemePanigated',
54
							params, 'schemes-paginated', 'schemes-table',
55
							'scheme-details-container');
56
				} else {
57
					loadPaginatedPreviousItems('/getPaginatedSchemes', null,
58
							'schemes-paginated', 'schemes-table',
59
							'scheme-details-container');
60
				}
61
				$(this).blur();
62
			});
63
 
64
	$(".scheme-details").live('click', function() {
23343 ashik.ali 65
		var schemeId = $(this).attr('data');
23752 govind 66
		console.log("schemeId = " + schemeId);
23343 ashik.ali 67
		loadSchemeDetails(schemeId, "scheme-details-container");
68
	});
23752 govind 69
 
70
	$(".active-scheme").live('click', function() {
23343 ashik.ali 71
		var schemeId = $(this).attr('data');
23752 govind 72
		console.log("active-scheme id : " + schemeId);
73
		var start = $("#schemes-paginated .start").text();
74
		// var end = $( "#schemes-paginated .end" ).text();
23343 ashik.ali 75
		var offset = start - 1;
23752 govind 76
		if (confirm("Are you sure you want to Active Scheme!") == true) {
23343 ashik.ali 77
			activeScheme(schemeId, offset, "schemes-table");
78
		}
79
	});
23752 govind 80
 
81
	$(".expire-scheme").live('click', function() {
23343 ashik.ali 82
		var schemeId = $(this).attr('data');
23752 govind 83
		console.log("expire-scheme id : " + schemeId);
84
		var start = $("#schemes-paginated .start").text();
85
		// var end = $( "#schemes-paginated .end" ).text();
23343 ashik.ali 86
		var offset = start - 1;
23752 govind 87
		if (confirm("Are you sure you want to Expire Scheme!") == true) {
23343 ashik.ali 88
			expireScheme(schemeId, offset, "schemes-table");
89
		}
90
	});
23752 govind 91
 
23347 ashik.ali 92
	$(".schemes").live('click', function() {
93
		console.log("Active Schemes Button Clicked...")
94
		schemes("main-content");
95
	});
23752 govind 96
 
23347 ashik.ali 97
	$(".schemes-download-page").live('click', function() {
98
		console.log("Schemes Download Clicked...")
99
		loadSchemesDownloadPage("main-content");
22860 ashik.ali 100
	});
23752 govind 101
 
23556 amit.gupta 102
	$(".schemes-update").live('click', function() {
103
		loadSchemeUpdatePage("main-content");
104
	});
23557 amit.gupta 105
 
106
	$(".add-schemes").live('click', function() {
23752 govind 107
 
23557 amit.gupta 108
		schemeIds = $("#schemeids").val();
109
		itemIds = $("#itemids").val();
23752 govind 110
		if (itemIds.trim().length === 0 || schemeIds.trim().length === 0) {
23557 amit.gupta 111
			alert("fields shouldn't be blank");
112
		}
113
		updateSchemes(schemeIds, itemIds);
114
	});
23715 govind 115
	$(".delete-schemes").live('click', function() {
23819 govind 116
		if (confirm("Are you sure you want to delete Scheme!") == true) {
23752 govind 117
			schemeIds = $("#schemeid").val();
118
			itemIds = $("#itemid").val();
119
			if (itemIds.trim().length === 0 || schemeIds.trim().length === 0) {
120
				alert("fields shouldn't be blank");
121
			}
122
			deleteScheme(schemeIds, itemIds);
23715 govind 123
		}
23752 govind 124
	});
125
	$("#scheme-search-button").live('click', function() {
126
		var searchText = $("#scheme-search-text").val();
127
		if (typeof (searchText) == "undefined" || !searchText) {
128
			searchText = "";
23715 govind 129
		}
23752 govind 130
		loadSchemeSearchInfo(searchText);
23715 govind 131
	});
23752 govind 132
 
133
	$("#scheme-search-text").live("keyup", function(e) {
134
		var keyCode = e.keyCode || e.which;
135
		if (keyCode == 13) {
136
			$("#scheme-search-button").click();
137
		}
138
	});
139
	$("#scheme-item-search-button").live('click', function() {
140
		var searchText = $("#scheme-item-search-text").val();
141
		if (typeof (searchText) == "undefined" || !searchText) {
142
			searchText = "";
143
		}
144
		loadSchemeItemSearchInfo(searchText);
145
	});
146
 
147
	$("#scheme-item-search-text").live("keyup", function(e) {
148
		var keyCode = e.keyCode || e.which;
149
		if (keyCode == 13) {
150
			$("#scheme-item-search-button").click();
151
		}
152
	});
22860 ashik.ali 153
});
154
 
23752 govind 155
function configureTagListingItemsDescriptionDropDown() {
23347 ashik.ali 156
	$(document).ready(function() {
23752 govind 157
		$('#tagListingItemsDescription').multiselect({
158
			includeSelectAllOption : true,
159
			maxHeight : 200,
160
			buttonWidth : '180px',
161
			numberDisplayed : 1,
162
			nonSelectedText : 'Items',
163
			nSelectedText : ' - Items Selected',
164
			allSelectedText : 'All Items Selected',
165
			enableFiltering : true,
166
			enableCaseInsensitiveFiltering : true
167
 
168
		});
169
	});
23343 ashik.ali 170
}
171
 
23752 govind 172
function schemesDownload() {
23343 ashik.ali 173
	console.log("downloadItemLedgerReport Button clicked")
23347 ashik.ali 174
	var startDateTime = $('input[name="startDateTime"]').val();
23752 govind 175
	console.log("startDateTime : " + startDateTime);
23347 ashik.ali 176
	var endDateTime = $('input[name="endDateTime"]').val();
23752 govind 177
	console.log("endDateTime : " + endDateTime);
178
	doAjaxGetDownload(context + "/schemes/download?startDateTime="
179
			+ startDateTime + "&endDateTime=" + endDateTime,
23347 ashik.ali 180
			"SchemesReport.xlsx");
23343 ashik.ali 181
}
182
 
23752 govind 183
function loadSchemeDetails(schemeId, domId) {
184
	doGetAjaxRequestHandler(context + "/getSchemeById?schemeId=" + schemeId,
185
			function(response) {
186
				$('#' + domId).html(response);
187
				window.dispatchEvent(new Event('resize'));
188
			});
23343 ashik.ali 189
}
190
 
23752 govind 191
function activeScheme(schemeId, offset, domId) {
192
	doPutAjaxRequestHandler(context + "/activeSchemeById?schemeId=" + schemeId
193
			+ "&offset=" + offset, function(response) {
23343 ashik.ali 194
		$('#' + domId).html(response);
195
		$('#scheme-details-container').html('');
196
	});
23752 govind 197
 
23343 ashik.ali 198
}
199
 
23752 govind 200
function expireScheme(schemeId, offset, domId) {
201
	doPutAjaxRequestHandler(context + "/expireSchemeById?schemeId=" + schemeId
202
			+ "&offset=" + offset, function(response) {
23343 ashik.ali 203
		$('#' + domId).html(response);
204
		$('#scheme-details-container').html('');
205
	});
206
}
207
 
23752 govind 208
function loadScheme(domId) {
209
	doGetAjaxRequestHandler(context + "/createScheme", function(response) {
23343 ashik.ali 210
		$('#' + domId).html(response);
211
	});
23752 govind 212
 
23343 ashik.ali 213
}
214
 
23752 govind 215
function loadTagListingItemsDescriptionByBrand(domId, brand) {
216
	doGetAjaxRequestHandler(context + "/getTagListingItemsByBrand?brand="
217
			+ brand, function(response) {
23343 ashik.ali 218
		$('#' + domId).html(response);
23419 ashik.ali 219
		configureTagListingItemsDescriptionDropDown();
23343 ashik.ali 220
	});
23752 govind 221
 
23343 ashik.ali 222
}
223
 
23752 govind 224
function schemes(domId) {
225
	doGetAjaxRequestHandler(context + "/getSchemes", function(response) {
23343 ashik.ali 226
		$('#' + domId).html(response);
227
	});
228
}
229
 
23752 govind 230
function loadSchemesDownloadPage(domId) {
231
	doGetAjaxRequestHandler(context + "/schemes/downloadPage", function(
232
			response) {
23343 ashik.ali 233
		$('#' + domId).html(response);
234
	});
23556 amit.gupta 235
}
236
 
23752 govind 237
function loadSchemeUpdatePage(domId) {
238
	doGetAjaxRequestHandler(context + "/schemes/update-schemes-page", function(
239
			response) {
23556 amit.gupta 240
		$('#' + domId).html(response);
241
	});
23557 amit.gupta 242
}
243
 
23752 govind 244
function updateSchemes(shcemeIds, itemIds) {
245
	doPostAjaxRequestWithJsonHandler(context + '/schemes/update', JSON
246
			.stringify({
247
				"itemIds" : itemIds.split(",").map(Number),
248
				"schemeIds" : schemeIds.split(",").map(Number)
249
			}), function(response) {
250
		if (response == 'true') {
23557 amit.gupta 251
			alert("Schemes Added successfully");
252
		}
253
	});
23715 govind 254
}
23752 govind 255
function deleteScheme(shcemeIds, itemIds) {
256
	doPostAjaxRequestWithJsonHandler(context + '/schemes/delete', JSON
257
			.stringify({
258
				"itemIds" : itemIds.split(",").map(Number),
259
				"schemeIds" : schemeIds.split(",").map(Number)
260
			}), function(response) {
261
		if (response == 'true') {
23715 govind 262
			alert("Schemes Deleted successfully");
263
		}
264
	});
23752 govind 265
}
266
function loadSearchScheme(domId, search_text) {
267
	doGetAjaxRequestHandler(context + "/searchScheme/?searchTerm="
268
			+ search_text, function(response) {
269
		$('#' + domId).html(response);
270
	});
271
}
272
function loadSearchItemScheme(domId, search_text) {
273
	doGetAjaxRequestHandler(context + "/searchScheme/?searchItem="
274
			+ search_text, function(response) {
275
		$('#' + domId).html(response);
276
	});
277
}
278
function loadSchemeSearchInfo(search_text) {
279
	loadSearchScheme("main-content", search_text);
280
}
281
function loadSchemeItemSearchInfo(search_text) {
282
	loadSearchItemScheme("main-content", search_text);
23343 ashik.ali 283
}