Subversion Repositories SmartDukaan

Rev

Rev 27819 | Rev 28339 | 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
 
27754 amit.gupta 9
	$(document).on('click', ".pending_fofo_order", function() {
26647 tejbeer 10
		console.log("Helloo")
11
		loadPendingOrder("main-content");
12
	});
13
 
27755 amit.gupta 14
	$(document).on('click', "button.pendingOrderDetail",
27819 tejbeer 15
		function() {
16
			doGetAjaxRequestHandler(context
17
				+ "/getPendingOrderItem?orderId=" + $(this).data('orderid'), function(
18
					response) {
19
				$('.pending-order-container').html(response);
26647 tejbeer 20
			});
27819 tejbeer 21
		});
26647 tejbeer 22
 
27755 amit.gupta 23
	$(document).on('click', ".pendingOrderCancel",
27819 tejbeer 24
		function() {
26721 tejbeer 25
 
27819 tejbeer 26
			var orderId = $(this).data('orderid');
27
			console.log(orderId);
28
			if (confirm("Are you sure you want to cancel the order!") == true) {
29
				doPostAjaxRequestHandler(context
30
					+ "/cancelPendingOrder?id=" + orderId,
31
					function(response) {
32
						if (response == 'true') {
33
							alert("successfully Cancel");
34
							loadPendingOrder("main-content");
26721 tejbeer 35
						}
36
					});
37
 
27819 tejbeer 38
				return false;
39
			}
40
 
41
		});
42
 
27755 amit.gupta 43
	$(document).on('click', ".pendingOrderItemCancel",
27819 tejbeer 44
		function() {
26721 tejbeer 45
 
27819 tejbeer 46
			var orderItemId = $(this).data('orderitemid');
47
			if (confirm("Are you sure you want to cancel the order item!") == true) {
48
				doPostAjaxRequestHandler(context
49
					+ "/cancelPendingOrderItem?id="
50
					+ orderItemId, function(response) {
51
						if (response == 'true') {
52
							alert("successfully Cancel");
53
							loadPendingOrder("main-content");
26721 tejbeer 54
						}
55
					});
56
 
27819 tejbeer 57
				return false;
58
			}
59
 
60
		});
61
 
27754 amit.gupta 62
	$(document).on('click', ".sale-history", function() {
23343 ashik.ali 63
		console.log("Sale History Button Clicked...")
23973 govind 64
		saleHistory("main-content", "", "", startDate, endDate);
23343 ashik.ali 65
	});
24880 govind 66
 
27754 amit.gupta 67
	$(document).on('click', ".insurance-policy-details", function() {
24880 govind 68
		console.log("insurance-policy-details");
69
		insurancePolicyDetails("main-content");
70
	});
71
 
27861 tejbeer 72
	$(document).on('change', '.fofoLineItemAmount',
73
		function() {
74
			var amount = 0;
75
			var oldtotalAmount = 0;
76
			console.log(oldtotalAmount)
77
			$('#fofo-item-table')
78
				.find('tr')
79
				.each(
80
					function() {
81
						var row = $(this);
82
						console.log(row);
83
 
84
						var currentRow = $(this)
85
							.closest("tr");
86
 
87
						var col5 = currentRow.find(
88
							"td:eq(3)  input[type='number']").val();
89
 
90
 
91
						oldtotalAmount = currentRow.find(
92
							"td:eq(5)").html();
93
 
94
						console.log(col5);
95
						if (col5 != undefined) {
96
							if (col5 != 0) {
97
								amount = amount + parseInt(col5, 10);
98
 
99
							}
100
						}
101
					});
102
 
103
 
104
 
105
			$("#totalAmount").text(amount);
106
 
107
		});
108
 
