Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
24876 tejbeer 1
$(function() {
2
 
3
	$(".wallet-edit").live('click', function() {
4
		loadManualPayment("main-content");
5
	});
6
 
7
	$(".referenceSearch").live(
8
			'click',
9
			function() {
10
				var reference = $('#reference_id').val();
26518 amit.gupta 11
				var type = $('#reference-type option:selected').html();
24876 tejbeer 12
 
13
				if (type == "" || type == null || type == undefined) {
14
					alert("Please Choose Reference Type");
15
					return false;
16
				}
17
 
18
				doGetAjaxRequestHandler(context
19
						+ "/getWalletHistory?reference=" + reference
20
						+ "&referenceType=" + type, function(response) {
24942 tejbeer 21
 
25018 tejbeer 22
 
24942 tejbeer 23
					doGetAjaxRequestHandler(context + "/getPartnerName?reference="
24
							+ reference + "&referenceType=" + type, function(
25
							response) {
26
						response=JSON.parse(response);
27
						console.log(response.businessName+ "-" + response.address.city)
28
	                   $("#FofoId").val(response.businessName+ "-" + response.address.city);
29
						currentFofoId=response.partnerId;
30
					});
25018 tejbeer 31
					$('.wallet-history-container').html(response);
24876 tejbeer 32
				});
33
 
24942 tejbeer 34
 
24876 tejbeer 35
 
36
			});
24892 amit.gupta 37
 
24896 amit.gupta 38
	$(".fetchTransactions").live('click', function() {
26518 amit.gupta 39
		var type = $('#reference-type option:selected').html();
24896 amit.gupta 40
		doGetAjaxRequestHandler(context + "/getWalletHistoryByPartner?referenceType="+type+"&fofoId=" + currentFofoId, function(response) {
41
			$('.wallet-history-container').html(response);
24992 tejbeer 42
			$("#wallet-form")[0].reset();
24896 amit.gupta 43
		});
44
	});
24876 tejbeer 45
 
46
	$(".transactionSubmit").live(
47
			'click',
48
			function() {
49
				var reference = $('#reference_id').val();
26517 amit.gupta 50
				var typeValue = $('#reference-type option:selected').val();
24876 tejbeer 51
				var transactiontype = $('#transaction-type').val();
52
				var amount = $('#amount').val();
53
				var description = $('#description').val();
54
				var retailerId = currentFofoId
55
				console.log(currentFofoId)
26517 amit.gupta 56
				console.log(typeValue);
57
				if (typeValue == "") {
24876 tejbeer 58
					alert("Please Choose Reference Type");
59
					return;
60
				}
26517 amit.gupta 61
				if(typeValue < 16){
24942 tejbeer 62
					if(reference == ""){
63
						alert("Reference Id is required");
64
						return;
65
					}
66
				}
67
 
24876 tejbeer 68
				if (transactiontype == "") {
69
					alert("Please Choose Transaction Type");
70
					return;
71
				}
72
				if (amount == "") {
73
					alert("amount is required");
74
					return;
75
				}
76
 
77
				if (description == "") {
78
					alert("description is required");
79
					return;
80
				}
81
				if (retailerId == "") {
26487 amit.gupta 82
					alert("Partner name is required");
24876 tejbeer 83
					return;
84
				}
26490 amit.gupta 85
				if (typeof startDate == "string") {
26487 amit.gupta 86
					if (confirm("Business Date is " + startDate.split("T")[0] + "?") == true) {
87
						if (confirm("Are you sure you want update wallet") == true) {
88
 
89
							doPostAjaxRequestHandler(context
90
									+ "/walletUpdate?reference=" + reference
26517 amit.gupta 91
									+ "&referenceTypeValue=" + typeValue + "&transactiontype="
26487 amit.gupta 92
									+ transactiontype + "&amount=" + amount
93
									+ "&description=" + description + "&retailerId="
94
									+ currentFofoId +"&businessTimestamp=" + startDate, function(response) {
95
								if (response != 0) {
96
									alert("successfully submit");
97
									console.log(response)
98
									$("#reference_id").val(response);
99
								//	$("button.referenceSearch").click();
100
									$("button.fetchTransactions").click();
101
								}else{
102
									alert("failed transaction")
103
								}
104
 
105
							});
24876 tejbeer 106
						}
26487 amit.gupta 107
					}
26490 amit.gupta 108
				} else {
109
					alert("Valid date is required");
24876 tejbeer 110
				}
26487 amit.gupta 111
 
24876 tejbeer 112
			});
113
 
114
});
115
function loadManualPayment(domId) {
116
	doGetAjaxRequestHandler(context + "/manualPayment", function(response) {
117
		$('#' + domId).html(response);
118
	});
119
}