Subversion Repositories SmartDukaan

Rev

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