Subversion Repositories SmartDukaan

Rev

Rev 26520 | Rev 27755 | 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
 
27754 amit.gupta 3
	$(document).on('click', ".wallet-edit", function() {
24876 tejbeer 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
 
27754 amit.gupta 38
	$(document).on('click', ".fetchTransactions", function() {
26518 amit.gupta 39
		var type = $('#reference-type option:selected').html();
26520 amit.gupta 40
		if($('#reference-type option:selected').val()=="") {
41
			type = "";
42
		}
43
				doGetAjaxRequestHandler(context
44
						+ "/getWalletHistoryByPartner?referenceType="+type+"&fofoId=" + currentFofoId, function(response) {
24896 amit.gupta 45
			$('.wallet-history-container').html(response);
24992 tejbeer 46
			$("#wallet-form")[0].reset();
24896 amit.gupta 47
		});
48
	});
24876 tejbeer 49
 
50
	$(".transactionSubmit").live(
51
			'click',
52
			function() {
53
				var reference = $('#reference_id').val();
26517 amit.gupta 54
				var typeValue = $('#reference-type option:selected').val();
24876 tejbeer 55
				var transactiontype = $('#transaction-type').val();
56
				var amount = $('#amount').val();
57
				var description = $('#description').val();
58
				var retailerId = currentFofoId
59
				console.log(currentFofoId)
26517 amit.gupta 60
				console.log(typeValue);
61
				if (typeValue == "") {
24876 tejbeer 62
					alert("Please Choose Reference Type");
63
					return;
64
				}
26517 amit.gupta 65
				if(typeValue < 16){
24942 tejbeer 66
					if(reference == ""){
67
						alert("Reference Id is required");
68
						return;
69
					}
70
				}
71
 
24876 tejbeer 72
				if (transactiontype == "") {
73
					alert("Please Choose Transaction Type");
74
					return;
75
				}
76
				if (amount == "") {
77
					alert("amount is required");
78
					return;
79
				}
80
 
81
				if (description == "") {
82
					alert("description is required");
83
					return;
84
				}
85
				if (retailerId == "") {
26487 amit.gupta 86
					alert("Partner name is required");
24876 tejbeer 87
					return;
88
				}
26490 amit.gupta 89
				if (typeof startDate == "string") {
26487 amit.gupta 90
					if (confirm("Business Date is " + startDate.split("T")[0] + "?") == true) {
91
						if (confirm("Are you sure you want update wallet") == true) {
92
 
93
							doPostAjaxRequestHandler(context
94
									+ "/walletUpdate?reference=" + reference
26517 amit.gupta 95
									+ "&referenceTypeValue=" + typeValue + "&transactiontype="
26487 amit.gupta 96
									+ transactiontype + "&amount=" + amount
97
									+ "&description=" + description + "&retailerId="
98
									+ currentFofoId +"&businessTimestamp=" + startDate, function(response) {
99
								if (response != 0) {
100
									alert("successfully submit");
101
									console.log(response)
102
									$("#reference_id").val(response);
103
								//	$("button.referenceSearch").click();
104
									$("button.fetchTransactions").click();
105
								}else{
106
									alert("failed transaction")
107
								}
108
 
109
							});
24876 tejbeer 110
						}
26487 amit.gupta 111
					}
26490 amit.gupta 112
				} else {
113
					alert("Valid date is required");
24876 tejbeer 114
				}
26487 amit.gupta 115
 
24876 tejbeer 116
			});
117
 
118
});
119
function loadManualPayment(domId) {
120
	doGetAjaxRequestHandler(context + "/manualPayment", function(response) {
121
		$('#' + domId).html(response);
122
	});
123
}