| 30694 |
amit.gupta |
1 |
var grnhistory = grnhistory || {};
|
| 23343 |
ashik.ali |
2 |
grnhistory.searchText = "";
|
|
|
3 |
grnhistory.searchType = "";
|
|
|
4 |
grnhistory.startTime = "0";
|
|
|
5 |
grnhistory.endTime = "0";
|
|
|
6 |
|
| 30694 |
amit.gupta |
7 |
$(function () {
|
|
|
8 |
$(document).on('click', ".new_grn", function () {
|
| 23343 |
ashik.ali |
9 |
loadNewGrn("main-content");
|
|
|
10 |
});
|
|
|
11 |
|
| 30694 |
amit.gupta |
12 |
$(document).on('click', ".grn_history", function () {
|
| 32584 |
raveendra. |
13 |
loadGrnHistory("main-content", "", "", moment().format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS), moment().format(moment.HTML5_FMT.DATETIME_LOCAL_SECONDS));
|
| 23343 |
ashik.ali |
14 |
});
|
| 30694 |
amit.gupta |
15 |
|
|
|
16 |
$(document).on('click', ".pending_grn", function () {
|
| 23886 |
amit.gupta |
17 |
loadPendingGrn("main-content");
|
| 23343 |
ashik.ali |
18 |
});
|
|
|
19 |
|
| 30694 |
amit.gupta |
20 |
$(document).on('click', "td.startGrnSerialized", function () {
|
| 23343 |
ashik.ali |
21 |
var invoiceNumber = $(this).attr('invoiceNumber');
|
|
|
22 |
var quantity = $(this).attr('quantity');
|
|
|
23 |
var displayName = $(this).attr('displayName');
|
|
|
24 |
var itemId = $(this).attr('itemId');
|
|
|
25 |
console.log(quantity);
|
|
|
26 |
$(".modal-body .grnInvoiceNumber>span").text(invoiceNumber);
|
|
|
27 |
$(".modal-body .grnProductInfo>span").text(displayName);
|
|
|
28 |
$("#scanModel .invoiceNumber").val(invoiceNumber);
|
|
|
29 |
$("#scanModel .itemId").val(itemId);
|
| 30694 |
amit.gupta |
30 |
$("#grnImeiInformation").empty();
|
| 23343 |
ashik.ali |
31 |
var qty = parseInt(quantity);
|
|
|
32 |
var divCode = '<div class="row">CONTENT</div><p></p>';
|
| 30701 |
amit.gupta |
33 |
doGetAjaxRequestHandler(`/purchase/get-imeis?invoiceNumber=${invoiceNumber}&itemId=${itemId}`, function (data) {
|
|
|
34 |
let response = data.response;
|
|
|
35 |
let index = 0;
|
|
|
36 |
while (index < response.length) {
|
|
|
37 |
let currentRow = response.length - index < 4 ? response.length - index : 4;
|
|
|
38 |
let rowArr = [];
|
|
|
39 |
for (let i = 0; i < currentRow; i++) {
|
|
|
40 |
let checkedDiv =
|
|
|
41 |
`<div class="col-sm-3">
|
|
|
42 |
<label class="checkbox-inline">
|
|
|
43 |
<input type="checkbox" value="${response[index]}"> ${response[index]}
|
|
|
44 |
</label>
|
|
|
45 |
</div>`;
|
|
|
46 |
rowArr.push(checkedDiv);
|
|
|
47 |
index++;
|
| 23343 |
ashik.ali |
48 |
}
|
| 30701 |
amit.gupta |
49 |
$("#grnImeiInformation").append(divCode.replace("CONTENT", rowArr.join("")));
|
| 23343 |
ashik.ali |
50 |
}
|
| 30701 |
amit.gupta |
51 |
});
|
| 23343 |
ashik.ali |
52 |
});
|
| 30701 |
amit.gupta |
53 |
});
|
| 23343 |
ashik.ali |
54 |
|
| 30701 |
amit.gupta |
55 |
$(document).on('click', "td.startGrnNonSerialized", function () {
|
|
|
56 |
var invoiceNumber = $(this).attr('invoiceNumber');
|
|
|
57 |
var quantity = $(this).attr('quantity');
|
|
|
58 |
var displayName = $(this).attr('displayName');
|
|
|
59 |
var itemId = $(this).attr('itemId');
|
|
|
60 |
console.log(quantity);
|
|
|
61 |
$("#scanNonSerializedModel .modal-body .grnInvoiceNumber>span").text(invoiceNumber);
|
|
|
62 |
$("#scanNonSerializedModel .modal-body .grnProductInfo>span").text(displayName);
|
|
|
63 |
$("#scanNonSerializedModel .invoiceNumber").val(invoiceNumber);
|
|
|
64 |
$("#scanNonSerializedModel .itemId").val(itemId);
|
|
|
65 |
$("#grnImeiInformation").empty();
|
|
|
66 |
var qty = parseInt(quantity);
|
|
|
67 |
var divCode = '<div class="row">CONTENT</div><p></p>';
|
|
|
68 |
var innerDiv = '<div class="col-sm-3">' +
|
|
|
69 |
'<div class="input-group">' +
|
|
|
70 |
'<input type="text" class="form-control">' +
|
|
|
71 |
'</div>' +
|
|
|
72 |
'</div>';
|
| 33995 |
vikas.jang |
73 |
while (qty > 0) {
|
| 30701 |
amit.gupta |
74 |
var divText = "";
|
| 35458 |
amit |
75 |
var loopCount = qty < 4 ? qty : 4;
|
|
|
76 |
for (var i = 0; i < loopCount; i++) {
|
|
|
77 |
divText = divText + innerDiv;
|
|
|
78 |
qty = qty - 1;
|
| 23343 |
ashik.ali |
79 |
}
|
| 30701 |
amit.gupta |
80 |
divText = divCode.replace("CONTENT", divText);
|
|
|
81 |
$("#grnImeiInformation")
|
|
|
82 |
.append(divText)
|
|
|
83 |
}
|
|
|
84 |
});
|
| 30694 |
amit.gupta |
85 |
|
| 30701 |
amit.gupta |
86 |
$(document).on('click', "#grnSubmitSerialized", function () {
|
| 30702 |
amit.gupta |
87 |
let imeis = [];
|
|
|
88 |
$("#grnImeiInformation :input:checked").each(function () {
|
| 30701 |
amit.gupta |
89 |
var input = $(this).val().trim();
|
|
|
90 |
imeis.push(input);
|
|
|
91 |
});
|
| 30702 |
amit.gupta |
92 |
let invoiceNumber = $("#scanModel .invoiceNumber").val();
|
|
|
93 |
let itemId = $("#scanModel .itemId").val();
|
|
|
94 |
let postData = JSON.stringify({
|
| 30701 |
amit.gupta |
95 |
"itemId": parseInt(itemId),
|
|
|
96 |
"invoiceNumber": invoiceNumber,
|
|
|
97 |
"serialNumbers": imeis
|
|
|
98 |
});
|
|
|
99 |
doPostAjaxRequestWithJsonHandler(context + "/scanSerialized", postData, function (response) {
|
|
|
100 |
bootbox.alert("Purchase booked successfully", function () {
|
|
|
101 |
$('#scanModel').on('hidden.bs.modal', function (event) {
|
|
|
102 |
$("#purchase-reference-submit-button").click();
|
|
|
103 |
$(this).off(event);
|
| 27198 |
amit.gupta |
104 |
});
|
| 30701 |
amit.gupta |
105 |
$('#scanModel').modal('hide');
|
| 23343 |
ashik.ali |
106 |
});
|
| 30701 |
amit.gupta |
107 |
});
|
|
|
108 |
return false;
|
|
|
109 |
});
|
|
|
110 |
|
|
|
111 |
$(document).on('click', "#grnNonSerializedSubmit", function () {
|
|
|
112 |
var error = false;
|
|
|
113 |
var errorText = "";
|
|
|
114 |
if (error) {
|
| 23343 |
ashik.ali |
115 |
return false;
|
| 30701 |
amit.gupta |
116 |
}
|
|
|
117 |
var invoiceNumber = $("#scanNonSerializedModel .invoiceNumber").val();
|
|
|
118 |
var itemId = $("#scanNonSerializedModel .itemId").val();
|
|
|
119 |
var quantity = $("#scanNonSerializedModel .quantity").val();
|
|
|
120 |
var postData = JSON.stringify({
|
|
|
121 |
"itemId": parseInt(itemId),
|
|
|
122 |
"invoiceNumber": invoiceNumber,
|
|
|
123 |
"quantity": parseInt(quantity)
|
| 23343 |
ashik.ali |
124 |
});
|
| 30701 |
amit.gupta |
125 |
doPostAjaxRequestWithJsonHandler(context + "/scanNonSerialized", postData, function (response) {
|
|
|
126 |
bootbox.alert("Purchase booked successfully", function () {
|
|
|
127 |
$('#scanNonSerializedModel').on('hidden.bs.modal', function (event) {
|
|
|
128 |
$(this).off(event);
|
|
|
129 |
$("#purchase-reference-submit-button").click();
|
| 27198 |
amit.gupta |
130 |
});
|
| 30701 |
amit.gupta |
131 |
$('#scanNonSerializedModel').modal('hide');
|
| 23343 |
ashik.ali |
132 |
});
|
|
|
133 |
});
|
| 30701 |
amit.gupta |
134 |
return false;
|
|
|
135 |
});
|
| 23343 |
ashik.ali |
136 |
|
| 30701 |
amit.gupta |
137 |
$(document).on('change', "#grnImeiInformation :input", function () {
|
| 35458 |
amit |
138 |
var value = $(this).val().trim();
|
|
|
139 |
if (value !== "") {
|
| 30701 |
amit.gupta |
140 |
$('#grnImeiInformation :input').removeClass("border-highlight");
|
| 35458 |
amit |
141 |
if (findDuplicateSerialNumbers(value) > 0) {
|
|
|
142 |
var inputs = $("#grnImeiInformation :input[value='" + value + "']");
|
| 30701 |
amit.gupta |
143 |
if (inputs.length > 1) {
|
|
|
144 |
inputs.each(function () {
|
| 35458 |
amit |
145 |
$(this).addClass("border-highlight");
|
| 30701 |
amit.gupta |
146 |
});
|
| 23343 |
ashik.ali |
147 |
}
|
|
|
148 |
}
|
| 30701 |
amit.gupta |
149 |
}
|
|
|
150 |
});
|
| 30694 |
amit.gupta |
151 |
|
| 30701 |
amit.gupta |
152 |
$(document).on('paste', "#grnImeiInformation :input", function () {
|
| 35458 |
amit |
153 |
if ($(this).val().trim() !== "") {
|
| 30701 |
amit.gupta |
154 |
$(this).next("input .form-control").focus();
|
|
|
155 |
}
|
|
|
156 |
});
|
| 23343 |
ashik.ali |
157 |
|
| 30701 |
amit.gupta |
158 |
$(document).on("keyup", "#airwayBillOrInvoiceNumberText", function (e) {
|
|
|
159 |
var keyCode = e.keyCode || e.which;
|
| 35458 |
amit |
160 |
if (keyCode === 13) {
|
| 30701 |
amit.gupta |
161 |
$("#purchase-reference-submit-button").click();
|
|
|
162 |
}
|
|
|
163 |
});
|
| 23343 |
ashik.ali |
164 |
|
| 30701 |
amit.gupta |
165 |
$(document).on('click', "#grn-history-search-button", function () {
|
|
|
166 |
grnhistory.searchText = $("#grn-history-search-text").val();
|
|
|
167 |
grnhistory.searchType = "purchaseReference";
|
| 35458 |
amit |
168 |
var dateRange = getDatesFromPicker($("#grnDateRange"));
|
|
|
169 |
grnhistory.startTime = dateRange.startDate;
|
|
|
170 |
grnhistory.endTime = dateRange.endDate;
|
|
|
171 |
if (typeof (grnhistory.searchText) === "undefined" || !grnhistory.searchText) {
|
| 30701 |
amit.gupta |
172 |
grnhistory.searchText = "";
|
|
|
173 |
}
|
|
|
174 |
loadGrnHistorySearchInfo(grnhistory.searchText, grnhistory.searchType, grnhistory.startTime, grnhistory.endTime);
|
|
|
175 |
});
|
| 30694 |
amit.gupta |
176 |
|
| 30701 |
amit.gupta |
177 |
$(document).on('click', "#grn-history-download-button", function () {
|
|
|
178 |
grnhistory.searchText = $("#grn-history-search-text").val();
|
|
|
179 |
grnhistory.searchType = "purchaseReference";
|
| 35458 |
amit |
180 |
var dateRange = getDatesFromPicker($("#grnDateRange"));
|
|
|
181 |
grnhistory.startTime = dateRange.startDate;
|
|
|
182 |
grnhistory.endTime = dateRange.endDate;
|
|
|
183 |
if (typeof (grnhistory.searchText) === "undefined" || !grnhistory.searchText) {
|
| 30701 |
amit.gupta |
184 |
grnhistory.searchText = "";
|
|
|
185 |
}
|
|
|
186 |
downloadPurchaseInvoices(grnhistory.searchText, grnhistory.searchType, grnhistory.startTime, grnhistory.endTime);
|
|
|
187 |
});
|
| 30694 |
amit.gupta |
188 |
|
| 30701 |
amit.gupta |
189 |
$(document).on("keyup", "#grn-history-search-text", function (e) {
|
|
|
190 |
var keyCode = e.keyCode || e.which;
|
| 35458 |
amit |
191 |
if (keyCode === 13) {
|
| 30701 |
amit.gupta |
192 |
$("#grn-history-search-button").click();
|
|
|
193 |
}
|
|
|
194 |
});
|
| 23343 |
ashik.ali |
195 |
|
| 30701 |
amit.gupta |
196 |
$(document).on('click', "#grn-history-paginated .next", function () {
|
|
|
197 |
var params = {};
|
|
|
198 |
params['purchaseReference'] = grnhistory.searchText;
|
|
|
199 |
params['searchType'] = grnhistory.searchType;
|
|
|
200 |
params['startTime'] = grnhistory.startTime;
|
|
|
201 |
params['endTime'] = grnhistory.endTime;
|
|
|
202 |
loadPaginatedNextItems('/getPaginatedGrnHistory', params, 'grn-history-paginated', 'grn-history-table', null);
|
|
|
203 |
$(this).blur();
|
| 30694 |
amit.gupta |
204 |
|
| 30701 |
amit.gupta |
205 |
});
|
| 30694 |
amit.gupta |
206 |
|
| 30701 |
amit.gupta |
207 |
$(document).on('click', "#grn-history-paginated .previous", function () {
|
|
|
208 |
var params = {};
|
|
|
209 |
params['purchaseReference'] = grnhistory.searchText;
|
|
|
210 |
params['searchType'] = grnhistory.searchType;
|
|
|
211 |
params['startTime'] = grnhistory.startTime;
|
|
|
212 |
params['endTime'] = grnhistory.endTime;
|
|
|
213 |
loadPaginatedPreviousItems('/getPaginatedGrnHistory', params, 'grn-history-paginated', 'grn-history-table', null);
|
|
|
214 |
$(this).blur();
|
| 30694 |
amit.gupta |
215 |
|
| 30701 |
amit.gupta |
216 |
});
|
| 30694 |
amit.gupta |
217 |
|
| 30701 |
amit.gupta |
218 |
$(document).on('click', "#grn-history-date-button", function () {
|
|
|
219 |
var dateRange = $('#reportrange span').text();
|
|
|
220 |
grnhistory.startTime = getDatesFromPicker($("#grnDateRange")).startDate;
|
|
|
221 |
grnhistory.endTime = getDatesFromPicker($("#grnDateRange")).endDate;
|
|
|
222 |
grnhistory.searchType = "dateFilter";
|
|
|
223 |
grnhistory.searchText = "";
|
|
|
224 |
loadGrnHistorySearchInfo(grnhistory.searchText, grnhistory.searchType, grnhistory.startTime, grnhistory.endTime);
|
|
|
225 |
});
|
| 23343 |
ashik.ali |
226 |
|
| 30701 |
amit.gupta |
227 |
$(document).on('click', ".grn-details", function () {
|
|
|
228 |
var purchaseId = $(this).attr('data');
|
|
|
229 |
console.log(purchaseId);
|
|
|
230 |
loadGrnDetails(purchaseId, "grn-details-container");
|
|
|
231 |
});
|
| 30694 |
amit.gupta |
232 |
|
| 30701 |
amit.gupta |
233 |
$(document).on('click', ".pending-grn-details", function () {
|
|
|
234 |
console.log("pending-grn-details clicked");
|
|
|
235 |
var orderId = $(this).attr('data');
|
|
|
236 |
console.log("orderId : " + orderId);
|
|
|
237 |
loadPendingGrnDetails(orderId, "pending-grn-details-container");
|
|
|
238 |
});
|
| 23343 |
ashik.ali |
239 |
|
| 30701 |
amit.gupta |
240 |
$(document).on('click', ".pending-grn", function () {
|
|
|
241 |
var purchaseReference = $(this).attr('data');
|
|
|
242 |
console.log(purchaseReference);
|
|
|
243 |
loadPendingGrnDetails(purchaseReference, "main-content");
|
| 23343 |
ashik.ali |
244 |
});
|
|
|
245 |
|
|
|
246 |
|
| 30466 |
amit.gupta |
247 |
function loadNewGrn(domId, invoiceNumber) {
|
|
|
248 |
doGetAjaxRequestHandler(context + "/purchase", function (response) {
|
| 23343 |
ashik.ali |
249 |
$('#' + domId).html(response);
|
| 35458 |
amit |
250 |
if (invoiceNumber !== undefined) {
|
| 30466 |
amit.gupta |
251 |
$("#airwayBillOrInvoiceNumberText").val(invoiceNumber);
|
|
|
252 |
$("#purchase-reference-submit-button").click();
|
|
|
253 |
}
|
| 23343 |
ashik.ali |
254 |
});
|
|
|
255 |
}
|
|
|
256 |
|
| 30694 |
amit.gupta |
257 |
function getPurchaseByInvoiceNumber() {
|
| 23343 |
ashik.ali |
258 |
var airwayBillOrInvoiceNumber = $('#airwayBillOrInvoiceNumberText').val();
|
| 30694 |
amit.gupta |
259 |
doGetAjaxRequestHandler(context + "/purchaseByInvoiceNumber?airwayBillOrInvoiceNumber=" + airwayBillOrInvoiceNumber, function (response) {
|
| 23343 |
ashik.ali |
260 |
$('#main-content').html(response);
|
|
|
261 |
});
|
|
|
262 |
}
|
|
|
263 |
|
| 30694 |
amit.gupta |
264 |
function loadPendingGrn(domId) {
|
|
|
265 |
doGetAjaxRequestHandler(context + "/pendingGrn", function (response) {
|
| 23343 |
ashik.ali |
266 |
$('#' + domId).html(response);
|
|
|
267 |
});
|
|
|
268 |
}
|
|
|
269 |
|
| 30694 |
amit.gupta |
270 |
function loadGrnHistory(domId, purchase_reference, searchType, startTime, endTime) {
|
|
|
271 |
doGetAjaxRequestHandler(context + "/grnHistory?purchaseReference=" + purchase_reference + "&searchType=" + searchType
|
|
|
272 |
+ "&startTime=" + startTime
|
|
|
273 |
+ "&endTime=" + endTime, function (response) {
|
| 23343 |
ashik.ali |
274 |
$('#' + domId).html(response);
|
|
|
275 |
});
|
|
|
276 |
}
|
|
|
277 |
|
| 30694 |
amit.gupta |
278 |
function loadGrnHistorySearchInfo(search_text, searchType, startTime, endTime) {
|
|
|
279 |
loadGrnHistory("main-content", search_text, searchType, startTime, endTime);
|
| 23343 |
ashik.ali |
280 |
}
|
|
|
281 |
|
| 30694 |
amit.gupta |
282 |
function downloadPurchaseInvoice(search_text, searchType, startTime, endTime) {
|
| 35458 |
amit |
283 |
var purchaseInvoice_url = context + "/grnHistory?purchaseReference=" + search_text + "&searchType=" + searchType
|
| 30694 |
amit.gupta |
284 |
+ "&startTime=" + startTime + "&endTime=" + endTime;
|
| 35458 |
amit |
285 |
return purchaseInvoice_url;
|
| 26013 |
amit.gupta |
286 |
}
|
|
|
287 |
|
| 30694 |
amit.gupta |
288 |
function findDuplicateSerialNumbers(value) {
|
|
|
289 |
var result = $("#grnImeiInformation :input[value='" + value + "']").length - 1;
|
|
|
290 |
return result;
|
| 23343 |
ashik.ali |
291 |
}
|
|
|
292 |
|
| 30694 |
amit.gupta |
293 |
function loadGrnDetails(purchaseId, domId) {
|
|
|
294 |
doGetAjaxRequestHandler(context + "/grnHistoryDetailByPurchaseId?purchaseId=" + purchaseId, function (response) {
|
| 23343 |
ashik.ali |
295 |
$('#' + domId).html(response);
|
|
|
296 |
window.dispatchEvent(new Event('resize'));
|
| 30694 |
amit.gupta |
297 |
});
|
| 23343 |
ashik.ali |
298 |
}
|
|
|
299 |
|
| 30694 |
amit.gupta |
300 |
function loadPendingGrnDetails(orderId, domId) {
|
|
|
301 |
doGetAjaxRequestHandler(context + "/pendingGrnDetails?orderId=" + orderId, function (response) {
|
| 23343 |
ashik.ali |
302 |
$('#' + domId).html(response);
|
|
|
303 |
window.dispatchEvent(new Event('resize'));
|
|
|
304 |
});
|
| 30694 |
amit.gupta |
305 |
|
| 23343 |
ashik.ali |
306 |
}
|
| 30694 |
amit.gupta |
307 |
|
|
|
308 |
function grnPartial(invoiceNumber) {
|
| 35458 |
amit |
309 |
var serialNumbers = $("#all-imeis").tagsinput('items');
|
|
|
310 |
if (serialNumbers.length === 0) {
|
|
|
311 |
alert("Please add IMEIs");
|
| 30702 |
amit.gupta |
312 |
$("#all-imeis").focus();
|
|
|
313 |
return false;
|
|
|
314 |
}
|
| 30694 |
amit.gupta |
315 |
let imeisJson = {
|
|
|
316 |
serialNumbers: serialNumbers,
|
|
|
317 |
invoiceNumber: invoiceNumber
|
|
|
318 |
}
|
|
|
319 |
doPostAjaxRequestWithJsonHandler(`${context}/purchase/grn-imeis`, JSON.stringify(imeisJson), function (data) {
|
|
|
320 |
let response = data.response;
|
|
|
321 |
if (response) {
|
|
|
322 |
alert("Purchase booked successfully");
|
|
|
323 |
$("#purchase-reference-submit-button").click();
|
|
|
324 |
}
|
|
|
325 |
});
|
|
|
326 |
}
|
| 34163 |
ranu |
327 |
|
|
|
328 |
$(document).on('click', ".hid-allocation", function () {
|
|
|
329 |
doGetAjaxRequestHandler(context + "/pur-sale-ratio/stock/hid-allocation",
|
|
|
330 |
function (response) {
|
|
|
331 |
$('#' + 'main-content').html(response);
|
|
|
332 |
});
|
|
|
333 |
});
|
|
|
334 |
|
|
|
335 |
$(document).on('click', '.partner-hid-allocation', function () {
|
|
|
336 |
partnerHidAllocationList();
|
|
|
337 |
});
|
|
|
338 |
|
|
|
339 |
function partnerHidAllocationList() {
|
| 35458 |
amit |
340 |
if (typeof partnerId !== "undefined") {
|
| 34163 |
ranu |
341 |
doGetAjaxRequestHandler(context + "/pur-sale-ratio/stock/hid-catalog-allocation-list?fofoId=" + partnerId,
|
|
|
342 |
function (response) {
|
|
|
343 |
$('.hid-allocation-conatiner').html(response);
|
|
|
344 |
});
|
|
|
345 |
} else {
|
|
|
346 |
doGetAjaxRequestHandler(context + "/pur-sale-ratio/stock/hid-catalog-allocation-list?fofoId=0",
|
|
|
347 |
function (response) {
|
|
|
348 |
$('.hid-allocation-conatiner').html(response);
|
| 34198 |
ranu |
349 |
});
|
|
|
350 |
}
|
|
|
351 |
|
|
|
352 |
}
|
|
|
353 |
|
|
|
354 |
var table = $('.hidCatalogAllocationList').DataTable();
|
|
|
355 |
$(document).on('dblclick', '.hidCatalogAllocationList tbody tr', function () {
|
|
|
356 |
var data = table.row(this).data();
|
|
|
357 |
$(this).find(":input").attr('disabled', false).show();
|
|
|
358 |
});
|
|
|
359 |
|
|
|
360 |
$(document).on('click', ".generate-allocation-request", function () {
|
|
|
361 |
var catalogid = $(this).data('catalogid');
|
|
|
362 |
const self = this;
|
|
|
363 |
if (confirm("Are you sure you want to generate a request for allocation limit")) {
|
|
|
364 |
var requestedAllocation = $(this).closest('tr').find('input[name="allocation-limit"]').val();
|
|
|
365 |
|
|
|
366 |
if (!requestedAllocation) {
|
|
|
367 |
alert("Please enter a requested allocation before submitting.");
|
|
|
368 |
return;
|
|
|
369 |
}
|
|
|
370 |
|
|
|
371 |
doGetAjaxRequestHandler(`${context}/pur-sale-ratio/generate-allocation-request?catalogId=${catalogid}&fofoId=${partnerId}&requestedAllocation=${requestedAllocation}`, function (response) {
|
|
|
372 |
if (response) {
|
|
|
373 |
alert("Allocation request has been sent.");
|
|
|
374 |
partnerHidAllocationList();
|
|
|
375 |
}
|
|
|
376 |
});
|
| 34163 |
ranu |
377 |
}
|
| 34198 |
ranu |
378 |
});
|
|
|
379 |
|
| 34295 |
ranu |
380 |
$(document).on('click', '.edit-allocation', function () {
|
|
|
381 |
var $row = $(this).closest('tr'); // Get the closest table row
|
|
|
382 |
var $input = $row.find('.reuested_allocation'); // Find the input inside the row
|
|
|
383 |
$input.prop('disabled', false).focus(); // Enable input and focus on it
|
|
|
384 |
});
|
| 34198 |
ranu |
385 |
|
| 34295 |
ranu |
386 |
$(document).on('click', ".allocation-request-edit", function () {
|
|
|
387 |
var $row = $(this).closest('tr');
|
|
|
388 |
var allocationId = $(this).data('id');
|
|
|
389 |
var requestedAllocation = $row.find('.reuested_allocation').val();
|
|
|
390 |
|
|
|
391 |
if (!requestedAllocation) {
|
|
|
392 |
alert("Please enter a requested allocation before submitting.");
|
|
|
393 |
return;
|
|
|
394 |
}
|
|
|
395 |
|
|
|
396 |
if (confirm("Are you sure you want to update the allocation?")) {
|
|
|
397 |
doGetAjaxRequestHandler(`${context}/pur-sale-ratio/edit-allocation-request?allocationId=${allocationId}&requestedAllocation=${requestedAllocation}`, function (response) {
|
|
|
398 |
if (response) {
|
|
|
399 |
alert("Allocation request has been sent.");
|
|
|
400 |
loadRequestedAllocations();
|
|
|
401 |
}
|
|
|
402 |
});
|
|
|
403 |
}
|
|
|
404 |
});
|
|
|
405 |
|
|
|
406 |
|
| 34198 |
ranu |
407 |
$(document).on('click', ".reuested-allocations", function () {
|
|
|
408 |
loadRequestedAllocations();
|
|
|
409 |
});
|
|
|
410 |
|
|
|
411 |
$(document).on('click', ".allocation-request-approve-reject", function () {
|
|
|
412 |
var id = $(this).data('id');
|
|
|
413 |
var status = $(this).data('status');
|
|
|
414 |
doGetAjaxRequestHandler(context + `/pur-sale-ratio/allocation-request-approve-reject?id=${id}&status=${status}`,
|
|
|
415 |
function (response) {
|
|
|
416 |
loadRequestedAllocations();
|
|
|
417 |
});
|
|
|
418 |
});
|
|
|
419 |
|
|
|
420 |
function loadRequestedAllocations() {
|
|
|
421 |
doGetAjaxRequestHandler(context + "/pur-sale-ratio/requested-allocations",
|
|
|
422 |
function (response) {
|
|
|
423 |
$('#' + 'main-content').html(response);
|
|
|
424 |
});
|
| 34163 |
ranu |
425 |
}
|
|
|
426 |
|
|
|
427 |
|