diff --git a/app/Http/Controllers/Api/CompaniesController.php b/app/Http/Controllers/Api/CompaniesController.php
index 4d5a1b2a4f..ebafd9a98e 100644
--- a/app/Http/Controllers/Api/CompaniesController.php
+++ b/app/Http/Controllers/Api/CompaniesController.php
@@ -22,10 +22,21 @@ class CompaniesController extends Controller
{
$this->authorize('view', Company::class);
- $allowed_columns = ['id','name'];
+ $allowed_columns = [
+ 'id',
+ 'name',
+ 'created_at',
+ 'updated_at',
+ 'users_count',
+ 'assets_count',
+ 'licenses_count',
+ 'accessories_count',
+ 'consumables_count',
+ 'components_count',
+ ];
$companies = Company::withCount('assets','licenses','accessories','consumables','components','users')
- ->withCount('users')->withCount('users')->withCount('assets')
+ ->withCount('users')->withCount('assets')
->withCount('licenses')->withCount('accessories')
->withCount('consumables')->withCount('components');
diff --git a/app/Http/Controllers/Api/ComponentsController.php b/app/Http/Controllers/Api/ComponentsController.php
index 4e7a3c4ed7..894d0daa17 100644
--- a/app/Http/Controllers/Api/ComponentsController.php
+++ b/app/Http/Controllers/Api/ComponentsController.php
@@ -149,7 +149,7 @@ class ComponentsController extends Controller
*/
public function getAssets(Request $request, $id)
{
- $this->authorize('index', Asset::class);
+ $this->authorize('view', \App\Models\Asset::class);
$component = Component::findOrFail($id);
$assets = $component->assets();
diff --git a/app/Http/Controllers/AssetsController.php b/app/Http/Controllers/AssetsController.php
index a2598dca63..4fc6d8d2b4 100755
--- a/app/Http/Controllers/AssetsController.php
+++ b/app/Http/Controllers/AssetsController.php
@@ -219,7 +219,7 @@ class AssetsController extends Controller
// Was the asset created?
if ($asset->save()) {
- $asset->logCreate();
+
if (request('assigned_user')) {
$target = User::find(request('assigned_user'));
diff --git a/app/Http/Controllers/LicensesController.php b/app/Http/Controllers/LicensesController.php
index 559f979fad..bfbcbb3b69 100755
--- a/app/Http/Controllers/LicensesController.php
+++ b/app/Http/Controllers/LicensesController.php
@@ -315,7 +315,7 @@ class LicensesController extends Controller
$licenseSeat->asset_id = $request->input('asset_id');
// Override asset's assigned user if available
- if ($target->assigned_to!='') {
+ if ($target->checkedOutToUser()) {
$licenseSeat->assigned_to = $target->assigned_to;
}
diff --git a/app/Http/Transformers/ActionlogsTransformer.php b/app/Http/Transformers/ActionlogsTransformer.php
index ea7b615617..3bb9142083 100644
--- a/app/Http/Transformers/ActionlogsTransformer.php
+++ b/app/Http/Transformers/ActionlogsTransformer.php
@@ -54,6 +54,7 @@ class ActionlogsTransformer
'note' => ($actionlog->note) ? e($actionlog->note): null,
'signature_file' => ($actionlog->accept_signature) ? route('log.signature.view', ['filename' => $actionlog->accept_signature ]) : null,
+ 'log_meta' => ($actionlog->log_meta) ? json_decode($actionlog->log_meta): null,
];
diff --git a/app/Http/Transformers/AssetModelsTransformer.php b/app/Http/Transformers/AssetModelsTransformer.php
index 8c94f00577..f9ba38160e 100644
--- a/app/Http/Transformers/AssetModelsTransformer.php
+++ b/app/Http/Transformers/AssetModelsTransformer.php
@@ -53,7 +53,7 @@ class AssetModelsTransformer
$permissions_array['available_actions'] = [
'update' => (Gate::allows('update', AssetModel::class) && ($assetmodel->deleted_at=='')) ? true : false,
- 'delete' => (Gate::allows('delete', AssetModel::class) && ($assetmodel->deleted_at=='')) ? true : false,
+ 'delete' => (Gate::allows('delete', AssetModel::class) && ($assetmodel->assets_count==0) && ($assetmodel->deleted_at=='')) ? true : false,
'clone' => (Gate::allows('create', AssetModel::class) && ($assetmodel->deleted_at=='')) ,
'restore' => (Gate::allows('create', AssetModel::class) && ($assetmodel->deleted_at!='')) ? true : false,
];
diff --git a/app/Http/Transformers/CompaniesTransformer.php b/app/Http/Transformers/CompaniesTransformer.php
index d8f89ea3b0..e4e8a48711 100644
--- a/app/Http/Transformers/CompaniesTransformer.php
+++ b/app/Http/Transformers/CompaniesTransformer.php
@@ -38,7 +38,7 @@ class CompaniesTransformer
$permissions_array['available_actions'] = [
'update' => Gate::allows('update', Company::class) ? true : false,
- 'delete' => Gate::allows('delete', Company::class) ? true : false,
+ 'delete' => (Gate::allows('delete', Category::class) && ($company->assets_count == 0) && ($company->accessories_count == 0) && ($company->consumables_count == 0) && ($company->components_count == 0) && ($company->users_count == 0)) ? true : false,
];
$array += $permissions_array;
diff --git a/app/Http/Transformers/DepartmentsTranformer.php b/app/Http/Transformers/DepartmentsTranformer.php
index dd51e73aa8..f81954f947 100644
--- a/app/Http/Transformers/DepartmentsTranformer.php
+++ b/app/Http/Transformers/DepartmentsTranformer.php
@@ -47,7 +47,7 @@ class DepartmentsTransformer
$permissions_array['available_actions'] = [
'update' => Gate::allows('update', Department::class) ? true : false,
- 'delete' => Gate::allows('delete', Department::class) ? true : false,
+ 'delete' => (Gate::allows('delete', Department::class) && ($department->users_count==0) && ($department->deleted_at=='')) ? true : false,
];
$array += $permissions_array;
diff --git a/app/Http/Transformers/LocationsTransformer.php b/app/Http/Transformers/LocationsTransformer.php
index 96fd25fee6..f8aa322c30 100644
--- a/app/Http/Transformers/LocationsTransformer.php
+++ b/app/Http/Transformers/LocationsTransformer.php
@@ -57,7 +57,7 @@ class LocationsTransformer
$permissions_array['available_actions'] = [
'update' => Gate::allows('update', Location::class) ? true : false,
- 'delete' => Gate::allows('delete', Location::class) ? true : false,
+ 'delete' => (Gate::allows('delete', Department::class) && ($location->assigned_assets_count==0) && ($location->assets_count==0) && ($location->users_count==0) && ($location->deleted_at=='')) ? true : false,
];
$array += $permissions_array;
diff --git a/app/Http/Transformers/ManufacturersTransformer.php b/app/Http/Transformers/ManufacturersTransformer.php
index 7ef0ea54a6..6972d0bbc4 100644
--- a/app/Http/Transformers/ManufacturersTransformer.php
+++ b/app/Http/Transformers/ManufacturersTransformer.php
@@ -40,7 +40,7 @@ class ManufacturersTransformer
$permissions_array['available_actions'] = [
'update' => Gate::allows('update', Manufacturer::class) ? true : false,
- 'delete' => Gate::allows('delete', Manufacturer::class) ? true : false,
+ 'delete' => (Gate::allows('delete', Manufacturer::class) && ($manufacturer->assets_count == 0) && ($manufacturer->licenses_count==0) && ($manufacturer->consumables_count==0) && ($manufacturer->accessories_count==0) && ($manufacturer->deleted_at=='')) ? true : false,
];
$array += $permissions_array;
diff --git a/app/Models/Actionlog.php b/app/Models/Actionlog.php
index 36603b4bad..4c126bb387 100755
--- a/app/Models/Actionlog.php
+++ b/app/Models/Actionlog.php
@@ -218,7 +218,8 @@ class Actionlog extends SnipeModel
$query->where('companies.name', 'LIKE', '%'.$search.'%');
});
})->orWhere('action_type', 'LIKE', '%'.$search.'%')
- ->orWhere('note', 'LIKE', '%'.$search.'%');
+ ->orWhere('note', 'LIKE', '%'.$search.'%')
+ ->orWhere('log_meta', 'LIKE', '%'.$search.'%');
}
});
diff --git a/app/Observers/AssetObserver.php b/app/Observers/AssetObserver.php
index 3066057d1c..7cac06ed29 100644
--- a/app/Observers/AssetObserver.php
+++ b/app/Observers/AssetObserver.php
@@ -18,18 +18,36 @@ class AssetObserver
public function updating(Asset $asset)
{
-
- if ((isset($asset->getOriginal()['assigned_to'])) && ($asset->getAttributes()['assigned_to'] == $asset->getOriginal()['assigned_to'])
+ // If the asset isn't being checked out or audited, log the update.
+ // (Those other actions already create log entries.)
+ if (($asset->getAttributes()['assigned_to'] == $asset->getOriginal()['assigned_to'])
&& ($asset->getAttributes()['next_audit_date'] == $asset->getOriginal()['next_audit_date'])
- && ($asset->getAttributes()['last_checkout'] == $asset->getOriginal()['last_checkout'])
- && ($asset->getAttributes()['status_id'] == $asset->getOriginal()['status_id']))
+ && ($asset->getAttributes()['last_checkout'] == $asset->getOriginal()['last_checkout']))
{
+ $changed = [];
+
+ foreach ($asset->getOriginal() as $key => $value) {
+ if ($asset->getOriginal()[$key] != $asset->getAttributes()[$key]) {
+ $changed[$key]['old'] = $asset->getOriginal()[$key];
+ $changed[$key]['new'] = $asset->getAttributes()[$key];
+ }
+ }
+
+
$logAction = new Actionlog();
$logAction->item_type = Asset::class;
$logAction->item_id = $asset->id;
$logAction->created_at = date("Y-m-d H:i:s");
$logAction->user_id = Auth::id();
+ $logAction->log_meta = json_encode($changed);
$logAction->logaction('update');
+
+ } else {
+
+ \Log::debug('Something else happened');
+ \Log::debug($asset->getOriginal()['assigned_to'].' == '.$asset->getAttributes()['assigned_to']);
+ \Log::debug($asset->getOriginal()['next_audit_date'].' == '.$asset->getAttributes()['next_audit_date']);
+ \Log::debug($asset->getOriginal()['last_checkout'].' == '.$asset->getAttributes()['last_checkout']);
}
}
diff --git a/app/Presenters/CompanyPresenter.php b/app/Presenters/CompanyPresenter.php
index 233245ff7d..1d0ab86b4a 100644
--- a/app/Presenters/CompanyPresenter.php
+++ b/app/Presenters/CompanyPresenter.php
@@ -41,51 +41,51 @@ class CompanyPresenter extends Presenter
],[
"field" => "users_count",
"searchable" => false,
- "sortable" => false,
+ "sortable" => true,
"title" => ''.trans('general.users').'',
"visible" => true,
],[
"field" => "assets_count",
"searchable" => false,
- "sortable" => false,
+ "sortable" => true,
"title" => ''.trans('general.assets').'',
"visible" => true,
],[
"field" => "licenses_count",
"searchable" => false,
- "sortable" => false,
+ "sortable" => true,
"visible" => true,
"title" => ' '.trans('general.licenses').'',
],[
"field" => "accessories_count",
"searchable" => false,
- "sortable" => false,
+ "sortable" => true,
"visible" => true,
"title" => ' '.trans('general.accessories').'',
],[
"field" => "consumables_count",
"searchable" => false,
- "sortable" => false,
+ "sortable" => true,
"visible" => true,
"title" => ' '.trans('general.consumables').'',
],[
"field" => "components_count",
"searchable" => false,
- "sortable" => false,
+ "sortable" => true,
"visible" => true,
"title" => ' '.trans('general.components').'',
],[
"field" => "updated_at",
"searchable" => false,
- "sortable" => false,
+ "sortable" => true,
"visible" => false,
"title" => trans('general.updated_at'),
],[
"field" => "created_at",
"searchable" => false,
- "sortable" => false,
+ "sortable" => true,
"visible" => false,
"title" => trans('general.created_at'),
],[
diff --git a/database/migrations/2017_12_12_033618_add_actionlog_meta.php b/database/migrations/2017_12_12_033618_add_actionlog_meta.php
new file mode 100644
index 0000000000..a9a662fa1a
--- /dev/null
+++ b/database/migrations/2017_12_12_033618_add_actionlog_meta.php
@@ -0,0 +1,32 @@
+text('log_meta')->nullable()->default(null);
+ });
+ }
+
+ /**
+ * Reverse the migrations.
+ *
+ * @return void
+ */
+ public function down()
+ {
+ Schema::table('action_logs', function (Blueprint $table) {
+ $table->dropColumn('log_meta');
+ });
+ }
+}
diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php
index 6ee49939d6..638e94d7f3 100755
--- a/resources/views/hardware/view.blade.php
+++ b/resources/views/hardware/view.blade.php
@@ -143,29 +143,32 @@
{{ trans('admin/hardware/form.manufacturer') }} |
- @can('view', \App\Models\Manufacturer::class)
-
- {{ $asset->model->manufacturer->name }}
-
- @else
- {{ $asset->model->manufacturer->name }}
- @endcan
+
|
@endif
@@ -426,7 +429,7 @@
{!! $asset->assignedTo->present()->glyph() . ' ' .$asset->assignedTo->present()->nameUrl() !!}
-
+
@if ((isset($asset->assignedTo->email)) && ($asset->assignedTo->email!=''))
- {{ $asset->assignedTo->email }}
@endif
@@ -614,26 +617,33 @@
|
{{ trans('general.date') }} |
- {{ trans('general.admin') }} |
- {{ trans('general.action') }} |
+ {{ trans('general.admin') }} |
+ {{ trans('general.action') }} |
{{ trans('general.item') }} |
{{ trans('general.target') }} |
{{ trans('general.notes') }} |
@if ($snipeSettings->require_accept_signature=='1')
- {{ trans('general.signature') }} |
+ {{ trans('general.signature') }} |
@endif
+ Changed |
+
@@ -673,7 +683,7 @@
{{ trans('general.notes') }} |
|
- {{ trans('general.file_name') }} |
+ {{ trans('general.file_name') }} |
|
|
diff --git a/resources/views/layouts/default.blade.php b/resources/views/layouts/default.blade.php
index f896bbb383..59d7e08ad7 100644
--- a/resources/views/layouts/default.blade.php
+++ b/resources/views/layouts/default.blade.php
@@ -479,7 +479,7 @@
@endcan
- @can('index', \App\Models\Consumable::class)
+ @can('view', \App\Models\Component::class)
-
diff --git a/resources/views/licenses/view.blade.php b/resources/views/licenses/view.blade.php
index 6ee5ffc7c9..dc1bee4c88 100755
--- a/resources/views/licenses/view.blade.php
+++ b/resources/views/licenses/view.blade.php
@@ -56,34 +56,44 @@
Seat {{ $count }} |
@if (($licensedto->user) && ($licensedto->deleted_at == NULL))
+
@can('users.view')
+
{{ $licensedto->user->present()->fullName() }}
@else
+
{{ $licensedto->user->present()->fullName() }}
@endcan
+
@elseif (($licensedto->user) && ($licensedto->deleted_at != NULL))
+
{{ $licensedto->user->present()->fullName() }}
- @elseif ($licensedto->asset)
- @if ($licensedto->asset->assigned_to != 0)
- @can('users.view')
- {!! $licensedto->asset->assignedTo->present()->nameUrl() !!}
- @else
- {{ $licensedto->asset->assignedTo->present()->name() }}
- @endcan
- @endif
+
@endif
|
@if ($licensedto->asset)
+
@can('view', $licensedto->asset)
+
{{ $licensedto->asset->name }} {{ $licensedto->asset->asset_tag }}
@else
+
{{ $licensedto->asset->name }} {{ $licensedto->asset->asset_tag }}
@endcan
+
+ @if ($licensedto->asset->location)
+ @can('locations.view')
+ ({!! $licensedto->asset->location->present()->nameUrl() !!})
+ @else
+ ({{ $licensedto->asset->location->present()->name() }})
+ @endcan
+ @endif
+
@endif
|
diff --git a/resources/views/models/view.blade.php b/resources/views/models/view.blade.php
index 383e1d9cab..3b5b8d7f9e 100755
--- a/resources/views/models/view.blade.php
+++ b/resources/views/models/view.blade.php
@@ -42,27 +42,48 @@
@endif
-
-
-
- {{ trans('general.id') }} |
- {{ trans('admin/companies/table.title') }} |
- {{ trans('general.name') }} |
- {{ trans('general.asset_tag') }} |
- {{ trans('admin/hardware/table.serial') }} |
- {{ trans('general.user') }} |
- {{ trans('admin/hardware/table.change') }} |
- {{ trans('table.actions') }} |
-
-
-
+
+
+ {{ Form::open([
+ 'method' => 'POST',
+ 'route' => ['hardware/bulkedit'],
+ 'class' => 'form-inline',
+ 'id' => 'bulkForm']) }}
+
+
+
+
+
+
+
+
+ |
+ {{ trans('general.id') }} |
+ {{ trans('admin/companies/table.title') }} |
+ {{ trans('general.name') }} |
+ {{ trans('general.asset_tag') }} |
+ {{ trans('admin/hardware/table.serial') }} |
+ {{ trans('admin/hardware/form.checkedout_to') }} |
+ {{ trans('admin/hardware/table.change') }} |
+ {{ trans('table.actions') }} |
+
+
+
+ {{ Form::close() }}
+
+
diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.php
index 1f78566ad1..d049a5c233 100644
--- a/resources/views/partials/bootstrap-table.blade.php
+++ b/resources/views/partials/bootstrap-table.blade.php
@@ -395,6 +395,19 @@
}
}
+
+
+ function changeLogFormatter(value) {
+ var result = '';
+ for (var index in value) {
+ result += index + ': ' + value[index].old + ' ' + value[index].new + ' '
+ }
+
+ return result;
+
+ }
+
+
function deployedLocationFormatter(row, value) {
if ((row) && (row!=undefined)) {
return ' ' + row.name + '';
diff --git a/resources/views/reports/activity.blade.php b/resources/views/reports/activity.blade.php
index 755266d017..4fba5715de 100644
--- a/resources/views/reports/activity.blade.php
+++ b/resources/views/reports/activity.blade.php
@@ -32,6 +32,7 @@
| {{ trans('general.item') }} |
To |
{{ trans('general.notes') }} |
+ Changed |