Subversion Repositories SmartDukaan

Rev

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