Subversion Repositories SmartDukaan

Rev

Rev 28722 | 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 () {
2
	$(document).on('click', ".unsettled-payments", function () {
24089 tejbeer 3
		loadPaymentsRequest("main-content");
4
	});
30599 amit.gupta 5
 
6
	$(document).on('click', '.create-unsettled-payments', function () {
24089 tejbeer 7
		var transactionReference = $('input[name="transactionReference"]').val();
8
		var description = $('input[name="description"]').val();
30599 amit.gupta 9
		var amount = $('input[name="amount"]').val();
10
		var referencedate = $('#referencedate').val();
24089 tejbeer 11
 
30599 amit.gupta 12
 
13
		if (transactionReference === "" && description === "" && amount === "" && referencedate === "") {
14
			alert("Field can't be empty");
15
			return;
16
		}
17
 
18
		if (transactionReference === "") {
19
			alert("Transaction Reference is required");
20
			return;
21
		}
22
		if (description === "") {
23
			alert("Description is required");
24
			return;
25
		}
26
		if (amount === "") {
27
			alert("amount is required");
28
			return;
29
		}
30
		if (referencedate === "") {
31
			alert("Reference Date is required");
32
			return;
33
		}
34
 
35
		var unsettledData = {};
36
 
37
		unsettledData['transactionReference'] = $('input[name="transactionReference"]').val();
38
		unsettledData['description'] = $('input[name="description"]').val();
39
		unsettledData['referenceDate'] = getDatesFromPicker('input[name="dateTime"]').startDate;
40
		unsettledData['amount'] = $('input[name="amount"]').val();
41
		if (confirm("Are you sure you want to create Payment") == true) {
42
			doPostAjaxRequestWithJsonHandler(context + "/createUnsettledPaymentsEntries", JSON.stringify(unsettledData), function (response) {
43
				if (response == 'true') {
44
					alert("successfully create");
24089 tejbeer 45
					loadPaymentsRequest("main-content");
30599 amit.gupta 46
				}
24089 tejbeer 47
			});
30599 amit.gupta 48
 
49
			return false;
50
		}
24089 tejbeer 51
	});
30599 amit.gupta 52
 
53
 
54
	$(document).on('click', ".remove-unsettledPayment",
55
		function () {
56
			if (confirm("Are you sure you want to Remove the Entry")) {
57
				id = $(this).data('requestid');
58
				console.log(id);
59
				unsettledRequestRemoved(id);
60
			}
61
		});
24089 tejbeer 62
});
63
 
64
 
30599 amit.gupta 65
function unsettledRequestRemoved(id) {
66
	doDeleteAjaxRequestHandler(context + "/removeUnsettledPaymentsEntries?id=" + id, function (response) {
67
		if (response == 'true') {
68
			alert("successfully Removed");
24089 tejbeer 69
			loadPaymentsRequest("main-content");
30599 amit.gupta 70
		}
24089 tejbeer 71
 
72
	});
73
 
74
}
75
 
30599 amit.gupta 76
function loadPaymentsRequest(domId) {
77
	doGetAjaxRequestHandler(context + "/getcreateUnsettledPayments", function (response) {
24089 tejbeer 78
		$('#' + domId).html(response);
79
	});
30599 amit.gupta 80
}