27755 amit.gupta 109
	$(document).on('click', ".updatePaymentDetails",
27819 tejbeer 110
		function() {
111
			console
112
				.log("updatePaymentDetails target Button Clicked...");
113
			var i = 1;
27861 tejbeer 114
			var paymentOptionsTotalAmount = 0;
27819 tejbeer 115
			var invoiceNumber = $(this).data('invoicenumber');
116
			var fofoId = $(this).data('fofoid');
27861 tejbeer 117
			var totalAmount = $('#editAmount').val();
27819 tejbeer 118
			var totalNumberOfPaymentOptionId = $(this).data(
119
				'totalnumberofpaymentoptionid');
120
			console.log("totalNumberOfPaymentOptionId"
121
				+ totalNumberOfPaymentOptionId);
122
			var referenceId = $(this).data('orderid');
123
			var referenceType = "ORDER";
124
			var createdTimeStamp = $(this).data('createddatetime');
125
			console.log(createdTimeStamp);
126
			console.log(fofoId);
127
			console.log(referenceId);
128
			console.log(invoiceNumber);
129
			console.log(referenceType);
130
			var paymentOptionTransactionModels = [];
27861 tejbeer 131
			var jsonObject = {};
27819 tejbeer 132
			var inputvalues = {};
133
			$('.paymentOptions input')
134
				.each(
24105 govind 135
					function() {
27819 tejbeer 136
						console.log($(this).val())
27861 tejbeer 137
						paymentOptionsTotalAmount += parseInt($(this).val(), 10)
27819 tejbeer 138
						if (!isFinite($(this).val())) {
139
							return;
140
						}
141
						inputvalues = {};
142
						inputvalues['paymentOptionId'] = $(
143
							this).data(
144
								'payment-option-id');
145
						inputvalues['amount'] = $(this)
146
							.val();
147
						inputvalues['createdTimeStamp'] = createdTimeStamp;
24105 govind 148
						console
27819 tejbeer 149
							.log(inputvalues['createdTimeStamp']);
150
						if (!inputvalues['amount']) {
151
							inputvalues['amount'] = "0";
24880 govind 152
						}
27819 tejbeer 153
						console.log("inputvalues['amount']"
154
							+ inputvalues['amount']);
155
						paymentOptionTransactionModels
156
							.push(inputvalues);
157
					});
158
			if (paymentOptionTransactionModels.length != totalNumberOfPaymentOptionId) {
159
				alert("Sending less or more paymentOptionIds for"
160
					+ fofoId);
161
				return false;
162
			}
27861 tejbeer 163
 
164
 
165
 
166
			var ItemIdsAmountArray = [];
167
			var itemIdsAmount;
168
			$('#fofo-item-table')
169
				.find('tr')
170
				.each(
171
					function() {
172
						var row = $(this);
173
						console.log(row);
174
 
175
 
176
 
177
						var currentRow = $(this)
178
							.closest("tr");
179
 
180
						var itemId = currentRow.find(
181
							"td:eq(0)").html();
182
 
183
						var col5 = currentRow.find(
184
							"td:eq(3)  input[type='number']").val();
185
						var fofoItemId = currentRow.find(
186
							"td:eq(3)  input[type='hidden']").val();
187
						console.log(itemId)
188
 
189
						console.log(col5);
190
						if (col5 != undefined) {
191
							if (col5 != 0) {
192
 
193
								itemIdsAmount = {
194
									"fofoItemId": fofoItemId,
195
									"amount": col5,
196
									"itemId": itemId
197
 
198
								}
199
								console.log(itemIdsAmount);
200
								ItemIdsAmountArray.push(itemIdsAmount);
201
 
202
								console.log(ItemIdsAmountArray)
203
							}
204
						}
205
					});
206
 
207
 
208
			var totalAmount = $("#totalAmount").html();
209
			console.log(totalAmount)
210
			console.log(paymentOptionsTotalAmount)
211
			if (paymentOptionsTotalAmount != totalAmount) {
212
				alert("Payment Options and Total Amount are not Same");
213
				return false;
214
			}
215
 
27819 tejbeer 216
			console.log(paymentOptionTransactionModels);
27861 tejbeer 217
			jsonObject['paymentOptionTransactionModel'] = paymentOptionTransactionModels;
218
			jsonObject['itemAmountModel'] = ItemIdsAmountArray;
219
 
220
			console.log(jsonObject);
27819 tejbeer 221
			if (confirm("Are you sure you want to update paymentTransaction!") == true) {
222
				doPutAjaxRequestWithJsonHandler(
223
					context
224
					+ "/updatePaymentTransaction?referenceId="
225
					+ referenceId + "&referenceType="
226
					+ referenceType + "&fofoId="
27861 tejbeer 227
					+ fofoId + "&totalAmount=" + totalAmount,
27819 tejbeer 228
					JSON
27861 tejbeer 229
						.stringify(jsonObject),
27819 tejbeer 230
					function(response) {
231
						if (response === 'true') {
232
							alert("successfully added");
233
							loadSearchOrderDetails(
234
								invoiceNumber,
235
								"search-order-details-container");
24105 govind 236
						}
237
					});
27819 tejbeer 238
			}
24105 govind 239
 
27819 tejbeer 240
		});
241
 
