Subversion Repositories SmartDukaan

Rev

Rev 24658 | Rev 24753 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 24658 Rev 24739
Line 1... Line 1...
1
$(function() {
1
$(function() {
2
	$(".good_inventory").live('click', function() {
2
	$(".good_inventory").live('click', function() {
3
		loadGoodInventory("main-content","");
3
		loadGoodInventory("main-content", "");
4
	});
4
	});
5
	
5
 
6
	$(".catalog").live('click', function() {
6
	$(".catalog").live('click', function() {
7
		loadCatalog("main-content","");
7
		loadCatalog("main-content", "");
8
	});
8
	});
9
	
9
 
10
	$(".review_order").live('click', function() {
10
	$(".review_order").live('click', function() {
11
		loadOrder("main-content");
11
		loadOrder("main-content");
12
	});
12
	});
13
	
13
 
-
 
14
	$(".keep-a-tab").live('click', function() {
-
 
15
		loadtabOrder("main-content");
-
 
16
	});
14
	$(".item_aging").live('click', function() {
17
	$(".item_aging").live('click', function() {
15
		getInventoryItemAgingByInterval("main-content", "");
18
		getInventoryItemAgingByInterval("main-content", "");
16
	});
19
	});
17
	
20
 
18
	$("#item-aging-search-button").live('click', function() {
21
	$("#item-aging-search-button").live('click', function() {
19
		searchContent = $("#item-aging-search-text").val();
22
		searchContent = $("#item-aging-search-text").val();
20
		if (typeof (searchContent) == "undefined" || !searchContent){
23
		if (typeof (searchContent) == "undefined" || !searchContent) {
21
			searchContent = "";
24
			searchContent = "";
22
		}
25
		}
23
		getInventoryItemAgingByInterval("main-content", searchContent);
26
		getInventoryItemAgingByInterval("main-content", searchContent);
24
    });
27
	});
25
	
28
 
26
	
-
 
27
	$("#item-aging-search-text").live("keyup", function(e) {
29
	$("#item-aging-search-text").live("keyup", function(e) {
28
		var keyCode = e.keyCode || e.which;
30
		var keyCode = e.keyCode || e.which;
29
    	if(keyCode == 13){
31
		if (keyCode == 13) {
30
        	$("#item-aging-search-button").click();
32
			$("#item-aging-search-button").click();
31
    	}
33
		}
32
	});
34
	});
33
	
35
 
34
	$("#item-aging-paginated .next").live('click', function() {
36
	$("#item-aging-paginated .next").live('click', function() {
35
		var end = $( "#item-aging-paginated .end" ).text();
37
		var end = $("#item-aging-paginated .end").text();
36
		getItemAgingNextPreviousItems(end, "");
38
		getItemAgingNextPreviousItems(end, "");
37
		$("#item-aging-paginated .next").blur();
39
		$("#item-aging-paginated .next").blur();
38
    });
40
	});
39
	
41
 
40
	$("#item-aging-paginated .previous").live('click', function() {
42
	$("#item-aging-paginated .previous").live('click', function() {
41
		var start = $( "#item-aging-paginated .start" ).text();
43
		var start = $("#item-aging-paginated .start").text();
42
		getItemAgingNextPreviousItems(start - 11, "");
44
		getItemAgingNextPreviousItems(start - 11, "");
43
		$("#item-aging-paginated .previous").blur();
45
		$("#item-aging-paginated .previous").blur();
44
    });
46
	});
45
	
47
 
46
	$(".download_aging_report").live('click', function() {
48
	$(".download_aging_report").live('click', function() {
47
		downloadAgingReport();
49
		downloadAgingReport();
48
	});
50
	});
49
	
51
 
50
	$(".download_reports").live('click', function() {
52
	$(".download_reports").live('click', function() {
51
		downloadReports();
53
		downloadReports();
52
	});
54
	});
53
	
55
 
54
	$(".item-ledger-report-download-page").live('click', function() {
56
	$(".item-ledger-report-download-page").live('click', function() {
55
		loadItemLedgerReportDownloadPage("main-content");
57
		loadItemLedgerReportDownloadPage("main-content");
56
	});
58
	});
57
	
59
 
58
	$(".bad_inventory").live('click', function() {
60
	$(".bad_inventory").live('click', function() {
59
		loadBadInventory("main-content","");
61
		loadBadInventory("main-content", "");
60
	});
62
	});
61
	
63
 
62
	$("#good-inventory-paginated .next").live('click', function() {
64
	$("#good-inventory-paginated .next").live(
-
 
65
			'click',
-
 
66
			function() {
63
		var searchText = $("#good-inventory-search-text").val();
67
				var searchText = $("#good-inventory-search-text").val();
64
		if (typeof (searchText) == "undefined" || !searchText){
68
				if (typeof (searchText) == "undefined" || !searchText) {
65
			searchText = "";
69
					searchText = "";
66
			
70
 
67
		}
71
				}
68
		var params = {};
72
				var params = {};
69
		params['searchTerm'] = searchText;
73
				params['searchTerm'] = searchText;
70
		loadPaginatedNextItems('/getPaginatedCurrentInventorySnapshot', params, 'good-inventory-paginated', 'good-inventory-table', null);
74
				loadPaginatedNextItems('/getPaginatedCurrentInventorySnapshot',
-
 
75
						params, 'good-inventory-paginated',
-
 
76
						'good-inventory-table', null);
71
		$(this).blur();
77
				$(this).blur();
72
    });
78
			});
73
	
79
 
74
	$("#good-inventory-paginated .previous").live('click', function() {
80
	$("#good-inventory-paginated .previous").live(
-
 
81
			'click',
-
 
82
			function() {
75
		var searchText = $("#good-inventory-search-text").val();
83
				var searchText = $("#good-inventory-search-text").val();
76
		if (typeof (searchText) == "undefined" || !searchText){
84
				if (typeof (searchText) == "undefined" || !searchText) {
77
			searchText = "";
85
					searchText = "";
78
		}
86
				}
79
		var params = {};
87
				var params = {};
80
		params['searchTerm'] = searchText;
88
				params['searchTerm'] = searchText;
-
 
89
				loadPaginatedPreviousItems(
-
 
90
						'/getPaginatedCurrentInventorySnapshot', params,
81
		loadPaginatedPreviousItems('/getPaginatedCurrentInventorySnapshot', params, 'good-inventory-paginated', 'good-inventory-table', null);
91
						'good-inventory-paginated', 'good-inventory-table',
-
 
92
						null);
82
		$(this).blur();
93
				$(this).blur();
83
    });
94
			});
84
	
95
 
85
	$("#good-inventory-search-button").live('click', function() {
96
	$("#good-inventory-search-button").live('click', function() {
86
		var searchText = $("#good-inventory-search-text").val();
97
		var searchText = $("#good-inventory-search-text").val();
87
		if (typeof (searchText) == "undefined" || !searchText){
98
		if (typeof (searchText) == "undefined" || !searchText) {
88
			searchText = "";
99
			searchText = "";
89
		}
100
		}
90
		loadGoodInventorySearchInfo(searchText);
101
		loadGoodInventorySearchInfo(searchText);
91
    });
102
	});
92
	
103
 
93
	$("#good-inventory-search-text").live("keyup", function(e) {
104
	$("#good-inventory-search-text").live("keyup", function(e) {
94
		var keyCode = e.keyCode || e.which;
105
		var keyCode = e.keyCode || e.which;
95
    	if(keyCode == 13){
106
		if (keyCode == 13) {
96
        	$("#good-inventory-search-button").click();
107
			$("#good-inventory-search-button").click();
97
    	}
-
 
98
	});
-
 
99
	
-
 
100
	
-
 
101
	$("#catalog-paginated .next").live('click', function() {
-
 
102
		var searchText = $("#catalog-search-text").val();
-
 
103
		if (typeof (searchText) == "undefined" || !searchText){
-
 
104
			searchText = "";
-
 
105
		}
-
 
106
		
-
 
107
		var params = {};
-
 
108
		params['searchTerm'] = searchText;
-
 
109
		loadPaginatedNextItems('/getPaginatedCatalog', params, 'catalog-paginated', 'catalog-table', null);
-
 
110
		$(this).blur();
-
 
111
    });
-
 
112
	
-
 
113
	$("#catalog-paginated .previous").live('click', function() {
-
 
114
		var searchText = $("#catalog-search-text").val();
-
 
115
		if (typeof (searchText) == "undefined" || !searchText){
-
 
116
			searchText = "";
-
 
117
		}
108
		}
-
 
109
	});
-
 
110
 
-
 
111
	$("#catalog-paginated .next").live(
-
 
112
			'click',
-
 
113
			function() {
-
 
114
				var searchText = $("#catalog-search-text").val();
-
 
115
				if (typeof (searchText) == "undefined" || !searchText) {
-
 
116
					searchText = "";
118
		
117
				}
-
 
118
 
-
 
119
				var params = {};
-
 
120
				params['searchTerm'] = searchText;
-
 
121
				loadPaginatedNextItems('/getPaginatedCatalog', params,
-
 
122
						'catalog-paginated', 'catalog-table', null);
-
 
123
				$(this).blur();
-
 
124
			});
-
 
125
 
-
 
126
	$("#catalog-paginated .previous").live(
-
 
127
			'click',
-
 
128
			function() {
-
 
129
				var searchText = $("#catalog-search-text").val();
-
 
130
				if (typeof (searchText) == "undefined" || !searchText) {
-
 
131
					searchText = "";
-
 
132
				}
-
 
133
 
119
		var params = {};
134
				var params = {};
120
		params['searchTerm'] = searchText;
135
				params['searchTerm'] = searchText;
121
		loadPaginatedPreviousItems('/getPaginatedCatalog', params, 'catalog-paginated', 'catalog-table', null);
136
				loadPaginatedPreviousItems('/getPaginatedCatalog', params,
-
 
137
						'catalog-paginated', 'catalog-table', null);
122
		$(this).blur();
138
				$(this).blur();
123
    });
139
			});
124
	
140
 
125
	$("#catalog-search-button").live('click', function() {
141
	$("#catalog-search-button").live('click', function() {
126
		var searchText = $("#catalog-search-text").val();
142
		var searchText = $("#catalog-search-text").val();
127
		if (typeof (searchText) == "undefined" || !searchText){
143
		if (typeof (searchText) == "undefined" || !searchText) {
128
			searchText = "";
144
			searchText = "";
129
		}
145
		}
130
		loadCatalogSearchInfo(searchText);
146
		loadCatalogSearchInfo(searchText);
131
    });
147
	});
132
	
148
 
133
	$("#catalog-search-text").live("keyup", function(e) {
149
	$("#catalog-search-text").live("keyup", function(e) {
134
		var keyCode = e.keyCode || e.which;
150
		var keyCode = e.keyCode || e.which;
135
    	if(keyCode == 13){
151
		if (keyCode == 13) {
136
        	$("#catalog-search-button").click();
152
			$("#catalog-search-button").click();
137
    	}
153
		}
138
	});
154
	});
139
	
155
	
140
});
-
 
141
 
-
 
142
 
-
 
143
function loadGoodInventory(domId, search_text){
156
	$(".cancellation").live("click", function(e) {
144
	doGetAjaxRequestHandler(context+"/getCurrentInventorySnapshot?searchTerm="+search_text, function(response){
-
 
145
		$('#' + domId).html(response);
157
		orderid = $(this).data('orderid');
-
 
158
        cancelOrder(orderid, "CANCELLED_DUE_TO_LOW_INVENTORY")
146
	});
159
	});
147
}
-
 
148
 
160
 
149
function loadCatalog(domId, search_text){
161
	$(".keepatab").live("click", function(e) {
150
	doGetAjaxRequestHandler(context+"/getCatalog?searchTerm="+search_text, function(response){
162
		orderid = $(this).data('orderid');
151
		$('#' + domId).html(response);
163
		cancelOrder(orderid, "KEEP_A_TAB")
-
 
164
		
152
	});
165
	});
153
	
166
	
-
 
167
	$(".closeOrder").live("click", function(e) {
-
 
168
		orderid = $(this).data('orderid');
-
 
169
		if (confirm("Are you sure you want to close the order") == true) {
-
 
170
 
-
 
171
			doPostAjaxRequestHandler(context + "/closeOrder?orderId="
-
 
172
					+ orderid, function(response) {
-
 
173
				if (response == 'true') {
-
 
174
					alert("successfully close");
-
 
175
					loadtabOrder("main-content");
-
 
176
				}
-
 
177
			});
-
 
178
		}
154
	
179
		
-
 
180
	});
-
 
181
 
-
 
182
});
-
 
183
 
-
 
184
function loadGoodInventory(domId, search_text) {
-
 
185
	doGetAjaxRequestHandler(context
-
 
186
			+ "/getCurrentInventorySnapshot?searchTerm=" + search_text,
-
 
187
			function(response) {
-
 
188
				$('#' + domId).html(response);
-
 
189
			});
155
}
190
}
156
 
