Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regex for entity? #111

Open
osmoonlight opened this issue Nov 10, 2024 · 1 comment
Open

Regex for entity? #111

osmoonlight opened this issue Nov 10, 2024 · 1 comment

Comments

@osmoonlight
Copy link

Just started working with GLPI and was looking for something that creates asset numbers automatically. So this plugin is what I need.

However, is there a way to set the template in a way that takes the entity (or location) from the auto-imported item? I have setup rules that assign an entity and location based on their IP addresses. As I am working with multiple entities, I would like to get that information somehow into the inventory number (entityA-PC0000X, entityB-PR0002 and so forth).
Can this be done with a regex? Any other option?

Cheers

@osmoonlight
Copy link
Author

So...after some digging I arrived at the next stumbling block. Yet, it's so close...

In the glpi - marketplace - geninventorynumber - inc folder I added two lines to the generation.class.php file:

$autonom = str_replace (
....
....
'\n',
'\g',
'\l', //Placeholder for location
...
...
...
$item->input['name'] ?? $item->fields['name'] ?? '',
'',
$item->input['locations_id'] ?? $item->fields[locations_id'] ?? '',
....

So far so good. When I add \l to the mask for the inventory number generation, I get the correct information, i.e. the index number for the item location.

Million dollar question now is, what would the code have to look like when I want the location name instead of the id? I can't simply replace locations_id with name because this will give me the device name not the location name.

Any suggestion? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant