Subversion Repositories SmartDukaan

Rev

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

Rev 34580 Rev 35998
Line 24... Line 24...
24
		var debitNoteId = $(this).closest('tr').data('id');
24
		var debitNoteId = $(this).closest('tr').data('id');
25
		$("#debit-note-items").find("tr.filter").hide().filter('[data-id="' + debitNoteId + '"]').show();
25
		$("#debit-note-items").find("tr.filter").hide().filter('[data-id="' + debitNoteId + '"]').show();
26
		$(this).closest('table').find('tr').removeClass('alert-warning');
26
		$(this).closest('table').find('tr').removeClass('alert-warning');
27
		$(this).closest('tr').addClass('alert-warning');
27
		$(this).closest('tr').addClass('alert-warning');
28
	});
28
	});
29
	
29
 
30
	
30
 
31
	$(document).on('click', "a.request-return", function() {
31
	$(document).on('click', "a.request-return", function() {
32
		if(confirm("Are you sure?")) {
32
		if(confirm("Are you sure?")) {
33
			createReturnRequest($(this).data("inventoryitemid"), $(this));
33
			createReturnRequest($(this).data("inventoryitemid"), $(this));
34
		}
34
		}
35
	});
35
	});
Line 41... Line 41...
41
	$(document).on('click', "a.deny-return", function() {
41
	$(document).on('click', "a.deny-return", function() {
42
		if(confirm("Are you sure to Deny?")) {
42
		if(confirm("Are you sure to Deny?")) {
43
			denyReturnRequest($(this).closest('td').data("returnid"), $(this).closest('td'));
43
			denyReturnRequest($(this).closest('td').data("returnid"), $(this).closest('td'));
44
		}
44
		}
45
	});
45
	});
46
	/*$(document).on('click', "a.generate-debit-note", function() {
-
 
47
		if(confirm("Are you sure?")) {
-
 
48
			generateDebitNote($(this).closest('tr').data("id"));
-
 
49
		}
46
 
50
	});*/
-
 
51
	/*$(document).on('click', '#store-container').find('a', function (){
-
 
52
		fofoId=$(this).data('id');
-
 
53
		doAjaxRequestHandler(context+"/return/inventory/" + fofoId, "GET", function(response){
-
 
54
			inventoryTable.rows().remove().rows.add($(response)).draw(false);
-
 
55
		});
-
 
56
	});*/
-
 
57
	$(document).on('click', '#inventory-container a', function (){
47
	$(document).on('click', '#inventory-container a', function (){
58
		itemId=$(this).data('id');
48
		itemId=$(this).data('id');
59
		if(!fofoId){
49
		if(!fofoId){
60
			fofoId =$('select[name="fofo-users"]').val();
50
			fofoId =$('select[name="fofo-users"]').val();
61
			console.log("fofo Id -"+fofoId);
51
			console.log("fofo Id -"+fofoId);
62
		}
52
		}
63
		doAjaxRequestHandler(context+"/return/inventory/" + fofoId + "/" + itemId, "GET", function(response){
53
		doAjaxRequestHandler(context+"/return/inventory/" + fofoId + "/" + itemId, "GET", function(response){
64
			returnsTable.rows().remove().rows.add($(response)).draw(false);
54
			returnsTable.rows().remove().rows.add($(response)).draw(false);
65
		});
55
		});
66
	});
56
	});
-
 
57
 
-
 
58
	$(document).on('click', '.vendor_return', function () {
-
 
59
		doAjaxRequestHandler(context + "/return/to/vendor", "GET", function (response) {
-
 
60
			$('#main-content').html(response);
-
 
61
		});
-
 
62
	});
-
 
63
 
-
 
64
	// Invoice Return
-
 
65
	$(document).on('click', 'a.invoice-return', function () {
-
 
66
		doAjaxRequestHandler(context + "/return/invoice", "GET", function (response) {
-
 
67
			$('#main-content').html(response);
-
 
68
		});
-
 
69
	});
-
 
70
 
-
 
71
	// Search by Debit Note Number
-
 
72
	$(document).on('click', '#search-debit-note-btn', function () {
-
 
73
		var debitNoteNumber = $('#debit-note-number-input').val();
-
 
74
		if (!debitNoteNumber) {
-
 
75
			alert("Please enter a debit note number");
-
 
76
			return;
-
 
77
		}
-
 
78
		doAjaxRequestHandler(context + "/return/search/debit-note?debitNoteNumber=" + encodeURIComponent(debitNoteNumber), "GET", function (response) {
-
 
79
			$('#invoice-return-results').html(response);
-
 
80
		});
-
 
81
	});
