Subversion Repositories SmartDukaan

Rev

Rev 24739 | Rev 24917 | 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() {
24739 tejbeer 3
		loadGoodInventory("main-content", "");
23343 ashik.ali 4
	});
24739 tejbeer 5
 
23343 ashik.ali 6
	$(".catalog").live('click', function() {
24739 tejbeer 7
		loadCatalog("main-content", "");
23343 ashik.ali 8
	});
24739 tejbeer 9
 
24658 tejbeer 10
	$(".review_order").live('click', function() {
11
		loadOrder("main-content");
12
	});
24739 tejbeer 13
 
14
	$(".keep-a-tab").live('click', function() {
15
		loadtabOrder("main-content");
16
	});
23343 ashik.ali 17
	$(".item_aging").live('click', function() {
18
		getInventoryItemAgingByInterval("main-content", "");
19
	});
24739 tejbeer 20
 
23343 ashik.ali 21
	$("#item-aging-search-button").live('click', function() {
22
		searchContent = $("#item-aging-search-text").val();
24739 tejbeer 23
		if (typeof (searchContent) == "undefined" || !searchContent) {
23343 ashik.ali 24
			searchContent = "";
25
		}
26
		getInventoryItemAgingByInterval("main-content", searchContent);
24739 tejbeer 27
	});
28
 
23343 ashik.ali 29
	$("#item-aging-search-text").live("keyup", function(e) {
30
		var keyCode = e.keyCode || e.which;
24739 tejbeer 31
		if (keyCode == 13) {
32
			$("#item-aging-search-button").click();
33
		}
23343 ashik.ali 34
	});
24739 tejbeer 35
 
23629 ashik.ali 36
	$("#item-aging-paginated .next").live('click', function() {
24739 tejbeer 37
		var end = $("#item-aging-paginated .end").text();
23629 ashik.ali 38
		getItemAgingNextPreviousItems(end, "");
39
		$("#item-aging-paginated .next").blur();
24739 tejbeer 40
	});
41
 
23343 ashik.ali 42
	$("#item-aging-paginated .previous").live('click', function() {
24739 tejbeer 43
		var start = $("#item-aging-paginated .start").text();
23343 ashik.ali 44
		getItemAgingNextPreviousItems(start - 11, "");
45
		$("#item-aging-paginated .previous").blur();
24739 tejbeer 46
	});
47
 
23343 ashik.ali 48
	$(".download_aging_report").live('click', function() {
49
		downloadAgingReport();
50
	});
24739 tejbeer 51
 
23637 amit.gupta 52
	$(".download_reports").live('click', function() {
53
		downloadReports();
54
	});
24739 tejbeer 55
 
23343 ashik.ali 56
	$(".item-ledger-report-download-page").live('click', function() {
57
		loadItemLedgerReportDownloadPage("main-content");
58
	});
24739 tejbeer 59
 
23343 ashik.ali 60
	$(".bad_inventory").live('click', function() {
24739 tejbeer 61
		loadBadInventory("main-content", "");
23343 ashik.ali 62
	});
24739 tejbeer 63
 
64
	$("#good-inventory-paginated .next").live(
65
			'click',
66
			function() {
67
				var searchText = $("#good-inventory-search-text").val();
68
				if (typeof (searchText) == "undefined" || !searchText) {
69
					searchText = "";
70
 
71
				}
72
				var params = {};
73
				params['searchTerm'] = searchText;
74
				loadPaginatedNextItems('/getPaginatedCurrentInventorySnapshot',
75
						params, 'good-inventory-paginated',
76
						'good-inventory-table', null);
77
				$(this).blur();
78
			});
79
 
80
	$("#good-inventory-paginated .previous").live(
81
			'click',
82
			function() {
83
				var searchText = $("#good-inventory-search-text").val();
84
				if (typeof (searchText) == "undefined" || !searchText) {
85
					searchText = "";
86
				}
87
				var params = {};
88
				params['searchTerm'] = searchText;
89
				loadPaginatedPreviousItems(
90
						'/getPaginatedCurrentInventorySnapshot', params,
91
						'good-inventory-paginated', 'good-inventory-table',
92
						null);
93
				$(this).blur();
94
			});