191
 
-
 
192
function loadCatalog(domId, search_text) {
-
 
193
	doGetAjaxRequestHandler(context + "/getCatalog?searchTerm=" + search_text,
-
 
194
			function(response) {
-
 
195
				$('#' + domId).html(response);
-
 
196
			});
157
 
197
 
-
 
198
}
-
 
199
 
158
function loadOrder(domId){
200
function loadOrder(domId) {
159
	doGetAjaxRequestHandler(context+"/getCurrentOrder", function(response){
201
	doGetAjaxRequestHandler(context + "/getInProcessOrder", function(response) {
160
		$('#' + domId).html(response);
202
		$('#' + domId).html(response);
161
	});
203
	});
162
	
-
 
163
	
204
 
164
}
205
}
165
 
206
 
166
function getInventoryItemAgingByInterval(domId, searchContent){
207
function loadtabOrder(domId){
167
	doPostAjaxRequestWithJsonHandler(context+"/getInventoryItemAgingByInterval?searchContent="+searchContent, JSON.stringify([5,15,30,45]), function(response){
208
	doGetAjaxRequestHandler(context + "/getKeepInTabOrder", function(response) {
168
		$('#' + domId).html(response);
209
		$('#' + domId).html(response);
169
	});
210
	});
-
 
211
 
170
}
212
}
171
 
