Mark that amount is unknown in part tables and info page

Fixes issue #282
This commit is contained in:
Jan Böhmer 2023-04-29 22:33:46 +02:00
parent 6ffd45a82a
commit 334d81db08
3 changed files with 44 additions and 4 deletions

View file

@ -178,7 +178,22 @@ final class PartsDataTable implements DataTableTypeInterface
$amount = $context->getAmountSum();
$expiredAmount = $context->getExpiredAmountSum();
$ret = htmlspecialchars($this->amountFormatter->format($amount, $context->getPartUnit()));
$ret = '';
if ($context->isAmountUnknown()) {
//When all amounts are unknown, we show a question mark
if ($amount === 0.0) {
$ret .= sprintf('<b class="text-primary" title="%s">?</b>',
$this->translator->trans('part_lots.instock_unknown'));
} else { //Otherwise mark it with greater equal and the (known) amount
$ret .= sprintf('<b class="text-primary" title="%s">≥</b>',
$this->translator->trans('part_lots.instock_unknown')
);
$ret .= htmlspecialchars($this->amountFormatter->format($amount, $context->getPartUnit()));
}
} else {
$ret .= htmlspecialchars($this->amountFormatter->format($amount, $context->getPartUnit()));
}
//If we have expired lots, we show them in parentheses behind
if ($expiredAmount > 0) {