Subversion Repositories SmartDukaan

Rev

Rev 23419 | Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
23343 ashik.ali 1
$(function() {
2
	$(".good_inventory").live('click', function() {
3
		loadGoodInventory("main-content","");
4
	});
5
 
6
	$(".catalog").live('click', function() {
7
		loadCatalog("main-content","");
8
	});
9
 
10
	$(".item_aging").live('click', function() {
11
		getInventoryItemAgingByInterval("main-content", "");
12
	});
13
 
14
	$("#item-aging-paginated .next").live('click', function() {
15
		var end = $( "#item-aging-paginated .end" ).text();
16
		getItemAgingNextPreviousItems(end, "");
17
		$("#item-aging-paginated .next").blur();
18
    });
19
 
20
	$("#item-aging-search-button").live('click', function() {
21
		searchContent = $("#item-aging-search-text").val();
22
		if (typeof (searchContent) == "undefined" || !searchContent){
23
			searchContent = "";
24
		}
25
		getInventoryItemAgingByInterval("main-content", searchContent);
26
    });
27
 
28
 
29
	$("#item-aging-search-text").live("keyup", function(e) {
30
		var keyCode = e.keyCode || e.which;
31
    	if(keyCode == 13){
32
        	$("#item-aging-search-button").click();
33
    	}
34
	});
35
 
36
	$("#item-aging-paginated .previous").live('click', function() {
37
		var start = $( "#item-aging-paginated .start" ).text();
38
		getItemAgingNextPreviousItems(start - 11, "");
39
		$("#item-aging-paginated .previous").blur();
40
    });
41
 
42
	$(".download_aging_report").live('click', function() {
43
		downloadAgingReport();
44
	});
45
 
46
	$(".item-ledger-report-download-page").live('click', function() {
47
		loadItemLedgerReportDownloadPage("main-content");
48
	});
49
 
50
	/*$(".item-ledger-report-download").live('click', function() {
51
		var startEndDateTime = $('input[name="startEndDateTime"]').val().split("-");
52
		var startDateTime = $.trim(startEndDateTime[0]);
53
		var endDateTime = $.trim(startEndDateTime[1]);
54
		downloadItemLedgerReport(startDateTime, endDateTime);
55
	});*/
56
 
57
	$(".bad_inventory").live('click', function() {
58
		loadBadInventory("main-content","");
59
	});
60
 
61
	$("#good-inventory-paginated .next").live('click', function() {
62
		var start = $( "#good-inventory-paginated .start" ).text();
63
		var end = $( "#good-inventory-paginated .end" ).text();
64
		var searchText = $("#good-inventory-search-text").val();
65
		if (typeof (searchText) == "undefined" || !searchText){
66
			searchText = "";
67
		}
68
		getNextItems(start,end, searchText);
69
		$("#good-inventory-paginated .next").blur();
70
 
71
    });
72
 
73
	$("#good-inventory-paginated .previous").live('click', function() {
74
		var start = $( "#good-inventory-paginated .start" ).text();
75
		var end =  $( "#good-inventory-paginated .end" ).text();
76
		var searchText = $("#good-inventory-search-text").val();
77
		if (typeof (searchText) == "undefined" || !searchText){
78
			searchText = "";
79
		}
80
		var pre = end - 20;
81
		getPreviousItems(start, end, pre, searchText);
82
		$("#good-inventory-paginated .previous").blur();
83
    });
84
 
85
	$("#good-inventory-search-button").live('click', function() {
86
		var searchText = $("#good-inventory-search-text").val();
87
		if (typeof (searchText) == "undefined" || !searchText){
88
			searchText = "";
89
		}
90
		loadGoodInventorySearchInfo(searchText);
91
    });
92
 
93
	$("#good-inventory-search-text").live("keyup", function(e) {
94
		var keyCode = e.keyCode || e.which;
95
    	if(keyCode == 13){
96
        	$("#good-inventory-search-button").click();
97
    	}
98
	});
99
 
100
 
101
	$("#catalog-paginated .next").live('click', function() {
102
		var start = $( "#catalog-paginated .start" ).text();
103
		var end = $( "#catalog-paginated .end" ).text();
104
		var searchText = $("#catalog-search-text").val();
105
		if (typeof (searchText) == "undefined" || !searchText){
106
			searchText = "";
107
		}
108
		getNextCatalogItems(start,end,searchText);
109
		$("#catalog-paginated .next").blur();
110
    });
111
 
112
	$("#catalog-paginated .previous").live('click', function() {
113
		var start = $( "#catalog-paginated .start" ).text();
114
		var end =  $( "#catalog-paginated .end" ).text();
115
		var searchText = $("#catalog-search-text").val();
116
		if (typeof (searchText) == "undefined" || !searchText){
117
			searchText = "";
118
		}
119
		var pre = end - 20;
120
		getPreviousCatalogItems(start,end,pre,searchText);
121
		$("#catalog-paginated .previous").blur();
122
    });
123
 
124
	$("#catalog-search-button").live('click', function() {
125
		var searchText = $("#catalog-search-text").val();
126
		if (typeof (searchText) == "undefined" || !searchText){
127
			searchText = "";
128
		}
129
		loadCatalogSearchInfo(searchText);
130
    });
131
 
132
	$("#catalog-search-text").live("keyup", function(e) {
133
		var keyCode = e.keyCode || e.which;
134
    	if(keyCode == 13){
135
        	$("#catalog-search-button").click();
136
    	}
137
	});
138
 
139
});
140
 
