Subversion Repositories SmartDukaan

Rev

Rev 23343 | Rev 23500 | Go to most recent revision | Details | Compare with Previous | 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
		}
23419 ashik.ali 80
		var size = $("#good-inventory-paginated .size").text();
81
		if(parseInt(end) == parseInt(size)){
82
			var mod = parseInt(end) % 10;
83
			end = parseInt(end) + (10 - mod); 
84
		}
23343 ashik.ali 85
		var pre = end - 20;
86
		getPreviousItems(start, end, pre, searchText);
87
		$("#good-inventory-paginated .previous").blur();
88
    });
89
 
90
	$("#good-inventory-search-button").live('click', function() {
91
		var searchText = $("#good-inventory-search-text").val();
92
		if (typeof (searchText) == "undefined" || !searchText){
93
			searchText = "";
94
		}
95
		loadGoodInventorySearchInfo(searchText);
96
    });
97
 
98
	$("#good-inventory-search-text").live("keyup", function(e) {
99
		var keyCode = e.keyCode || e.which;
100
    	if(keyCode == 13){
101
        	$("#good-inventory-search-button").click();
102
    	}
103
	});
104
 
105
 
106
	$("#catalog-paginated .next").live('click', function() {
107
		var start = $( "#catalog-paginated .start" ).text();
108
		var end = $( "#catalog-paginated .end" ).text();
109
		var searchText = $("#catalog-search-text").val();
110
		if (typeof (searchText) == "undefined" || !searchText){
111
			searchText = "";
112
		}
113
		getNextCatalogItems(start,end,searchText);
114
		$("#catalog-paginated .next").blur();
115
    });
116
 
117
	$("#catalog-paginated .previous").live('click', function() {
118
		var start = $( "#catalog-paginated .start" ).text();
119
		var end =  $( "#catalog-paginated .end" ).text();
120
		var searchText = $("#catalog-search-text").val();
121
		if (typeof (searchText) == "undefined" || !searchText){
122
			searchText = "";
123
		}
23419 ashik.ali 124
		var size = $("#catalog-paginated .size").text();
125
		if(parseInt(end) == parseInt(size)){
126
			var mod = parseInt(end) % 10;
127
			end = parseInt(end) + (10 - mod); 
128
		}
23343 ashik.ali 129
		var pre = end - 20;
130
		getPreviousCatalogItems(start,end,pre,searchText);
131
		$("#catalog-paginated .previous").blur();
132
    });
133
 
134
	$("#catalog-search-button").live('click', function() {
135
		var searchText = $("#catalog-search-text").val();
136
		if (typeof (searchText) == "undefined" || !searchText){
137
			searchText = "";
138
		}
139
		loadCatalogSearchInfo(searchText);
140
    });
141
 
142
	$("#catalog-search-text").live("keyup", function(e) {
143
		var keyCode = e.keyCode || e.which;
144
    	if(keyCode == 13){
145
        	$("#catalog-search-button").click();
146
    	}
147
	});
148
 
149
});
150
 
151
 
152
function loadGoodInventory(domId, search_text){
153
	doAjaxRequestHandler(context+"/getCurrentInventorySnapshot/?searchTerm="+search_text, "GET", function(response){
154
		$('#' + domId).html(response);
155
	});
156
}
157
 
158
function loadCatalog(domId, search_text){
159
	doAjaxRequestHandler(context+"/getCatalog/?searchTerm="+search_text, "GET", function(response){
160
		$('#' + domId).html(response);
161
	});
162
}
163
 
164
function getInventoryItemAgingByInterval(domId, searchContent){
165
	doAjaxRequestWithJsonHandler(context+"/getInventoryItemAgingByInterval?searchContent="+searchContent, "POST", JSON.stringify([5,15,30,45]), function(response){
166
		$('#' + domId).html(response);
167
	});
168
}
169
 
170
 
171
function downloadAgingReport(){
172
	data = JSON.stringify([5,15,30,45]),
173
	doAjaxPostDownload(context+"/downloadInventoryItemAgingByInterval",
174
			data, "InventoryItemAging.xlsx");
175
 
176
}
177
 
178
function downloadItemLedgerReport(){
179
	console.log("downloadItemLedgerReport Button clicked")
180
	var startDateTime = $('input[name="startDateTime"]').val();
181
	console.log("startDateTime : "+startDateTime);
182
	var endDateTime = $('input[name="endDateTime"]').val();
183
	console.log("endDateTime : "+endDateTime);
184
	//data = JSON.stringify([5,10,15,20,25,30,35,40]),
185
	doAjaxGetDownload(context+"/itemLedger/complete/download?startDateTime="+startDateTime+"&endDateTime="+endDateTime,
186
			"ItemCompleteLedegerReport.xlsx");
187
}
188
 
189
 
