| 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() {
|
|
|
9 |
var searchText = $("#scheme-item-search-text").val();
|
|
|
10 |
// var searchTxt=$("#scheme-search-text").val();
|
|
|
11 |
console.log(searchText);
|
|
|
12 |
if (typeof (searchText) == "undefined" || !searchText) {
|
|
|
13 |
searchText = "";
|
|
|
14 |
}
|
|
|
15 |
|
|
|
16 |
if ((searchText)) {
|
|
|
17 |
var params = {};
|
|
|
18 |
params['searchItem'] = searchText;
|
|
|
19 |
loadPaginatedNextItems('/searchItemSchemePanigated',
|
|
|
20 |
params, 'schemes-paginated', 'schemes-table',
|
|
|
21 |
'scheme-details-container');
|
|
|
22 |
} else {
|
|
|
23 |
loadPaginatedNextItems('/getPaginatedSchemes', null,
|
|
|
24 |
'schemes-paginated', 'schemes-table',
|
|
|
25 |
'scheme-details-container');
|
|
|
26 |
}
|
|
|
27 |
$(this).blur();
|
|
|
28 |
});
|
|
|
29 |
|
|
|
30 |
$("#schemes-paginated .previous").live(
|
|
|
31 |
'click',
|
|
|
32 |
function() {
|
|
|
33 |
var searchText = $("#scheme-item-search-text").val();
|
|
|
34 |
// var searchTxt=$("#scheme-search-text").val();
|
|
|
35 |
console.log(searchText);
|
|
|
36 |
if (typeof (searchText) == "undefined" || !searchText) {
|
|
|
37 |
searchText = "";
|
|
|
38 |
}
|
|
|
39 |
|
|
|
40 |
if ((searchText)) {
|
|
|
41 |
var params = {};
|
|
|
42 |
params['searchItem'] = searchText;
|
|
|
43 |
loadPaginatedPreviousItems('/searchItemSchemePanigated',
|
|
|
44 |
params, 'schemes-paginated', 'schemes-table',
|
|
|
45 |
'scheme-details-container');
|
|
|
46 |
} else {
|
|
|
47 |
loadPaginatedPreviousItems('/getPaginatedSchemes', null,
|
|
|
48 |
'schemes-paginated', 'schemes-table',
|
|
|
49 |
'scheme-details-container');
|
|
|
50 |
}
|
|
|
51 |
$(this).blur();
|
|
|
52 |
});
|
|
|
53 |
|
|
|
54 |
$(".scheme-details").live('click', function() {
|
| 23343 |
ashik.ali |
55 |
var schemeId = $(this).attr('data');
|
| 23752 |
govind |
56 |
console.log("schemeId = " + schemeId);
|
| 23343 |
ashik.ali |
57 |
loadSchemeDetails(schemeId, "scheme-details-container");
|
|
|
58 |
});
|
| 23752 |
govind |
59 |
|
|
|
60 |
$(".active-scheme").live('click', function() {
|
| 23343 |
ashik.ali |
61 |
var schemeId = $(this).attr('data');
|
| 23752 |
govind |
62 |
console.log("active-scheme id : " + schemeId);
|
|
|
63 |
var start = $("#schemes-paginated .start").text();
|
|
|
64 |
// var end = $( "#schemes-paginated .end" ).text();
|
| 23343 |
ashik.ali |
65 |
var offset = start - 1;
|
| 23752 |
govind |
66 |
if (confirm("Are you sure you want to Active Scheme!") == true) {
|
| 23343 |
ashik.ali |
67 |
activeScheme(schemeId, offset, "schemes-table");
|
|
|
68 |
}
|
|
|
69 |
});
|
| 23752 |
govind |
70 |
|
|
|
71 |
$(".expire-scheme").live('click', function() {
|
| 23343 |
ashik.ali |
72 |
var schemeId = $(this).attr('data');
|
| 23752 |
govind |
73 |
console.log("expire-scheme id : " + schemeId);
|
|
|
74 |
var start = $("#schemes-paginated .start").text();
|
|
|
75 |
// var end = $( "#schemes-paginated .end" ).text();
|
| 23343 |
ashik.ali |
76 |
var offset = start - 1;
|
| 23752 |
govind |
77 |
if (confirm("Are you sure you want to Expire Scheme!") == true) {
|
| 23343 |
ashik.ali |
78 |
expireScheme(schemeId, offset, "schemes-table");
|
|
|
79 |
}
|
|
|
80 |
});
|
| 23914 |
govind |
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 |
});
|
| 23752 |
govind |
115 |
|
| 23347 |
ashik.ali |
116 |
$(".schemes").live('click', function() {
|
|
|
117 |
console.log("Active Schemes Button Clicked...")
|
|
|
118 |
schemes("main-content");
|
|
|
119 |
});
|
| 23752 |
govind |
120 |
|
| 23347 |
ashik.ali |
121 |
$(".schemes-download-page").live('click', function() {
|
|
|
122 |
console.log("Schemes Download Clicked...")
|
|
|
123 |
loadSchemesDownloadPage("main-content");
|
| 22860 |
ashik.ali |
124 |
});
|
| 23752 |
govind |
125 |
|
| 23556 |
amit.gupta |
126 |
$(".schemes-update").live('click', function() {
|
|
|
127 |
loadSchemeUpdatePage("main-content");
|
|
|
128 |
});
|
| 23557 |
amit.gupta |
129 |
|
|
|
130 |
$(".add-schemes").live('click', function() {
|
| 23752 |
govind |
131 |
|
| 23557 |
amit.gupta |
132 |
schemeIds = $("#schemeids").val();
|
|
|
133 |
itemIds = $("#itemids").val();
|
| 23914 |
govind |
134 |
console.log(schemeIds);
|
|
|
135 |
console.log(itemIds);
|
|
|
136 |
if (confirm("Are you sure you want to Add Item to Scheme!") == true) {
|
| 23752 |
govind |
137 |
if (itemIds.trim().length === 0 || schemeIds.trim().length === 0) {
|
| 23557 |
amit.gupta |
138 |
alert("fields shouldn't be blank");
|
| 23914 |
govind |
139 |
return;
|
| 23557 |
amit.gupta |
140 |
}
|
|
|
141 |
updateSchemes(schemeIds, itemIds);
|
| 23914 |
govind |
142 |
}
|
| 23557 |
amit.gupta |
143 |
});
|
| 23715 |
govind |
144 |
$(".delete-schemes").live('click', function() {
|
| 23819 |
govind |
145 |
if (confirm("Are you sure you want to delete Scheme!") == true) {
|
| 23914 |
govind |
146 |
schemeId = $(this).data('schemeid');
|
|
|
147 |
itemId = $(this).data('itemid');
|
|
|
148 |
console.log(schemeId);
|
|
|
149 |
console.log(itemId);
|
|
|
150 |
deleteScheme(schemeId, itemId);
|
| 23715 |
govind |
151 |
}
|
| 23752 |
govind |
152 |
});
|
|
|
153 |
$("#scheme-search-button").live('click', function() {
|
|
|
154 |
var searchText = $("#scheme-search-text").val();
|
|
|
155 |
if (typeof (searchText) == "undefined" || !searchText) {
|
|
|
156 |
searchText = "";
|
| 23715 |
govind |
157 |
}
|
| 23752 |
govind |
158 |
loadSchemeSearchInfo(searchText);
|
| 23715 |
govind |
159 |
});
|
| 23752 |
govind |
160 |
|
|
|
161 |
$("#scheme-search-text").live("keyup", function(e) {
|
|
|
162 |
var keyCode = e.keyCode || e.which;
|
|
|
163 |
if (keyCode == 13) {
|
|
|
164 |
$("#scheme-search-button").click();
|
|
|
165 |
}
|
|
|
166 |
});
|
|
|
167 |
$("#scheme-item-search-button").live('click', function() {
|
|
|
168 |
var searchText = $("#scheme-item-search-text").val();
|
|
|
169 |
if (typeof (searchText) == "undefined" || !searchText) {
|
|
|
170 |
searchText = "";
|
|
|
171 |
}
|
|
|
172 |
loadSchemeItemSearchInfo(searchText);
|
|
|
173 |
});
|
|
|
174 |
|
|
|
175 |
$("#scheme-item-search-text").live("keyup", function(e) {
|
|
|
176 |
var keyCode = e.keyCode || e.which;
|
|
|
177 |
if (keyCode == 13) {
|
|
|
178 |
$("#scheme-item-search-button").click();
|
|
|
179 |
}
|
|
|
180 |
});
|
| 22860 |
ashik.ali |
181 |
});
|
|
|
182 |
|
| 23752 |
govind |
183 |
function configureTagListingItemsDescriptionDropDown() {
|
| 23347 |
ashik.ali |
184 |
$(document).ready(function() {
|
| 23752 |
govind |
185 |
$('#tagListingItemsDescription').multiselect({
|
|
|
186 |
includeSelectAllOption : true,
|
|
|
187 |
maxHeight : 200,
|
|
|
188 |
buttonWidth : '180px',
|
|
|
189 |
numberDisplayed : 1,
|
|
|
190 |
nonSelectedText : 'Items',
|
|
|
191 |
nSelectedText : ' - Items Selected',
|
|
|
192 |
allSelectedText : 'All Items Selected',
|
|
|
193 |
enableFiltering : true,
|
|
|
194 |
enableCaseInsensitiveFiltering : true
|
|
|
195 |
|
|
|
196 |
});
|
|
|
197 |
});
|
| 23343 |
ashik.ali |
198 |
}
|
|
|
199 |
|
| 23752 |
govind |
200 |
function schemesDownload() {
|
| 23343 |
ashik.ali |
201 |
console.log("downloadItemLedgerReport Button clicked")
|
| 23914 |
govind |
202 |
var startDateTime = $('input[name="startDateTime"]').val();
|
|
|
203 |
console.log("startDateTime : " + startDateTime);
|
|
|
204 |
var endDateTime = $('input[name="endDateTime"]').val();
|
|
|
205 |
console.log("endDateTime : " + endDateTime);
|
| 23752 |
govind |
206 |
doAjaxGetDownload(context + "/schemes/download?startDateTime="
|
| 23914 |
govind |
207 |
+ startDateTime + "&endDateTime=" + endDateTime,
|
| 23347 |
ashik.ali |
208 |
"SchemesReport.xlsx");
|
| 23343 |
ashik.ali |
209 |
}
|
| 23914 |
govind |
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 |
}
|
|
|
217 |
}
|
| 23752 |
govind |
218 |
function loadSchemeDetails(schemeId, domId) {
|
|
|
219 |
doGetAjaxRequestHandler(context + "/getSchemeById?schemeId=" + schemeId,
|
|
|
220 |
function(response) {
|
|
|
221 |
$('#' + domId).html(response);
|
|
|
222 |
window.dispatchEvent(new Event('resize'));
|
|
|
223 |
});
|
| 23343 |
ashik.ali |
224 |
}
|
|
|
225 |
|
| 23752 |
govind |
226 |
function activeScheme(schemeId, offset, domId) {
|
|
|
227 |
doPutAjaxRequestHandler(context + "/activeSchemeById?schemeId=" + schemeId
|
|
|
228 |
+ "&offset=" + offset, function(response) {
|
| 23343 |
ashik.ali |
229 |
$('#' + domId).html(response);
|
|
|
230 |
$('#scheme-details-container').html('');
|
|
|
231 |
});
|
| 23752 |
govind |
232 |
|
| 23343 |
ashik.ali |
233 |
}
|
|
|
234 |
|
| 23752 |
govind |
235 |
function expireScheme(schemeId, offset, domId) {
|
|
|
236 |
doPutAjaxRequestHandler(context + "/expireSchemeById?schemeId=" + schemeId
|
|
|
237 |
+ "&offset=" + offset, function(response) {
|
| 23343 |
ashik.ali |
238 |
$('#' + domId).html(response);
|
|
|
239 |
$('#scheme-details-container').html('');
|
|
|
240 |
});
|
|
|
241 |
}
|
| 23914 |
govind |
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 |
});
|
| 23343 |
ashik.ali |
253 |
|
| 23914 |
govind |
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 |
}
|
|
|
267 |
|
| 23752 |
govind |
268 |
function loadScheme(domId) {
|
|
|
269 |
doGetAjaxRequestHandler(context + "/createScheme", function(response) {
|
| 23343 |
ashik.ali |
270 |
$('#' + domId).html(response);
|
|
|
271 |
});
|
| 23752 |
govind |
272 |
|
| 23343 |
ashik.ali |
273 |
}
|
|
|
274 |
|
| 23914 |
govind |
275 |
// function loadTagListingItemsDescriptionByBrand(domId, brand) {
|
|
|
276 |
// doGetAjaxRequestHandler(context + "/getTagListingItemsByBrand?brand="
|
|
|
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) {
|
|
|
286 |
$('#' + domId).html(response);
|
|
|
287 |
configureTagListingItemsDescriptionDropDown();
|
|
|
288 |
});
|
| 23752 |
govind |
289 |
|
| 23343 |
ashik.ali |
290 |
}
|
|
|
291 |
|
| 23752 |
govind |
292 |
function schemes(domId) {
|
|
|
293 |
doGetAjaxRequestHandler(context + "/getSchemes", function(response) {
|
| 23343 |
ashik.ali |
294 |
$('#' + domId).html(response);
|
|
|
295 |
});
|
|
|
296 |
}
|
|
|
297 |
|
| 23752 |
govind |
298 |
function loadSchemesDownloadPage(domId) {
|
|
|
299 |
doGetAjaxRequestHandler(context + "/schemes/downloadPage", function(
|
|
|
300 |
response) {
|
| 23343 |
ashik.ali |
301 |
$('#' + domId).html(response);
|
|
|
302 |
});
|
| 23556 |
amit.gupta |
303 |
}
|
|
|
304 |
|
| 23752 |
govind |
305 |
function loadSchemeUpdatePage(domId) {
|
|
|
306 |
doGetAjaxRequestHandler(context + "/schemes/update-schemes-page", function(
|
|
|
307 |
response) {
|
| 23556 |
amit.gupta |
308 |
$('#' + domId).html(response);
|
|
|
309 |
});
|
| 23557 |
amit.gupta |
310 |
}
|
|
|
311 |
|
| 23752 |
govind |
312 |
function updateSchemes(shcemeIds, itemIds) {
|
|
|
313 |
doPostAjaxRequestWithJsonHandler(context + '/schemes/update', JSON
|
|
|
314 |
.stringify({
|
|
|
315 |
"itemIds" : itemIds.split(",").map(Number),
|
|
|
316 |
"schemeIds" : schemeIds.split(",").map(Number)
|
|
|
317 |
}), function(response) {
|
|
|
318 |
if (response == 'true') {
|
| 23914 |
govind |
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");
|
| 23557 |
amit.gupta |
325 |
}
|
|
|
326 |
});
|
| 23715 |
govind |
327 |
}
|
| 23914 |
govind |
328 |
function deleteScheme(shcemeId, itemId) {
|
|
|
329 |
doDeleteAjaxRequestHandler(context + "/schemes/delete?schemeId=" + shcemeId
|
|
|
330 |
+ "&itemId=" + itemId, function(response) {
|
| 23752 |
govind |
331 |
if (response == 'true') {
|
| 23914 |
govind |
332 |
alert("ItemId Deleted successfully from Scheme");
|
|
|
333 |
loadSchemeDetails(shcemeId, "scheme-details-container");
|
| 23715 |
govind |
334 |
}
|
|
|
335 |
});
|
| 23752 |
govind |
336 |
}
|
|
|
337 |
function loadSearchScheme(domId, search_text) {
|
|
|
338 |
doGetAjaxRequestHandler(context + "/searchScheme/?searchTerm="
|
|
|
339 |
+ search_text, function(response) {
|
|
|
340 |
$('#' + domId).html(response);
|
|
|
341 |
});
|
|
|
342 |
}
|
|
|
343 |
function loadSearchItemScheme(domId, search_text) {
|
|
|
344 |
doGetAjaxRequestHandler(context + "/searchScheme/?searchItem="
|
|
|
345 |
+ search_text, function(response) {
|
|
|
346 |
$('#' + domId).html(response);
|
|
|
347 |
});
|
|
|
348 |
}
|
|
|
349 |
function loadSchemeSearchInfo(search_text) {
|
|
|
350 |
loadSearchScheme("main-content", search_text);
|
|
|
351 |
}
|
|
|
352 |
function loadSchemeItemSearchInfo(search_text) {
|
|
|
353 |
loadSearchItemScheme("main-content", search_text);
|
| 23914 |
govind |
354 |
}
|