Subversion Repositories SmartDukaan

Rev

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