通用对象¶
- 源代码链接: https://github.com/pluginsGLPI/genericobject
- 下载: https://github.com/pluginsGLPI/genericobject/releases
This user manual applies to version 2.14 of the GLPI Generic Object Plugin.
要求¶
Please refer to plugin page <https://plugins.glpi-project.org/#/plugin/genericobject>.
特点¶
此插件允许您添加新的库存对象类型,并将其集成到GLPI框架中。
它支持以下GLPI功能:
- 实体和子实体管理;
- 搜索;
- 模板;
- 历史;
- 桌面支持集成
- CSV文件注入插件集成;
- 项目卸载插件集成;
- 指令管理插件集成。
用法示例¶
- 新建 inventory 对象 car.
- 为*车*增加准确字段,如:名称、序列号、库存数量、类型、型号、颜色、*状态*等。
- Describe the behaviour of a car: visible in subentity, retain history, etc.
- Adjust the rights on cars.
- Activate the cars object.
- Manage your collection of cars in GLPI.
安装插件¶
- 解压缩存档。
- 将``genericobject``目录移动到``<GLPI_ROOT>/plugins``目录
- 导航到*配置>插件*页面,
- 安装并激活插件。
使用率¶
创建一个新的对象类型¶
这是第一步
- 单击插件配置表单中的* + *按钮。
- 创建新类型的库存对象:
- name: mandatory, lowercase, and must be composed of letters only;
- 标签:默认情况下,与名称相同。
- 验证。
- 激活新项类型以使用它。
Example: Create a new type of inventory object car.
编辑标签¶
对于每种类型,``<GLPI_ROOT>/files/_plugins/genericobject/locales/itemtype/`中都有一个语言文件。
该插件创建:
- 当前语言的语言文件
- GLPI默认语言的语言文件
注解
如果当前语言和默认语言相同,则只创建一个文件。
若要更改项目类型的标签,对于英语,请编辑文件:
<?php
// <GLPI_ROOT>/files/_plugins/genericobject/locales/<itemtype>/<itemtype>.en_GB.php
$LANG['genericobject']['<itemtype>'][1] = "<type's label>";
You can also define labels globally in <GLPI_ROOT>/files/_plugins/genericobject/locales/fields.<lang>.php
files:
<?php
// <GLPI_ROOT>/files/_plugins/genericobject/locales/<itemtype>/<itemtype>.en_GB.php
$LANG['genericobject']['fields']['<itemtype>'] = "<type's label>";
安装行为¶
Example: Describe the behaviour of a car: visible in subentity, retain history, etc.
新类型的管理方式与通常的GLPI类型(计算机,监视器,网络设备等)相同。
注解
所有对象至少分配给*实体*
行为选项卡允许您定义:
- *子实体:*允许类型递归;
- *桌面支持:*允许对象与工单相关联;
- *回收站:*使用GLPI回收站功能;
- Notes: use GLPI’s note functionnality;
- *历史:*允许此类型的历史记录;
- *模板:*允许模板管理;
- *文件:*允许将文件附加到此类物体上;
- Loans: allows objects to be loaned;
- *合同:*将对象链接到一个或多个合同;
- *网络连接:*允许使用端口和管理此类型;
- CSV file injection plugin: allows this type to be available for use in the plugin;
- *项目卸载插件:*允许卸载此类型;
- *订单管理插件:*允许此类型链接到订单;
添加字段¶
Example: Add the accurate fields for a car, like: name, serial number, inventory number, type, model, color, state, etc.
导航到* 字段*选项卡。
该插件附带了几个可用的字段:
- 名称
- 类型
- 模型
- 序列号
- 库存编号
- 项目用户
- 群组
- 状态
- 注释
- Notes
- 位置
- 其他
- 生产厂家
- URL地址
- 创建日期
- 截止日期
- 类别
- 在桌面支持中可见
- 负责硬件技术人员
- 域
- 联系
- 联系电话
注解
使用某些行为会自动向对象添加一些字段:
- 网络连接=>位置
- loans => location
- 桌面支持=>在桌面支持中可见
- notes => notepad
桌面支持集成¶
要在帮助台中使用对象,请使用以下设置:
- In Behaviour tab : use helpdesk must be set to Yes.
- 如果定义了* 用户 *字段,则允许项目在*我的项目*列表中可见(作为其所有者是用户的项目)。
- 如果定义了*群组*字段,它也允许项目在*我的项目*列表中可见(作为属于用户所属组的项目)。
- 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.
添加新字段¶
注解
所有对象的类型都可以使用新字段。
- 创建一个名为”<GLPI_ROOT>/files/_plugins/genericobject/fields/<type>.constant.php”的新文件
For example, for a car type the constant file will be <GLPI_ROOT>/files/_plugins/genericobject/fields/car.constant.php
.
请注意,文件的第一行必须是以下内容,否则新字段将不会出现在列表中:
<?php
global $GO_FIELDS, $LANG;
- 添加新字段定义。
添加一个简单的下拉字段¶
<?php
$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';
注解
语言变量必须在语言文件中定义(参见上面的注释)。
- 添加分配给实体的下拉字段:
<?php
$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';
//Does the dropdown take care of entities ? (true/false)
$GO_FIELDS['plugin_genericobject_mytypecolors_id']['entities_id'] = true;
//Can values be recursive ? (true/false, only taking in account if entities_id is set to true)
$GO_FIELDS['plugin_genericobject_mytypecolors_id']['is_recursive'] = true;
添加树下拉字段¶
<?php
$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';
//Is it a tree-dropdown, or a simple one ? (true/false)
$GO_FIELDS['plugin_genericobject_mytypecolors_id']['is_tree'] = true;
注解
您可以同时使用以下参数:entities_id,is_recursive,is_tree。
添加基于GLPI核心对象的下拉字段(用户,位置…)¶
<?php
$GO_FIELDS['users_id_passengers_id']['name'] = 'Passenger';
$GO_FIELDS['users_id_passengers_id']['input_type'] = 'dropdown';
注解
括号内的名称([]
)**必须以``users_id``开头,才能被识别为基于GLPI用户列表的字段。
请参阅文件``<GLPI_ROOT>/files/_plugins/genericobject/fields/field.constant.php``以获取可用字段的完整列表。
添加全局下拉列表¶
全局下拉列表可用于所有项类型。 一个很好的例子是:
<?php
$GO_FIELDS['categories_id']['name'] = $LANG['common'][36];
$GO_FIELDS['categories_id']['input_type'] = 'dropdown';
$GO_FIELDS['categories_id']['dropdown_type'] = 'global';
将为每个项类型创建特定的类别表。 表名和字段名将以这种方式计算:
- 表:
glpi_plugin_genericobject_<itemtypename>_category
- 字段名称:
plugin_genericobject_<itemtype>categories_id
添加整数字段¶
<?php
$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
添加文本字段¶
<?php
$GO_FIELDS['mytextfield']['name'] = 'My text field';
$GO_FIELDS['mytextfield']['input_type'] = 'text';
在 2.1.2 版更改: 通过添加以下参数,您可以告诉插件在使用模板时可以自动生成此字段:
<?php
$GO_FIELDS['mytextfield']['autoname'] = true;
添加是/否字段¶
<?php
$GO_FIELDS['mybooleanfield']['name'] = 'My boolean field';
$GO_FIELDS['mybooleanfield']['input_type'] = 'bool';
添加日期字段¶
<?php
$GO_FIELDS['creationdate']['name'] = $LANG['genericobject']['fields'][30];
$GO_FIELDS['creationdate']['input_type'] = 'date';
添加日期&时间字段¶
<?php
$GO_FIELDS['creationdate']['name'] = $LANG['genericobject']['fields'][30];
$GO_FIELDS['creationdate']['input_type'] = 'datetime';
注解
如果您不希望使用大量操作修改字段,请在其定义中添加以下行:
<?php
$GO_FIELDS['myfield']['massiveaction'] = false;
添加全局字段¶
要使所有项类型都可以访问您的字段:
- 创建一个名为”<GLPI_ROOT>/files/_plugins/genericobject/fields/field.constant.php”的新文件
- 将您的定义放在此文件中。
设置权利¶
您可以为每个配置文件定义每个对象类型的访问权限。 可用选项包括:
- 正确的类型:无访问,读,写。
- 将该类型对象与工单关联的权利:是, 否。
要关联权限,您可以:
- 使用*项目类型*表单中的*权限*选项卡。
- 导航到*管理>配置文件*并管理每个配置文件的权限。
通用对象的用例作为CMMS¶
本文档的目的¶
在生物医学环境中显示通用对象作为CMMS(计算机化维护管理系统)的完整用法。
在本用例结束时,您将拥有:
- a dedicated Biomed entity (under Root entity)
- containing Biomedical objects (in Assets menu)
- 内置和用户定义的字段
- 由使用*Admin_biomed*配置文件的用户管理
步骤¶
以下步骤假设您拥有超级管理员授权:
- 在GLPI上安装通用对象(使用genericobject >= 0.85-1.0和GLPI >= 0.90进行验证)
- 通用对象配置
- GLPI 配置
- 开始使用通用对象和GLPI
通用对象配置¶
创建您的对象类型¶
请参阅:ref:`create_new_object`部分并使用*biomedical*作为内部标识符。标签将自动设置为*Biomedical*(大写*B*)。
注销/登录后,您将在资产中看到* Biomedical *菜单。
Define Biomedical’s new fields¶
These fields will be usable only by Biomedical’s objects :
- 创建一个名为: ``<GLPI_ROOT>/files/_plugins/genericobject/fields/biomedical.constant.php``的新文件
- 添加以下内容:
<?php
global $GO_FIELDS, $LANG;
// CODE CNEH
$GO_FIELDS['plugin_genericobject_cnehcodes_id']['name'] = $LANG['genericobject']['PluginGenericobjectBiomedical'][1];
$GO_FIELDS['plugin_genericobject_cnehcodes_id']['field'] = 'cnehcode';
$GO_FIELDS['plugin_genericobject_cnehcodes_id']['input_type'] = 'dropdown';
// REFORME (yes or no)
$GO_FIELDS['reformed']['name'] = $LANG['genericobject']['PluginGenericobjectBiomedical'][2];
$GO_FIELDS['reformed']['input_type'] = 'bool';
// CLASSE CE (3 choix possibles 1,2a ou 2b)
$GO_FIELDS['plugin_genericobject_classeces_id']['name'] = $LANG['genericobject']['PluginGenericobjectBiomedical'][3];
$GO_FIELDS['plugin_genericobject_classeces_id']['field'] = 'classce';
$GO_FIELDS['plugin_genericobject_classeces_id']['input_type'] = 'dropdown';
// UF (Unité Fonctionnelle)
$GO_FIELDS['plugin_genericobject_ufs_id']['name'] = $LANG['genericobject']['PluginGenericobjectBiomedical'][4];
$GO_FIELDS['plugin_genericobject_ufs_id']['field'] = 'uf';
$GO_FIELDS['plugin_genericobject_ufs_id']['input_type'] = 'dropdown';
// PRESTATAIRE BIOMED
$GO_FIELDS['plugin_genericobject_prestataires_id']['name'] = $LANG['genericobject']['PluginGenericobjectBiomedical'][5];
$GO_FIELDS['plugin_genericobject_prestataires_id']['field'] = 'prestataire biomed';
$GO_FIELDS['plugin_genericobject_prestataires_id']['input_type'] = 'dropdown';
// TYPE D'EQUIPEMENT BIOMED
$GO_FIELDS['plugin_genericobject_typedequipementbiomeds_id']['name'] = $LANG['genericobject']['PluginGenericobjectBiomedical'][6];
$GO_FIELDS['plugin_genericobject_typedequipementbiomeds_id']['field'] = "type d 'equipement biomed";
$GO_FIELDS['plugin_genericobject_typedequipementbiomeds_id']['input_type'] = 'dropdown';
// Criticite
$GO_FIELDS['plugin_genericobject_criticites_id']['name'] = $LANG['genericobject']['PluginGenericobjectBiomedical'][7];
$GO_FIELDS['plugin_genericobject_criticites_id']['field'] = 'criticite';
$GO_FIELDS['plugin_genericobject_criticites_id']['input_type'] = 'dropdown';
// Numéro marquage CE
$GO_FIELDS['plugin_genericobject_marquageces_id']['name'] = $LANG['genericobject']['PluginGenericobjectBiomedical'][8];
$GO_FIELDS['plugin_genericobject_marquageces_id']['field'] = 'marquagece';
$GO_FIELDS['plugin_genericobject_marquageces_id']['input_type'] = 'dropdown';
// Classe électrique
$GO_FIELDS['plugin_genericobject_classeelecs_id']['name'] = $LANG['genericobject']['PluginGenericobjectBiomedical'][9];
$GO_FIELDS['plugin_genericobject_classeelecs_id']['field'] = 'classeelec';
$GO_FIELDS['plugin_genericobject_classeelecs_id']['input_type'] = 'dropdown';
?>
警告
在``[plugin_genericobject_field * s_id *]``中必须尾随``s_id``,因为GLPI框架要求外键字段以``s_id``结尾。 在数据库中,glpi_plugin_genericobject_fields``是表名和``id
,它的外键。 请参阅`GLPI开发人员文档<http://glpi-developer-documentation.readthedocs.io/en/master/devapi/database/dbmodel.html#fields>`_。
定义字段标签¶
请参阅:ref:`edit_labels`部分。
- 编辑您的语言环境文件,例如:
<GLPI_ROOT>/files/_plugins/genericobject/locales/biomedical/biomedical.fr_FR.php
- 在文件末尾添加以下内容:
<?php
// Fields
$LANG['genericobject']['PluginGenericobjectBiomedical'][1]="Code CNEH";
$LANG['genericobject']['PluginGenericobjectBiomedical'][2]="Réformé";
$LANG['genericobject']['PluginGenericobjectBiomedical'][3]="Classe CE";
$LANG['genericobject']['PluginGenericobjectBiomedical'][4]="UF";
$LANG['genericobject']['PluginGenericobjectBiomedical'][5]="Prestataire Biomed";
$LANG['genericobject']['PluginGenericobjectBiomedical'][6]="Type d'équipement biomed";
$LANG['genericobject']['PluginGenericobjectBiomedical'][7]="Criticité";
$LANG['genericobject']['PluginGenericobjectBiomedical'][8]="Marquage CE";
$LANG['genericobject']['PluginGenericobjectBiomedical'][9]="Classe électrique";
GLPI 配置¶
定义Admin_biomed配置文件¶
- 克隆*管理员*资料
- 在*Admin_biomed*个人资料中设置以下权限:
- Administration > Profiles > Admin_biomed > Assets tab > Unselect all
- Administration > Profiles > Admin_biomed > Assistance tab > Association > Associable items to a ticket > Biomedical
- Administration > Profiles > Admin_biomed > Management tab > Select all
- Administration > Profiles > Admin_biomed > Objects management tab > Biomedical > Select all
注解
With these settings, Admin_biomed users only see Biomedical in Assets menu.
Define Biomed entity and authorizations rules¶
- Create Biomed entity under Root entity in Administration > Entities
- Configure authorizations rules to assign Admin_biomed profile to Biomed entity users.
开始使用通用对象和GLPI¶
As Admin_biomed user, you can create your first object in Assets > Biomedical.
为了获得时间,请在*设置>下拉菜单>对象管理*中为新字段定义值。