Subversion Repositories SmartDukaan

Rev

Rev 26721 | Rev 27754 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
25093 amit.gupta 1
var saleSearchObj = saleSearchObj || {};
2
saleSearchObj.searchText = "";
3
saleSearchObj.searchType = "";
4
saleSearchObj.startTime = "";
5
saleSearchObj.endTime = "";
23343 ashik.ali 6
 
7
$(function() {
23973 govind 8
 
26647 tejbeer 9
	$(".pending_fofo_order").live('click', function() {
10
		console.log("Helloo")
11
		loadPendingOrder("main-content");
12
	});
13
 
26817 amit.gupta 14
	$("button.pendingOrderDetail").live(
26647 tejbeer 15
			'click',
16
			function() {
17
				doGetAjaxRequestHandler(context
26817 amit.gupta 18
						+ "/getPendingOrderItem?orderId=" + $(this).data('orderid'), function(
26647 tejbeer 19
						response) {
20
					$('.pending-order-container').html(response);
21
				});
22
			});
23
 
26721 tejbeer 24
	$(".pendingOrderCancel")
25
			.live(
26
					'click',
27
					function() {
28
 
29
						var orderId = $(this).data('orderid');
30
						console.log(orderId);
31
						if (confirm("Are you sure you want to cancel the order!") == true) {
32
							doPostAjaxRequestHandler(context
33
									+ "/cancelPendingOrder?id=" + orderId,
34
									function(response) {
35
										if (response == 'true') {
36
											alert("successfully Cancel");
37
											loadPendingOrder("main-content");
38
										}
39
									});
40
 
41
							return false;
42
						}
43
 
44
					});
45
 
46
	$(".pendingOrderItemCancel")
47
			.live(
48
					'click',
49
					function() {
50
 
51
						var orderItemId = $(this).data('orderitemid');
52
						if (confirm("Are you sure you want to cancel the order item!") == true) {
53
							doPostAjaxRequestHandler(context
54
									+ "/cancelPendingOrderItem?id="
55
									+ orderItemId, function(response) {
56
								if (response == 'true') {
57
									alert("successfully Cancel");
58
									loadPendingOrder("main-content");
59
								}
60
							});
61
 
62
							return false;
63
						}
64
 
65
					});
66
 
23343 ashik.ali 67
	$(".sale-history").live('click', function() {
68
		console.log("Sale History Button Clicked...")
23973 govind 69
		saleHistory("main-content", "", "", startDate, endDate);
23343 ashik.ali 70
	});
24880 govind 71
 
72
	$(".insurance-policy-details").live('click', function() {
73
		console.log("insurance-policy-details");
74
		insurancePolicyDetails("main-content");
75
	});
76
 
24105 govind 77
	$(".updatePaymentDetails")
78
			.live(
79
					'click',
80
					function() {
81
						console
82
								.log("updatePaymentDetails target Button Clicked...");
83
						var i = 1;
84
						var changedTotalAmount = 0;
85
						var invoiceNumber = $(this).data('invoicenumber');
86
						var fofoId = $(this).data('fofoid');
24880 govind 87
 
88
						var totalNumberOfPaymentOptionId = $(this).data(
89
								'totalnumberofpaymentoptionid');
90
						console.log("totalNumberOfPaymentOptionId"
91
								+ totalNumberOfPaymentOptionId);
24105 govind 92
						var referenceId = $(this).data('orderid');
93
						var referenceType = "ORDER";
24880 govind 94
						var createdTimeStamp = $(this).data('createddatetime');
24152 govind 95
						console.log(createdTimeStamp);
24105 govind 96
						console.log(fofoId);
97
						console.log(referenceId);
98
						console.log(invoiceNumber);
99
						console.log(referenceType);
100
						var paymentOptionTransactionModels = [];
101
						var inputvalues = {};
24880 govind 102
						$('.paymentOptions input')
103
								.each(
104
										function() {
105
											console.log($(this).val())
106
											if (!isFinite($(this).val())) {
107
												return;
108
											}
109
											inputvalues = {};
110
											inputvalues['paymentOptionId'] = $(
111
													this).data(
112
													'payment-option-id');
113
											inputvalues['amount'] = $(this)
114
													.val();
115
											inputvalues['createdTimeStamp'] = createdTimeStamp;
116
											console
117
													.log(inputvalues['createdTimeStamp']);
118
											if (!inputvalues['amount']) {
119
												inputvalues['amount'] = "0";
120
											}
121
											console.log("inputvalues['amount']"
122
													+ inputvalues['amount']);
123
											paymentOptionTransactionModels
124
													.push(inputvalues);
125
										});
126
						if (paymentOptionTransactionModels.length != totalNumberOfPaymentOptionId) {
127
							alert("Sending less or more paymentOptionIds for"
128
									+ fofoId);
129
							return false;
130
						}
24105 govind 131
						console.log(paymentOptionTransactionModels);
132
						if (confirm("Are you sure you want to update paymentTransaction!") == true) {
133
							doPutAjaxRequestWithJsonHandler(
134
									context
135
											+ "/updatePaymentTransaction?referenceId="
136
											+ referenceId + "&referenceType="
137
											+ referenceType + "&fofoId="
138
											+ fofoId,
139
									JSON
140
											.stringify(paymentOptionTransactionModels),
141
									function(response) {
142
										if (response === 'true') {
143
											alert("successfully added");
144
											loadSearchOrderDetails(
145
													invoiceNumber,
146
													"search-order-details-container");
147
										}
148
									});
149
						}
23973 govind 150
 
24105 govind 151
					});
152
 
23973 govind 153
	$('#searchType').live(
154
			'change',
155
			function() {
156
				var searchType = $("#searchType option:selected").val();
157
				var searchTypevalue = $(this).find('option:selected').text();
158
				;
25093 amit.gupta 159
				saleSearchObj.searchType = searchType;
23973 govind 160
				console.log("selected searchType = " + searchType);
24105 govind 161
 
25093 amit.gupta 162
				saleHistory("main-content", saleSearchObj.searchType, "",
23973 govind 163
						startDate, endDate);
24105 govind 164
 
165
				$("#sale-history-search-text").val('');
23973 govind 166
			});
167
 
26647 tejbeer 168
	$("#sale-history-search-button")
169
			.live(
170
					'click',
171
					function() {
172
						var searchType = $("#searchType option:selected").val();
173
						console.log("searchType = " + searchType);
174
						$("#searchType").removeClass("border-highlight");
175
						saleSearchObj.searchText = $(
176
								"#sale-history-search-text").val();
177
						saleSearchObj.searchType = searchType;
178
						saleSearchObj.startTime = startDate;
179
						saleSearchObj.endTime = endDate;
180
						if (typeof (saleSearchObj.searchText) == "undefined"
181
								|| !saleSearchObj.searchText) {
182
							saleSearchObj.searchText = "";
183
						}
184
						saleHistorySearchInfo(saleSearchObj.searchType,
185
								saleSearchObj.searchText,
186
								saleSearchObj.startTime, saleSearchObj.endTime);
187
					});
188
	$("#invoice-download-button")
189
			.live(
190
					'click',
191
					function() {
192
						var searchType = $("#searchType option:selected").val();
193
						console.log("searchType = " + searchType);
194
						$("#searchType").removeClass("border-highlight");
195
						saleSearchObj.searchText = $(
196
								"#sale-history-search-text").val();
197
						saleSearchObj.searchType = searchType;
198
						saleSearchObj.startTime = startDate;
199
						saleSearchObj.endTime = endDate;
200
						if (typeof (saleSearchObj.searchText) == "undefined"
201
								|| !saleSearchObj.searchText) {
202
							saleSearchObj.searchText = "";
203
						}
204
						downloadInvoices(saleSearchObj.searchType,
205
								saleSearchObj.searchText,
206
								saleSearchObj.startTime, saleSearchObj.endTime);
207
					});
23973 govind 208
 
23584 ashik.ali 209
	$(".search-order").live('click', function() {
210
		console.log("search-order clicked")
211
		loadSearchOrder("main-content");
23973 govind 212
	});
213
 
214
	$("#search-order-button").live(
215
			'click',
216
			function() {
217
				console.log("search-order-button clicked")
218
				var invoiceNumber = $("#search-order-text").val();
219
				loadSearchOrderDetails(invoiceNumber,
220
						"search-order-details-container");
221
			});
222
 
223
	$("#sale-history-paginated .next").live(
224
			'click',
225
			function() {
226
				var params = {};
25608 tejbeer 227
				params['searchType'] = saleSearchObj.searchType;
228
				params['searchValue'] = saleSearchObj.searchText;
23973 govind 229
				params['startTime'] = walletHistory.startTime;
230
				params['endTime'] = walletHistory.endTime;
231
				loadPaginatedNextItems('/getPaginatedSaleHistory', params,
232
						'sale-history-paginated', 'sale-history-table',
233
						'sale-details-container');
234
				$(this).blur();
235
			});
24880 govind 236
	$("#insurance-paginated .next").live(
237
			'click',
238
			function() {
239
				loadPaginatedNextItems('/insuranceDetailsPaginated', null,
240
						'insurance-paginated', 'insurance-details-table',
241
						'insurance-policy-details-container');
242
				$(this).blur();
243
			});
244
	$("#insurance-paginated .previous").live(
245
			'click',
246
			function() {
247
				loadPaginatedNextItems('/insuranceDetailsPaginated', null,
248
						'insurance-paginated', 'insurance-details-table',
249
						'insurance-policy-details-container');
250
				$(this).blur();
251
			});
23973 govind 252
 
253
	$("#sale-history-paginated .previous").live(
254
			'click',
255
			function() {
256
				var params = {};
25608 tejbeer 257
				params['searchType'] = saleSearchObj.searchType;
258
				params['searchValue'] = saleSearchObj.searchText;
23973 govind 259
				params['startTime'] = walletHistory.startTime;
260
				params['endTime'] = walletHistory.endTime;
261
				loadPaginatedPreviousItems('/getPaginatedSaleHistory', params,
262
						'sale-history-paginated', 'sale-history-table',
263
						'sale-details-container');
264
				$(this).blur();
265
			});
266
 
267
	// grn-details
268
 
269
	$(".sale-details").live('click', function() {
23654 amit.gupta 270
		orderId = $(this).attr('data');
23973 govind 271
		console.log("orderId = " + orderId);
272
		loadSaleDetails(orderId, "sale-details-container");
23343 ashik.ali 273
	});
274
});
275
 
