diff --git a/app/Http/Controllers/Api/AssetModelsController.php b/app/Http/Controllers/Api/AssetModelsController.php index 6d2eeb54e9..a8916af45e 100644 --- a/app/Http/Controllers/Api/AssetModelsController.php +++ b/app/Http/Controllers/Api/AssetModelsController.php @@ -194,6 +194,7 @@ class AssetModelsController extends Controller 'models.category_id', ])->with('manufacturer','category'); + $settings = \App\Models\Setting::getSettings(); if ($request->has('search')) { $assetmodels = $assetmodels->SearchByManufacturerOrCat($request->input('search')); @@ -202,8 +203,24 @@ class AssetModelsController extends Controller $assetmodels = $assetmodels->OrderCategory('ASC')->OrderManufacturer('ASC')->orderby('models.name', 'asc')->orderby('models.model_number', 'asc')->paginate(50); foreach ($assetmodels as $assetmodel) { - $assetmodel->use_text = (($assetmodel->category) ? e($assetmodel->category->name) : '').': '.$assetmodel->present()->modelName; - $assetmodel->use_image = ($assetmodel->image) ? url('/').'/uploads/models/'.$assetmodel->image : null; + + $assetmodel->use_text = ''; + + if ($settings->modellistCheckedValue('category')) { + $assetmodel->use_text .= (($assetmodel->category) ? e($assetmodel->category->name).' - ' : ''); + } + + if ($settings->modellistCheckedValue('manufacturer')) { + $assetmodel->use_text .= (($assetmodel->manufacturer) ? e($assetmodel->manufacturer->name).' ' : ''); + } + + $assetmodel->use_text .= e($assetmodel->name); + + if (($settings->modellistCheckedValue('model_number')) && ($assetmodel->model_number!='')) { + $assetmodel->use_text .= ' (#'.e($assetmodel->model_number).')'; + } + + $assetmodel->use_image = ($settings->modellistCheckedValue('image') && ($assetmodel->image)) ? url('/').'/uploads/models/'.$assetmodel->image : null; } return (new SelectlistTransformer)->transformSelectlist($assetmodels); diff --git a/app/Http/Controllers/AssetsController.php b/app/Http/Controllers/AssetsController.php index a7794e2478..875243d0db 100755 --- a/app/Http/Controllers/AssetsController.php +++ b/app/Http/Controllers/AssetsController.php @@ -575,6 +575,7 @@ class AssetsController extends Controller $data['log_id'] = $logaction->id; $data['first_name'] = get_class($target) == User::class ? $target->first_name : ''; + $data['last_name'] = get_class($target) == User::class ? $target->last_name : ''; $data['item_name'] = $asset->present()->name(); $data['checkin_date'] = $logaction->created_at; $data['item_tag'] = $asset->asset_tag; diff --git a/app/Http/Controllers/SettingsController.php b/app/Http/Controllers/SettingsController.php index a5f50e5bd8..d9caa63bc8 100755 --- a/app/Http/Controllers/SettingsController.php +++ b/app/Http/Controllers/SettingsController.php @@ -314,6 +314,14 @@ class SettingsController extends Controller return redirect()->to('admin')->with('error', trans('admin/settings/message.update.error')); } + $setting->modellist_displays = ''; + + if (($request->has('show_in_model_list')) && (count($request->has('show_in_model_list')) > 0)) + { + $setting->modellist_displays = implode(',', $request->input('show_in_model_list')); + } + + $setting->full_multiple_companies_support = $request->input('full_multiple_companies_support', '0'); $setting->load_remote = $request->input('load_remote', '0'); $setting->show_archived_in_list = $request->input('show_archived_in_list', '0'); diff --git a/app/Models/Setting.php b/app/Models/Setting.php index a745234b7a..7c824b9e62 100755 --- a/app/Models/Setting.php +++ b/app/Models/Setting.php @@ -86,6 +86,23 @@ class Setting extends Model return null; } + public function modellistCheckedValue ($element) { + + // If the value is blank for some reason + if ($this->modellist_displays=='') { + return false; + } + $values = explode(',', $this->modellist_displays); + + foreach ($values as $value) { + if ($value == $element) { + return true; + } + } + return false; + + } + /** * Escapes the custom CSS, and then un-escapes the greater-than symbol * so it can work with direct descendant characters for bootstrap diff --git a/database/migrations/2018_01_19_203121_add_dashboard_message_to_settings.php b/database/migrations/2018_01_19_203121_add_dashboard_message_to_settings.php index 89e0cd2f2f..390f2b3db4 100644 --- a/database/migrations/2018_01_19_203121_add_dashboard_message_to_settings.php +++ b/database/migrations/2018_01_19_203121_add_dashboard_message_to_settings.php @@ -26,7 +26,7 @@ class AddDashboardMessageToSettings extends Migration public function down() { Schema::table('settings', function (Blueprint $table) { - $table->text('dashboard_message'); + $table->dropColumn('dashboard_message'); }); } } diff --git a/database/migrations/2018_01_24_062633_add_footer_settings_to_settings.php b/database/migrations/2018_01_24_062633_add_footer_settings_to_settings.php index 5b9de3ce59..38365938d3 100644 --- a/database/migrations/2018_01_24_062633_add_footer_settings_to_settings.php +++ b/database/migrations/2018_01_24_062633_add_footer_settings_to_settings.php @@ -27,8 +27,8 @@ class AddFooterSettingsToSettings extends Migration public function down() { Schema::table('settings', function (Blueprint $table) { - $table->text('support_footer'); - $table->text('footer_text'); + $table->dropColumn('support_footer'); + $table->dropColumn('footer_text'); }); } } diff --git a/database/migrations/2018_01_24_093426_add_modellist_preferenc.php b/database/migrations/2018_01_24_093426_add_modellist_preferenc.php new file mode 100644 index 0000000000..d9974a2d83 --- /dev/null +++ b/database/migrations/2018_01_24_093426_add_modellist_preferenc.php @@ -0,0 +1,32 @@ +char('modellist_displays')->nullable()->default('image,category,manufacturer,model_number'); + }); + } + + /** + * Reverse the migrations. + * + * @return void + */ + public function down() + { + Schema::table('settings', function (Blueprint $table) { + $table->dropColumn('modellist_displays'); + }); + } +} diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index d3b603cae5..2fc2242649 100644 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -17,7 +17,7 @@ else fi # create data directories -for dir in 'data/private_uploads' 'data/uploads' 'data/uploads/avatars' 'data/uploads/barcodes' 'data/uploads/models' 'data/uploads/suppliers' 'dumps'; do +for dir in 'data/private_uploads' 'data/uploads' 'data/uploads/avatars' 'data/uploads/barcodes' 'data/uploads/categories' 'data/uploads/companies' 'data/uploads/departments' 'data/uploads/locations' 'data/uploads/manufacturers' 'data/uploads/models' 'data/uploads/suppliers' 'dumps'; do mkdir -p "/var/lib/snipeit/$dir" done diff --git a/resources/lang/en/admin/settings/general.php b/resources/lang/en/admin/settings/general.php index 012cedb08a..c717910dd1 100644 --- a/resources/lang/en/admin/settings/general.php +++ b/resources/lang/en/admin/settings/general.php @@ -81,6 +81,7 @@ return array( 'logo' => 'Logo', 'full_multiple_companies_support_help_text' => 'Restricting users (including admins) assigned to companies to their company\'s assets.', 'full_multiple_companies_support_text' => 'Full Multiple Companies Support', + 'show_in_model_list' => 'Show in Model Dropdowns', 'optional' => 'optional', 'per_page' => 'Results Per Page', 'php' => 'PHP Version', diff --git a/resources/views/emails/checkin-asset.blade.php b/resources/views/emails/checkin-asset.blade.php index 8364802b5d..9d9c15bc64 100644 --- a/resources/views/emails/checkin-asset.blade.php +++ b/resources/views/emails/checkin-asset.blade.php @@ -1,7 +1,7 @@ @extends('emails/layouts/default') @section('content') -

{{ trans('mail.hello') }} {{ $first_name }},

+

{{ trans('mail.hello') }} {{ $first_name }} {{ $last_name }},

{{ trans('mail.the_following_item') }} diff --git a/resources/views/reports/depreciation.blade.php b/resources/views/reports/depreciation.blade.php index f36f24483a..792f75c8d6 100644 --- a/resources/views/reports/depreciation.blade.php +++ b/resources/views/reports/depreciation.blade.php @@ -99,7 +99,7 @@ @if ($asset->purchase_cost > 0) - @if ($asset->location ) + @if ($asset->location && $asset->location->currency) {{ $asset->location->currency }} @else {{ $snipeSettings->default_currency }} @@ -107,7 +107,7 @@ {{ \App\Helpers\Helper::formatCurrencyOutput($asset->purchase_cost) }} - @if ($asset->location ) + @if ($asset->location && $asset->location->currency) {{ $asset->location->currency }} @else {{ $snipeSettings->default_currency }} @@ -116,7 +116,7 @@ {{ \App\Helpers\Helper::formatCurrencyOutput($asset->getDepreciatedValue()) }} - @if ($asset->location) + @if ($asset->location && $asset->location->currency) {{ $asset->location->currency }} @else {{ $snipeSettings->default_currency }} diff --git a/resources/views/settings/general.blade.php b/resources/views/settings/general.blade.php index e547383ccb..eff72b3c2f 100644 --- a/resources/views/settings/general.blade.php +++ b/resources/views/settings/general.blade.php @@ -237,6 +237,21 @@ + +

+
+ {{ Form::label('show_in_model_list', + trans('admin/settings/general.show_in_model_list')) }} +
+
+ {{ Form::checkbox('show_in_model_list[]', 'image', Input::old('show_in_model_list', $snipeSettings->modellistCheckedValue('image')),array('class' => 'minimal')) }} {{ trans('general.image') }}
+ {{ Form::checkbox('show_in_model_list[]', 'category', Input::old('show_in_model_list', $snipeSettings->modellistCheckedValue('category')),array('class' => 'minimal')) }} {{ trans('general.category') }}
+ {{ Form::checkbox('show_in_model_list[]', 'manufacturer', Input::old('show_in_model_list', $snipeSettings->modellistCheckedValue('manufacturer')),array('class' => 'minimal')) }} {{ trans('general.manufacturer') }}
+ {{ Form::checkbox('show_in_model_list[]', 'model_number', Input::old('show_in_model_list', $snipeSettings->modellistCheckedValue('model_number')),array('class' => 'minimal')) }} {{ trans('general.model_no') }}
+
+
+ +