mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 01:25:55 +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
|
||||
*/
|
||||
|
|
|
@ -41,8 +41,17 @@
|
|||
<span class="text-muted">{{ helper.structural_entity_link(part.category) }}</span>
|
||||
</h6>
|
||||
<h6><i class="fas fa-shapes fa-fw"></i>
|
||||
<span class="{% if part.notEnoughInstock %}text-danger font-weight-bold{% else %}text-muted{% endif %}">
|
||||
<span title="{% trans %}instock.label{% endtrans %}">{{ part.amountSum | format_amount(part.partUnit) }}</span>
|
||||
<span class="{% if part.notEnoughInstock and not part.amountUnknown %}text-danger font-weight-bold{% else %}text-muted{% endif %}">
|
||||
{% if not part.amountUnknown %}
|
||||
{# For known instock we can just show the label as normal #}
|
||||
<span title="{% trans %}instock.label{% endtrans %}">{{ part.amountSum | format_amount(part.partUnit) }}</span>
|
||||
{% else %}
|
||||
{% if part.amountSum == 0.0 %}
|
||||
<b title="{% trans %}part_lots.instock_unknown{% endtrans %}">?</b>
|
||||
{% else %}
|
||||
<span title="{% trans %}part_lots.instock_unknown{% endtrans %}">≥{{ part.amountSum | format_amount(part.partUnit) }}</span>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if part.expiredAmountSum > 0 %}
|
||||
<span title="{% trans %}part_lots.is_expired{% endtrans %}" class="text-muted">(+{{ part.expiredAmountSum }})</span>
|
||||
{% endif %}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue