| 23343 |
ashik.ali |
1 |
$(function() {
|
|
|
2 |
$(".create-scheme").live('click', function() {
|
|
|
3 |
loadScheme("main-content");
|
|
|
4 |
});
|
|
|
5 |
|
|
|
6 |
$("#schemes-paginated .next").live('click', function() {
|
|
|
7 |
var start = $( "#schemes-paginated .start" ).text();
|
|
|
8 |
var end = $( "#schemes-paginated .end" ).text();
|
|
|
9 |
getSchemesNextItems(start, end);
|
|
|
10 |
$("#schemes-paginated .next").blur();
|
|
|
11 |
});
|
|
|
12 |
|
|
|
13 |
$("#schemes-paginated .previous").live('click', function() {
|
|
|
14 |
var start = $( "#schemes-paginated .start" ).text();
|
|
|
15 |
var end = $( "#schemes-paginated .end" ).text();
|
|
|
16 |
var pre = end - 20;
|
|
|
17 |
getSchemesPreviousItems(start, end, pre);
|
|
|
18 |
$("#schemes-paginated .previous").blur();
|
|
|
19 |
});
|
|
|
20 |
|
|
|
21 |
$(".scheme-details").live('click',function(){
|
|
|
22 |
var schemeId = $(this).attr('data');
|
|
|
23 |
console.log("schemeId = "+schemeId);
|
|
|
24 |
loadSchemeDetails(schemeId, "scheme-details-container");
|
|
|
25 |
});
|
|
|
26 |
|
|
|
27 |
$(".active-scheme").live('click',function(){
|
|
|
28 |
var schemeId = $(this).attr('data');
|
|
|
29 |
console.log("active-scheme id : "+schemeId);
|
|
|
30 |
var start = $( "#schemes-paginated .start" ).text();
|
|
|
31 |
//var end = $( "#schemes-paginated .end" ).text();
|
|
|
32 |
var offset = start - 1;
|
|
|
33 |
if(confirm("Are you sure you want to Active Scheme!") == true){
|
|
|
34 |
activeScheme(schemeId, offset, "schemes-table");
|
|
|
35 |
}
|
|
|
36 |
});
|
|
|
37 |
|
|
|
38 |
$(".expire-scheme").live('click',function(){
|
|
|
39 |
var schemeId = $(this).attr('data');
|
|
|
40 |
console.log("expire-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 Expire Scheme!") == true){
|
|
|
45 |
expireScheme(schemeId, offset, "schemes-table");
|
|
|
46 |
}
|
|
|
47 |
});
|
|
|
48 |
|
| 23347 |
ashik.ali |
49 |
$(".schemes").live('click', function() {
|
|
|
50 |
console.log("Active Schemes Button Clicked...")
|
|
|
51 |
schemes("main-content");
|
|
|
52 |
});
|
| 23343 |
ashik.ali |
53 |
|
| 23347 |
ashik.ali |
54 |
$(".schemes-download-page").live('click', function() {
|
|
|
55 |
console.log("Schemes Download Clicked...")
|
|
|
56 |
loadSchemesDownloadPage("main-content");
|
| 22860 |
ashik.ali |
57 |
});
|
|
|
58 |
});
|
|
|
59 |
|
| 23347 |
ashik.ali |
60 |
function configureItemsDescriptionDropDown(){
|
|
|
61 |
$(document).ready(function() {
|
|
|
62 |
$('#itemsDescription').multiselect({
|
|
|
63 |
includeSelectAllOption: true,
|
|
|
64 |
maxHeight: 200,
|
|
|
65 |
buttonWidth: '180px',
|
|
|
66 |
numberDisplayed: 1,
|
|
|
67 |
nonSelectedText: 'Items',
|
|
|
68 |
nSelectedText: ' - Items Selected',
|
|
|
69 |
allSelectedText: 'All Items Selected',
|
|
|
70 |
enableFiltering: true
|
|
|
71 |
});
|
|
|
72 |
});
|
| 23343 |
ashik.ali |
73 |
}
|
|
|
74 |
|
|
|
75 |
function schemesDownload(){
|
|
|
76 |
console.log("downloadItemLedgerReport Button clicked")
|
| 23347 |
ashik.ali |
77 |
var startDateTime = $('input[name="startDateTime"]').val();
|
| 23343 |
ashik.ali |
78 |
console.log("startDateTime : "+startDateTime);
|
| 23347 |
ashik.ali |
79 |
var endDateTime = $('input[name="endDateTime"]').val();
|
| 23343 |
ashik.ali |
80 |
console.log("endDateTime : "+endDateTime);
|
|
|
81 |
doAjaxGetDownload(context+"/schemes/download?startDateTime="+startDateTime+"&endDateTime="+endDateTime,
|
| 23347 |
ashik.ali |
82 |
"SchemesReport.xlsx");
|
| 23343 |
ashik.ali |
83 |
}
|
|
|
84 |
|
|
|
85 |
function getSchemesNextItems(start, end){
|
|
|
86 |
console.log(start);
|
|
|
87 |
console.log(end);
|
|
|
88 |
console.log(+end + +10);
|
|
|
89 |
console.log(+start + +10);
|
|
|
90 |
doAjaxRequestHandler(context+"/getPaginatedSchemes?offset="+end, "GET", function(response){
|
|
|
91 |
$( "#schemes-paginated .end" ).text(+end + +10);
|
|
|
92 |
$( "#schemes-paginated .start" ).text(+start + +10);
|
|
|
93 |
var last = $( "#schemes-paginated .end" ).text();
|
|
|
94 |
var temp = $( "#schemes-paginated .size" ).text();
|
|
|
95 |
if (parseInt(last) >= parseInt(temp)){
|
|
|
96 |
$("#schemes-paginated .next").prop('disabled', true);
|
|
|
97 |
//$( "#good-inventory-paginated .end" ).text(temp);
|
|
|
98 |
}
|
|
|
99 |
$('#schemes-table').html(response);
|
|
|
100 |
$('#scheme-details-container').html('');
|
|
|
101 |
$("#schemes-paginated .previous").prop('disabled', false);
|
|
|
102 |
});
|
|
|
103 |
|
|
|
104 |
}
|
|
|
105 |
|
|
|
106 |
|
|
|
107 |
function getSchemesPreviousItems(start, end, pre){
|
|
|
108 |
|
|
|
109 |
doAjaxRequestHandler(context+"/getPaginatedSchemes/?offset="+pre, "GET", function(response){
|
|
|
110 |
$( "#schemes-paginated .end" ).text(+end - +10);
|
|
|
111 |
$( "#schemes-paginated .start" ).text(+start - +10);
|
|
|
112 |
$('#schemes-table').html(response);
|
|
|
113 |
$('#scheme-details-container').html('');
|
|
|
114 |
$("#schemes-paginated .next").prop('disabled', false);
|
|
|
115 |
if (parseInt(pre)==0)
|
|
|
116 |
{
|
|
|
117 |
$("#schemes-paginated .previous").prop('disabled', true);
|
|
|
118 |
}
|
|
|
119 |
});
|
|
|
120 |
|
| 23347 |
ashik.ali |
121 |
|
| 23343 |
ashik.ali |
122 |
}
|
|
|
123 |
|
|
|
124 |
function loadSchemeDetails(schemeId, domId){
|
|
|
125 |
doAjaxRequestHandler(context+"/getSchemeById?schemeId="+schemeId, "GET", function(response){
|
|
|
126 |
$('#' + domId).html(response);
|
|
|
127 |
window.dispatchEvent(new Event('resize'));
|
|
|
128 |
});
|
|
|
129 |
}
|
|
|
130 |
|
|
|
131 |
function activeScheme(schemeId, offset, domId){
|
|
|
132 |
doAjaxRequestHandler(context+"/activeSchemeById?schemeId="+schemeId
|
|
|
133 |
+"&offset="+offset, "PUT", function(response){
|
|
|
134 |
$('#' + domId).html(response);
|
|
|
135 |
$('#scheme-details-container').html('');
|
|
|
136 |
});
|
| 23347 |
ashik.ali |
137 |
|
| 23343 |
ashik.ali |
138 |
}
|
|
|
139 |
|
|
|
140 |
function expireScheme(schemeId, offset, domId){
|
|
|
141 |
doAjaxRequestHandler(context+"/expireSchemeById?schemeId="+schemeId
|
|
|
142 |
+"&offset="+offset, "PUT", function(response){
|
|
|
143 |
$('#' + domId).html(response);
|
|
|
144 |
$('#scheme-details-container').html('');
|
|
|
145 |
});
|
|
|
146 |
}
|
|
|
147 |
|
|
|
148 |
function loadScheme(domId){
|
|
|
149 |
doAjaxRequestHandler(context+"/createScheme", "GET", function(response){
|
|
|
150 |
$('#' + domId).html(response);
|
|
|
151 |
});
|
| 23347 |
ashik.ali |
152 |
|
| 23343 |
ashik.ali |
153 |
}
|
|
|
154 |
|
|
|
155 |
function loadItemsDescriptionByBrand(domId, brand){
|
|
|
156 |
doAjaxRequestHandler(context+"/getItemsByBrand?brand="+brand, "GET", function(response){
|
|
|
157 |
$('#' + domId).html(response);
|
|
|
158 |
configureItemsDescriptionDropDown();
|
|
|
159 |
});
|
|
|
160 |
|
|
|
161 |
}
|
|
|
162 |
|
|
|
163 |
function schemes(domId){
|
|
|
164 |
doAjaxRequestHandler(context+"/getSchemes", "GET", function(response){
|
|
|
165 |
$('#' + domId).html(response);
|
|
|
166 |
});
|
|
|
167 |
}
|
|
|
168 |
|
|
|
169 |
function loadSchemesDownloadPage(domId){
|
|
|
170 |
doAjaxRequestHandler(context+"/schemes/downloadPage", "GET", function(response){
|
|
|
171 |
$('#' + domId).html(response);
|
|
|
172 |
});
|
|
|
173 |
}
|