mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
adds count on tabs and reports and index
This commit is contained in:
parent
8a0ed49623
commit
5e1562ae4c
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace App\Helpers;
|
||||
use App\Models\Accessory;
|
||||
use App\Models\Actionlog;
|
||||
use App\Models\Asset;
|
||||
use App\Models\AssetModel;
|
||||
use App\Models\Component;
|
||||
|
@ -9,6 +10,7 @@ use App\Models\Consumable;
|
|||
use App\Models\CustomField;
|
||||
use App\Models\CustomFieldset;
|
||||
use App\Models\Depreciation;
|
||||
use App\Models\LicenseSeat;
|
||||
use App\Models\Setting;
|
||||
use App\Models\Statuslabel;
|
||||
use App\Models\License;
|
||||
|
@ -1529,4 +1531,14 @@ class Helper
|
|||
}
|
||||
return redirect()->back()->with('error', trans('admin/hardware/message.checkout.error'));
|
||||
}
|
||||
public static function unReassignableCount($license)
|
||||
{
|
||||
|
||||
if (!$license->reassignable) {
|
||||
$count = Actionlog::where('action_type', '=', 'checkin from')
|
||||
->where('item_id', '=', $license->id)
|
||||
->count();
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -248,16 +248,23 @@ class LicensesController extends Controller
|
|||
}
|
||||
|
||||
$users_count = User::where('autoassign_licenses', '1')->count();
|
||||
$total_seats_count = $license->totalSeatsByLicenseID();
|
||||
$total_seats_count = (int) $license->totalSeatsByLicenseID();
|
||||
$available_seats_count = $license->availCount()->count();
|
||||
$unreassignable_seats_count = Helper::unReassignableCount($license);
|
||||
if(!$license->reassignable){
|
||||
$checkedout_seats_count = ($total_seats_count - $available_seats_count - $unreassignable_seats_count );
|
||||
}
|
||||
else {
|
||||
$checkedout_seats_count = ($total_seats_count - $available_seats_count);
|
||||
}
|
||||
|
||||
$this->authorize('view', $license);
|
||||
return view('licenses.view', compact('license'))
|
||||
->with('users_count', $users_count)
|
||||
->with('total_seats_count', $total_seats_count)
|
||||
->with('available_seats_count', $available_seats_count)
|
||||
->with('checkedout_seats_count', $checkedout_seats_count);
|
||||
->with('checkedout_seats_count', $checkedout_seats_count)
|
||||
->with('unreassignable_seats_count', $unreassignable_seats_count);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ class LicensesTransformer
|
|||
'notes' => Helper::parseEscapedMarkedownInline($license->notes),
|
||||
'expiration_date' => Helper::getFormattedDateObject($license->expiration_date, 'date'),
|
||||
'seats' => (int) $license->seats,
|
||||
'free_seats_count' => (int) $license->free_seats_count,
|
||||
'free_seats_count' => (int) $license->free_seats_count - Helper::unReassignableCount($license),
|
||||
'min_amt' => ($license->min_amt) ? (int) ($license->min_amt) : null,
|
||||
'license_name' => ($license->license_name) ? e($license->license_name) : null,
|
||||
'license_email' => ($license->license_email) ? e($license->license_email) : null,
|
||||
|
|
|
@ -594,7 +594,8 @@ class License extends Depreciable
|
|||
{
|
||||
$total = $this->licenseSeatsCount;
|
||||
$taken = $this->assigned_seats_count;
|
||||
$diff = ($total - $taken);
|
||||
$unreassignable = Helper::unReassignableCount($this);
|
||||
$diff = ($total - $taken - $unreassignable);
|
||||
|
||||
return (int) $diff;
|
||||
}
|
||||
|
|
|
@ -50,7 +50,7 @@ return array(
|
|||
|
||||
'checkin' => array(
|
||||
'error' => 'There was an issue checking in the license. Please try again.',
|
||||
'not_reassignable' => 'Seat has been used.',
|
||||
'not_reassignable' => 'Seat has been used',
|
||||
'success' => 'The license was checked in successfully'
|
||||
),
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
<x-icon type="seats" class="fa-2x" />
|
||||
</span>
|
||||
<span class="hidden-xs hidden-sm">{{ trans('admin/licenses/form.seats') }}</span>
|
||||
<span class="badge badge-secondary">{{ number_format($license->availCount()->count()) }} / {{ number_format($license->seats) }}</span>
|
||||
<span class="badge badge-secondary">{{ number_format($license->availCount()->count() - number_format($unreassignable_seats_count) ) }} / {{ number_format($license->seats)}}</span>
|
||||
|
||||
</a>
|
||||
</li>
|
||||
|
|
Loading…
Reference in a new issue