adds licenses available, updated teranslations

This commit is contained in:
Godfrey M 2024-04-22 17:58:49 -07:00
parent 14ddf36d46
commit 5fc6771543
3 changed files with 25 additions and 5 deletions

View file

@ -307,12 +307,12 @@ class LicensesController extends Controller
$response = new StreamedResponse(function () { $response = new StreamedResponse(function () {
// Open output stream // Open output stream
$handle = fopen('php://output', 'w'); $handle = fopen('php://output', 'w');
$licenses= License::with('company', $licenses= License::with('company',
'manufacturer', 'manufacturer',
'category', 'category',
'supplier', 'supplier',
'adminuser') 'adminuser',
'assignedusers')
->orderBy('created_at', 'DESC'); ->orderBy('created_at', 'DESC');
Company::scopeCompanyables($licenses) Company::scopeCompanyables($licenses)
->chunk(500, function ($licenses) use ($handle) { ->chunk(500, function ($licenses) use ($handle) {
@ -325,6 +325,7 @@ class LicensesController extends Controller
trans('general.purchase_date'), trans('general.purchase_date'),
trans('general.purchase_cost'), trans('general.purchase_cost'),
trans('general.order_number'), trans('general.order_number'),
trans('general.licenses_available'),
trans('admin/licenses/table.seats'), trans('admin/licenses/table.seats'),
trans('general.created_by'), trans('general.created_by'),
trans('general.depreciation'), trans('general.depreciation'),
@ -357,6 +358,7 @@ class LicensesController extends Controller
$license->purchase_date, $license->purchase_date,
$license->purchase_cost, $license->purchase_cost,
$license->order_number, $license->order_number,
$license->free_seat_count,
$license->seats, $license->seats,
$license->adminuser->present()->fullName(), $license->adminuser->present()->fullName(),
$license->depreciation ? $license->depreciation->name: '', $license->depreciation ? $license->depreciation->name: '',

View file

@ -81,6 +81,7 @@ class License extends Depreciable
'serial', 'serial',
'supplier_id', 'supplier_id',
'termination_date', 'termination_date',
'free_seat_count',
'user_id', 'user_id',
'min_amt', 'min_amt',
]; ];
@ -114,6 +115,7 @@ class License extends Depreciable
'category' => ['name'], 'category' => ['name'],
'depreciation' => ['name'], 'depreciation' => ['name'],
]; ];
protected $appends = ['free_seat_count'];
/** /**
* Update seat counts when the license is updated * Update seat counts when the license is updated
@ -280,6 +282,16 @@ class License extends Depreciable
} }
$this->attributes['termination_date'] = $value; $this->attributes['termination_date'] = $value;
} }
/**
* Sets free_seat_count attribute
*
* @author G. Martinez
* @since [v6.3]
* @return mixed
*/
public function getFreeSeatCountAttribute(){
return $this->attributes['free_seat_count'] = $this->remaincount();
}
/** /**
* Establishes the license -> company relationship * Establishes the license -> company relationship
@ -502,7 +514,13 @@ class License extends Depreciable
->whereNull('deleted_at') ->whereNull('deleted_at')
->count(); ->count();
} }
/**
* Returns the available seats remaining
*
* @author A. Gianotto <snipe@snipe.net>
* @since [v2.0]
* @return int
*/
/** /**
* Returns the number of total available seats for this license * Returns the number of total available seats for this license
@ -579,7 +597,7 @@ class License extends Depreciable
$taken = $this->assigned_seats_count; $taken = $this->assigned_seats_count;
$diff = ($total - $taken); $diff = ($total - $taken);
return $diff; return (int) $diff;
} }
/** /**

View file

@ -176,7 +176,7 @@ return [
'last_name' => 'Last Name', 'last_name' => 'Last Name',
'license' => 'License', 'license' => 'License',
'license_report' => 'License Report', 'license_report' => 'License Report',
'licenses_available' => 'licenses available', 'licenses_available' => 'Licenses available',
'licenses' => 'Licenses', 'licenses' => 'Licenses',
'list_all' => 'List All', 'list_all' => 'List All',
'loading' => 'Loading... please wait....', 'loading' => 'Loading... please wait....',