95
 
23343 ashik.ali 96
	$("#good-inventory-search-button").live('click', function() {
97
		var searchText = $("#good-inventory-search-text").val();
24739 tejbeer 98
		if (typeof (searchText) == "undefined" || !searchText) {
23343 ashik.ali 99
			searchText = "";
100
		}
101
		loadGoodInventorySearchInfo(searchText);
24739 tejbeer 102
	});
103
 
23343 ashik.ali 104
	$("#good-inventory-search-text").live("keyup", function(e) {
105
		var keyCode = e.keyCode || e.which;
24739 tejbeer 106
		if (keyCode == 13) {
107
			$("#good-inventory-search-button").click();
108
		}
23343 ashik.ali 109
	});
24739 tejbeer 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 = "";
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
 
134
				var params = {};
135
				params['searchTerm'] = searchText;
136
				loadPaginatedPreviousItems('/getPaginatedCatalog', params,
137
						'catalog-paginated', 'catalog-table', null);
138
				$(this).blur();
139
			});
140
 
23343 ashik.ali 141
	$("#catalog-search-button").live('click', function() {
142
		var searchText = $("#catalog-search-text").val();
24739 tejbeer 143
		if (typeof (searchText) == "undefined" || !searchText) {
23343 ashik.ali 144
			searchText = "";
145
		}
146
		loadCatalogSearchInfo(searchText);
24739 tejbeer 147
	});
148
 
23343 ashik.ali 149
	$("#catalog-search-text").live("keyup", function(e) {
150
		var keyCode = e.keyCode || e.which;
24739 tejbeer 151
		if (keyCode == 13) {
152
			$("#catalog-search-button").click();
153
		}
23343 ashik.ali 154
	});
155
 
24739 tejbeer 156
	$(".cancellation").live("click", function(e) {
157
		orderid = $(this).data('orderid');
158
        cancelOrder(orderid, "CANCELLED_DUE_TO_LOW_INVENTORY")
159
	});
23343 ashik.ali 160
 
24739 tejbeer 161
	$(".keepatab").live("click", function(e) {
162
		orderid = $(this).data('orderid');
163
		cancelOrder(orderid, "KEEP_A_TAB")
164
 
165
	});
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) {
23343 ashik.ali 170
 
24739 tejbeer 171
			doPostAjaxRequestHandler(context + "/closeOrder?orderId="
24753 tejbeer 172
					+ orderd, function(response) {
24739 tejbeer 173
				if (response == 'true') {
174
					alert("successfully close");
175
					loadtabOrder("main-content");
176
				}
177
			});
178
		}
179
 
23343 ashik.ali 180
	});
24739 tejbeer 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
			});
23343 ashik.ali 190
}
191
 
24739 tejbeer 192
function loadCatalog(domId, search_text) {
193
	doGetAjaxRequestHandler(context + "/getCatalog?searchTerm=" + search_text,
194
			function(response) {
195
				$('#' + domId).html(response);
196
			});
197
 
23343 ashik.ali 198
}
199
 
24739 tejbeer 200
function loadOrder(domId) {
201
	doGetAjaxRequestHandler(context + "/getInProcessOrder", function(response) {
24658 tejbeer 202
		$('#' + domId).html(response);
203
	});
24739 tejbeer 204
 
24658 tejbeer 205
}
206
 
24739 tejbeer 207
function loadtabOrder(domId){
208
	doGetAjaxRequestHandler(context + "/getKeepInTabOrder", function(response) {
23343 ashik.ali 209
		$('#' + domId).html(response);
210
	});
24739 tejbeer 211
 
23343 ashik.ali 212
}
213
 
214
 
24739 tejbeer 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
			});
23343 ashik.ali 222
}
223
 
