Subversion Repositories SmartDukaan

Rev

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