141
 
142
function loadGoodInventory(domId, search_text){
143
	doAjaxRequestHandler(context+"/getCurrentInventorySnapshot/?searchTerm="+search_text, "GET", function(response){
144
		$('#' + domId).html(response);
145
	});
146
}
147
 
148
function loadCatalog(domId, search_text){
149
	doAjaxRequestHandler(context+"/getCatalog/?searchTerm="+search_text, "GET", function(response){
150
		$('#' + domId).html(response);
151
	});
152
}
153
 
154
function getInventoryItemAgingByInterval(domId, searchContent){
155
	doAjaxRequestWithJsonHandler(context+"/getInventoryItemAgingByInterval?searchContent="+searchContent, "POST", JSON.stringify([5,15,30,45]), function(response){
156
		$('#' + domId).html(response);
157
	});
158
}
159
 
160
 
161
function downloadAgingReport(){
162
	data = JSON.stringify([5,15,30,45]),
163
	doAjaxPostDownload(context+"/downloadInventoryItemAgingByInterval",
164
			data, "InventoryItemAging.xlsx");
165
 
166
}
167
 
168
function downloadItemLedgerReport(){
169
	console.log("downloadItemLedgerReport Button clicked")
170
	var startDateTime = $('input[name="startDateTime"]').val();
171
	console.log("startDateTime : "+startDateTime);
172
	var endDateTime = $('input[name="endDateTime"]').val();
173
	console.log("endDateTime : "+endDateTime);
174
	//data = JSON.stringify([5,10,15,20,25,30,35,40]),
175
	doAjaxGetDownload(context+"/itemLedger/complete/download?startDateTime="+startDateTime+"&endDateTime="+endDateTime,
176
			"ItemCompleteLedegerReport.xlsx");
177
}
178
 
179
 
180
function getItemAgingNextPreviousItems(offset, searchContent){
181
	console.log("getItemAgingNextPreviousItems() called");
182
	doAjaxRequestWithJsonHandler(context+"/getInventoryItemAgingByInterval?offset="+offset+"&searchContent="+searchContent, "POST", JSON.stringify([5,15,30,45]), function(response){
183
		$('#main-content').html(response);
184
	});
185
 
186
}
187
 
188
 
189
function loadBadInventory(domId, search_text){
190
	doAjaxRequestHandler(context+"/getBadInventorySnapshot/?searchTerm="+search_text, "GET", function(response){
191
		$('#' + domId).html(response);
192
	});
193
}
194
 
195
 
196
function getNextItems(start, end, searchText){
197
	console.log(start);
198
	console.log(end);
199
	console.log(+end + +10);
200
	console.log(+start + +10);
201
	doAjaxRequestHandler(context+"/getPaginatedCurrentInventorySnapshot/?offset="+end+"&searchTerm="+searchText, "GET", function(response){
202
		$( "#good-inventory-paginated .end" ).text(+end + +10);
203
		$( "#good-inventory-paginated .start" ).text(+start + +10);
204
		var last = $( "#good-inventory-paginated .end" ).text();
205
		var temp = $( "#good-inventory-paginated .size" ).text();
206
		if (parseInt(last) >= parseInt(temp)){
207
			$("#good-inventory-paginated .next").prop('disabled', true);
208
			//$( "#good-inventory-paginated .end" ).text(temp);
209
		}
210
	    $('#good-inventory-table').html(response);
211
	    $("#good-inventory-paginated .previous").prop('disabled', false);
212
	});
213
 
214
 
215
}
216
 
217
function getPreviousItems(start,end,pre,searchText){
218
	doAjaxRequestHandler(context+"/getPaginatedCurrentInventorySnapshot/?offset="+pre+"&searchTerm="+searchText, "GET", function(response){
219
		$( "#good-inventory-paginated .end" ).text(+end - +10);
220
		$( "#good-inventory-paginated .start" ).text(+start - +10);
221
		$('#good-inventory-table').html(response);
222
		$("#good-inventory-paginated .next").prop('disabled', false);
223
		if (parseInt(pre)==0)
224
		{
225
			$("#good-inventory-paginated .previous").prop('disabled', true);
226
		}
227
	});
228
 
229
}
230
 
231
function loadGoodInventorySearchInfo(search_text){
232
	loadGoodInventory("main-content",search_text);
233
}
234
 
235
 
236
function getNextCatalogItems(start, end, searchText){
237
	console.log(start);
238
	console.log(end);
239
	console.log(+end + +10);
240
	console.log(+start + +10);
241
	doAjaxRequestHandler(context+"/getPaginatedCatalog/?offset="+end+"&searchTerm="+searchText, "GET", function(response){
242
		$( "#catalog-paginated .end" ).text(+end + +10);
243
		$( "#catalog-paginated .start" ).text(+start + +10);
244
		var last = $( "#catalog-paginated .end" ).text();
245
		var temp = $( "#catalog-paginated .size" ).text();
246
		if (parseInt(last) >= parseInt(temp)){
247
			$("#catalog-paginated .next").prop('disabled', true);
248
		}
249
	    $('#catalog-table').html(response);
250
	    $("#catalog-paginated .previous").prop('disabled', false);
251
	});
252
}
253
 
254
function getPreviousCatalogItems(start,end,pre,searchText){
255
	doAjaxRequestHandler(context+"/getPaginatedCatalog/?offset="+pre+"&searchTerm="+searchText, "GET", function(response){
256
		$( "#catalog-paginated .end" ).text(+end - +10);
257
		$( "#catalog-paginated .start" ).text(+start - +10);
258
		$('#catalog-table').html(response);
259
		$("#catalog-paginated .next").prop('disabled', false);
260
		if (parseInt(pre)==0)
261
		{
262
			$("#catalog-paginated .previous").prop('disabled', true);
263
		}
264
	});
265
 
266
}
267
 
268
function loadCatalogSearchInfo(search_text){
269
	loadCatalog("main-content",search_text);
270
}
271
 
272
function loadItemLedgerReportDownloadPage(domId){
273
	doAjaxRequestHandler(context+"/itemLedger/downloadPage", "GET", function(response){
274
		$('#' + domId).html(response);
275
	});
276
}