snipe / snipe-it

A free open source IT asset/license management system
https://snipeitapp.com
GNU Affero General Public License v3.0
10.91k stars 3.15k forks source link

[Feature Request]: More asset label title placeholder fields #15462

Open awnz opened 2 weeks ago

awnz commented 2 weeks ago

Is your feature request related to a problem? Please describe.

I've found myself handling assets for a couple of smallbiz and nonprofit orgs which I have as separate 'Companies' in Snipe-IT.

I think it would be useful to have more placeholders in the asset label title.

I've done this for myself as a quick hack for {COMPANY_PHONE} as one extra line in Label.php but if anyone else thinks it would be useful I could submit a PR? What other placeholders would be useful?

Describe the solution you'd like

As above - implement more placeholders for asset labels (I will contribute if there is any interest) - see example: image

Describe alternatives you've considered

No response

Additional context

No response

edits x2: replaced screenshot, updated wording

welcome[bot] commented 2 weeks ago

👋 Thanks for opening your first issue here! If you're reporting a 🐞 bug, please make sure you include steps to reproduce it. We get a lot of issues on this repo, so please be patient and we will get back to you as soon as we can.

awnz commented 2 weeks ago

I'm on v6.2.4 so have done this (only for {COMPANY_PHONE}) as:

if ($asset->company && !empty($settings->label2_title)) {
    $title = str_replace('{COMPANY}',       $asset->company->name,  $settings->label2_title);
    $title = str_replace('{COMPANY_PHONE}', $asset->company->phone, $title); // new line
    $settings->qr_text;
    $assetData->put('title', $title);
}

... but guess on v7 it would look more like (this is totally untested):

if ($template->getSupportTitle() && !empty($settings->label2_title)) {
    $title = str_replace('{COMPANY}',       data_get($asset, 'company.name'),  $settings->label2_title);
    $title = str_replace('{COMPANY_PHONE}', data_get($asset, 'company.phone'), $title); // new line
    $assetData->put('title', $title);
}