Subversion Repositories SmartDukaan

Rev

Rev 24942 | Rev 25018 | 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) {
21
					$('.wallet-history-container').html(response);
24942 tejbeer 22
 
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
					});
24876 tejbeer 31
				});
32
 
24942 tejbeer 33
 
24876 tejbeer 34
 
35
			});
24892 amit.gupta 36
 
24896 amit.gupta 37
	$(".fetchTransactions").live('click', function() {
38
		var type = $('#reference-type option:selected').val();
39
		doGetAjaxRequestHandler(context + "/getWalletHistoryByPartner?referenceType="+type+"&fofoId=" + currentFofoId, function(response) {
40
			$('.wallet-history-container').html(response);
24992 tejbeer 41
			$("#wallet-form")[0].reset();
24896 amit.gupta 42
		});
43
	});
24876 tejbeer 44
 
45
	$(".transactionSubmit").live(
46
			'click',
47
			function() {
48
				var reference = $('#reference_id').val();
49
				var type = $('#reference-type option:selected').val();
50
				var transactiontype = $('#transaction-type').val();
51
				var amount = $('#amount').val();
52
				var description = $('#description').val();
53
				var retailerId = currentFofoId
54
				console.log(currentFofoId)
24942 tejbeer 55
				console.log(type);
24876 tejbeer 56
				if (type == "") {
57
					alert("Please Choose Reference Type");
58
					return;
59
				}
24942 tejbeer 60
				if(type!='INCENTIVES'&&type!='OTHERS'){
61
 
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 == "") {
82
					alert("partner name is required");
83
					return;
84
				}
85
 
86
				if (confirm("Are you sure you want update wallet") == true) {
87
 
88
					doPostAjaxRequestHandler(context
89
							+ "/walletUpdate?reference=" + reference
90
							+ "&referenceType=" + type + "&transactiontype="
91
							+ transactiontype + "&amount=" + amount
92
							+ "&description=" + description + "&retailerId="
93
							+ currentFofoId, function(response) {
24942 tejbeer 94
						if (response != 0) {
24876 tejbeer 95
							alert("successfully submit");
24942 tejbeer 96
							console.log(response)
97
							$("#reference_id").val(response);
24992 tejbeer 98
						//	$("button.referenceSearch").click();
99
							$("button.fetchTransactions").click();
24876 tejbeer 100
						}
101
					});
102
				}
103
			});
104
 
105
});
106
function loadManualPayment(domId) {
107
	doGetAjaxRequestHandler(context + "/manualPayment", function(response) {
108
		$('#' + domId).html(response);
109
	});
110
}