From 968701b9718aea0b0fbfae66c4e09430cf9f7ef3 Mon Sep 17 00:00:00 2001 From: akemidx Date: Mon, 10 Apr 2023 17:28:19 -0400 Subject: [PATCH 01/10] starting to implant the str lower solution --- resources/views/hardware/view.blade.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php index e33f681f6e..2e69fc3bba 100755 --- a/resources/views/hardware/view.blade.php +++ b/resources/views/hardware/view.blade.php @@ -608,6 +608,11 @@ {{ trans('hardware/general.mfg_warranty_lookup') }} + @elseif ((strtolower($asset->model->manufacturer->name) == "hp") || (str_starts_with(str_replace(' ','',strtolower($asset->model->manufacturer->name)),"lenovoinc"))) + + {{ trans('hardware/general.mfg_warranty_lookup') }} + + @endif @endif From 71ff987e3c87baa7c3220d6b9cc8445efd4d75f8 Mon Sep 17 00:00:00 2001 From: akemidx Date: Tue, 11 Apr 2023 14:32:11 -0400 Subject: [PATCH 02/10] dynamic link w/ dynamic image --- resources/views/hardware/view.blade.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php index 2e69fc3bba..3fcf6667d4 100755 --- a/resources/views/hardware/view.blade.php +++ b/resources/views/hardware/view.blade.php @@ -608,9 +608,9 @@ {{ trans('hardware/general.mfg_warranty_lookup') }} - @elseif ((strtolower($asset->model->manufacturer->name) == "hp") || (str_starts_with(str_replace(' ','',strtolower($asset->model->manufacturer->name)),"lenovoinc"))) - - {{ trans('hardware/general.mfg_warranty_lookup') }} + @elseif (strtolower($asset->model->manufacturer->name)) + + {{ trans('hardware/general.mfg_warranty_lookup') }} @endif From 2453913080f439277edde3df291419c96b854386 Mon Sep 17 00:00:00 2001 From: akemidx Date: Tue, 11 Apr 2023 14:53:44 -0400 Subject: [PATCH 03/10] dynamic link w/ dynamic image --- resources/views/hardware/view.blade.php | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php index 3fcf6667d4..39e28957d9 100755 --- a/resources/views/hardware/view.blade.php +++ b/resources/views/hardware/view.blade.php @@ -596,24 +596,9 @@ {{ trans('admin/hardware/form.months') }} @if ($asset->serial && $asset->model->manufacturer) - @if ((strtolower($asset->model->manufacturer->name) == "apple") || (str_starts_with(str_replace(' ','',strtolower($asset->model->manufacturer->name)),"appleinc"))) - - + + {{ trans('hardware/general.mfg_warranty_lookup') }} - @elseif ((strtolower($asset->model->manufacturer->name) == "dell") || (str_starts_with(str_replace(' ','',strtolower($asset->model->manufacturer->name)),"dellinc"))) - - {{ trans('hardware/general.mfg_warranty_lookup') }} - - @elseif ((strtolower($asset->model->manufacturer->name) == "lenovo") || (str_starts_with(str_replace(' ','',strtolower($asset->model->manufacturer->name)),"lenovoinc"))) - - {{ trans('hardware/general.mfg_warranty_lookup') }} - - @elseif (strtolower($asset->model->manufacturer->name)) - - {{ trans('hardware/general.mfg_warranty_lookup') }} - - - @endif @endif From 0a993b2aa16c91fd0716e7807f6af15cc21b3edc Mon Sep 17 00:00:00 2001 From: akemidx Date: Wed, 12 Apr 2023 18:52:21 -0400 Subject: [PATCH 04/10] added external link icon to warranty link --- resources/views/hardware/view.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php index 39e28957d9..b5f61cf2c7 100755 --- a/resources/views/hardware/view.blade.php +++ b/resources/views/hardware/view.blade.php @@ -597,7 +597,7 @@ @if ($asset->serial && $asset->model->manufacturer) - {{ trans('hardware/general.mfg_warranty_lookup') }} + {{ trans('hardware/general.mfg_warranty_lookup') }} @endif From 16a5a883e532fb4eea229a2dc95c015483f78763 Mon Sep 17 00:00:00 2001 From: akemidx Date: Thu, 20 Apr 2023 16:34:25 -0400 Subject: [PATCH 05/10] new request, preparing support_url for validation --- .../Controllers/ManufacturersController.php | 5 ++- app/Http/Requests/SaveManufacturerRequest.php | 41 +++++++++++++++++++ app/Presenters/AssetPresenter.php | 14 +++++++ resources/views/hardware/view.blade.php | 2 +- 4 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 app/Http/Requests/SaveManufacturerRequest.php diff --git a/app/Http/Controllers/ManufacturersController.php b/app/Http/Controllers/ManufacturersController.php index 1f7d2f2c07..6e024ab8a6 100755 --- a/app/Http/Controllers/ManufacturersController.php +++ b/app/Http/Controllers/ManufacturersController.php @@ -3,6 +3,7 @@ namespace App\Http\Controllers; use App\Http\Requests\ImageUploadRequest; +use App\Http\Requests\SaveManufacturerRequest; use App\Models\Manufacturer; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; @@ -114,7 +115,7 @@ class ManufacturersController extends Controller * @since [v1.0] * @throws \Illuminate\Auth\Access\AuthorizationException */ - public function update(ImageUploadRequest $request, $manufacturerId = null) + public function update(SaveManufacturerRequest $request, $manufacturerId = null) { $this->authorize('update', Manufacturer::class); // Check if the manufacturer exists @@ -123,7 +124,7 @@ class ManufacturersController extends Controller return redirect()->route('manufacturers.index')->with('error', trans('admin/manufacturers/message.does_not_exist')); } - // Save the data + // Save the data $manufacturer->name = $request->input('name'); $manufacturer->url = $request->input('url'); $manufacturer->support_url = $request->input('support_url'); diff --git a/app/Http/Requests/SaveManufacturerRequest.php b/app/Http/Requests/SaveManufacturerRequest.php new file mode 100644 index 0000000000..dc96042e09 --- /dev/null +++ b/app/Http/Requests/SaveManufacturerRequest.php @@ -0,0 +1,41 @@ +getRules(); + } + + /** + * Prepare the data for validation. + * + * @return void + */ + protected function prepareForValidation() + { + $this->merge([ + 'support_url' => $this->input('support_url'), + ]); + dd($this->all()); + } +} diff --git a/app/Presenters/AssetPresenter.php b/app/Presenters/AssetPresenter.php index 4be0f56010..06364fe31a 100644 --- a/app/Presenters/AssetPresenter.php +++ b/app/Presenters/AssetPresenter.php @@ -534,6 +534,20 @@ class AssetPresenter extends Presenter return false; } + /** + * Used to take user created warranty URL and dynamically fill in the needed values per asset + * @return string + */ + public function supportUrl() + { + $tempurl = $this->model->model->manufacturer->support_url; + + $tempurl = (str_replace('{LOCALE}',\App\Models\Setting::getSettings()->locale,$tempurl)); + $tempurl = (str_replace('{SERIAL}',$this->model->serial,$tempurl)); + + return $tempurl; + } + /** * Url to view this item. * @return string diff --git a/resources/views/hardware/view.blade.php b/resources/views/hardware/view.blade.php index b5f61cf2c7..c4510adee6 100755 --- a/resources/views/hardware/view.blade.php +++ b/resources/views/hardware/view.blade.php @@ -596,7 +596,7 @@ {{ trans('admin/hardware/form.months') }} @if ($asset->serial && $asset->model->manufacturer) - + {{ trans('hardware/general.mfg_warranty_lookup') }} @endif From 9cd278318543ca6f25556b5179fcf000cc91ed93 Mon Sep 17 00:00:00 2001 From: akemidx Date: Mon, 24 Apr 2023 20:07:21 -0400 Subject: [PATCH 06/10] Regex added for link instead --- app/Http/Controllers/ManufacturersController.php | 2 +- app/Models/Manufacturer.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/ManufacturersController.php b/app/Http/Controllers/ManufacturersController.php index 6e024ab8a6..2eaabc707f 100755 --- a/app/Http/Controllers/ManufacturersController.php +++ b/app/Http/Controllers/ManufacturersController.php @@ -115,7 +115,7 @@ class ManufacturersController extends Controller * @since [v1.0] * @throws \Illuminate\Auth\Access\AuthorizationException */ - public function update(SaveManufacturerRequest $request, $manufacturerId = null) + public function update(ImageUploadRequest $request, $manufacturerId = null) { $this->authorize('update', Manufacturer::class); // Check if the manufacturer exists diff --git a/app/Models/Manufacturer.php b/app/Models/Manufacturer.php index 5f01c3c273..4d61e10429 100755 --- a/app/Models/Manufacturer.php +++ b/app/Models/Manufacturer.php @@ -23,8 +23,8 @@ class Manufacturer extends SnipeModel protected $rules = [ 'name' => 'required|min:2|max:255|unique:manufacturers,name,NULL,id,deleted_at,NULL', 'url' => 'url|nullable', - 'support_url' => 'url|nullable', 'support_email' => 'email|nullable', + 'support_url' => ['regex:/.+:\/\/.+/','nullable'], ]; protected $hidden = ['user_id']; From aab53cf6832c98ef7940df2d043a265505888a1b Mon Sep 17 00:00:00 2001 From: akemidx Date: Wed, 26 Apr 2023 15:18:13 -0400 Subject: [PATCH 07/10] remove regex, add in starts_with --- app/Http/Requests/SaveManufacturerRequest.php | 41 ------------------- app/Models/Manufacturer.php | 2 +- 2 files changed, 1 insertion(+), 42 deletions(-) delete mode 100644 app/Http/Requests/SaveManufacturerRequest.php diff --git a/app/Http/Requests/SaveManufacturerRequest.php b/app/Http/Requests/SaveManufacturerRequest.php deleted file mode 100644 index dc96042e09..0000000000 --- a/app/Http/Requests/SaveManufacturerRequest.php +++ /dev/null @@ -1,41 +0,0 @@ -getRules(); - } - - /** - * Prepare the data for validation. - * - * @return void - */ - protected function prepareForValidation() - { - $this->merge([ - 'support_url' => $this->input('support_url'), - ]); - dd($this->all()); - } -} diff --git a/app/Models/Manufacturer.php b/app/Models/Manufacturer.php index 4d61e10429..6acbffe7cd 100755 --- a/app/Models/Manufacturer.php +++ b/app/Models/Manufacturer.php @@ -24,7 +24,7 @@ class Manufacturer extends SnipeModel 'name' => 'required|min:2|max:255|unique:manufacturers,name,NULL,id,deleted_at,NULL', 'url' => 'url|nullable', 'support_email' => 'email|nullable', - 'support_url' => ['regex:/.+:\/\/.+/','nullable'], + 'support_url' => ['starts_with:http://,https://,afp://,facetime://,file://,irc://','nullable'], ]; protected $hidden = ['user_id']; From 497d17835f04fcca81fb6e20d5087917426a082b Mon Sep 17 00:00:00 2001 From: akemidx Date: Wed, 26 Apr 2023 17:06:08 -0400 Subject: [PATCH 08/10] requested edits --- app/Http/Controllers/ManufacturersController.php | 1 - app/Models/Manufacturer.php | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/Http/Controllers/ManufacturersController.php b/app/Http/Controllers/ManufacturersController.php index 2eaabc707f..e849d70a14 100755 --- a/app/Http/Controllers/ManufacturersController.php +++ b/app/Http/Controllers/ManufacturersController.php @@ -3,7 +3,6 @@ namespace App\Http\Controllers; use App\Http\Requests\ImageUploadRequest; -use App\Http\Requests\SaveManufacturerRequest; use App\Models\Manufacturer; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; diff --git a/app/Models/Manufacturer.php b/app/Models/Manufacturer.php index 6acbffe7cd..099a978778 100755 --- a/app/Models/Manufacturer.php +++ b/app/Models/Manufacturer.php @@ -24,7 +24,7 @@ class Manufacturer extends SnipeModel 'name' => 'required|min:2|max:255|unique:manufacturers,name,NULL,id,deleted_at,NULL', 'url' => 'url|nullable', 'support_email' => 'email|nullable', - 'support_url' => ['starts_with:http://,https://,afp://,facetime://,file://,irc://','nullable'], + 'support_url' => 'starts_with:http://,https://,afp://,facetime://,file://,irc://','nullable', ]; protected $hidden = ['user_id']; From b5b335a2cad4c986e0e6a380635721a0365fff4a Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 26 Apr 2023 14:41:19 -0700 Subject: [PATCH 09/10] Use the asset tag instead of asset name if no name is given Signed-off-by: snipe --- resources/views/partials/bootstrap-table.blade.php | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/resources/views/partials/bootstrap-table.blade.php b/resources/views/partials/bootstrap-table.blade.php index 21a4f29349..3e6a9ea3b0 100644 --- a/resources/views/partials/bootstrap-table.blade.php +++ b/resources/views/partials/bootstrap-table.blade.php @@ -269,12 +269,19 @@ } if ((row.available_actions) && (row.available_actions.delete === true)) { + + // use the asset tag if no name is provided + var name_for_box = row.name + if (row.name=='') { + var name_for_box = row.asset_tag + } + actions += '' - + 'Delete '; + + '{{ trans('general.delete') }} '; } else { actions += ' '; } From 7c0ef581c5164a1019b68455c987b11206681bd0 Mon Sep 17 00:00:00 2001 From: snipe Date: Wed, 26 Apr 2023 15:12:36 -0700 Subject: [PATCH 10/10] Added help text to the now-dynamic manufacturer URLS Signed-off-by: snipe --- resources/lang/en/admin/manufacturers/message.php | 1 + resources/views/manufacturers/edit.blade.php | 1 + 2 files changed, 2 insertions(+) diff --git a/resources/lang/en/admin/manufacturers/message.php b/resources/lang/en/admin/manufacturers/message.php index 21a4bc5aaf..d6656683ae 100644 --- a/resources/lang/en/admin/manufacturers/message.php +++ b/resources/lang/en/admin/manufacturers/message.php @@ -2,6 +2,7 @@ return array( + 'support_url_help' => 'Use {LOCALE} and {SERIAL} in your URL as variables to have those values auto-populate when viewing assets.', 'does_not_exist' => 'Manufacturer does not exist.', 'assoc_users' => 'This manufacturer is currently associated with at least one model and cannot be deleted. Please update your models to no longer reference this manufacturer and try again. ', diff --git a/resources/views/manufacturers/edit.blade.php b/resources/views/manufacturers/edit.blade.php index fbbb812ba6..c533718b85 100755 --- a/resources/views/manufacturers/edit.blade.php +++ b/resources/views/manufacturers/edit.blade.php @@ -26,6 +26,7 @@
+

{!! trans('admin/manufacturers/message.support_url_help') !!}

{!! $errors->first('support_url', '') !!}