mirror of
https://github.com/snipe/snipe-it.git
synced 2024-11-09 23:24:06 -08:00
Added numCheckedOut method
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
d9b7df5b85
commit
79a13e3618
|
@ -329,6 +329,20 @@ class Accessory extends SnipeModel
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check how many items within an accessory are checked out
|
||||||
|
*
|
||||||
|
* @author [A. Gianotto] [<snipe@snipe.net>]
|
||||||
|
* @since [v5.0]
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public function numCheckedOut()
|
||||||
|
{
|
||||||
|
\Log::debug('numCheckedOut: '.$this->users_count ?? $this->users->count());
|
||||||
|
return $this->users_count ?? $this->users->count();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check how many items of an accessory remain.
|
* Check how many items of an accessory remain.
|
||||||
*
|
*
|
||||||
|
@ -342,10 +356,14 @@ class Accessory extends SnipeModel
|
||||||
*/
|
*/
|
||||||
public function numRemaining()
|
public function numRemaining()
|
||||||
{
|
{
|
||||||
$checkedout = $this->users_count;
|
$checkedout = $this->numCheckedOut();
|
||||||
$total = $this->qty;
|
$total = $this->qty;
|
||||||
$remaining = $total - $checkedout;
|
$remaining = $total - $checkedout;
|
||||||
|
|
||||||
|
\Log::debug('checked out: '.$checkedout);
|
||||||
|
\Log::debug('total: '.$total);
|
||||||
|
\Log::debug('remaining: '.$remaining);
|
||||||
|
|
||||||
return (int) $remaining;
|
return (int) $remaining;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue