| 23343 |
ashik.ali |
1 |
$(function() {
|
|
|
2 |
$(".create-scheme").live('click', function() {
|
|
|
3 |
loadScheme("main-content");
|
|
|
4 |
});
|
|
|
5 |
|
| 23419 |
ashik.ali |
6 |
$('#tag-listing-brands li a').live('click', function(){
|
|
|
7 |
$('#tag-listing-brand-value').text($(this).text());
|
|
|
8 |
loadTagListingItemsDescriptionByBrand("tag-listing-items-description-container", $(this).text());
|
|
|
9 |
console.log($(this).text());
|
|
|
10 |
});
|
|
|
11 |
|
| 23343 |
ashik.ali |
12 |
$("#schemes-paginated .next").live('click', function() {
|
|
|
13 |
var start = $( "#schemes-paginated .start" ).text();
|
|
|
14 |
var end = $( "#schemes-paginated .end" ).text();
|
|
|
15 |
getSchemesNextItems(start, end);
|
|
|
16 |
$("#schemes-paginated .next").blur();
|
|
|
17 |
});
|
|
|
18 |
|
|
|
19 |
$("#schemes-paginated .previous").live('click', function() {
|
|
|
20 |
var start = $( "#schemes-paginated .start" ).text();
|
|
|
21 |
var end = $( "#schemes-paginated .end" ).text();
|
| 23419 |
ashik.ali |
22 |
var size = $("#schemes-paginated .size").text();
|
|
|
23 |
if(parseInt(end) == parseInt(size)){
|
|
|
24 |
var mod = parseInt(end) % 10;
|
|
|
25 |
end = parseInt(end) + (10 - mod);
|
|
|
26 |
}
|
| 23343 |
ashik.ali |
27 |
var pre = end - 20;
|
|
|
28 |
getSchemesPreviousItems(start, end, pre);
|
|
|
29 |
$("#schemes-paginated .previous").blur();
|
|
|
30 |
});
|
|
|
31 |
|
|
|
32 |
$(".scheme-details").live('click',function(){
|
|
|
33 |
var schemeId = $(this).attr('data');
|
|
|
34 |
console.log("schemeId = "+schemeId);
|
|
|
35 |
loadSchemeDetails(schemeId, "scheme-details-container");
|
|
|
36 |
});
|
|
|
37 |
|
|
|
38 |
$(".active-scheme").live('click',function(){
|
|
|
39 |
var schemeId = $(this).attr('data');
|
|
|
40 |
console.log("active-scheme id : "+schemeId);
|
|
|
41 |
var start = $( "#schemes-paginated .start" ).text();
|
|
|
42 |
//var end = $( "#schemes-paginated .end" ).text();
|
|
|
43 |
var offset = start - 1;
|
|
|
44 |
if(confirm("Are you sure you want to Active Scheme!") == true){
|
|
|
45 |
activeScheme(schemeId, offset, "schemes-table");
|
|
|
46 |
}
|
|
|
47 |
});
|
|
|
48 |
|
|
|
49 |
$(".expire-scheme").live('click',function(){
|
|
|
50 |
var schemeId = $(this).attr('data');
|
|
|
51 |
console.log("expire-scheme id : "+schemeId);
|
|
|
52 |
var start = $( "#schemes-paginated .start" ).text();
|
|
|
53 |
//var end = $( "#schemes-paginated .end" ).text();
|
|
|
54 |
var offset = start - 1;
|
|
|
55 |
if(confirm("Are you sure you want to Expire Scheme!") == true){
|
|
|
56 |
expireScheme(schemeId, offset, "schemes-table");
|
|
|
57 |
}
|
|
|
58 |
});
|
|
|
59 |
|
| 23347 |
ashik.ali |
60 |
$(".schemes").live('click', function() {
|
|
|
61 |
console.log("Active Schemes Button Clicked...")
|
|
|
62 |
schemes("main-content");
|
|
|
63 |
});
|
| 23343 |
ashik.ali |
64 |
|
| 23347 |
ashik.ali |
65 |
$(".schemes-download-page").live('click', function() {
|
|
|
66 |
console.log("Schemes Download Clicked...")
|
|
|
67 |
loadSchemesDownloadPage("main-content");
|
| 22860 |
ashik.ali |
68 |
});
|
| 23556 |
amit.gupta |
69 |
|
|
|
70 |
$(".schemes-update").live('click', function() {
|
|
|
71 |
loadSchemeUpdatePage("main-content");
|
|
|
72 |
});
|
| 23557 |
amit.gupta |
73 |
|
|
|
74 |
$(".add-schemes").live('click', function() {
|
|
|
75 |
schemeIds = $("#schemeids").val();
|
|
|
76 |
itemIds = $("#itemids").val();
|
|
|
77 |
if(itemIds.trim().length === 0 || schemeIds.trim().length === 0) {
|
|
|
78 |
alert("fields shouldn't be blank");
|
|
|
79 |
}
|
|
|
80 |
updateSchemes(schemeIds, itemIds);
|
|
|
81 |
});
|
| 22860 |
ashik.ali |
82 |
});
|
|
|
83 |
|
| 23419 |
ashik.ali |
84 |
function configureTagListingItemsDescriptionDropDown(){
|
| 23347 |
ashik.ali |
85 |
$(document).ready(function() {
|
| 23419 |
ashik.ali |
86 |
$('#tagListingItemsDescription').multiselect({
|
|
|
87 |
includeSelectAllOption: true,
|
|
|
88 |
maxHeight: 200,
|
|
|
89 |
buttonWidth: '180px',
|
|
|
90 |
numberDisplayed: 1,
|
|
|
91 |
nonSelectedText: 'Items',
|
|
|
92 |
nSelectedText: ' - Items Selected',
|
|
|
93 |
allSelectedText: 'All Items Selected',
|
|
|
94 |
enableFiltering: true
|
| 23347 |
ashik.ali |
95 |
});
|
|
|
96 |
});
|
| 23343 |
ashik.ali |
97 |
}
|
|
|
98 |
|
|
|
99 |
function schemesDownload(){
|
|
|
100 |
console.log("downloadItemLedgerReport Button clicked")
|
| 23347 |
ashik.ali |
101 |
var startDateTime = $('input[name="startDateTime"]').val();
|
| 23343 |
ashik.ali |
102 |
console.log("startDateTime : "+startDateTime);
|
| 23347 |
ashik.ali |
103 |
var endDateTime = $('input[name="endDateTime"]').val();
|
| 23343 |
ashik.ali |
104 |
console.log("endDateTime : "+endDateTime);
|
|
|
105 |
doAjaxGetDownload(context+"/schemes/download?startDateTime="+startDateTime+"&endDateTime="+endDateTime,
|
| 23347 |
ashik.ali |
106 |
"SchemesReport.xlsx");
|
| 23343 |
ashik.ali |
107 |
}
|
|
|
108 |
|
|
|
109 |
function getSchemesNextItems(start, end){
|
|
|
110 |
console.log(start);
|
|
|
111 |
console.log(end);
|
|
|
112 |
console.log(+end + +10);
|
|
|
113 |
console.log(+start + +10);
|
| 23500 |
ashik.ali |
114 |
doGetAjaxRequestHandler(context+"/getPaginatedSchemes?offset="+end, function(response){
|
| 23419 |
ashik.ali |
115 |
var size = $("#schemes-paginated .size").text();
|
|
|
116 |
if((parseInt(end) + 10) > parseInt(size)){
|
|
|
117 |
console.log("(end + 10) > size == true");
|
|
|
118 |
$( "#schemes-paginated .end" ).text(size);
|
|
|
119 |
}else{
|
|
|
120 |
console.log("(end + 10) > size == false");
|
|
|
121 |
$( "#schemes-paginated .end" ).text(+end + +10);
|
|
|
122 |
}
|
| 23343 |
ashik.ali |
123 |
$( "#schemes-paginated .start" ).text(+start + +10);
|
|
|
124 |
var last = $( "#schemes-paginated .end" ).text();
|
|
|
125 |
var temp = $( "#schemes-paginated .size" ).text();
|
|
|
126 |
if (parseInt(last) >= parseInt(temp)){
|
|
|
127 |
$("#schemes-paginated .next").prop('disabled', true);
|
|
|
128 |
//$( "#good-inventory-paginated .end" ).text(temp);
|
|
|
129 |
}
|
|
|
130 |
$('#schemes-table').html(response);
|
|
|
131 |
$('#scheme-details-container').html('');
|
|
|
132 |
$("#schemes-paginated .previous").prop('disabled', false);
|
|
|
133 |
});
|
|
|
134 |
|
|
|
135 |
}
|
|
|
136 |
|
|
|
137 |
|
|
|
138 |
function getSchemesPreviousItems(start, end, pre){
|
|
|
139 |
|
| 23500 |
ashik.ali |
140 |
doGetAjaxRequestHandler(context+"/getPaginatedSchemes/?offset="+pre, function(response){
|
| 23343 |
ashik.ali |
141 |
$( "#schemes-paginated .end" ).text(+end - +10);
|
|
|
142 |
$( "#schemes-paginated .start" ).text(+start - +10);
|
|
|
143 |
$('#schemes-table').html(response);
|
|
|
144 |
$('#scheme-details-container').html('');
|
|
|
145 |
$("#schemes-paginated .next").prop('disabled', false);
|
|
|
146 |
if (parseInt(pre)==0)
|
|
|
147 |
{
|
|
|
148 |
$("#schemes-paginated .previous").prop('disabled', true);
|
|
|
149 |
}
|
|
|
150 |
});
|
|
|
151 |
|
| 23347 |
ashik.ali |
152 |
|
| 23343 |
ashik.ali |
153 |
}
|
|
|
154 |
|
|
|
155 |
function loadSchemeDetails(schemeId, domId){
|
| 23500 |
ashik.ali |
156 |
doGetAjaxRequestHandler(context+"/getSchemeById?schemeId="+schemeId, function(response){
|
| 23343 |
ashik.ali |
157 |
$('#' + domId).html(response);
|
|
|
158 |
window.dispatchEvent(new Event('resize'));
|
|
|
159 |
});
|
|
|
160 |
}
|
|
|
161 |
|
|
|
162 |
function activeScheme(schemeId, offset, domId){
|
| 23500 |
ashik.ali |
163 |
doPutAjaxRequestHandler(context+"/activeSchemeById?schemeId="+schemeId
|
|
|
164 |
+"&offset="+offset, function(response){
|
| 23343 |
ashik.ali |
165 |
$('#' + domId).html(response);
|
|
|
166 |
$('#scheme-details-container').html('');
|
|
|
167 |
});
|
| 23347 |
ashik.ali |
168 |
|
| 23343 |
ashik.ali |
169 |
}
|
|
|
170 |
|
|
|
171 |
function expireScheme(schemeId, offset, domId){
|
| 23500 |
ashik.ali |
172 |
doPutAjaxRequestHandler(context+"/expireSchemeById?schemeId="+schemeId
|
|
|
173 |
+"&offset="+offset, function(response){
|
| 23343 |
ashik.ali |
174 |
$('#' + domId).html(response);
|
|
|
175 |
$('#scheme-details-container').html('');
|
|
|
176 |
});
|
|
|
177 |
}
|
|
|
178 |
|
|
|
179 |
function loadScheme(domId){
|
| 23500 |
ashik.ali |
180 |
doGetAjaxRequestHandler(context+"/createScheme", function(response){
|
| 23343 |
ashik.ali |
181 |
$('#' + domId).html(response);
|
|
|
182 |
});
|
| 23347 |
ashik.ali |
183 |
|
| 23343 |
ashik.ali |
184 |
}
|
|
|
185 |
|
| 23419 |
ashik.ali |
186 |
function loadTagListingItemsDescriptionByBrand(domId, brand){
|
| 23500 |
ashik.ali |
187 |
doGetAjaxRequestHandler(context+"/getTagListingItemsByBrand?brand="+brand, function(response){
|
| 23343 |
ashik.ali |
188 |
$('#' + domId).html(response);
|
| 23419 |
ashik.ali |
189 |
configureTagListingItemsDescriptionDropDown();
|
| 23343 |
ashik.ali |
190 |
});
|
|
|
191 |
|
|
|
192 |
}
|
|
|
193 |
|
|
|
194 |
function schemes(domId){
|
| 23500 |
ashik.ali |
195 |
doGetAjaxRequestHandler(context+"/getSchemes", function(response){
|
| 23343 |
ashik.ali |
196 |
$('#' + domId).html(response);
|
|
|
197 |
});
|
|
|
198 |
}
|
|
|
199 |
|
|
|
200 |
function loadSchemesDownloadPage(domId){
|
| 23500 |
ashik.ali |
201 |
doGetAjaxRequestHandler(context+"/schemes/downloadPage", function(response){
|
| 23343 |
ashik.ali |
202 |
$('#' + domId).html(response);
|
|
|
203 |
});
|
| 23556 |
amit.gupta |
204 |
}
|
|
|
205 |
|
|
|
206 |
function loadSchemeUpdatePage(domId){
|
|
|
207 |
doGetAjaxRequestHandler(context+"/schemes/update-schemes-page", function(response){
|
|
|
208 |
$('#' + domId).html(response);
|
|
|
209 |
});
|
| 23557 |
amit.gupta |
210 |
}
|
|
|
211 |
|
|
|
212 |
function updateSchemes(shcemeIds, itemIds){
|
|
|
213 |
doPostAjaxRequestWithJsonHandler(context + '/schemes/update', JSON.stringify({"itemIds":itemIds.split(",").map(Number), "schemeIds":schemeIds.split(",").map(Number)}), function(response){
|
|
|
214 |
if(response=='true') {
|
|
|
215 |
alert("Schemes Added successfully");
|
|
|
216 |
}
|
|
|
217 |
});
|
| 23343 |
ashik.ali |
218 |
}
|