| Line 1380... |
Line 1380... |
| 1380 |
}
|
1380 |
}
|
| 1381 |
|
1381 |
|
| 1382 |
var cap = pricing.movableOnThisPo;
|
1382 |
var cap = pricing.movableOnThisPo;
|
| 1383 |
$row.data('movableOnThisPo', cap);
|
1383 |
$row.data('movableOnThisPo', cap);
|
| 1384 |
|
1384 |
|
| 1385 |
var rows = mvAvailLine('In stock', pricing.inStock);
|
1385 |
var rows = mvAvailLine('In stock', pricing.inStock, '');
|
| 1386 |
if (pricing.promisedTotal > 0) {
|
1386 |
if (pricing.promisedTotal > 0) {
|
| 1387 |
rows += mvAvailLine('Promised on open orders', pricing.promisedTotal);
|
1387 |
rows += mvAvailLine('Promised on open orders', pricing.promisedTotal, '');
|
| 1388 |
$.each(pricing.promised || [], function (i, po) {
|
1388 |
$.each(pricing.promised || [], function (i, po) {
|
| 1389 |
rows += '<tr class="mv-po"><td>' + mvEscape(po.poNumber) + ' · ' + mvEscape(po.poDate)
|
1389 |
rows += mvAvailLine(mvEscape(po.poNumber) + ' · ' + mvEscape(po.poDate)
|
| 1390 |
+ (po.destination ? ' → ' + mvEscape(po.destination) : '')
|
1390 |
+ (po.destination ? ' → ' + mvEscape(po.destination) : ''), po.qty, ' mv-po');
|
| 1391 |
+ '</td><td>' + po.qty + '</td></tr>';
|
- |
|
| 1392 |
});
|
1391 |
});
|
| 1393 |
}
|
1392 |
}
|
| 1394 |
if (pricing.inbound > 0) {
|
1393 |
if (pricing.inbound > 0) {
|
| 1395 |
rows += mvAvailLine('On the way in (not yet received)', pricing.inbound);
|
1394 |
rows += mvAvailLine('On the way in (not yet received)', pricing.inbound, '');
|
| 1396 |
}
|
1395 |
}
|
| 1397 |
rows += '<tr class="mv-total"><td>Can move on this PO</td><td>' + cap + '</td></tr>';
|
1396 |
rows += mvAvailLine('Can move on this PO', cap, ' mv-total');
|
| 1398 |
|
1397 |
|
| 1399 |
var note = '';
|
1398 |
var note = '';
|
| 1400 |
if (pricing.costSplit) {
|
1399 |
if (pricing.costSplit) {
|
| 1401 |
note += '<div class="mv-note">' + (pricing.movableAltogether - cap)
|
1400 |
note += '<div class="mv-note">' + (pricing.movableAltogether - cap)
|
| 1402 |
+ ' more came in at a different cost — raise a separate PO for those.</div>';
|
1401 |
+ ' more came in at a different cost — raise a separate PO for those.</div>';
|
| 1403 |
}
|
1402 |
}
|
| 1404 |
if (cap === 0) {
|
1403 |
if (cap === 0) {
|
| - |
|
1404 |
note += '<div class="mv-note">' + (pricing.promisedTotal > 0
|
| 1405 |
note += '<div class="mv-note">Nothing can move until one of the orders above is completed or closed.</div>';
|
1405 |
? 'Nothing can move until one of the orders above is completed or closed.'
|
| - |
|
1406 |
: 'Nothing can move from here yet.') + '</div>';
|
| 1406 |
}
|
1407 |
}
|
| 1407 |
|
1408 |
|
| 1408 |
$icon.attr('data-mv-content', '<table class="mv-avail">' + rows + '</table>' + note);
|
1409 |
$icon.attr('data-mv-content', '<div class="mv-avail">' + rows + '</div>' + note);
|
| 1409 |
$icon.removeClass('mv-none mv-part');
|
1410 |
$icon.removeClass('mv-none mv-part');
|
| 1410 |
if (cap === 0) {
|
1411 |
if (cap === 0) {
|
| 1411 |
$icon.addClass('mv-none');
|
1412 |
$icon.addClass('mv-none');
|
| 1412 |
} else if (pricing.promisedTotal > 0) {
|
1413 |
} else if (pricing.promisedTotal > 0) {
|
| 1413 |
$icon.addClass('mv-part');
|
1414 |
$icon.addClass('mv-part');
|
| Line 1448... |
Line 1449... |
| 1448 |
$qty.removeClass('mv-over');
|
1449 |
$qty.removeClass('mv-over');
|
| 1449 |
$warn.hide().empty();
|
1450 |
$warn.hide().empty();
|
| 1450 |
}
|
1451 |
}
|
| 1451 |
}
|
1452 |
}
|
| 1452 |
|
1453 |
|
| - |
|
1454 |
/**
|
| - |
|
1455 |
* One line of the breakdown.
|
| - |
|
1456 |
*
|
| - |
|
1457 |
* Built from divs and spans on purpose: Bootstrap's popover sanitizer whitelists neither tables nor their rows, and
|
| - |
|
1458 |
* strips a non-whitelisted element together with everything inside it - a table here renders as nothing at all.
|
| - |
|
1459 |
*/
|
| 1453 |
function mvAvailLine(label, value) {
|
1460 |
function mvAvailLine(label, value, extraClass) {
|
| - |
|
1461 |
return '<div class="mv-row' + extraClass + '"><span class="mv-label">' + label
|
| 1454 |
return '<tr><td>' + label + '</td><td>' + value + '</td></tr>';
|
1462 |
+ '</span><span class="mv-val">' + value + '</span></div>';
|
| 1455 |
}
|
1463 |
}
|
| 1456 |
|
1464 |
|
| 1457 |
/** Values here are warehouse and order names out of the database, so they are escaped before going into the popover. */
|
1465 |
/** Values here are warehouse and order names out of the database, so they are escaped before going into the popover. */
|
| 1458 |
function mvEscape(value) {
|
1466 |
function mvEscape(value) {
|
| 1459 |
return $('<div/>').text(value === null || typeof value === 'undefined' ? '' : value).html();
|
1467 |
return $('<div/>').text(value === null || typeof value === 'undefined' ? '' : value).html();
|