Skip to content

Commit

Permalink
Fix for wrong math on remaining licenses when assigned to an asset
Browse files Browse the repository at this point in the history
  • Loading branch information
snipe committed Feb 11, 2015
1 parent e343c15 commit cd5a352
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
17 changes: 10 additions & 7 deletions app/models/License.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,23 @@ public function availcount()
*/
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()
{
$total = $this->totalSeatsByLicenseID();
$taken = $this->assignedcount();
$diff = ($total - $taken);

return $diff;
}

Expand Down
2 changes: 1 addition & 1 deletion app/views/backend/hardware/index.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit cd5a352

Please sign in to comment.