190
function getItemAgingNextPreviousItems(offset, searchContent){
191
	console.log("getItemAgingNextPreviousItems() called");
192
	doAjaxRequestWithJsonHandler(context+"/getInventoryItemAgingByInterval?offset="+offset+"&searchContent="+searchContent, "POST", JSON.stringify([5,15,30,45]), function(response){
193
		$('#main-content').html(response);
194
	});
195
 
196
}
197
 
198
 
199
function loadBadInventory(domId, search_text){
200
	doAjaxRequestHandler(context+"/getBadInventorySnapshot/?searchTerm="+search_text, "GET", function(response){
201
		$('#' + domId).html(response);
202
	});
203
}
204
 
205
 
206
function getNextItems(start, end, searchText){
207
	console.log(start);
208
	console.log(end);
209
	console.log(+end + +10);
210
	console.log(+start + +10);
211
	doAjaxRequestHandler(context+"/getPaginatedCurrentInventorySnapshot/?offset="+end+"&searchTerm="+searchText, "GET", function(response){
23419 ashik.ali 212
		var size = $("#good-inventory-paginated .size").text();
213
		if((parseInt(end) + 10) > parseInt(size)){
214
			console.log("(end + 10) > size == true");
215
			$( "#good-inventory-paginated .end" ).text(size);
216
		}else{
217
			console.log("(end + 10) > size == false");
218
			$( "#good-inventory-paginated .end" ).text(+end + +10);
219
		}
23343 ashik.ali 220
		$( "#good-inventory-paginated .start" ).text(+start + +10);
221
		var last = $( "#good-inventory-paginated .end" ).text();
222
		var temp = $( "#good-inventory-paginated .size" ).text();
223
		if (parseInt(last) >= parseInt(temp)){
224
			$("#good-inventory-paginated .next").prop('disabled', true);
225
			//$( "#good-inventory-paginated .end" ).text(temp);
226
		}
227
	    $('#good-inventory-table').html(response);
228
	    $("#good-inventory-paginated .previous").prop('disabled', false);
229
	});
230
 
231
 
232
}
233
 
234
function getPreviousItems(start,end,pre,searchText){
235
	doAjaxRequestHandler(context+"/getPaginatedCurrentInventorySnapshot/?offset="+pre+"&searchTerm="+searchText, "GET", function(response){
236
		$( "#good-inventory-paginated .end" ).text(+end - +10);
237
		$( "#good-inventory-paginated .start" ).text(+start - +10);
238
		$('#good-inventory-table').html(response);
239
		$("#good-inventory-paginated .next").prop('disabled', false);
240
		if (parseInt(pre)==0)
241
		{
242
			$("#good-inventory-paginated .previous").prop('disabled', true);
243
		}
244
	});
245
 
246
}
247
 
248
function loadGoodInventorySearchInfo(search_text){
249
	loadGoodInventory("main-content",search_text);
250
}
251
 
252
 
253
function getNextCatalogItems(start, end, searchText){
254
	console.log(start);
255
	console.log(end);
256
	console.log(+end + +10);
257
	console.log(+start + +10);
258
	doAjaxRequestHandler(context+"/getPaginatedCatalog/?offset="+end+"&searchTerm="+searchText, "GET", function(response){
23419 ashik.ali 259
		var size = $("#catalog-paginated .size").text();
260
		if((parseInt(end) + 10) > parseInt(size)){
261
			console.log("(end + 10) > size == true");
262
			$( "#catalog-paginated .end" ).text(size);
263
		}else{
264
			console.log("(end + 10) > size == false");
265
			$( "#catalog-paginated .end" ).text(+end + +10);
266
		}
23343 ashik.ali 267
		$( "#catalog-paginated .start" ).text(+start + +10);
268
		var last = $( "#catalog-paginated .end" ).text();
269
		var temp = $( "#catalog-paginated .size" ).text();
270
		if (parseInt(last) >= parseInt(temp)){
271
			$("#catalog-paginated .next").prop('disabled', true);
272
		}
273
	    $('#catalog-table').html(response);
274
	    $("#catalog-paginated .previous").prop('disabled', false);
275
	});
276
}
277
 
278
function getPreviousCatalogItems(start,end,pre,searchText){
279
	doAjaxRequestHandler(context+"/getPaginatedCatalog/?offset="+pre+"&searchTerm="+searchText, "GET", function(response){
280
		$( "#catalog-paginated .end" ).text(+end - +10);
281
		$( "#catalog-paginated .start" ).text(+start - +10);
282
		$('#catalog-table').html(response);
283
		$("#catalog-paginated .next").prop('disabled', false);
284
		if (parseInt(pre)==0)
285
		{
286
			$("#catalog-paginated .previous").prop('disabled', true);
287
		}
288
	});
289
 
290
}
291
 
292
function loadCatalogSearchInfo(search_text){
293
	loadCatalog("main-content",search_text);
294
}
295
 
296
function loadItemLedgerReportDownloadPage(domId){
297
	doAjaxRequestHandler(context+"/itemLedger/downloadPage", "GET", function(response){
298
		$('#' + domId).html(response);
299
	});
300
}