Merge pull request #12906 from akemidx/feature/sc-20622

Dynamic warranty link for manufacturers' support urls
This commit is contained in:
snipe 2023-04-26 14:49:22 -07:00 committed by GitHub
commit 5eac314f4d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 14 deletions

View file

@ -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' => 'starts_with:http://,https://,afp://,facetime://,file://,irc://','nullable',
];
protected $hidden = ['user_id'];

View file

@ -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

View file

@ -596,19 +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")))
<a href="https://checkcoverage.apple.com/?locale={{ (str_replace('-','_',\App\Models\Setting::getSettings()->locale)) }}" target="_blank">
<i class="fa-brands fa-apple" aria-hidden="true"><span class="sr-only">{{ trans('hardware/general.mfg_warranty_lookup') }}</span></i>
<a href="{{ $asset->present()->supportUrl() }}" target="_blank">
<i class="fa fa-external-link" style="width:25px;height:25px;"><span class="sr-only">{{ trans('hardware/general.mfg_warranty_lookup') }}</span></i>
</a>
@elseif ((strtolower($asset->model->manufacturer->name) == "dell") || (str_starts_with(str_replace(' ','',strtolower($asset->model->manufacturer->name)),"dellinc")))
<a href="https://www.dell.com/support/home/en-us?app=warranty" target="_blank">
<img src="/img/demo/manufacturers/dellicon.png" style="width:25px;height:25px;"><span class="sr-only">{{ trans('hardware/general.mfg_warranty_lookup') }}</span></i>
</a>
@elseif ((strtolower($asset->model->manufacturer->name) == "lenovo") || (str_starts_with(str_replace(' ','',strtolower($asset->model->manufacturer->name)),"lenovoinc")))
<a href="https://pcsupport.lenovo.com/us/en/warrantylookup#/" target="_blank">
<img src="/img/demo/manufacturers/lenovoicon.png" style="width:25px;height:25px;"><span class="sr-only">{{ trans('hardware/general.mfg_warranty_lookup') }}</span></i>
</a>
@endif
@endif
</div>
</div>