Subversion Repositories SmartDukaan

Rev

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

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