27755 amit.gupta 242
	$(document).on('change', '#searchType',
27819 tejbeer 243
		function() {
244
			var searchType = $("#searchType option:selected").val();
245
			var searchTypevalue = $(this).find('option:selected').text();
246
			;
247
			saleSearchObj.searchType = searchType;
248
			console.log("selected searchType = " + searchType);
24105 govind 249
 
27819 tejbeer 250
			saleHistory("main-content", saleSearchObj.searchType, "",
251
				startDate, endDate);
24105 govind 252
 
27819 tejbeer 253
			$("#sale-history-search-text").val('');
254
		});
23973 govind 255
 
27755 amit.gupta 256
	$(document).on('click', "#sale-history-search-button",
27819 tejbeer 257
		function() {
258
			var searchType = $("#searchType option:selected").val();
259
			console.log("searchType = " + searchType);
260
			$("#searchType").removeClass("border-highlight");
261
			saleSearchObj.searchText = $(
262
				"#sale-history-search-text").val();
263
			saleSearchObj.searchType = searchType;
264
			saleSearchObj.startTime = startDate;
265
			saleSearchObj.endTime = endDate;
266
			if (typeof (saleSearchObj.searchText) == "undefined"
267
				|| !saleSearchObj.searchText) {
268
				saleSearchObj.searchText = "";
269
			}
270
			saleHistorySearchInfo(saleSearchObj.searchType,
271
				saleSearchObj.searchText,
272
				saleSearchObj.startTime, saleSearchObj.endTime);
273
		});
27755 amit.gupta 274
	$(document).on('click', "#invoice-download-button",
27819 tejbeer 275
		function() {
276
			var searchType = $("#searchType option:selected").val();
277
			console.log("searchType = " + searchType);
278
			$("#searchType").removeClass("border-highlight");
279
			saleSearchObj.searchText = $(
280
				"#sale-history-search-text").val();
281
			saleSearchObj.searchType = searchType;
282
			saleSearchObj.startTime = startDate;
283
			saleSearchObj.endTime = endDate;
284
			if (typeof (saleSearchObj.searchText) == "undefined"
285
				|| !saleSearchObj.searchText) {
286
				saleSearchObj.searchText = "";
287
			}
288
			downloadInvoices(saleSearchObj.searchType,
289
				saleSearchObj.searchText,
290
				saleSearchObj.startTime, saleSearchObj.endTime);
291
		});
23973 govind 292
 
27754 amit.gupta 293
	$(document).on('click', ".search-order", function() {
23584 ashik.ali 294
		console.log("search-order clicked")
295
		loadSearchOrder("main-content");
23973 govind 296
	});
297
 
27819 tejbeer 298
	$(document).on('click', ".invoices-cancel", function() {
299
		console.log("searc-order clicked")
300
		loadInvoiceSearchOrder("main-content");
301
	});
302
 
27755 amit.gupta 303
	$(document).on('click', "#search-order-button",
27819 tejbeer 304
		function() {
305
			console.log("search-order-button clicked")
306
			var invoiceNumber = $("#search-order-text").val();
307
			loadSearchOrderDetails(invoiceNumber,
308
				"search-order-details-container");
309
		});
23973 govind 310
 
27819 tejbeer 311
	$(document).on('click', "#search-invoice-button",
312
		function() {
313
			console.log("search-order-button clicked")
314
			var invoiceNumber = $("#search-invoice-text").val();
315
			console.log(invoiceNumber);
316
			loadSearchOrderDetails(invoiceNumber,
317
				"search-order-details-container");
318
		});
319
 
320
 
321
 
322
	$(document).on('click', "#cancel-invoice-button",
323
		function() {
324
			var invoiceNumber = $("#search-invoice-text").val();
325
			console.log(invoiceNumber);
326
			if (confirm("Are you sure you want to cancel the order !") == true) {
327
				doPostAjaxRequestHandler(context
328
					+ "/cancelOrderByInvoice?invoiceNumbers="
329
					+ invoiceNumber, function(response) {
330
						if (response == 'true') {
331
							alert("Successfully Cancel");
332
							loadInvoiceSearchOrder("main-content");
333
						}
334
					});
335
 
336
				return false;
337
			}
338
		});
339
 
27755 amit.gupta 340
	$(document).on('click', "#sale-history-paginated .next",
27819 tejbeer 341
		function() {
342
			var params = {};
343
			params['searchType'] = saleSearchObj.searchType;
344
			params['searchValue'] = saleSearchObj.searchText;
345
			params['startTime'] = walletHistory.startTime;
346
			params['endTime'] = walletHistory.endTime;
347
			loadPaginatedNextItems('/getPaginatedSaleHistory', params,
348
				'sale-history-paginated', 'sale-history-table',
349
				'sale-details-container');
350
			$(this).blur();
351
		});
