Subversion Repositories SmartDukaan

Rev

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

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