mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
Fixed division by zero error
This commit is contained in:
parent
fb35e40342
commit
cb91829729
|
@ -214,7 +214,12 @@ class Helper
|
|||
foreach ($consumables as $consumable) {
|
||||
$avail = $consumable->numRemaining();
|
||||
if ($avail < ($consumable->min_amt) + \App\Models\Setting::getSettings()->alert_threshold) {
|
||||
$percent = number_format((($consumable->numRemaining() / $consumable->qty) * 100), 0);
|
||||
if ($consumable->total_qty > 0) {
|
||||
$percent = number_format((($consumable->numRemaining() / $consumable->total_qty) * 100), 0);
|
||||
} else {
|
||||
$percent = 100;
|
||||
}
|
||||
|
||||
$items_array[$all_count]['id'] = $consumable->id;
|
||||
$items_array[$all_count]['name'] = $consumable->name;
|
||||
$items_array[$all_count]['type'] = 'consumables';
|
||||
|
@ -230,7 +235,13 @@ class Helper
|
|||
foreach ($accessories as $accessory) {
|
||||
$avail = $accessory->numRemaining();
|
||||
if ($avail < ($accessory->min_amt) + \App\Models\Setting::getSettings()->alert_threshold) {
|
||||
$percent = number_format((($accessory->numRemaining() / $accessory->qty) * 100), 0);
|
||||
|
||||
if ($accessory->total_qty > 0) {
|
||||
$percent = number_format((($accessory->numRemaining() / $accessory->total_qty) * 100), 0);
|
||||
} else {
|
||||
$percent = 100;
|
||||
}
|
||||
|
||||
$items_array[$all_count]['id'] = $accessory->id;
|
||||
$items_array[$all_count]['name'] = $accessory->name;
|
||||
$items_array[$all_count]['type'] = 'accessories';
|
||||
|
@ -245,7 +256,12 @@ class Helper
|
|||
foreach ($components as $component) {
|
||||
$avail = $component->numRemaining();
|
||||
if ($avail < ($component->min_amt) + \App\Models\Setting::getSettings()->alert_threshold) {
|
||||
if ($component->total_qty > 0) {
|
||||
$percent = number_format((($component->numRemaining() / $component->total_qty) * 100), 0);
|
||||
} else {
|
||||
$percent = 100;
|
||||
}
|
||||
|
||||
$items_array[$all_count]['id'] = $component->id;
|
||||
$items_array[$all_count]['name'] = $component->name;
|
||||
$items_array[$all_count]['type'] = 'components';
|
||||
|
|
Loading…
Reference in a new issue