20x En manual » History » Version 12

Version 11 (themroc, 09/12/2011 11:51 PM) → Version 12/34 (themroc, 09/12/2011 11:56 PM)

h1. Generic Object Plugin User Manual

{{>toc}}

h2.
Features

This plugin allows you to add new inventory objects types, integrated into GLPI framework.

It supports following GLPI features:

* entity and sub-entities management;
* search;
* templates;
* history;
* helpdesk integration;
* CSV file injection plugin integration;
* Item uninstallation plugin integration;
* order management plugin integration.

h2.
Example of usage :

* # Objective: Manage your car fleet like the rest of your IT Assets.
# Create a new type of inventory object @car@.
# Add the accurate fields for a @car@, like: @name@, @serial number@, @inventory number@, @type@, @model@, @color@, @state@, etc.
# Describe the behaviour of a @car@: visible in subentity, retain history, etc.
# Adjust the rights on @cars@.
# Activate the @cars@ object.
# Manage you collection of @cars@ in GLPI.

h2. It supports following GLPI features:

* entity and sub-entities management;
* search;
* templates;
* history;
* helpdesk integration;
* CSV file injection plugin integration;
* Item uninstallation plugin integration;
* order management plugin integration.

h1.
Install the Plugin

# Uncompress the archive.
# Move the _genericobject_ directory to <glpi root>/plugins.
# Make sure that apache's can write in the following directories :
#* inc/
#* front/
#* ajax/
#* locales/
#* fields/
# Navigate to the "Configuration -> Plugins" page,
# Install and active the plugin.

h2. h1. Usage

h3. h2. Create a new object type

This is the first step

# clicking on the @+@ button in the plugin configuration form.
# Create the new type of inventory object:
#* @name@: mandatory, lowercase, and must be composed of letters only;
#* @label@: by default, the same as the name.
# Validate.
# Activate the new item type to use it.

h2. Type's label modification

Once a type is created, a language file is available in locales/itemtype/.
The plugin creates :
* a language file for the current locale
* a language file for the default GLPI language
Note : if the current and default languages are the same, only one file is created.

By editing the following file, you can change the itemtype's label (for example for an english language):
* for english : <glpi root>/plugins/genericobject/objects/<itemtype>/<itemtype>.en_GB.php

<pre>
<?php
$LANG['genericobject']['<itemtype>'][1] = '<type's label>';
?>
</pre>

h2. Behaviour

It's now time to define how it'll behave. The new type will be managed the same way as the usual GLPI core&#x27;s types (computer, monitor, network devices, etc.) etc)

_Note: all objects are at least assigned to an entity_

The _Behaviour_ tab allows you to define :
* Sub-entites : allows the type to be recursive
* Helpdesk : allows an object to be associated to a ticket
* Trash : use GLPI's trash functionnality
* Notes : use GLPI's note functionnality
* History : allow history for this type
* Templates : allows template management
* Documents : allows documents to be attached to an object of this type
* Loans : allows objects to be loaned
* Contract : link an object to one or more contracts
* network connections : allow ports to be used and management for this type
* CSV file injection plugin : allows this type to be available for use in the plugin
* item's uninstallation plugin : allows this type to be uninstalled
* order management plugin : allows this type to be linked to an order

h2. Fields

Now we can add new fields to the type. To do it, you need to go to the _Fields_ tab.
The plugin comes with several ready to use fields :
* name
* type
* model
* serial number
* inventory number
* item's user
* group
* status
* comments
* notes
* location
* other
* manufacturer
* URL
* Creation date
* Expiration date
* Category
* Visible in Helpdesk
* Technician in charge of the hardware
* Domain
* Contact
* Contact number

Note : using some behaviour will add automaticall fields to the object :
* network connection : location
* loans : location
* helpdesk : is visible in Helpdesk
* notes : notepad

h3. Helpdesk integration

You can use an object in the helpdesk, but it's necessary to pay attention to the following instructions :
* in _Behaviour_ tab : use helpdesk must be set to Yes
* if the _User_ field is defined, it allows item to be visible in the 'My Items' list (as item whose owner is the user)
* if the _Group_ field is defined, it allows item to be visible in the 'My Items' list too (as item belonging to a group in which the user belongs too)
* if _Helpdesk visible_ field is set and if the value is set to No in the object, then the object won't be visible at all in the helpdesk

h3. Add new fields

It's possible to add news fields but they'll be available for use for all the object's types.Simply create a new file in <glpi root>/plugins/genericobject/fields/constants/<type'name>.php and contains the new fields definitions.

* Add a simple dropdown field :
<pre>
$GO_FIELDS['plugin_genericobject_mytypecolors_id']['name']=$LANG['genericobject']['<type's name>'][2];
$GO_FIELDS['plugin_genericobject_mytypecolors_id']['field']='color';
$GO_FIELDS['plugin_genericobject_mytypecolors_id']['input_type']='dropdown';
</pre>

Note : the language variable must be defined in the language file (see explaination above).

* Add a dropdown field that is assigned to an entity
<pre>
$GO_FIELDS['color']['name']=$LANG['genericobject']['<type's name>'][2];
$GO_FIELDS['plugin_genericobject_mytypecolors_id']['field']='color';
$GO_FIELDS['plugin_genericobject_mytypecolors_id']['input_type']='dropdown';
$GO_FIELDS['plugin_genericobject_mytypecolors_id']['entities_id']=true; //Does the dropdown take care of entities ? (true/false)
$GO_FIELDS['plugin_genericobject_mytypecolors_id']['is_recursive']=true; //Can values be recursive ? (true/false, only taking in account if entities_id is set to true)
</pre>

* Add a tree dropdown field
<pre>
$GO_FIELDS['color']['name']=$LANG['genericobject']['<type's name>'][2];
$GO_FIELDS['plugin_genericobject_mytypecolors_id']['field']='color';
$GO_FIELDS['plugin_genericobject_mytypecolors_id']['input_type']='dropdown';
$GO_FIELDS['plugin_genericobject_mytypecolors_id']['is_tree']=true; //Does the dropdown take care of entities ? (true/false)
</pre>
Note : you can use at the same time the following parameters : entities_is, is_recursive, is_tree.

* Add a global dropdown : a global dropdown can be used in all itemtypes. A good example would be :
<pre>
$GO_FIELDS['categories_id']['name'] = $LANG['common'][36];
$GO_FIELDS['categories_id']['input_type'] = 'dropdown';
$GO_FIELDS['categories_id']['dropdown_type'] = 'global';
</pre>
A specific category table will be created for each itemtype.
The table name and field name will the computed this way :
* table : glpi_plugin_genericobject_<itemtypename>_category
* field name : plugin_genericobject_<itemtype>categories_id

* Add an integer field :
<pre>
$GO_FIELDS['testinteger']['name'] = 'testinteger';
$GO_FIELDS['testinteger']['input_type'] = 'integer';
$GO_FIELDS['testinteger']['min'] = 10; //not mandatory, by default 0
$GO_FIELDS['testinteger']['max'] = 40; //not mandatory, by default 100
$GO_FIELDS['testinteger']['step'] = 3; //not mandatory, by default 1
</pre>

* Add a text field :
<pre>
$GO_FIELDS['mytextfield']['name'] = 'My text field';
$GO_FIELDS['mytextfield']['input_type'] = 'text';
</pre>

* Add a Yes/No field :
<pre>
$GO_FIELDS['mybooleanfield']['name'] = 'My boolean field';
$GO_FIELDS['mybooleanfield']['input_type'] = 'bool';
</pre>

* Add a date field :
<pre>
$GO_FIELDS['creationdate']['name'] = $LANG['genericobject']['fields'][30];
$GO_FIELDS['creationdate']['input_type'] = 'date';
</pre>

* Add a date & time field :
<pre>
$GO_FIELDS['creationdate']['name'] = $LANG['genericobject']['fields'][30];
$GO_FIELDS['creationdate']['input_type'] = 'datetime';
</pre>

_Note : if you don't want a field to be modified using massive actions, add the following line to it's definition_ :
<pre>
$GO_FIELDS['myfield']['massiveaction'] = false;
</pre>

h3. Adding global fields

If you want your fields to be accessible to all itemtypes, you can create a file called <pre><glpi root>/plugins/genericobject/fields/myconstant.php</pre> and put your definitions in it.

h2. Rights

You can define access rights for each object's type, for each profile. Available options are :
* right on the type : no access / read / write
* right to associate this type of object to tickets : yes / non
To do so, there's a "Rights" tab in the itemtype form, or you can do it by profile in "Administration => Profiles".

h1. Use

Once activated, the new type is ready to be used. It's available for users in the 'Plugins -> Objects management' menu.