Subversion Repositories SmartDukaan

Rev

Rev 34261 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
30599 amit.gupta 1
$(function () {
34861 ranu 2
	$(document).on('click', ".franchisee-accounts", function () {
3
		console.log("Franchisee accounts clicked");
4
		loadFranchiseeAccount("main-content");
5
	});
24876 tejbeer 6
 
30599 amit.gupta 7
	$(document).on('click', ".wallet-edit", function () {
24876 tejbeer 8
		loadManualPayment("main-content");
9
	});
10
 
27755 amit.gupta 11
	$(document).on('click', ".referenceSearch",
30599 amit.gupta 12
		function () {
13
			var reference = $('#reference_id').val();
14
			var type = $('#reference-type option:selected').html();
24876 tejbeer 15
 
30599 amit.gupta 16
			if (type == "" || type == null || type == undefined) {
17
				alert("Please Choose Reference Type");
18
				return false;
19
			}
24876 tejbeer 20
 
30599 amit.gupta 21
			doGetAjaxRequestHandler(context
22
				+ "/getWalletHistory?reference=" + reference
23
				+ "&referenceType=" + type, function (response) {
24
 
25
 
26
				doGetAjaxRequestHandler(context + "/getPartnerName?reference="
27
					+ reference + "&referenceType=" + type, function (
28
					response) {
29
					response = JSON.parse(response);
30
					console.log(response.businessName + "-" + response.address.city)
31
					$("#FofoId").val(response.businessName + "-" + response.address.city);
32
					currentFofoId = response.partnerId;
24876 tejbeer 33
				});
30599 amit.gupta 34
				$('.wallet-history-container').html(response);
35
			});
24876 tejbeer 36
 
37
 
30599 amit.gupta 38
		});
39
 
40
	$(document).on('click', ".fetchTransactions", function () {
26518 amit.gupta 41
		var type = $('#reference-type option:selected').html();
30599 amit.gupta 42
		if ($('#reference-type option:selected').val() == "") {
26520 amit.gupta 43
			type = "";
44
		}
30599 amit.gupta 45
		doGetAjaxRequestHandler(context
46
			+ "/getWalletHistoryByPartner?referenceType=" + type + "&fofoId=" + currentFofoId, function (response) {
24896 amit.gupta 47
			$('.wallet-history-container').html(response);
24992 tejbeer 48
			$("#wallet-form")[0].reset();
24896 amit.gupta 49
		});
50
	});
24876 tejbeer 51
 
27755 amit.gupta 52
	$(document).on('click', ".transactionSubmit",
30599 amit.gupta 53
		function () {
54
			var reference = $('#reference_id').val();
55
			var typeValue = $('#reference-type option:selected').val();
56
			var transactiontype = $('#transaction-type').val();
57
			var amount = $('#amount').val();
58
			var description = $('#description').val();
59
			var retailerId = currentFofoId
60
			console.log(currentFofoId)
61
			console.log(typeValue);
62
			if (typeValue == "") {
63
				alert("Please Choose Reference Type");
64
				return;
65
			}
66
			if (typeValue < 16) {
67
				if (reference == "") {
68
					alert("Reference Id is required");
24876 tejbeer 69
					return;
70
				}
30599 amit.gupta 71
			}
24876 tejbeer 72
 
30599 amit.gupta 73
			if (transactiontype == "") {
74
				alert("Please Choose Transaction Type");
75
				return;
76
			}
77
			if (amount == "") {
78
				alert("amount is required");
79
				return;
80
			}
81
 
82
			if (description == "") {
83
				alert("description is required");
84
				return;
85
			}
86
			if (retailerId == "") {
87
				alert("Partner name is required");
88
				return;
89
			}
90
			let startDate = getDatesFromPicker($("#businessDate")).startDate;
91
			if (confirm("Business Date is " + startDate.split("T")[0] + "?") == true) {
92
				if (confirm("Are you sure you want update wallet") == true) {
93
 
94
					doPostAjaxRequestHandler(context
95
						+ "/walletUpdate?reference=" + reference
96
						+ "&referenceTypeValue=" + typeValue + "&transactiontype="
97
						+ transactiontype + "&amount=" + amount
98
						+ "&description=" + description + "&retailerId="
99
						+ currentFofoId + "&businessTimestamp=" + startDate, function (response) {
100
						if (response != 0) {
101
							alert("successfully submit");
102
							console.log(response)
103
							$("#reference_id").val(response);
104
							//	$("button.referenceSearch").click();
105
							$("button.fetchTransactions").click();
106
						} else {
107
							alert("failed transaction")
24876 tejbeer 108
						}
30599 amit.gupta 109
 
110
					});
24876 tejbeer 111
				}
30599 amit.gupta 112
			}
26487 amit.gupta 113
 
30599 amit.gupta 114
		});
24876 tejbeer 115
 
116
});
30599 amit.gupta 117
 
34261 tejus.loha 118
 
119
// [id^="downloadAddWalletRequest"] - all id that start with downloadAddWalletRequest
120
$(document).on('click', '[id^="downloadAddWalletRequest"]', function() {
121
	const startDate = $('input[name="from"]').val();
122
	const endDate = $('input[name="to"]').val();
123
	const buttonId = $(this).attr('id');
124
 
125
	console.log("startDate - ", startDate);
126
	console.log("endDate - ", endDate);
127
	const reportTypes = {
128
		'downloadAddWalletRequestPendingReport': 'pending',
129
		'downloadAddWalletRequestApprovedReport': 'approved',
130
		'downloadAddWalletRequestRejectReport': 'rejected'
131
	};
132
 
133
	const reportType = reportTypes[buttonId];
134
	console.log("reportType - ", reportType);
135
	if (reportType) {
136
		window.location.href = `${context}/downloadAddWalletRequestReport?status=${reportType}&startDate=${startDate}&endDate=${endDate}`;
137
	}
138
});
139
 
24876 tejbeer 140
function loadManualPayment(domId) {
30599 amit.gupta 141
	doGetAjaxRequestHandler(context + "/manualPayment", function (response) {
24876 tejbeer 142
		$('#' + domId).html(response);
143
	});
144
}
34861 ranu 145
 
146
function loadFranchiseeAccount(domId) {
147
	doGetAjaxRequestHandler(context + "/loadFranchiseeAccount",
148
		function (response) {
149
			$('#' + domId).html(response);
150
		});
151
}