Subversion Repositories SmartDukaan

Rev

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