Subversion Repositories SmartDukaan

Rev

Rev 27755 | Rev 34261 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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