Subversion Repositories SmartDukaan

Rev

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

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