Subversion Repositories SmartDukaan

Rev

Rev 23500 | Rev 23637 | 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-search-button").live('click', function() {
15
		searchContent = $("#item-aging-search-text").val();
16
		if (typeof (searchContent) == "undefined" || !searchContent){
17
			searchContent = "";
18
		}
19
		getInventoryItemAgingByInterval("main-content", searchContent);
20
    });
21
 
22
 
23
	$("#item-aging-search-text").live("keyup", function(e) {
24
		var keyCode = e.keyCode || e.which;
25
    	if(keyCode == 13){
26
        	$("#item-aging-search-button").click();
27
    	}
28
	});
29
 
23629 ashik.ali 30
	$("#item-aging-paginated .next").live('click', function() {
31
		var end = $( "#item-aging-paginated .end" ).text();
32
		getItemAgingNextPreviousItems(end, "");
33
		$("#item-aging-paginated .next").blur();
34
    });
35
 
23343 ashik.ali 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 searchText = $("#good-inventory-search-text").val();
56
		if (typeof (searchText) == "undefined" || !searchText){
57
			searchText = "";
58
		}
23629 ashik.ali 59
		var params = {};
60
		params['searchTerm'] = searchText;
61
		loadPaginatedNextItems('/getPaginatedCurrentInventorySnapshot', params, 'good-inventory-paginated', 'good-inventory-table', null);
62
		$(this).blur();
23343 ashik.ali 63
    });
64
 
65
	$("#good-inventory-paginated .previous").live('click', function() {
66
		var searchText = $("#good-inventory-search-text").val();
67
		if (typeof (searchText) == "undefined" || !searchText){
68
			searchText = "";
69
		}
23629 ashik.ali 70
		var params = {};
71
		params['searchTerm'] = searchText;
72
		loadPaginatedPreviousItems('/getPaginatedCurrentInventorySnapshot', params, 'good-inventory-paginated', 'good-inventory-table', null);
73
		$(this).blur();
23343 ashik.ali 74
    });
75
 
76
	$("#good-inventory-search-button").live('click', function() {
77
		var searchText = $("#good-inventory-search-text").val();
78
		if (typeof (searchText) == "undefined" || !searchText){
79
			searchText = "";
80
		}
81
		loadGoodInventorySearchInfo(searchText);
82
    });
83
 
84
	$("#good-inventory-search-text").live("keyup", function(e) {
85
		var keyCode = e.keyCode || e.which;
86
    	if(keyCode == 13){
87
        	$("#good-inventory-search-button").click();
88
    	}
89
	});
90
 
91
 
92
	$("#catalog-paginated .next").live('click', function() {
93
		var searchText = $("#catalog-search-text").val();
94
		if (typeof (searchText) == "undefined" || !searchText){
95
			searchText = "";
96
		}
23629 ashik.ali 97
 
98
		var params = {};
99
		params['searchTerm'] = searchText;
100
		loadPaginatedNextItems('/getPaginatedCatalog', params, 'catalog-paginated', 'catalog-table', null);
101
		$(this).blur();
23343 ashik.ali 102
    });
103
 
104
	$("#catalog-paginated .previous").live('click', function() {
105
		var searchText = $("#catalog-search-text").val();
106
		if (typeof (searchText) == "undefined" || !searchText){
107
			searchText = "";
108
		}
23629 ashik.ali 109
 
110
		var params = {};
111
		params['searchTerm'] = searchText;
112
		loadPaginatedPreviousItems('/getPaginatedCatalog', params, 'catalog-paginated', 'catalog-table', null);
113
		$(this).blur();
23343 ashik.ali 114
    });
115
 
116
	$("#catalog-search-button").live('click', function() {
117
		var searchText = $("#catalog-search-text").val();
118
		if (typeof (searchText) == "undefined" || !searchText){
119
			searchText = "";
120
		}
121
		loadCatalogSearchInfo(searchText);
122
    });
123
 
124
	$("#catalog-search-text").live("keyup", function(e) {
125
		var keyCode = e.keyCode || e.which;
126
    	if(keyCode == 13){
127
        	$("#catalog-search-button").click();
128
    	}
129
	});
130
 
131
});
132
 
133
 
134
function loadGoodInventory(domId, search_text){
23500 ashik.ali 135
	doGetAjaxRequestHandler(context+"/getCurrentInventorySnapshot/?searchTerm="+search_text, function(response){
23343 ashik.ali 136
		$('#' + domId).html(response);
137
	});
138
}
139
 
140
function loadCatalog(domId, search_text){
23500 ashik.ali 141
	doGetAjaxRequestHandler(context+"/getCatalog/?searchTerm="+search_text, function(response){
23343 ashik.ali 142
		$('#' + domId).html(response);
143
	});
144
}
145
 
146
function getInventoryItemAgingByInterval(domId, searchContent){
23500 ashik.ali 147
	doPostAjaxRequestWithJsonHandler(context+"/getInventoryItemAgingByInterval?searchContent="+searchContent, JSON.stringify([5,15,30,45]), function(response){
23343 ashik.ali 148
		$('#' + domId).html(response);
149
	});
150
}
151
 
152
 
153
function downloadAgingReport(){
154
	data = JSON.stringify([5,15,30,45]),
155
	doAjaxPostDownload(context+"/downloadInventoryItemAgingByInterval",
156
			data, "InventoryItemAging.xlsx");
157
 
158
}
159
 
160
function downloadItemLedgerReport(){
161
	console.log("downloadItemLedgerReport Button clicked")
162
	var startDateTime = $('input[name="startDateTime"]').val();
163
	console.log("startDateTime : "+startDateTime);
164
	var endDateTime = $('input[name="endDateTime"]').val();
165
	console.log("endDateTime : "+endDateTime);
166
	//data = JSON.stringify([5,10,15,20,25,30,35,40]),
167
	doAjaxGetDownload(context+"/itemLedger/complete/download?startDateTime="+startDateTime+"&endDateTime="+endDateTime,
168
			"ItemCompleteLedegerReport.xlsx");
169
}
170
 
171
 
172
function getItemAgingNextPreviousItems(offset, searchContent){
173
	console.log("getItemAgingNextPreviousItems() called");
23500 ashik.ali 174
	doPostAjaxRequestWithJsonHandler(context+"/getInventoryItemAgingByInterval?offset="+offset+"&searchContent="+searchContent, JSON.stringify([5,15,30,45]), function(response){
23343 ashik.ali 175
		$('#main-content').html(response);
176
	});
177
 
178
}
179
 
180
 
181
function loadBadInventory(domId, search_text){
23500 ashik.ali 182
	doGetAjaxRequestHandler(context+"/getBadInventorySnapshot/?searchTerm="+search_text, function(response){
23343 ashik.ali 183
		$('#' + domId).html(response);
184
	});
185
}
186
 
187
function loadGoodInventorySearchInfo(search_text){
188
	loadGoodInventory("main-content",search_text);
189
}
190
 
191
function loadCatalogSearchInfo(search_text){
192
	loadCatalog("main-content",search_text);
193
}
194
 
195
function loadItemLedgerReportDownloadPage(domId){
23500 ashik.ali 196
	doGetAjaxRequestHandler(context+"/itemLedger/downloadPage", function(response){
23343 ashik.ali 197
		$('#' + domId).html(response);
198
	});
199
}