Subversion Repositories SmartDukaan

Rev

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

Rev Author Line No. Line
23506 amit.gupta 1
$(function() {
2
	$("a.view-returns").live('click', function() {
3
		viewReturns("main-content");
4
	});
5
	$("a.pending-returns").live('click', function() {
6
		viewPendingReturns("main-content");
7
	});
8
	$("a.approved-returns").live('click', function() {
9
		viewApprovedReturns("main-content");
10
	});
11
 
23539 amit.gupta 12
	$("a.view-debit-note").live('click', function() {
13
		viewDebitNotes("main-content");
14
	});
15
 
23506 amit.gupta 16
	$("a.wh-display-name").live('click', function() {
17
		var whId = $(this).closest('tr').data('id');
18
		$("#approved-returns-container").find("tr.filter").hide().filter('[data-id="' + whId + '"]').show();
19
		$(this).closest('tr').removeClass('warning');
20
		$(this).closest('tr').addClass('warning');
21
	});
23539 amit.gupta 22
 
23
	$("a.debit-note").live('click', function() {
24
		var debitNoteId = $(this).closest('tr').data('id');
25
		$("#debit-note-items").find("tr.filter").hide().filter('[data-id="' + debitNoteId + '"]').show();
26
		$(this).closest('tr').removeClass('warning');
27
		$(this).closest('tr').addClass('warning');
28
	});
23506 amit.gupta 29
 
30
 
31
	$("a.request-return").live('click', function() {
32
		if(confirm("Are you sure?")) {
33
			createReturnRequest($(this).data("inventoryitemid"), $(this));
34
		}
35
	});
36
	$("a.approve-return").live('click', function() {
37
		if(confirm("Are you sure to Approve?")) {
38
			approveReturnRequest($(this).closest('td').data("inventoryitemid"), $(this).closest('td'));
39
		}
40
	});
41
	$("a.deny-return").live('click', function() {
42
		if(confirm("Are you sure to Deny?")) {
43
			denyReturnRequest($(this).closest('td').data("inventoryitemid"), $(this).closest('td'));
44
		}
45
	});
23532 amit.gupta 46
	/*$("a.generate-debit-note").live('click', function() {
23506 amit.gupta 47
		if(confirm("Are you sure?")) {
48
			generateDebitNote($(this).closest('tr').data("id"));
49
		}
23532 amit.gupta 50
	});*/
23506 amit.gupta 51
});
52
 
53
function viewReturns(domId){
54
	doAjaxRequestHandler(context+"/return/inventory", "GET", function(response){
55
		$('#' + domId).html(response);
56
	});
57
}
58
 
59
function viewPendingReturns(domId){
60
	doAjaxRequestHandler(context+"/return/pending", "GET", function(response){
61
		$('#' + domId).html(response);
62
	});
63
}
64
 
65
function viewApprovedReturns(domId){
66
	doAjaxRequestHandler(context+"/return/approved", "GET", function(response){
67
		$('#' + domId).html(response);
68
		$("#approved-returns").find('a:first').click();
69
	});
70
}
71
 
23539 amit.gupta 72
function viewDebitNotes(domId){
73
	doAjaxRequestHandler(context+"/return/debit-note-created", "GET", function(response){
74
		$('#' + domId).html(response);
75
		$("#debit-notes").find('a:first').click();
76
	});
77
}
78
 
23506 amit.gupta 79
function createReturnRequest(inventoryItemId, container){
80
	doAjaxRequestHandler(context+"/return/inventory/" + inventoryItemId, "PUT", function(response){
81
		if(response=='true') {
82
			container.closest('td').html('Return requested');
83
		}
84
	});
85
}
86
 
87
function approveReturnRequest(inventoryItemId, container){
88
	doAjaxRequestHandler(context+"/return/inventory/approve/" + inventoryItemId, "PUT", function(response){
89
		if(response=='true') {
90
			container.closest('td').html('Return Approved');
91
		}
92
	});
93
}
94
 
95
function denyReturnRequest(inventoryItemId, container){
96
	doAjaxRequestHandler(context+"/return/inventory/deny/" + inventoryItemId, "PUT", function(response){
97
		if(response=='true') {
98
			container.closest('td').html('Return denied');
99
		}
100
	});
101
}
102
 
103
function viewDebitNote(warehouseId){
104
	doAjaxRequestHandler(context+"/return/debit-note/view/" + warehouseId, "GET", function(response){
105
		//Download PDF code
106
	});
107
}
108
 
109
function generateDebitNote(warehouseId){
110
	doAjaxRequestHandler(context+"/return/debit-note/generate/" + warehouseId, "PUT", function(response){
111
		if(response=='true') {
112
			//Download the pdf 
113
		}
114
	});	
115
}
116
 
117
function getDebitNote(debitNotedId) {
118
	doAjaxRequestHandler(context+"/return/debit-note/" + debitNotedId, "GET", function(response){
119
 
120
	});
121
}
122