Subversion Repositories SmartDukaan

Rev

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