Subversion Repositories SmartDukaan

Rev

Rev 24992 | Rev 26487 | 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();
11
				var type = $('#reference-type option:selected').val();
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() {
39
		var type = $('#reference-type option:selected').val();
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();
50
				var type = $('#reference-type option:selected').val();
51
				var transactiontype = $('#transaction-type').val();
52
				var amount = $('#amount').val();
53
				var description = $('#description').val();
54
				var retailerId = currentFofoId
55
				console.log(currentFofoId)
24942 tejbeer 56
				console.log(type);
24876 tejbeer 57
				if (type == "") {
58
					alert("Please Choose Reference Type");
59
					return;
60
				}
24942 tejbeer 61
				if(type!='INCENTIVES'&&type!='OTHERS'){
62
 
63
					if(reference == ""){
64
						alert("Reference Id is required");
65
						return;
66
					}
67
				}
68
 
24876 tejbeer 69
				if (transactiontype == "") {
70
					alert("Please Choose Transaction Type");
71
					return;
72
				}
73
				if (amount == "") {
74
					alert("amount is required");
75
					return;
76
				}
77
 
78
				if (description == "") {
79
					alert("description is required");
80
					return;
81
				}
82
				if (retailerId == "") {
83
					alert("partner name is required");
84
					return;
85
				}
86
 
87
				if (confirm("Are you sure you want update wallet") == true) {
88
 
89
					doPostAjaxRequestHandler(context
90
							+ "/walletUpdate?reference=" + reference
91
							+ "&referenceType=" + type + "&transactiontype="
92
							+ transactiontype + "&amount=" + amount
93
							+ "&description=" + description + "&retailerId="
94
							+ currentFofoId, function(response) {
24942 tejbeer 95
						if (response != 0) {
24876 tejbeer 96
							alert("successfully submit");
24942 tejbeer 97
							console.log(response)
98
							$("#reference_id").val(response);
24992 tejbeer 99
						//	$("button.referenceSearch").click();
100
							$("button.fetchTransactions").click();
25018 tejbeer 101
						}else{
102
							alert("failed transaction")
24876 tejbeer 103
						}
25018 tejbeer 104
 
24876 tejbeer 105
					});
106
				}
107
			});
108
 
109
});
110
function loadManualPayment(domId) {
111
	doGetAjaxRequestHandler(context + "/manualPayment", function(response) {
112
		$('#' + domId).html(response);
113
	});
114
}