-
 
82
 
-
 
83
	$(document).on('click', '#return-invoice-button', function () {
-
 
84
		var invoiceNumber = $('#invoice-number-input').val();
-
 
85
		if (!invoiceNumber) {
-
 
86
			alert("Please enter an invoice number");
-
 
87
			return;
-
 
88
		}
-
 
89
		doAjaxRequestHandler(context + "/return/invoice/search?invoiceNumber=" + encodeURIComponent(invoiceNumber), "GET", function (response) {
-
 
90
			$('#invoice-return-results').html(response);
-
 
91
		});
-
 
92
	});
-
 
93
 
-
 
94
	// Debit Note Details
-
 
95
	$(document).on('click', '.debit-note-details', function () {
-
 
96
		var debitNoteId = $(this).data("debitnote-id");
-
 
97
		doAjaxRequestHandler(context + "/return/debit-note/details/" + debitNoteId, "GET", function (response) {
-
 
98
			$('#main-content').html(response);
-
 
99
		});
-
 
100
	});
-
 
101
 
-
 
102
	// Receive Debit Note
-
 
103
	$(document).on('click', '.receive-debit-note', function () {
-
 
104
		var debitNoteId = $(this).data("debitnote-id");
-
 
105
		doAjaxRequestHandler(context + "/return/debit-note/receive/" + debitNoteId, "GET", function (response) {
-
 
106
			$('#main-content').html(response);
-
 
107
		});
-
 
108
	});
-
 
109
 
-
 
110
	// Show/hide DOA certificate section based on BAD selection on mobile items
-
 
111
	$(document).on('change', '.return-condition', function () {
-
 
112
		var hasMobileBad = false;
-
 
113
		$('#receive-debit-note-form tr[data-category-id]').each(function () {
-
 
114
			var categoryId = $(this).data('category-id');
-
 
115
			var condition = $(this).find('.return-condition').val();
-
 
116
			if (condition === 'BAD' && categoryId == 10006) {
-
 
117
				hasMobileBad = true;
-
 
118
			}
-
 
119
		});
-
 
120
		if (hasMobileBad) {
-
 
121
			$('#doa-certificate-section').show();
-
 
122
		} else {
-
 
123
			$('#doa-certificate-section').hide();
-
 
124
		}
-
 
125
	});
-
 
126
 
-
 
127
	// Submit receive debit note form
-
 
128
	$(document).on('submit', '#receive-debit-note-form', function (e) {
-
 
129
		e.preventDefault();
-
 
130
 
-
 
131
		// Validate remarks for BAD items
-
 
132
		var valid = true;
-
 
133
		$(this).find('tr[data-item-id]').each(function () {
-
 
134
			var condition = $(this).find('.return-condition').val();
-
 
135
			var remark = $(this).find('.remark-field').val();
-
 
136
			if (condition === 'BAD' && !remark) {
-
 
137
				alert("Remark is required for BAD/DOA returns");
-
 
138
				valid = false;
-
 
139
				return false;
-
 
140
			}
-
 
141
		});
-
 
142
		if (!valid) return;
-
 
143
 
-
 
144
		// Check DOA certificate if mobile BAD items exist
-
 
145
		var hasMobileBad = false;
-
 
146
		$(this).find('tr[data-category-id]').each(function () {
-
 
147
			if ($(this).data('category-id') == 10006 && $(this).find('.return-condition').val() === 'BAD') {
-
 
148
				hasMobileBad = true;
-
 
149
			}
-
 
150
		});
-
 
151
		if (hasMobileBad && !$('input[name="doaCertificateValid"]:checked').val()) {
-
 
152
			alert("Please select DOA certificate validity");
-
 
153
			return;
-
 
154
		}
-
 
155
 
-
 
156
		var debitNoteId = $(this).data('debitnote-id');
-
 
157
		if (confirm("Are you sure you want to confirm receipt for this debit note?")) {
-
 
158
			$.ajax({
-
 
159
				url: context + "/return/debit-note/receive/" + debitNoteId,
-
 
160
				type: "POST",
-
 
161
				data: $(this).serialize(),
-
 
162
				success: function (response) {
-
 
163
					if (response === 'true' || response.indexOf('true') >= 0) {
-
 
164
						alert("Debit note items received successfully");
-
 
165
						doAjaxRequestHandler(context + "/return/invoice", "GET", function (resp) {
-
 
166
							$('#main-content').html(resp);
-
 
167
						});
-
 
168
					} else {
-
 
169
						alert("Receipt failed: " + response);
-
 
170
					}
-
 
171
				},
-
 
172
				error: function (xhr) {
-
 
173
					alert("Error: " + xhr.responseText);
-
 
174
				}
-
 
175
			});
-
 
176
		}
-
 
177
	});
-
 
178
 
-
 
179
	// Refund Debit Note - opens refund view with receipt details
-
 
180
	$(document).on('click', '.refund-debit-note', function () {
-
 
181
		var debitNoteId = $(this).data("debitnote-id");
-
 
182
		doAjaxRequestHandler(context + "/return/debit-note/refund/" + debitNoteId, "GET", function (response) {
-
 
183
			$('#main-content').html(response);
-
 
184
		});
-
 
185
	});
-
 
186
 
-
 
187
	// Confirm refund with finance remark
-
 
188
	$(document).on('click', '.refund-debit-note-confirm', function () {
-
 
189
		var debitNoteId = $(this).data("debitnote-id");
-
 
190
		var financeRemark = $('#finance-remark').val();
-
 
191
		if (confirm("Are you sure you want to process refund for debit note " + debitNoteId + "?")) {
-
 
192
			doAjaxRequestHandler(context + "/return/debit-note/refund/" + debitNoteId + "?financeRemark=" + encodeURIComponent(financeRemark), "PUT", function (response) {
-
 
193
				if (response === 'true') {
-
 
194
					alert("Debit note refunded successfully");
-
 
195
					doAjaxRequestHandler(context + "/return/invoice", "GET", function (resp) {
-
 
196
						$('#main-content').html(resp);
-
 
197
					});
-
 
198
				} else {
-
 
199
					alert("Refund failed: " + response);
-
 
200
				}
-
 
201
			});
-
 
202
		}
-
 
203
	});
-
 
204
 
-
 
205
	// Reject debit note return
-
 
206
	$(document).on('click', '.reject-debit-note-confirm', function () {
-
 
207
		var debitNoteId = $(this).data("debitnote-id");
-
 
208
		var rejectRemark = $('#reject-remark').val();
-
 
209
		if (!rejectRemark) {
-
 
210
			alert("Please enter a reject remark");
-
 
211
			return;
-
 
212
		}
-
 
213
		if (confirm("Are you sure you want to reject return for debit note " + debitNoteId + "? This will reverse all scans and quantities.")) {
-
 
214
			doAjaxRequestHandler(context + "/return/debit-note/reject/" + debitNoteId + "?rejectRemark=" + encodeURIComponent(rejectRemark), "PUT", function (response) {
-
 
215
				if (response === 'true') {
-
 
216
					alert("Return rejected successfully");
-
 
217
					doAjaxRequestHandler(context + "/return/invoice", "GET", function (resp) {
-
 
218
						$('#main-content').html(resp);
-
 
219
					});
-
 
220
				} else {
-
 
221
					alert("Rejection failed: " + response);
-
 
222
				}
-
 
223
			});
-
 
224
		}
-
 
225
	});
67
});
226
});
68
 
227
 
69
function viewReturnStores(domId){
228
function viewReturnStores(domId){
70
	doAjaxRequestHandler(context+"/return/stores", "GET", function(response){
229
	doAjaxRequestHandler(context+"/return/stores", "GET", function(response){
71
		$('#' + domId).html(response);
230
		$('#' + domId).html(response);
Line 123... Line 282...
123
}
282
}
124
 
283
 
125
function generateDebitNote(warehouseId){
284
function generateDebitNote(warehouseId){
126
	doAjaxRequestHandler(context+"/return/debit-note/generate/" + warehouseId, "PUT", function(response){
285
	doAjaxRequestHandler(context+"/return/debit-note/generate/" + warehouseId, "PUT", function(response){
127
		if(response=='true') {
286
		if(response=='true') {
128
			//Download the pdf 
287
			//Download the pdf
129
		}
288
		}
130
	});	
289
	});
131
}
290
}
132
 
291
 
133
function getDebitNote(debitNotedId) {
292
function getDebitNote(debitNotedId) {
134
	doAjaxRequestHandler(context+"/return/debit-note/" + debitNotedId, "GET", function(response){
293
	doAjaxRequestHandler(context+"/return/debit-note/" + debitNotedId, "GET", function(response){
135
			
-
 
136
	});
-
 
137
}
-
 
138
 
-
 
139
 
294
 
140
$(document).on('click', '.vendor_return', function () {
-
 
141
 
-
 
142
	doAjaxRequestHandler(context + "/return/to/vendor", "GET", function (response) {
-
 
143
		$('#main-content').html(response);
-
 
144
	});
295
	});
145
});
296
}