23973 govind 276
function loadSaleDetails(orderId, domId) {
277
	doGetAjaxRequestHandler(context + "/saleDetails?orderId=" + orderId,
278
			function(response) {
279
				$('#' + domId).html(response);
280
			});
23343 ashik.ali 281
}
282
 
26647 tejbeer 283
function loadPendingOrder(domId) {
284
	doGetAjaxRequestHandler(context + "/pendingOrders", function(response) {
285
		$('#' + domId).html(response);
286
 
287
	});
288
}
289
 
23973 govind 290
function loadSearchOrder(domId) {
291
	doGetAjaxRequestHandler(context + "/getSearchOrder", function(response) {
23584 ashik.ali 292
		$('#' + domId).html(response);
293
	});
294
}
295
 
23973 govind 296
function loadSearchOrderDetails(invoiceNumber, domId) {
297
	doGetAjaxRequestHandler(context + "/searchOrderDetails?invoiceNumber="
298
			+ invoiceNumber, function(response) {
23584 ashik.ali 299
		$('#' + domId).html(response);
300
	});
301
}
302
 
23973 govind 303
function saleHistory(domId, searchType, searchValue, startTime, endTime) {
304
	doGetAjaxRequestHandler(context + "/saleHistory?searchType=" + searchType
305
			+ "&searchValue=" + searchValue + "&startTime=" + startTime
306
			+ "&endTime=" + endTime, function(response) {
23343 ashik.ali 307
		$('#' + domId).html(response);
308
	});
309
}
310
 
23973 govind 311
function saleHistorySearchInfo(searchType, searchText, startTime, endTime) {
23343 ashik.ali 312
	saleHistory("main-content", searchType, searchText, startTime, endTime);
24105 govind 313
 
314
}
24880 govind 315
function insurancePolicyDetails(domId) {
316
	doGetAjaxRequestHandler(context + "/insuranceDetails", function(response) {
317
		$('#' + domId).html(response);
318
	});
319
}
25093 amit.gupta 320
 
321
function downloadInvoices(searchType, searchValue, startTime, endTime) {
322
	doAjaxGetDownload(context + "/downloadInvoices?searchType=" + searchType
323
			+ "&searchValue=" + searchValue + "&startTime=" + startTime
324
			+ "&endTime=" + endTime, "invoices.pdf");
325
}