mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-24 18:58:46 +02:00
Mark that amount is unknown in part tables and info page
Fixes issue #282
This commit is contained in:
parent
6ffd45a82a
commit
334d81db08
3 changed files with 44 additions and 4 deletions
|
@ -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) {
|
||||
|
|
|
@ -160,9 +160,25 @@ trait InstockTrait
|
|||
return $this->getAmountSum() < $this->getMinAmount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true, if at least one of the part lots has an unknown amount.
|
||||
* It is possible that other part lots have a known amount, then getAmountSum() will return sum of all known amounts.
|
||||
* @return bool True if at least one part lot has an unknown amount.
|
||||
*/
|
||||
public function isAmountUnknown(): bool
|
||||
{
|
||||
foreach ($this->getPartLots() as $lot) {
|
||||
if ($lot->isInstockUnknown()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the summed amount of this part (over all part lots)
|
||||
* Part Lots that have unknown value or are expired, are not used for this value.
|
||||
* Part Lots that have unknown value or are expired, are not used for this value (counted as 0).
|
||||
*
|
||||
* @return float The amount of parts given in partUnit
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue