From bc14f225affe4d664b5d22c0f9e3183eb6c46aed Mon Sep 17 00:00:00 2001 From: Tim Bishop Date: Wed, 24 Jan 2018 16:55:51 +0000 Subject: [PATCH 1/5] Only use location currency if it's actually set. (#4904) This changes the depreciation report to only use the currency on a location if it's actually set to something. Previously, if an asset had a location it would use the currency even if it was blank rather than falling back to the default. --- resources/views/reports/depreciation.blade.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/views/reports/depreciation.blade.php b/resources/views/reports/depreciation.blade.php index f36f24483..792f75c8d 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 }} From e41ee1bcf8ace5ff30c73b36ef64e76d6a67396a Mon Sep 17 00:00:00 2001 From: Anh DAO-DUY Date: Wed, 24 Jan 2018 18:13:03 +0100 Subject: [PATCH 2/5] Fix upload images problem with Docker (#4906) Some folders were missing in this script file (Docker installation). Missing folders caused errors while uploading some images. --- docker/entrypoint.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index d3b603cae..2fc224264 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 From 9566fbd3cdd353a8e29259994835e39cf9b6463c Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 24 Jan 2018 10:41:49 -0800 Subject: [PATCH 3/5] Fixed borked down() migrations --- .../2018_01_19_203121_add_dashboard_message_to_settings.php | 2 +- .../2018_01_24_062633_add_footer_settings_to_settings.php | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) 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 89e0cd2f2..390f2b3db 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 5b9de3ce5..38365938d 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'); }); } } From 60c38a0c47d9944430faa0c514cfee53f9aafa33 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 24 Jan 2018 10:43:46 -0800 Subject: [PATCH 4/5] Added setting to choose what appears in model select list - Fixes #4879 --- .../Controllers/Api/AssetModelsController.php | 21 ++++++++++-- app/Http/Controllers/SettingsController.php | 8 +++++ app/Models/Setting.php | 17 ++++++++++ ...8_01_24_093426_add_modellist_preferenc.php | 32 +++++++++++++++++++ resources/lang/en/admin/settings/general.php | 1 + resources/views/settings/general.blade.php | 15 +++++++++ 6 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 database/migrations/2018_01_24_093426_add_modellist_preferenc.php diff --git a/app/Http/Controllers/Api/AssetModelsController.php b/app/Http/Controllers/Api/AssetModelsController.php index 6d2eeb54e..a8916af45 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/SettingsController.php b/app/Http/Controllers/SettingsController.php index a5f50e5bd..d9caa63bc 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 a745234b7..7c824b9e6 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_24_093426_add_modellist_preferenc.php b/database/migrations/2018_01_24_093426_add_modellist_preferenc.php new file mode 100644 index 000000000..d9974a2d8 --- /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/resources/lang/en/admin/settings/general.php b/resources/lang/en/admin/settings/general.php index 012cedb08..c717910dd 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/settings/general.blade.php b/resources/views/settings/general.blade.php index e547383cc..eff72b3c2 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') }}
+
+
+ +