Subversion Repositories SmartDukaan

Rev

Rev 29937 | Rev 34580 | 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');
34142 tejus.loha 59
		if(!fofoId){
60
			fofoId =$('select[name="fofo-users"]').val();
61
			console.log("fofo Id -"+fofoId);
62
		}
23638 amit.gupta 63
		doAjaxRequestHandler(context+"/return/inventory/" + fofoId + "/" + itemId, "GET", function(response){
64
			returnsTable.rows().remove().rows.add($(response)).draw(false);
65
		});
66
	});
23506 amit.gupta 67
});
68
 
23638 amit.gupta 69
function viewReturnStores(domId){
70
	doAjaxRequestHandler(context+"/return/stores", "GET", function(response){
23506 amit.gupta 71
		$('#' + domId).html(response);
72
	});
73
}
74
 
75
function viewPendingReturns(domId){
76
	doAjaxRequestHandler(context+"/return/pending", "GET", function(response){
77
		$('#' + domId).html(response);
78
	});
79
}
80
 
81
function viewApprovedReturns(domId){
82
	doAjaxRequestHandler(context+"/return/approved", "GET", function(response){
83
		$('#' + domId).html(response);
84
		$("#approved-returns").find('a:first').click();
85
	});
86
}
87
 
23539 amit.gupta 88
function viewDebitNotes(domId){
89
	doAjaxRequestHandler(context+"/return/debit-note-created", "GET", function(response){
90
		$('#' + domId).html(response);
91
		$("#debit-notes").find('a:first').click();
92
	});
93
}
94
 
23506 amit.gupta 95
function createReturnRequest(inventoryItemId, container){
96
	doAjaxRequestHandler(context+"/return/inventory/" + inventoryItemId, "PUT", function(response){
97
		if(response=='true') {
98
			container.closest('td').html('Return requested');
99
		}
100
	});
101
}
102
 
103
function approveReturnRequest(inventoryItemId, container){
104
	doAjaxRequestHandler(context+"/return/inventory/approve/" + inventoryItemId, "PUT", function(response){
105
		if(response=='true') {
106
			container.closest('td').html('Return Approved');
107
		}
108
	});
109
}
110
 
111
function denyReturnRequest(inventoryItemId, container){
112
	doAjaxRequestHandler(context+"/return/inventory/deny/" + inventoryItemId, "PUT", function(response){
113
		if(response=='true') {
114
			container.closest('td').html('Return denied');
115
		}
116
	});
117
}
118
 
119
function viewDebitNote(warehouseId){
120
	doAjaxRequestHandler(context+"/return/debit-note/view/" + warehouseId, "GET", function(response){
121
		//Download PDF code
122
	});
123
}
124
 
125
function generateDebitNote(warehouseId){
126
	doAjaxRequestHandler(context+"/return/debit-note/generate/" + warehouseId, "PUT", function(response){
127
		if(response=='true') {
128
			//Download the pdf 
129
		}
130
	});	
131
}
132
 
133
function getDebitNote(debitNotedId) {
134
	doAjaxRequestHandler(context+"/return/debit-note/" + debitNotedId, "GET", function(response){
135
 
136
	});
137
}
138