Fix for wrong math on remaining licenses when assigned to an asset

This commit is contained in:
snipe
2015-02-11 13:39:08 -08:00
parent e343c157c5
commit cd5a352961
2 changed files with 11 additions and 8 deletions
+10 -7
View File
@@ -112,12 +112,16 @@ class License extends Elegant
*/
public function assignedcount()
{
return DB::table('license_seats')
->whereNotNull('assigned_to')
->whereNotNull('asset_id')
->where('license_id', '=', $this->id)
->whereNull('deleted_at')
->count();
return LicenseSeat::where('license_id', '=', $this->id)
->where( function ( $query )
{
$query->whereNotNull('assigned_to')
->orWhereNotNull('asset_id');
})
->count();
}
public function remaincount()
@@ -125,7 +129,6 @@ class License extends Elegant
$total = $this->totalSeatsByLicenseID();
$taken = $this->assignedcount();
$diff = ($total - $taken);
return $diff;
}
+1 -1
View File
@@ -143,9 +143,9 @@
@endif
</td>
<td nowrap="nowrap">
<a href="{{ route('update/hardware', $asset->id) }}" class="btn btn-warning"><i class="icon-pencil icon-white"></i></a>
@if ($asset->deleted_at=='')
<a href="{{ route('update/hardware', $asset->id) }}" class="btn btn-warning"><i class="icon-pencil icon-white"></i></a>
<a data-html="false" class="btn delete-asset btn-danger" data-toggle="modal" href="{{ route('delete/hardware', $asset->id) }}" data-content="@lang('admin/hardware/message.delete.confirm')"
data-title="@lang('general.delete')
{{ htmlspecialchars($asset->asset_tag) }}?" onClick="return false;"><i class="icon-trash icon-white"></i></a>