| 30017 |
amit.gupta |
1 |
$(function () {
|
| 33910 |
amit.gupta |
2 |
$(document).on('click', "a.allocation_po", function () {
|
|
|
3 |
currentFofoId = 0;
|
|
|
4 |
counterSize = '';
|
|
|
5 |
loadIndent('main-content');
|
|
|
6 |
});
|
| 30017 |
amit.gupta |
7 |
|
| 33910 |
amit.gupta |
8 |
$(document).on('click', ".partners_allocation",
|
|
|
9 |
function () {
|
| 26721 |
tejbeer |
10 |
|
| 33910 |
amit.gupta |
11 |
doGetAjaxRequestHandler(context + "/getPartnerAllocation", function (response) {
|
|
|
12 |
$('#' + 'main-content').html(response);
|
| 30017 |
amit.gupta |
13 |
|
| 33910 |
amit.gupta |
14 |
});
|
| 30017 |
amit.gupta |
15 |
|
| 33910 |
amit.gupta |
16 |
});
|
| 30017 |
amit.gupta |
17 |
|
| 33910 |
amit.gupta |
18 |
$(document).on('click', ".partnerAllocation",
|
|
|
19 |
function () {
|
| 30017 |
amit.gupta |
20 |
|
| 33910 |
amit.gupta |
21 |
var fofoId = $('#fofo-users').val()
|
|
|
22 |
console.log(fofoId)
|
|
|
23 |
var url = "/indent/loadIndent?fofoId=" + fofoId + "&counterSize="
|
|
|
24 |
+ "TEN_LAC";
|
|
|
25 |
doAjaxRequestHandler(context + url, "GET", function (response) {
|
|
|
26 |
{
|
|
|
27 |
}
|
| 30017 |
amit.gupta |
28 |
|
|
|
29 |
|
| 33910 |
amit.gupta |
30 |
$('.partner-indent-container').html(response);
|
|
|
31 |
});
|
|
|
32 |
});
|
| 30017 |
amit.gupta |
33 |
|
|
|
34 |
|
| 33910 |
amit.gupta |
35 |
$(document).on('click', "button.mk_pause_button",
|
|
|
36 |
function () {
|
|
|
37 |
var clickedButton = $(this);
|
| 25721 |
tejbeer |
38 |
|
| 33910 |
amit.gupta |
39 |
var description = clickedButton.data("description");
|
|
|
40 |
var catalogId = clickedButton.data("id");
|
|
|
41 |
getColorsForItems(
|
|
|
42 |
catalogId,
|
|
|
43 |
0,
|
|
|
44 |
"Active/pause " + description,
|
|
|
45 |
function (itemIds) {
|
|
|
46 |
console.log(itemIds);
|
|
|
47 |
if (itemIds != null) {
|
|
|
48 |
bootbox
|
|
|
49 |
.confirm(
|
|
|
50 |
"Confirm Update "
|
|
|
51 |
+ clickedButton
|
|
|
52 |
.data("description")
|
|
|
53 |
+ "?",
|
|
|
54 |
function (result) {
|
|
|
55 |
console.log(result)
|
|
|
56 |
if (result) {
|
|
|
57 |
coloredItems
|
|
|
58 |
.forEach(function (
|
|
|
59 |
item) {
|
|
|
60 |
item.active = itemIds
|
|
|
61 |
.indexOf(item.id
|
|
|
62 |
+ "") >= 0;
|
|
|
63 |
console
|
|
|
64 |
.log(coloredItems)
|
|
|
65 |
});
|
| 25721 |
tejbeer |
66 |
|
| 33910 |
amit.gupta |
67 |
doPostAjaxRequestWithJsonHandler(
|
|
|
68 |
context
|
|
|
69 |
+ "/indent/confirm-pause/",
|
|
|
70 |
JSON
|
|
|
71 |
.stringify(coloredItems),
|
|
|
72 |
function (
|
|
|
73 |
response) {
|
|
|
74 |
if (response) {
|
|
|
75 |
bootbox
|
|
|
76 |
.alert("Item/s Updated Successfully");
|
|
|
77 |
} else {
|
|
|
78 |
bootbox
|
|
|
79 |
.alert("Could not pause item");
|
|
|
80 |
}
|
| 25721 |
tejbeer |
81 |
|
| 33910 |
amit.gupta |
82 |
});
|
|
|
83 |
}
|
|
|
84 |
});
|
|
|
85 |
}
|
|
|
86 |
});
|
|
|
87 |
});
|
| 26131 |
tejbeer |
88 |
|
| 30017 |
amit.gupta |
89 |
|
| 33910 |
amit.gupta |
90 |
$(document).on('click', "li.mk_counter_size", function () {
|
|
|
91 |
if ($(this).hasClass('active')) {
|
|
|
92 |
return;
|
|
|
93 |
}
|
|
|
94 |
currentFofoId = 0;
|
|
|
95 |
counterSize = $(this).find('a').html();
|
|
|
96 |
loadIndent('main-content');
|
|
|
97 |
});
|
|
|
98 |
$(document).on('click', "li.brandLi", function () {
|
|
|
99 |
if (!$(this).hasClass('active')) {
|
|
|
100 |
$("table.brandPerformance").toggle();
|
|
|
101 |
$("li.brandLi").removeClass('active');
|
|
|
102 |
$(this).addClass('active');
|
|
|
103 |
}
|
|
|
104 |
});
|
| 30017 |
amit.gupta |
105 |
|
| 33910 |
amit.gupta |
106 |
$(document).on('click', ".previous-month", function () {
|
|
|
107 |
currentFofoId = 0;
|
|
|
108 |
counterSize = '';
|
|
|
109 |
loadPreviousMonthIndent('main-content');
|
|
|
110 |
});
|
| 25721 |
tejbeer |
111 |
|
| 33910 |
amit.gupta |
112 |
$(document).on('click', ".current-month", function () {
|
|
|
113 |
currentFofoId = 0;
|
|
|
114 |
counterSize = '';
|
|
|
115 |
loadIndent('main-content');
|
|
|
116 |
});
|
|
|
117 |
$(document).on('click', 'a.create_indent', function () {
|
|
|
118 |
currentFofoId = 0;
|
|
|
119 |
counterSize = '';
|
|
|
120 |
loadIndent("main-content");
|
|
|
121 |
});
|
|
|
122 |
$(document).on('click', "button.create_indent", function () {
|
|
|
123 |
loadIndent("main-content");
|
|
|
124 |
});
|
| 23786 |
amit.gupta |
125 |
|
| 33910 |
amit.gupta |
126 |
$(document).on('click', "button.download_indent", function () {
|
|
|
127 |
downloadIndent();
|
|
|
128 |
});
|
| 25721 |
tejbeer |
129 |
|
| 33910 |
amit.gupta |
130 |
$(document).on('change', "#entire-catalog-table input",
|
|
|
131 |
function () {
|
|
|
132 |
var catalogId = parseInt($(this).data("catalog-id"));
|
|
|
133 |
var sellingPrice = parseInt($(this).data(
|
|
|
134 |
"selling-price"));
|
|
|
135 |
var quantity = parseInt($(this).val());
|
|
|
136 |
if (quantity > 40) {
|
|
|
137 |
alert("Quantity should not be above 40");
|
|
|
138 |
if (catalogId in indentMap) {
|
|
|
139 |
$(this).val(indentMap[catalogId].quantity);
|
|
|
140 |
} else {
|
|
|
141 |
$(this).val(0);
|
|
|
142 |
}
|
|
|
143 |
return;
|
|
|
144 |
}
|
|
|
145 |
brandName = $(this).data("brand-name");
|
|
|
146 |
description = $(this).data("description");
|
|
|
147 |
if (!(brandName in indentMap)) {
|
|
|
148 |
indentMap[brandName] = {};
|
|
|
149 |
}
|
|
|
150 |
if (catalogId in indentMap[brandName]) {
|
|
|
151 |
indentMap[brandName][catalogId]["quantity"] = quantity;
|
|
|
152 |
indentMap[brandName][catalogId]["sellingPrice"] = sellingPrice;
|
|
|
153 |
indentMap[brandName][catalogId]["description"] = description;
|
|
|
154 |
indentMap[brandName][catalogId]["catalogId"] = catalogId;
|
|
|
155 |
indentMap[brandName][catalogId]["diff"] = quantity
|
|
|
156 |
- indentMap[brandName][catalogId]["initialQuantity"];
|
|
|
157 |
} else {
|
|
|
158 |
indentMap[brandName][catalogId] = {
|
|
|
159 |
"quantity": quantity,
|
|
|
160 |
"sellingPrice": sellingPrice,
|
|
|
161 |
"description": description,
|
|
|
162 |
"catalogId": catalogId,
|
|
|
163 |
"initialQuantity": 0,
|
|
|
164 |
"diff": quantity
|
|
|
165 |
};
|
|
|
166 |
}
|
| 25721 |
tejbeer |
167 |
|
| 33910 |
amit.gupta |
168 |
console.log(indentMap);
|
|
|
169 |
console.log(currentFofoId)
|
|
|
170 |
doPostAjaxRequestHandler(context
|
|
|
171 |
+ "/open-indent/save?catalogId=" + catalogId + "&itemQty=" + quantity + "&fofoId=" + currentFofoId
|
|
|
172 |
, function (response) {
|
|
|
173 |
console.log(response);
|
|
|
174 |
if (response == 'true') {
|
|
|
175 |
}
|
|
|
176 |
});
|
|
|
177 |
populateIndentSummary();
|
|
|
178 |
});
|
| 25721 |
tejbeer |
179 |
|
| 30017 |
amit.gupta |
180 |
|
| 33910 |
amit.gupta |
181 |
/*
|
|
|
182 |
* $(document).on('click', "button.mk_submit_indent", function() {
|
|
|
183 |
* confirmString =[]; confirmString .push('<table class="table
|
|
|
184 |
* table-striped table-condensed table-bordered"
|
|
|
185 |
* id="entire-catalog-table">'); confirmString.push('<tr>');
|
|
|
186 |
* confirmString .push('<th style="width:100px">Catalog Id</th>');
|
|
|
187 |
* confirmString .push('<th style="width:250px">Description</th>');
|
|
|
188 |
* confirmString .push('<th style="width:150px">Unit Price</th>');
|
|
|
189 |
* confirmString .push('<th style="width:150px">Quantity</th>');
|
|
|
190 |
* confirmString .push('<th style="width:200px">Item total</th>');
|
|
|
191 |
* confirmString.push('</tr>'); changedItemIds
|
|
|
192 |
* .forEach(function(itemId) {
|
|
|
193 |
*
|
|
|
194 |
* confirmString .push('<tr style="background-color:#9C7D7E">');
|
|
|
195 |
* confirmString.push('<td>' + itemId + '</td>');
|
|
|
196 |
* confirmString.push('<td>' +indentMap[itemId].description + '</td>');
|
|
|
197 |
* confirmString .push('<td style="text-align:left">' +
|
|
|
198 |
* numberToComma(indentMap[itemId].sellingPrice) + '</td>');
|
|
|
199 |
* confirmString.push('<td style="text-align:left">' +
|
|
|
200 |
* indentMap[itemId].quantity + '(' +(indentMap[itemId].diff > 0 ? '+' :
|
|
|
201 |
* '-') + Math.abs(indentMap[itemId].diff) + ' pcs)</td>');
|
|
|
202 |
* confirmString .push('<td style="text-align:left">'
|
|
|
203 |
* +numberToComma(indentMap[itemId].quantity,
|
|
|
204 |
* indentMap[itemId].sellingPrice) + '</td>'); confirmString.push('</tr>');
|
|
|
205 |
* });
|
|
|
206 |
*
|
|
|
207 |
*
|
|
|
208 |
*
|
|
|
209 |
* for ( var itemId in indentMap) { if(itemId.indexOf(changedItemIds) >
|
|
|
210 |
* 0) { continue; } if(indentMap[itemId].quantity > 0) {
|
|
|
211 |
* confirmString.push('<tr>'); confirmString.push('<td>' + itemId + '</td>');
|
|
|
212 |
* confirmString.push('<td>' +indentMap[itemId].description + '</td>');
|
|
|
213 |
* confirmString .push('<td style="text-align:left">' +
|
|
|
214 |
* numberToComma(indentMap[itemId].sellingPrice) + '</td>');
|
|
|
215 |
* confirmString.push('<td style="text-align:left">' +
|
|
|
216 |
* indentMap[itemId].quantity + '</td>'); confirmString .push('<td style="text-align:left">' +
|
|
|
217 |
* numberToComma(indentMap[itemId].quantity
|
|
|
218 |
* ,indentMap[itemId].sellingPrice) + '</td>'); confirmString.push('</tr>'); } }
|
|
|
219 |
* confirmString.push('</table>');
|
|
|
220 |
* $('#indent-container1').html(confirmString.join('')) .show();
|
|
|
221 |
* $('#indent-container').hide(); $('button.mk_submit_indent').hide();
|
|
|
222 |
* $('button.bk_toedit_indent').show();
|
|
|
223 |
* $('button.confirm_indent').show();
|
|
|
224 |
*/
|
|
|
225 |
/*
|
|
|
226 |
* $(document).on('click', "button.confirm_indent", function() { var
|
|
|
227 |
* itemQtyList = []; for (catalogId in indentMap) { diff =
|
|
|
228 |
* indentMap[catalogId]["quantity"] -
|
|
|
229 |
* indentMap[catalogId]["initialQuantity"]; if (diff != 0) {
|
|
|
230 |
* itemQtyList.push({ "quantity" : indentMap[catalogId]["quantity"],
|
|
|
231 |
* "catalogId" : indentMap[catalogId]["catalogId"] }); } }
|
|
|
232 |
* doPostAjaxRequestWithJsonHandler(context +
|
|
|
233 |
* "/open-indent/save?fofoId=" + currentFofoId + "&counxterSize=" +
|
|
|
234 |
* counterSize, JSON .stringify(itemQtyList), function(data) {
|
|
|
235 |
* alert('Indent has been created Successfully!'); indentMap = {};
|
|
|
236 |
* loadIndent('main-content'); }); });
|
|
|
237 |
*/
|
| 30017 |
amit.gupta |
238 |
|
| 33910 |
amit.gupta |
239 |
$(document).on('click', ".confirm_indent",
|
|
|
240 |
function () {
|
|
|
241 |
if (confirm("Are you sure to confirm the indent") == true) {
|
|
|
242 |
doPostAjaxRequestHandler(context + "/open-indent/confirm?fofoId=" + currentFofoId,
|
|
|
243 |
function (response) {
|
| 30017 |
amit.gupta |
244 |
|
| 33910 |
amit.gupta |
245 |
console.log(response);
|
|
|
246 |
if (response == 'true') {
|
|
|
247 |
alert("successfully confirm");
|
|
|
248 |
// loadIndent('main-content');
|
|
|
249 |
}
|
|
|
250 |
});
|
| 30017 |
amit.gupta |
251 |
|
|
|
252 |
|
| 33910 |
amit.gupta |
253 |
}
|
|
|
254 |
});
|
| 23786 |
amit.gupta |
255 |
|
| 33910 |
amit.gupta |
256 |
/*
|
|
|
257 |
* $(document).on('click', "button.bk_toedit_indent", function() {
|
|
|
258 |
* $('button.bk_toedit_indent').hide(); $('button.confirm_indent').hide();
|
|
|
259 |
* $('button.mk_submit_indent').show(); $('#indent-container1').hide();
|
|
|
260 |
* $('#indent-container').show();
|
|
|
261 |
*
|
|
|
262 |
* });
|
|
|
263 |
*/
|
|
|
264 |
|
| 23405 |
amit.gupta |
265 |
});
|
|
|
266 |
|
| 23786 |
amit.gupta |
267 |
function populateIndentSummary() {
|
| 33910 |
amit.gupta |
268 |
$planSummary = $("#plansummary");
|
| 23786 |
amit.gupta |
269 |
|
| 33910 |
amit.gupta |
270 |
$planSummary.html('');
|
|
|
271 |
changedItemIds = [];
|
|
|
272 |
htmArr = [];
|
|
|
273 |
$('button.confirm_indent').hide();
|
|
|
274 |
for (var brandName in indentMap) {
|
| 25721 |
tejbeer |
275 |
|
| 30017 |
amit.gupta |
276 |
|
| 33910 |
amit.gupta |
277 |
allZero = true;
|
|
|
278 |
trArray = [];
|
| 30017 |
amit.gupta |
279 |
|
| 33910 |
amit.gupta |
280 |
for (var itemId in indentMap[brandName]) {
|
|
|
281 |
var description = indentMap[brandName][itemId]['description'];
|
| 25721 |
tejbeer |
282 |
|
| 33910 |
amit.gupta |
283 |
var itemQty = indentMap[brandName][itemId]['quantity'];
|
| 30017 |
amit.gupta |
284 |
|
|
|
285 |
|
| 33910 |
amit.gupta |
286 |
var sellingPrice = indentMap [brandName][itemId]['sellingPrice'];
|
|
|
287 |
var sellPrice = itemQty * sellingPrice;
|
| 30017 |
amit.gupta |
288 |
|
| 33910 |
amit.gupta |
289 |
if (itemQty != 0) {
|
|
|
290 |
allZero = false;
|
| 30017 |
amit.gupta |
291 |
|
| 33910 |
amit.gupta |
292 |
trString = `<tr>
|
| 25736 |
tejbeer |
293 |
<td style = "width:80%">${description}</td>
|
| 25721 |
tejbeer |
294 |
<td>${itemQty}</td>
|
| 25736 |
tejbeer |
295 |
<td class ="currency" >${sellPrice}</td>
|
|
|
296 |
</tr>`
|
| 33910 |
amit.gupta |
297 |
trArray.push(trString);
|
| 25721 |
tejbeer |
298 |
|
| 33910 |
amit.gupta |
299 |
}
|
| 30017 |
amit.gupta |
300 |
|
|
|
301 |
|
| 33910 |
amit.gupta |
302 |
}
|
|
|
303 |
if (!allZero) {
|
|
|
304 |
$('button.confirm_indent').show();
|
|
|
305 |
htmArr.push('<div>');
|
|
|
306 |
htmArr.push('<h4>' + brandName + '</h4>');
|
|
|
307 |
htmArr.push('<table class="table table-condensed" id = "planning-table">');
|
|
|
308 |
htmArr.push(trArray.join(' '));
|
|
|
309 |
htmArr.push('</table>');
|
|
|
310 |
htmArr.push('</div>');
|
| 30017 |
amit.gupta |
311 |
|
|
|
312 |
|
| 33910 |
amit.gupta |
313 |
}
|
| 25736 |
tejbeer |
314 |
|
| 33910 |
amit.gupta |
315 |
}
|
| 25721 |
tejbeer |
316 |
|
| 30017 |
amit.gupta |
317 |
|
| 33910 |
amit.gupta |
318 |
$planSummary.html(htmArr.join(""));
|
|
|
319 |
var total = 0;
|
|
|
320 |
$('#planning-table tr').each(function () {
|
| 30017 |
amit.gupta |
321 |
|
|
|
322 |
|
| 33910 |
amit.gupta |
323 |
var value = parseInt($('td', this).eq(2).text());
|
|
|
324 |
if (!isNaN(value)) {
|
|
|
325 |
total += value;
|
|
|
326 |
}
|
| 30017 |
amit.gupta |
327 |
|
| 33910 |
amit.gupta |
328 |
console.log(total);
|
| 30017 |
amit.gupta |
329 |
|
| 33910 |
amit.gupta |
330 |
});
|
| 30017 |
amit.gupta |
331 |
|
| 33910 |
amit.gupta |
332 |
divString = `<div style ="float:right"><b>Total:-</b><span class="currency">${total}</span></div>`
|
|
|
333 |
htmArr.push(divString);
|
|
|
334 |
$planSummary.html(htmArr.join(""));
|
| 30017 |
amit.gupta |
335 |
|
|
|
336 |
|
| 33910 |
amit.gupta |
337 |
// $('#planning-table tfoot td').eq(2).text('Total: ' + total);
|
| 30017 |
amit.gupta |
338 |
|
| 23405 |
amit.gupta |
339 |
}
|
| 30017 |
amit.gupta |
340 |
|
| 23786 |
amit.gupta |
341 |
function loadIndent(domId) {
|
| 33910 |
amit.gupta |
342 |
var url = "/indent/loadIndent?fofoId=" + currentFofoId + "&counterSize="
|
|
|
343 |
+ counterSize;
|
|
|
344 |
doAjaxRequestHandler(context + url, "GET", function (response) {
|
|
|
345 |
{
|
|
|
346 |
}
|
|
|
347 |
$('#' + domId).html(response);
|
|
|
348 |
});
|
| 23405 |
amit.gupta |
349 |
}
|
| 26131 |
tejbeer |
350 |
|
|
|
351 |
function loadPreviousMonthIndent(domId) {
|
| 33910 |
amit.gupta |
352 |
let url = `${context}/indent/loadIndentPreviousMonth?fofoId=${currentFofoId}&counterSize=${counterSize}`;
|
|
|
353 |
doAjaxRequestHandler(context + url, "GET", function (response) {
|
|
|
354 |
$('#' + domId).html(response);
|
|
|
355 |
});
|
| 26131 |
tejbeer |
356 |
}
|
| 30017 |
amit.gupta |
357 |
|
| 24229 |
amit.gupta |
358 |
function downloadIndent() {
|
| 33910 |
amit.gupta |
359 |
let url = `${context}/indent/download?fofoId=${currentFofoId}&counterSize=${counterSize}`;
|
|
|
360 |
doAjaxGetDownload(url, "indent.csv");
|
| 23405 |
amit.gupta |
361 |
}
|