213
 
172
 
214
 
-
 
215
function getInventoryItemAgingByInterval(domId, searchContent) {
-
 
216
	doPostAjaxRequestWithJsonHandler(
-
 
217
			context + "/getInventoryItemAgingByInterval?searchContent="
-
 
218
					+ searchContent, JSON.stringify([ 5, 15, 30, 45 ]),
-
 
219
			function(response) {
-
 
220
				$('#' + domId).html(response);
-
 
221
			});
-
 
222
}
-
 
223
 
173
function downloadAgingReport(){
224
function downloadAgingReport() {
174
	data = JSON.stringify([5,15,30,45]),
225
	data = JSON.stringify([ 5, 15, 30, 45 ]), doAjaxPostDownload(context
175
	doAjaxPostDownload(context+"/downloadInventoryItemAgingByInterval",
226
			+ "/downloadInventoryItemAgingByInterval", data,
176
			data, "InventoryItemAging.xlsx");
227
			"InventoryItemAging.xlsx");
177
	
228
 
178
}
229
}
179
 
230
 
180
function downloadReports(){
231
function downloadReports() {
181
	doGetAjaxRequestHandler(context+"/reports", function(response){
232
	doGetAjaxRequestHandler(context + "/reports", function(response) {
182
		$('#main-content').html(response);
233
		$('#main-content').html(response);
183
	});
234
	});
184
}
235
}
185
 
236
 
186
function downloadItemLedgerReport(){
237
function downloadItemLedgerReport() {
187
	console.log("downloadItemLedgerReport Button clicked")
238
	console.log("downloadItemLedgerReport Button clicked")
188
	var dateWise = $("#dateWise").get(0).checked;
239
	var dateWise = $("#dateWise").get(0).checked;
189
	doAjaxGetDownload(context+"/itemLedger/complete/download?startDateTime="+startDate+"&endDateTime="+endDate+"&dateWise="+dateWise,
240
	doAjaxGetDownload(context + "/itemLedger/complete/download?startDateTime="
-
 
241
			+ startDate + "&endDateTime=" + endDate + "&dateWise=" + dateWise,
190
			"ItemCompleteLedegerReport.xlsx");
242
			"ItemCompleteLedegerReport.xlsx");
191
}
243
}
192
 
244
 
193
 
-
 
194
function getItemAgingNextPreviousItems(offset, searchContent){
245
function getItemAgingNextPreviousItems(offset, searchContent) {
195
	console.log("getItemAgingNextPreviousItems() called");
246
	console.log("getItemAgingNextPreviousItems() called");
-
 
247
	doPostAjaxRequestWithJsonHandler(context
196
	doPostAjaxRequestWithJsonHandler(context+"/getInventoryItemAgingByInterval?offset="+offset+"&searchContent="+searchContent, JSON.stringify([5,15,30,45]), function(response){
248
			+ "/getInventoryItemAgingByInterval?offset=" + offset
-
 
249
			+ "&searchContent=" + searchContent, JSON
-
 
250
			.stringify([ 5, 15, 30, 45 ]), function(response) {
197
		$('#main-content').html(response);
251
		$('#main-content').html(response);
198
	});
252
	});
199
	
-
 
200
}
-
 
201
 
253
 
-
 
254
}
202
 