24739 tejbeer 224
function downloadAgingReport() {
225
	data = JSON.stringify([ 5, 15, 30, 45 ]), doAjaxPostDownload(context
226
			+ "/downloadInventoryItemAgingByInterval", data,
227
			"InventoryItemAging.xlsx");
228
 
229
}
230
 
231
function downloadReports() {
232
	doGetAjaxRequestHandler(context + "/reports", function(response) {
23637 amit.gupta 233
		$('#main-content').html(response);
234
	});
235
}
236
 
24739 tejbeer 237
function downloadItemLedgerReport() {
23343 ashik.ali 238
	console.log("downloadItemLedgerReport Button clicked")
24221 amit.gupta 239
	var dateWise = $("#dateWise").get(0).checked;
24739 tejbeer 240
	doAjaxGetDownload(context + "/itemLedger/complete/download?startDateTime="
241
			+ startDate + "&endDateTime=" + endDate + "&dateWise=" + dateWise,
23343 ashik.ali 242
			"ItemCompleteLedegerReport.xlsx");
243
}
244
 
24739 tejbeer 245
function getItemAgingNextPreviousItems(offset, searchContent) {
23343 ashik.ali 246
	console.log("getItemAgingNextPreviousItems() called");
24739 tejbeer 247
	doPostAjaxRequestWithJsonHandler(context
248
			+ "/getInventoryItemAgingByInterval?offset=" + offset
249
			+ "&searchContent=" + searchContent, JSON
250
			.stringify([ 5, 15, 30, 45 ]), function(response) {
23343 ashik.ali 251
		$('#main-content').html(response);
252
	});
24739 tejbeer 253
 
23343 ashik.ali 254
}
255
 
24739 tejbeer 256
function loadBadInventory(domId, search_text) {
257
	doGetAjaxRequestHandler(context + "/getBadInventorySnapshot?searchTerm="
258
			+ search_text, function(response) {
23343 ashik.ali 259
		$('#' + domId).html(response);
260
	});
261
}
262
 
24739 tejbeer 263
function loadGoodInventorySearchInfo(search_text) {
264
	loadGoodInventory("main-content", search_text);
23343 ashik.ali 265
}
266
 
24739 tejbeer 267
function loadCatalogSearchInfo(search_text) {
268
	loadCatalog("main-content", search_text);
23343 ashik.ali 269
}
270
 
24739 tejbeer 271
function loadItemLedgerReportDownloadPage(domId) {
272
	doGetAjaxRequestHandler(context + "/itemLedger/downloadPage", function(
273
			response) {
23343 ashik.ali 274
		$('#' + domId).html(response);
275
	});
24739 tejbeer 276
}
277
 
278
function cancelOrder(orderId,status) {
279
	console.log(orderId);
24753 tejbeer 280
 
281
 
282
	var dialog = bootbox
283
	.dialog({
284
		title : "Are you sure want to cancel the order",
285
		message : "<div class=form-inline'>"
286
				+ "<label for='reason'>Reason:</label>"
287
				+ "<textarea class='form-control' rows='1' id='reason'></textarea>"
288
				+ "</div>",
289
		buttons : {
290
			cancel : {
291
				label : "cancel",
292
				className : 'btn-danger',
293
				callback : function() {
294
					loadOrder("main-content");
295
				}
296
			},
297
			ok : {
298
				label : "ok",
299
				className : 'btn-info',
300
				callback : function() {
301
					reason = $('#reason').val();
302
					console.log(reason);
303
					if (reason == ""
304
							|| reason == null
305
							|| reason == undefined) {
306
						alert("reason field can't be empty");
307
						return false;
308
					}
309
 
310
					doPostAjaxRequestHandler(context + "/cancelOrder?orderId="
311
							+ orderId + "&reason=" + reason+ "&orderStatus=" + status, function(response) {
312
						if (response == 'true') {
313
							alert("successfully cancel");
24739 tejbeer 314
 
24753 tejbeer 315
							loadOrder("main-content");
316
						}
317
					});
24739 tejbeer 318
 
319
 
24753 tejbeer 320
				}
24739 tejbeer 321
			}
322
		}
323
	});
324
 
325
}