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