27755 amit.gupta 352
	$(document).on('click', "#insurance-paginated .next",
27819 tejbeer 353
		function() {
354
			loadPaginatedNextItems('/insuranceDetailsPaginated', null,
355
				'insurance-paginated', 'insurance-details-table',
356
				'insurance-policy-details-container');
357
			$(this).blur();
358
		});
27755 amit.gupta 359
	$(document).on('click', "#insurance-paginated .previous",
27819 tejbeer 360
		function() {
361
			loadPaginatedNextItems('/insuranceDetailsPaginated', null,
362
				'insurance-paginated', 'insurance-details-table',
363
				'insurance-policy-details-container');
364
			$(this).blur();
365
		});
23973 govind 366
 
27755 amit.gupta 367
	$(document).on('click', "#sale-history-paginated .previous",
27819 tejbeer 368
		function() {
369
			var params = {};
370
			params['searchType'] = saleSearchObj.searchType;
371
			params['searchValue'] = saleSearchObj.searchText;
372
			params['startTime'] = walletHistory.startTime;
373
			params['endTime'] = walletHistory.endTime;
374
			loadPaginatedPreviousItems('/getPaginatedSaleHistory', params,
375
				'sale-history-paginated', 'sale-history-table',
376
				'sale-details-container');
377
			$(this).blur();
378
		});
23973 govind 379
 
380
	// grn-details
381
 
27754 amit.gupta 382
	$(document).on('click', ".sale-details", function() {
23654 amit.gupta 383
		orderId = $(this).attr('data');
23973 govind 384
		console.log("orderId = " + orderId);
385
		loadSaleDetails(orderId, "sale-details-container");
23343 ashik.ali 386
	});
27861 tejbeer 387
 
388
	$(document).on('click', "#editamountbutton", function() {
389
		$('#editAmount').show();
390
	});
391
 
392
 
393
 
394
 
395
 
23343 ashik.ali 396
});
397
 
23973 govind 398
function loadSaleDetails(orderId, domId) {
399
	doGetAjaxRequestHandler(context + "/saleDetails?orderId=" + orderId,
27819 tejbeer 400
		function(response) {
401
			$('#' + domId).html(response);
402
		});
23343 ashik.ali 403
}
404
 
26647 tejbeer 405
function loadPendingOrder(domId) {
406
	doGetAjaxRequestHandler(context + "/pendingOrders", function(response) {
407
		$('#' + domId).html(response);
408
 
409
	});
410
}
411
 
23973 govind 412
function loadSearchOrder(domId) {
413
	doGetAjaxRequestHandler(context + "/getSearchOrder", function(response) {
23584 ashik.ali 414
		$('#' + domId).html(response);
415
	});
416
}
417
 
27819 tejbeer 418
function loadInvoiceSearchOrder(domId) {
419
	console.log("Hello");
420
	doGetAjaxRequestHandler(context + "/getInvoiceSearchOrder", function(response) {
23584 ashik.ali 421
		$('#' + domId).html(response);
422
	});
423
}
424
 
27819 tejbeer 425
function loadSearchOrderDetails(invoiceNumber, domId) {
426
	doGetAjaxRequestHandler(context + "/searchOrderDetails?invoiceNumber="
427
		+ invoiceNumber, function(response) {
428
			$('#' + domId).html(response);
27861 tejbeer 429
			$('#editAmount').hide();
430
 
27819 tejbeer 431
		});
432
}
433
 
23973 govind 434
function saleHistory(domId, searchType, searchValue, startTime, endTime) {
435
	doGetAjaxRequestHandler(context + "/saleHistory?searchType=" + searchType
27819 tejbeer 436
		+ "&searchValue=" + searchValue + "&startTime=" + startTime
437
		+ "&endTime=" + endTime, function(response) {
438
			$('#' + domId).html(response);
439
		});
23343 ashik.ali 440
}
441
 
23973 govind 442
function saleHistorySearchInfo(searchType, searchText, startTime, endTime) {
23343 ashik.ali 443
	saleHistory("main-content", searchType, searchText, startTime, endTime);
24105 govind 444
 
445
}
24880 govind 446
function insurancePolicyDetails(domId) {
447
	doGetAjaxRequestHandler(context + "/insuranceDetails", function(response) {
448
		$('#' + domId).html(response);
449
	});
450
}
25093 amit.gupta 451
 
452
function downloadInvoices(searchType, searchValue, startTime, endTime) {
453
	doAjaxGetDownload(context + "/downloadInvoices?searchType=" + searchType
27819 tejbeer 454
		+ "&searchValue=" + searchValue + "&startTime=" + startTime
455
		+ "&endTime=" + endTime, "invoices.pdf");
25093 amit.gupta 456
}