255
 
203
function loadBadInventory(domId, search_text){
256
function loadBadInventory(domId, search_text) {
204
	doGetAjaxRequestHandler(context+"/getBadInventorySnapshot?searchTerm="+search_text, function(response){
257
	doGetAjaxRequestHandler(context + "/getBadInventorySnapshot?searchTerm="
-
 
258
			+ search_text, function(response) {
205
		$('#' + domId).html(response);
259
		$('#' + domId).html(response);
206
	});
260
	});
207
}
261
}
208
 
262
 
209
function loadGoodInventorySearchInfo(search_text){
263
function loadGoodInventorySearchInfo(search_text) {
210
	loadGoodInventory("main-content",search_text);
264
	loadGoodInventory("main-content", search_text);
211
}
265
}
212
 
266
 
213
function loadCatalogSearchInfo(search_text){
267
function loadCatalogSearchInfo(search_text) {
214
	loadCatalog("main-content",search_text);
268
	loadCatalog("main-content", search_text);
215
}
269
}
216
 
270
 
217
function loadItemLedgerReportDownloadPage(domId){
271
function loadItemLedgerReportDownloadPage(domId) {
218
	doGetAjaxRequestHandler(context+"/itemLedger/downloadPage", function(response){
272
	doGetAjaxRequestHandler(context + "/itemLedger/downloadPage", function(
-
 
273
			response) {
219
		$('#' + domId).html(response);
274
		$('#' + domId).html(response);
220
	});
275
	});
221
}
-
 
222
276
}
-
 
277
 
-
 
278
function cancelOrder(orderId,status) {
-
 
279
	console.log(orderId);
-
 
280
 
-
 
281
	bootbox.prompt("reason", function(result) {
-
 
282
		if (result != null) {
-
 
283
			console.log(result);
-
 
284
			if (confirm("Are you sure you want to cancel the order") == true) {
-
 
285
 
-
 
286
				doPostAjaxRequestHandler(context + "/cancelOrder?orderId="
-
 
287
						+ orderId + "&reason=" + result+ "&orderStatus=" + status, function(response) {
-
 
288
					if (response == 'true') {
-
 
289
						alert("successfully cancel");
-
 
290
 
-
 
291
						loadOrder("main-content");
-
 
292
					}
-
 
293
				});
-
 
294
			}
-
 
295
		} else {
-
 
296
			bootbox.alert("reason is required");
-
 
297
		}
-
 
298
	});
-
 
299
 
-
 
300
}
-
 
301