Subversion Repositories SmartDukaan

Rev

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