diff --git a/app/Http/Controllers/Api/AssetsController.php b/app/Http/Controllers/Api/AssetsController.php index 2980057ea6..45e323b9c4 100644 --- a/app/Http/Controllers/Api/AssetsController.php +++ b/app/Http/Controllers/Api/AssetsController.php @@ -302,7 +302,7 @@ class AssetsController extends Controller $asset->use_text = $asset->present()->fullName; - if ($asset->checkedOutToUser()) { + if (($asset->checkedOutToUser()) && ($asset->assigned)) { $asset->use_text .= ' → '.$asset->assigned->getFullNameAttribute(); } diff --git a/app/Http/Controllers/LicensesController.php b/app/Http/Controllers/LicensesController.php index cd3308edbd..a26be9ac1e 100755 --- a/app/Http/Controllers/LicensesController.php +++ b/app/Http/Controllers/LicensesController.php @@ -288,9 +288,6 @@ class LicensesController extends Controller } - $assigned_to = $request->input('assigned_to'); - $asset_id = $request->input('asset_id'); - $this->authorize('checkout', $licenseSeat); // Declare the rules for the form validation @@ -309,51 +306,33 @@ class LicensesController extends Controller } $target = null; - // If assigned to a user - if ($assigned_to!='') { - // Check if the user exists - if (is_null($target = User::find($assigned_to))) { - // Redirect to the asset management page with error - return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.user_does_not_exist')); - } - } - // If assigned to an asset - if ($asset_id!='') { - if (is_null($target = Asset::find($asset_id))) { - // Redirect to the asset management page with error + // This item is checked out to a an asset + if (request('checkout_to_type')=='asset') { + if (is_null($target = Asset::find(request('asset_id')))) { return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.asset_does_not_exist')); } - - if (($request->has('assigned_to')) && ($request->has('asset_id'))) { - return redirect()->back()->withInput()->with('error', trans('admin/licenses/message.select_asset_or_person')); - } - } - - - if ($request->input('asset_id') == '') { - $licenseSeat->asset_id = null; - } else { $licenseSeat->asset_id = $request->input('asset_id'); - } - // Update the asset data - if ($request->input('assigned_to') == '') { - $licenseSeat->assigned_to = null; + // Override asset's assigned user if available + if ($target->assigned_to!='') { + $licenseSeat->assigned_to = $target->assigned_to; + } + } else { - $licenseSeat->assigned_to = $request->input('assigned_to'); + + // Fetch the target and set the license user + if (is_null($target = User::find(request('assigned_to')))) { + return redirect()->route('licenses.index')->with('error', trans('admin/licenses/message.user_does_not_exist')); + } + $licenseSeat->assigned_to = request('assigned_to'); } $licenseSeat->user_id = Auth::user()->id; - // Was the asset updated? + if ($licenseSeat->save()) { $licenseSeat->logCheckout($request->input('note'), $target); - - $data['license_id'] = $licenseSeat->license_id; - $data['note'] = $request->input('note'); - - // Redirect to the new asset page return redirect()->route("licenses.index")->with('success', trans('admin/licenses/message.checkout.success')); } diff --git a/app/Http/Controllers/ReportsController.php b/app/Http/Controllers/ReportsController.php index 6b4c332f9b..c60b33fcb3 100644 --- a/app/Http/Controllers/ReportsController.php +++ b/app/Http/Controllers/ReportsController.php @@ -156,6 +156,7 @@ class ReportsController extends Controller trans('admin/hardware/form.order'), trans('general.supplier'), trans('admin/hardware/table.checkoutto'), + trans('general.type'), trans('admin/hardware/table.checkout_date'), trans('admin/hardware/table.location'), trans('general.notes'), @@ -166,6 +167,8 @@ class ReportsController extends Controller fputcsv($handle, $headers); foreach ($assets as $asset) { + + // Add a new row with data $values=[ ($asset->company) ? $asset->company->name : '', @@ -175,12 +178,13 @@ class ReportsController extends Controller ($asset->model->model_number) ? $asset->model->model_number : '', ($asset->name) ? $asset->name : '', ($asset->serial) ? $asset->serial : '', - ($asset->assetstatus) ? e($asset->assetstatus->name) : '', + ($asset->assetstatus) ? e($asset->present()->statusText) : '', ($asset->purchase_date) ? e($asset->purchase_date) : '', ($asset->purchase_cost > 0) ? Helper::formatCurrencyOutput($asset->purchase_cost) : '', ($asset->order_number) ? e($asset->order_number) : '', ($asset->supplier) ? e($asset->supplier->name) : '', - ($asset->assignedTo) ? e($asset->assignedTo->present()->name()) : '', + ($asset->checkedOutToUser()) ? e($asset->assigned->getFullNameAttribute()) : ($asset->assigned ? e($asset->assigned->display_name) : ''), + ($asset->checkedOutToUser()) ? 'user' : e($asset->assignedType()), ($asset->last_checkout!='') ? e($asset->last_checkout) : '', ($asset->location) ? e($asset->location->name) : '', ($asset->notes) ? e($asset->notes) : '', diff --git a/app/Http/Transformers/AssetsTransformer.php b/app/Http/Transformers/AssetsTransformer.php index 2dbc9da726..b3435df54e 100644 --- a/app/Http/Transformers/AssetsTransformer.php +++ b/app/Http/Transformers/AssetsTransformer.php @@ -111,10 +111,23 @@ class AssetsTransformer 'checkout' => (bool) Gate::allows('checkout', Asset::class), 'checkin' => (bool) Gate::allows('checkin', Asset::class), 'clone' => Gate::allows('create', Asset::class) ? true : false, + 'restore' => false, 'update' => (bool) Gate::allows('update', Asset::class), 'delete' => (bool) Gate::allows('delete', Asset::class), ]; + if ($asset->deleted_at!='') { + $permissions_array['available_actions'] = [ + 'checkout' => true, + 'checkin' => false, + 'clone' => Gate::allows('create', Asset::class) ? true : false, + 'restore' => Gate::allows('create', Asset::class) ? true : false, + 'update' => false, + 'delete' => false, + ]; + } + + $array += $permissions_array; return $array; } diff --git a/config/version.php b/config/version.php index 6cad51c247..9635a9cb30 100644 --- a/config/version.php +++ b/config/version.php @@ -1,10 +1,10 @@ 'v4.1.6', - 'full_app_version' => 'v4.1.6 - build 2940-g0910587', - 'build_version' => '2940', + 'app_version' => 'v4.1.6-pre', + 'full_app_version' => 'v4.1.6-pre - build 2765-g1d6320a', + 'build_version' => '2765', 'prerelease_version' => '', 'hash_version' => 'g0910587', 'full_hash' => 'v4.1.5-34-g0910587', 'branch' => 'master', -); \ No newline at end of file +); diff --git a/database/seeds/CustomFieldSeeder.php b/database/seeds/CustomFieldSeeder.php index f6ec934a3f..1186ec86f6 100644 --- a/database/seeds/CustomFieldSeeder.php +++ b/database/seeds/CustomFieldSeeder.php @@ -1,6 +1,7 @@ truncate(); factory(CustomField::class, 4)->create(); } diff --git a/database/seeds/DatabaseSeeder.php b/database/seeds/DatabaseSeeder.php index 00c493faa7..b424dbc9e4 100644 --- a/database/seeds/DatabaseSeeder.php +++ b/database/seeds/DatabaseSeeder.php @@ -33,6 +33,10 @@ class DatabaseSeeder extends Seeder $this->call(ActionlogSeeder::class); $this->call(CustomFieldSeeder::class); + Artisan::call('snipeit:sync-asset-locations', ['--output' => 'all']); + $output = Artisan::output(); + \Log::info($output); + Model::reguard(); } } diff --git a/public/mix-manifest.json b/public/mix-manifest.json index 48f752751e..150723f8a2 100644 --- a/public/mix-manifest.json +++ b/public/mix-manifest.json @@ -8,7 +8,7 @@ "/css/app.css.map": "/css/app.css.map?id=bdbe05e6ecd70ccfac72", "/css/overrides.css.map": "/css/overrides.css.map?id=898c91d4a425b01b589b", "/css/dist/all.css": "/css/dist/all.css?id=7c3842d2639193ac7e88", - "/js/dist/all.js": "/js/dist/all.js?id=c25f257f81287cafe6a3", + "/js/dist/all.js": "/js/dist/all.js?id=7e993fb3b457ccc72b3f", "/css/build/all.css": "/css/build/all.css?id=7c3842d2639193ac7e88", - "/js/build/all.js": "/js/build/all.js?id=c25f257f81287cafe6a3" + "/js/build/all.js": "/js/build/all.js?id=7e993fb3b457ccc72b3f" } \ No newline at end of file diff --git a/resources/views/asset_maintenances/edit.blade.php b/resources/views/asset_maintenances/edit.blade.php index 09fdb92f06..63146bb80a 100644 --- a/resources/views/asset_maintenances/edit.blade.php +++ b/resources/views/asset_maintenances/edit.blade.php @@ -42,7 +42,7 @@
- {{ trans('admin/licenses/form.checkout_help') }} -
+ @include ('partials.forms.edit.asset-select', ['translated_name' => trans('admin/licenses/form.asset'), 'fieldname' => 'asset_id', 'style' => 'display:none;']) diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.php index 8b32bd5ad0..adb3c9b552 100644 --- a/resources/views/partials/bootstrap-table.blade.php +++ b/resources/views/partials/bootstrap-table.blade.php @@ -276,6 +276,14 @@ } + // This just prints out the item type in the activity report + function itemTypeFormatter(value, row) { + + if ((row) && (row.item) && (row.item.type)) { + return row.item.type; + } + } + function genericCheckinCheckoutFormatter(destination) { return function (value,row) { @@ -440,7 +448,7 @@ } function assetCompanyObjFilterFormatter(value, row) { - if (row.company) { + if ((row) && (row.company)) { return ' ' + row.company.name + ''; } } @@ -455,7 +463,7 @@ function employeeNumFormatter(value, row) { - if ((row.assigned_to) && ((row.assigned_to.employee_number))) { + if ((row) && (row.assigned_to) && ((row.assigned_to.employee_number))) { return ' ' + row.assigned_to.employee_number + ''; } } diff --git a/resources/views/partials/forms/checkout-selector.blade.php b/resources/views/partials/forms/checkout-selector.blade.php index b51a5d09b8..600470b6fa 100644 --- a/resources/views/partials/forms/checkout-selector.blade.php +++ b/resources/views/partials/forms/checkout-selector.blade.php @@ -2,15 +2,21 @@ {{ Form::label('name', trans('admin/hardware/form.checkout_to'), array('class' => 'col-md-3 control-label')) }}