Subversion Repositories SmartDukaan

Rev

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

Rev 23886 Rev 23914
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(
-
 
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(
6
	$("#schemes-paginated .next").live(
17
			'click',
7
			'click',
18
			function() {
8
			function() {
19
				var searchText = $("#scheme-item-search-text").val();
9
				var searchText = $("#scheme-item-search-text").val();
20
				// var searchTxt=$("#scheme-search-text").val();
10
				// var searchTxt=$("#scheme-search-text").val();
Line 86... Line 76...
86
		var offset = start - 1;
76
		var offset = start - 1;
87
		if (confirm("Are you sure you want to Expire Scheme!") == true) {
77
		if (confirm("Are you sure you want to Expire Scheme!") == true) {
88
			expireScheme(schemeId, offset, "schemes-table");
78
			expireScheme(schemeId, offset, "schemes-table");
89
		}
79
		}
90
	});
80
	});
-
 
81
	$("#extendDatetime-button")
-
 
82
			.live(
-
 
83
					'click',
-
 
84
					function() {
-
 
85
						console.log("extendAll button click");
-
 
86
						var extendDatetime = $('input[name="extendDatetime"]')
-
 
87
								.val();
-
 
88
						console.log("extendDatetime : " + extendDatetime);
-
 
89
						if (extendDatetime) {
-
 
90
							if (confirm("Are you sure you want to Extend expireDateTime for All Scheme!") == true) {
-
 
91
								extendAllScheme(extendDatetime, "schemes-table")
-
 
92
							}
-
 
93
						} else {
-
 
94
							alert("feild can't be blank");
-
 
95
						}
-
 
96
					});
-
 
97
	$("#extendScheme-button")
-
 
98
			.live(
-
 
99
					'click',
-
 
100
					function() {
-
 
101
						console.log("extend button click");
-
 
102
						var extendDatetime = $('input[name="extendScheme"]')
-
 
103
								.val();
-
 
104
						var schemeId = $('#schemeId').val()
-
 
105
						console.log("extendDatetime : " + extendDatetime);
-
 
106
						console.log(schemeId);
-
 
107
						if (extendDatetime) {
-
 
108
							if (confirm("Are you sure you want to Extend expireDateTime for Scheme!") == true) {
-
 
109
								extendSchemeById(schemeId)
-
 
110
							}
-
 
111
						} else {
-
 
112
							alert("feild can't be blank");
-
 
113
						}
-
 
114
					});
91
 
115
 
92
	$(".schemes").live('click', function() {
116
	$(".schemes").live('click', function() {
93
		console.log("Active Schemes Button Clicked...")
117
		console.log("Active Schemes Button Clicked...")
94
		schemes("main-content");
118
		schemes("main-content");
95
	});
119
	});
Line 105... Line 129...
105
 
129
 
106
	$(".add-schemes").live('click', function() {
130
	$(".add-schemes").live('click', function() {
107
 
131
 
108
		schemeIds = $("#schemeids").val();
132
		schemeIds = $("#schemeids").val();
109
		itemIds = $("#itemids").val();
133
		itemIds = $("#itemids").val();
-
 
134
		console.log(schemeIds);
-
 
135
		console.log(itemIds);
-
 
136
		if (confirm("Are you sure you want to Add Item to Scheme!") == true) {
110
		if (itemIds.trim().length === 0 || schemeIds.trim().length === 0) {
137
		if (itemIds.trim().length === 0 || schemeIds.trim().length === 0) {
111
			alert("fields shouldn't be blank");
138
			alert("fields shouldn't be blank");
-
 
139
			return;
112
		}
140
		}
113
		updateSchemes(schemeIds, itemIds);
141
		updateSchemes(schemeIds, itemIds);
-
 
142
		}
114
	});
143
	});
115
	$(".delete-schemes").live('click', function() {
144
	$(".delete-schemes").live('click', function() {
116
		if (confirm("Are you sure you want to delete Scheme!") == true) {
145
		if (confirm("Are you sure you want to delete Scheme!") == true) {
117
			schemeIds = $("#schemeid").val();
146
			schemeId = $(this).data('schemeid');
118
			itemIds = $("#itemid").val();
147
			itemId = $(this).data('itemid');
119
			if (itemIds.trim().length === 0 || schemeIds.trim().length === 0) {
148
			console.log(schemeId);
120
				alert("fields shouldn't be blank");
149
			console.log(itemId);
121
			}
-
 
122
			deleteScheme(schemeIds, itemIds);
150
			deleteScheme(schemeId, itemId);
123
		}
151
		}
124
	});
152
	});
125
	$("#scheme-search-button").live('click', function() {
153
	$("#scheme-search-button").live('click', function() {
126
		var searchText = $("#scheme-search-text").val();
154
		var searchText = $("#scheme-search-text").val();
127
		if (typeof (searchText) == "undefined" || !searchText) {
155
		if (typeof (searchText) == "undefined" || !searchText) {
Line 169... Line 197...
169
	});
197
	});
170
}
198
}
171
 
199
 
172
function schemesDownload() {
200
function schemesDownload() {
173
	console.log("downloadItemLedgerReport Button clicked")
201
	console.log("downloadItemLedgerReport Button clicked")
-
 
202
	var startDateTime = $('input[name="startDateTime"]').val();
-
 
203
	console.log("startDateTime : " + startDateTime);
-
 
204
	var endDateTime = $('input[name="endDateTime"]').val();
-
 
205
	console.log("endDateTime : " + endDateTime);
174
	doAjaxGetDownload(context + "/schemes/download?startDateTime="
206
	doAjaxGetDownload(context + "/schemes/download?startDateTime="
175
			+ startDate + "&endDateTime=" + endDate,
207
			+ startDateTime + "&endDateTime=" + endDateTime,
176
			"SchemesReport.xlsx");
208
			"SchemesReport.xlsx");
177
}
209
}
-
 
210
function selectedbrand() {
-
 
211
	var brands = $('#tag-listing-brands').val();
-
 
212
	console.log(brands);
-
 
213
	if (brands) {
-
 
214
		loadTagListingItemsDescriptionByBrand(
-
 
215
				"tag-listing-items-description-container", brands);
-
 
216
	}
178
 
217
}
179
function loadSchemeDetails(schemeId, domId) {
218
function loadSchemeDetails(schemeId, domId) {
180
	doGetAjaxRequestHandler(context + "/getSchemeById?schemeId=" + schemeId,
219
	doGetAjaxRequestHandler(context + "/getSchemeById?schemeId=" + schemeId,
181
			function(response) {
220
			function(response) {
182
				$('#' + domId).html(response);
221
				$('#' + domId).html(response);
183
				window.dispatchEvent(new Event('resize'));
222
				window.dispatchEvent(new Event('resize'));
Line 198... Line 237...
198
			+ "&offset=" + offset, function(response) {
237
			+ "&offset=" + offset, function(response) {
199
		$('#' + domId).html(response);
238
		$('#' + domId).html(response);
200
		$('#scheme-details-container').html('');
239
		$('#scheme-details-container').html('');
201
	});
240
	});
202
}
241
}
-
 
242
function extendAllScheme(domId) {
-
 
243
	doPostAjaxRequestWithJsonHandler(context + "/extendAllSchemes",
-
 
244
			JSON.stringify(startDate), function(response) {
-
 
245
		if (response == 'true') {
-
 
246
			alert("Scheme All Extended successfully");
-
 
247
			schemes("main-content");
-
 
248
		} else {
-
 
249
			alert("No scheme Activated Currently");
-
 
250
			schemes("main-content");
-
 
251
		}
-
 
252
	});
-
 
253
 
-
 
254
}
-
 
255
function extendSchemeById(schemeId) {
-
 
256
	doPostAjaxRequestWithJsonHandler(context + "/extendSchemeById?schemeId="+ schemeId,JSON.stringify(startDate), function(response) {
-
 
257
		if (response == 'true') {
-
 
258
			alert("Scheme extended successfully");
-
 
259
			schemes("main-content");
-
 
260
		} else {
-
 
261
			alert("Scheme already Expired");
-
 
262
			schemes("main-content");
-
 
263
		}
-
 
264
	});
-
 
265
 
-
 
266
}
203
 
267
 
204
function loadScheme(domId) {
268
function loadScheme(domId) {
205
	doGetAjaxRequestHandler(context + "/createScheme", function(response) {
269
	doGetAjaxRequestHandler(context + "/createScheme", function(response) {
206
		$('#' + domId).html(response);
270
		$('#' + domId).html(response);
207
	});
271
	});
208
 
272
 
209
}
273
}
210
 
274
 
211
function loadTagListingItemsDescriptionByBrand(domId, brand) {
275
// function loadTagListingItemsDescriptionByBrand(domId, brand) {
212
	doGetAjaxRequestHandler(context + "/getTagListingItemsByBrand?brand="
276
// doGetAjaxRequestHandler(context + "/getTagListingItemsByBrand?brand="
213
			+ brand, function(response) {
277
// + brand, function(response) {
-
 
278
// $('#' + domId).html(response);
-
 
279
// configureTagListingItemsDescriptionDropDown();
-
 
280
// });
-
 
281
//
-
 
282
// }
-
 
283
function loadTagListingItemsDescriptionByBrand(domId, brands) {
-
 
284
	doPostAjaxRequestWithJsonHandler(context + '/getTagListingItemsByBrand',
-
 
285
			JSON.stringify(brands), function(response) {
214
		$('#' + domId).html(response);
286
				$('#' + domId).html(response);
215
		configureTagListingItemsDescriptionDropDown();
287
				configureTagListingItemsDescriptionDropDown();
216
	});
288
			});
217
 
289
 
218
}
290
}
219
 
291
 
220
function schemes(domId) {
292
function schemes(domId) {
221
	doGetAjaxRequestHandler(context + "/getSchemes", function(response) {
293
	doGetAjaxRequestHandler(context + "/getSchemes", function(response) {
Line 242... Line 314...
242
			.stringify({
314
			.stringify({
243
				"itemIds" : itemIds.split(",").map(Number),
315
				"itemIds" : itemIds.split(",").map(Number),
244
				"schemeIds" : schemeIds.split(",").map(Number)
316
				"schemeIds" : schemeIds.split(",").map(Number)
245
			}), function(response) {
317
			}), function(response) {
246
		if (response == 'true') {
318
		if (response == 'true') {
247
			alert("Schemes Added successfully");
319
			alert("Item Added to scheme successfully");
-
 
320
			// $('#newItemToSchemeModal').modal('hide');
-
 
321
			loadSchemeDetails(shcemeIds, "scheme-details-container");
-
 
322
		} else {
-
 
323
			alert("Item already present");
-
 
324
			loadSchemeDetails(shcemeIds, "scheme-details-container");
248
		}
325
		}
249
	});
326
	});
250
}
327
}
251
function deleteScheme(shcemeIds, itemIds) {
328
function deleteScheme(shcemeId, itemId) {
252
	doPostAjaxRequestWithJsonHandler(context + '/schemes/delete', JSON
329
	doDeleteAjaxRequestHandler(context + "/schemes/delete?schemeId=" + shcemeId
253
			.stringify({
-
 
254
				"itemIds" : itemIds.split(",").map(Number),
-
 
255
				"schemeIds" : schemeIds.split(",").map(Number)
-
 
256
			}), function(response) {
330
			+ "&itemId=" + itemId, function(response) {
257
		if (response == 'true') {
331
		if (response == 'true') {
258
			alert("Schemes Deleted successfully");
332
			alert("ItemId Deleted successfully from Scheme");
-
 
333
			loadSchemeDetails(shcemeId, "scheme-details-container");
259
		}
334
		}
260
	});
335
	});
261
}
336
}
262
function loadSearchScheme(domId, search_text) {
337
function loadSearchScheme(domId, search_text) {
263
	doGetAjaxRequestHandler(context + "/searchScheme/?searchTerm="
338
	doGetAjaxRequestHandler(context + "/searchScheme/?searchTerm="
Line 274... Line 349...
274
function loadSchemeSearchInfo(search_text) {
349
function loadSchemeSearchInfo(search_text) {
275
	loadSearchScheme("main-content", search_text);
350
	loadSearchScheme("main-content", search_text);
276
}
351
}
277
function loadSchemeItemSearchInfo(search_text) {
352
function loadSchemeItemSearchInfo(search_text) {
278
	loadSearchItemScheme("main-content", search_text);
353
	loadSearchItemScheme("main-content", search_text);
279
}
-
 
280
354
}
-
 
355