Skip to content
1 change: 1 addition & 0 deletions app/Http/Controllers/Api/LicensesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public function index(Request $request) : JsonResponse | array
[
'id',
'name',
'version',
'purchase_cost',
'expiration_date',
'purchase_order',
Expand Down
2 changes: 2 additions & 0 deletions app/Http/Controllers/Licenses/LicensesController.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ public function store(Request $request)
$license->maintained = $request->input('maintained', 0);
$license->manufacturer_id = $request->input('manufacturer_id');
$license->name = $request->input('name');
$license->version = $request->input('version');
$license->notes = $request->input('notes');
$license->order_number = $request->input('order_number');
$license->purchase_cost = $request->input('purchase_cost');
Expand Down Expand Up @@ -169,6 +170,7 @@ public function update(Request $request, License $license)
$license->license_name = $request->input('license_name');
$license->maintained = $request->input('maintained',0);
$license->name = $request->input('name');
$license->version = $request->input('version');
$license->notes = $request->input('notes');
$license->order_number = $request->input('order_number');
$license->purchase_cost = $request->input('purchase_cost');
Expand Down
1 change: 1 addition & 0 deletions app/Http/Transformers/LicensesTransformer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function transformLicense(License $license)
$array = [
'id' => (int) $license->id,
'name' => e($license->name),
'version' => e($license->version),
'company' => ($license->company) ? ['id' => (int) $license->company->id, 'name'=> e($license->company->name)] : null,
'manufacturer' => ($license->manufacturer) ? ['id' => (int) $license->manufacturer->id, 'name'=> e($license->manufacturer->name)] : null,
'product_key' => (Gate::allows('viewKeys', License::class)) ? e($license->serial) : '------------',
Expand Down
1 change: 1 addition & 0 deletions app/Importer/LicenseImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public function createLicenseIfNotExists(array $row)
$this->item['reassignable'] = 1;
}
$this->item['seats'] = $this->findCsvMatch($row, 'seats');
$this->item['version'] = $this->findCsvMatch($row, 'version');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to add this to the mapping options as well for this to import properly.

$this->licenses_fields = [
'asset_tag' => trans('general.importer.checked_out_to_tag'),
'category' => trans('general.category'),
'checkout_class' => trans('general.importer.checkout_type'),
'company' => trans('general.company'),
'email' => trans('general.importer.checked_out_to_email'),
'expiration_date' => trans('admin/licenses/form.expiration'),
'full_name' => trans('general.importer.checked_out_to_fullname'),
'item_name' => trans('general.item_name_var', ['item' => trans('general.license')]),
'license_email' => trans('admin/licenses/form.to_email'),
'license_name' => trans('admin/licenses/form.to_name'),
'location' => trans('general.location'),
'maintained' => trans('admin/licenses/form.maintained'),
'manufacturer' => trans('general.manufacturer'),
'min_amt' => trans('general.min_amt'),
'notes' => trans('general.notes'),
'order_number' => trans('general.order_number'),
'purchase_cost' => trans('general.purchase_cost'),
'purchase_date' => trans('general.purchase_date'),
'purchase_order' => trans('admin/licenses/form.purchase_order'),
'reassignable' => trans('admin/licenses/form.reassignable'),
'seats' => trans('admin/licenses/form.seats'),
'serial' => trans('general.license_serial'),
'supplier' => trans('general.supplier'),
'termination_date' => trans('admin/licenses/form.termination_date'),
'username' => trans('general.importer.checked_out_to_username'),
];

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in commit 6d3e494


$this->item["termination_date"] = null;
if ($this->findCsvMatch($row, "termination_date")!='') {
Expand Down
2 changes: 2 additions & 0 deletions app/Models/License.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ class License extends Depreciable

protected $rules = [
'name' => 'required|string|min:3|max:255',
'name' => 'string|nullable',
'seats' => 'required|min:1|integer|limit_change:10000', // limit_change is a "pseudo-rule" that translates into 'between', see prepareLimitChangeRule() below
'license_email' => 'email|nullable|max:120',
'license_name' => 'string|nullable|max:100',
Expand Down Expand Up @@ -73,6 +74,7 @@ class License extends Depreciable
'manufacturer_id',
'category_id',
'name',
'version',
'notes',
'order_number',
'purchase_cost',
Expand Down
6 changes: 6 additions & 0 deletions app/Presenters/LicensePresenter.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ public static function dataTableLayout()
'switchable' => false,
'title' => trans('general.name'),
'formatter' => 'licensesLinkFormatter',
], [
], [
'field' => 'version',
'searchable' => false,
'sortable' => true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'd need to add version to the $allowed_columns in the Licenses API in order to sort on it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in commit 8ab9154

'title' => trans('admin/licenses/form.version'),
], [
'field' => 'product_key',
'searchable' => true,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('licenses', function (Blueprint $table) {
if (!Schema::hasColumn('licenses', 'version')) {
$table->string('version')->after('name')->nullable()->default(null);
};
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('licenses', function (Blueprint $table) {
$table->dropColumn('version');
});
}
};
1 change: 1 addition & 0 deletions resources/lang/en-GB/admin/licenses/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
'license_key' => 'Product Key',
'maintained' => 'Maintained',
'name' => 'Software Name',
'version' => 'Software Version',
'no_depreciation' => 'Do Not Depreciate',
'purchase_order' => 'Purchase Order Number',
'reassignable' => 'Reassignable',
Expand Down
1 change: 1 addition & 0 deletions resources/lang/en-US/admin/licenses/form.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
'license_key' => 'Product Key',
'maintained' => 'Maintained',
'name' => 'Software Name',
'version' => 'Software Version',
'no_depreciation' => 'Do Not Depreciate',
'purchase_order' => 'Purchase Order Number',
'reassignable' => 'Reassignable',
Expand Down
10 changes: 10 additions & 0 deletions resources/views/licenses/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@
{{-- Page content --}}
@section('inputFields')
@include ('partials.forms.edit.name', ['translated_name' => trans('admin/licenses/form.name')])

<!-- Version -->
<div class="form-group {{ $errors->has('version') ? 'has-error' : '' }}">
<label for="version" class="col-md-3 control-label">{{ trans('admin/licenses/form.version') }}</label>
<div class="col-md-8 col-sm-12">
<input class="form-control" type="text" name="version" aria-label="version" id="version" value="{{ old('version', $item->version) }}" style="width: 100%;">
{!! $errors->first('version', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
</div>

@include ('partials.forms.edit.category-select', ['translated_name' => trans('admin/categories/general.category_name'), 'fieldname' => 'category_id', 'required' => 'true', 'category_type' => 'license'])


Expand Down
10 changes: 10 additions & 0 deletions resources/views/licenses/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,16 @@
</div>
@endif

@if ($license->version)
<div class="row">
<div class="col-md-3">
<strong>{{ trans('admin/licenses/form.version') }}</strong>
</div>
<div class="col-md-9">
{{ $license->version }}
</div>
</div>
@endif

@if ($license->license_name!='')
<div class="row">
Expand Down
Loading