模块开发: Difference between revisions

Jump to navigation Jump to search
mNo edit summary
Tag: 2017 source edit
Line 15: Line 15:


为开发Dolibarr模块,有以下几个步骤,本向导逐步引导你开发模块,扩展Dolibarr功能。包括以下内容 :
为开发Dolibarr模块,有以下几个步骤,本向导逐步引导你开发模块,扩展Dolibarr功能。包括以下内容 :
* 在数据库中增加新表
 
* 增加菜单条目
*在数据库中增加新表
* 为新表增加新的屏显
*增加菜单条目
* 增删对象的选项卡 (发票、产品、订单、事件,...)
*为新表增加新的屏显
* 为导出工具添加预定义导出
*增删对象的选项卡 (发票、产品、订单、事件,...)
* 在主页增加插件(信息框)
*为导出工具添加预定义导出
* 添加新的替换变量
*在主页增加插件(信息框)
* 定义新权限
*添加新的替换变量
* 执行由特定Dolibarr动作自动触发的代码
*定义新权限
* 将代码插入Dolibarr钩子位置
*执行由特定Dolibarr动作自动触发的代码
* 添加编号模块(为数据自动编码的模块)
*将代码插入Dolibarr钩子位置
* 添加文件模板
*添加编号模块(为数据自动编码的模块)
* 添加新主题
*添加文件模板
*添加新主题
 
等等...
等等...


Line 37: Line 39:
这里可以找到一个启动外部模块开发的好模型:[https://github.com/Dolibarr/dolibarr/tree/develop/htdocs/modulebuilder/template Github Dolibarr模块]
这里可以找到一个启动外部模块开发的好模型:[https://github.com/Dolibarr/dolibarr/tree/develop/htdocs/modulebuilder/template Github Dolibarr模块]


=创建模块 =
=创建模块=


== 激活ModuleBuilder模块 ==
==激活ModuleBuilder模块==


从Dolibarr 6.0.0 开始,可以使用ModuleBuilder创建模块,为激活ModuleBuilder,按以下步骤:
从Dolibarr 6.0.0 开始,可以使用ModuleBuilder创建模块,为激活ModuleBuilder,按以下步骤:
* 设置参数 MAIN_FEATURES_LEVEL 的值为 2 ( 设置 / 其他 )(或者修改llx_const表中该项的记录的value值为2)
 
*设置参数 MAIN_FEATURES_LEVEL 的值为 2 ( 设置 / 其他 )(或者修改llx_const表中该项的记录的value值为2)
 
[[File:企业微信截图 20180725114721.png|800px]]
[[File:企业微信截图 20180725114721.png|800px]]




* 在'''主页-设置-模块'''中激活 ModuleBuilder.
*在'''主页-设置-模块'''中激活 ModuleBuilder.
 
[[File:激活modulebuilder.png|800px]]
[[File:激活modulebuilder.png|800px]]




* 点击右上角的'Bug'图标开始使用(或者在浏览器中输入'yourhost/modulebuilder')
*点击右上角的'Bug'图标开始使用(或者在浏览器中输入'yourhost/modulebuilder')
 
[[File:Buglogo.png]]
[[File:Buglogo.png]]




* 运行的ModuleBuilder界面如下:
*运行的ModuleBuilder界面如下:
 
[[File:Modulebuilder.png|800px]]
[[File:Modulebuilder.png|800px]]




== 创建模块类 (必需) ==
==创建模块类 (必需)==
'''何时''': 任何模块(除了主题)开始开发之日起。
'''何时''': 任何模块(除了主题)开始开发之日起。


'''自Dolibarr 6.0起, 应使用ModuleBuilder创建模块类'''
'''自Dolibarr 6.0起, 应使用ModuleBuilder创建模块类'''


=== 用ModuleBuilder创建模块类 ===
===用ModuleBuilder创建模块类 (新,Dolibarr v6.0起)===
在下图'模块名'处填入模块名,然后点击右侧的'创建'按键,创建模块类。
在下图'模块名'处填入模块名,然后点击右侧的'创建'按键,创建模块类。
* 改变模块ID值: $this->numero = 100000(将此100000变更为你为模块设置的ID值)。为了避免与其他模块发生冲突,您可以查阅列出已保留ID号的页面: [[List of modules id|模块ID列表]].
 
* 修改模块类的构造函数中的其他变量的值 (参考[[主模块代码框架|类文件代码]]中的注释内容).  
*改变模块ID值: $this->numero = 100000(将此100000变更为你为模块设置的ID值)。为了避免与其他模块发生冲突,您可以查阅列出已保留ID号的页面: [[List of modules id|模块ID列表]].
*修改模块类的构造函数中的其他变量的值 (参考[[主模块代码框架|类文件代码]]中的注释内容).
 
您的模块类已准备就绪。请参见下一步[[测试模块]]激活它。
您的模块类已准备就绪。请参见下一步[[测试模块]]激活它。


[[file:模块名.png|800px]]
[[file:模块名.png|800px]]


=== 创建模块类 ===
===创建模块类 (舊)===


* 创建目录 '''/htdocs/''mymodule''/core/modules'''. 从目录/modulebuilder/template/core/modules拷贝文件modMyModule.class.php到新建目录。
*创建目录 '''/htdocs/''mymodule''/core/modules'''. 从目录/modulebuilder/template/core/modules拷贝文件modMyModule.class.php到新建目录。


将 modMyModule.class.php 改名,名称对应于您的模块。名称以 'mod'开头,以.class.php结尾。 (例如:要创建模块 'NewName', 对应的模块名为'modNewName.class.php').
将 modMyModule.class.php 改名,名称对应于您的模块。名称以 'mod'开头,以.class.php结尾。 (例如:要创建模块 'NewName', 对应的模块名为'modNewName.class.php').
接下来修改此文件的内容如下:
接下来修改此文件的内容如下:
* 替换所有 "modMyModule",对应于模块名称。 此值须以'mod'开头且仅含字符 (例如,模块为 'NewName', 替换所有 "modMyModule" 为 "modNewName")。
 
* 改变模块ID值: $this->numero = 100000(将此100000变更为你为模块设置的ID值)。为了避免与其他模块发生冲突,您可以查阅列出已保留ID号的页面: [[List of modules id|List of modules id]].
*替换所有 "modMyModule",对应于模块名称。 此值须以'mod'开头且仅含字符 (例如,模块为 'NewName', 替换所有 "modMyModule" 为 "modNewName")。
* 修改模块类的构造函数中定义的其他变量的值 (参考[[主模块代码框架|类文件代码]]中注释的内容).  
*改变模块ID值: $this->numero = 100000(将此100000变更为你为模块设置的ID值)。为了避免与其他模块发生冲突,您可以查阅列出已保留ID号的页面: [[List of modules id|List of modules id]].
*修改模块类的构造函数中定义的其他变量的值 (参考[[主模块代码框架|类文件代码]]中注释的内容).
 
您的模块的文件描述符已准备就绪。请参见下一步[[测试模块]]激活它。
您的模块的文件描述符已准备就绪。请参见下一步[[测试模块]]激活它。


=== 测试模块 ===
===测试模块===


找到 '''设置->模块'''。
找到 '''设置->模块'''。
如果正确的设置了版本,你会看到模块及模块的激活开关。如果版本设置为了"develop" 或 "experiental", 则必须到 '''设置->其他'''中设置MAIN_FEATURES_LEVEL 为 1 来查看 "experimental"版模块或 2 来查看 "development"版模块。
如果正确的设置了版本,你会看到模块及模块的激活开关。如果版本设置为了"develop" 或 "experiental", 则必须到 '''设置->其他'''中设置MAIN_FEATURES_LEVEL 为 1 来查看 "experimental"版模块或 2 来查看 "development"版模块。


== 模块类路径树(必需)==
==模块类路径树(必需)==


模块组织文件的方法(zip文件须与此匹配)。
模块组织文件的方法(zip文件须与此匹配)。
Line 95: Line 106:
{{Template模块目录树}}
{{Template模块目录树}}


== 创建数据表和表的PHP类文件 (可选) ==
==创建数据表和表的PHP类文件 (可选)==
'''何时''': 模块有自己的数据
'''何时''': 模块有自己的数据


=== 创建.sql文件 ===
===创建.sql文件===
如果你的模块有自己的数据要管理,而Dolibarr的标准版中没有这些数据,就需要自定义数据库表来存储数据。
如果你的模块有自己的数据要管理,而Dolibarr的标准版中没有这些数据,就需要自定义数据库表来存储数据。


Line 108: Line 119:


''规则:''
''规则:''
* 新建表的命令在文件 '''llx_mytable.sql'''中, 或者还有 '''llx_mytable.key.sql''' (参见 '''install/mysql/tables''' 实例).
 
* 管理数据:在目录 '''/mymodule/sql/'''中创建文件 '''data.sql''' 文件中包括增删模改数据的命令。
*新建表的命令在文件 '''llx_mytable.sql'''中, 或者还有 '''llx_mytable.key.sql''' (参见 '''install/mysql/tables''' 实例).
* 不要使用双引号 (如使用 'chaine' 而不使用 "chaine") 因为双引号有特殊意义(PostGreSQL)。
*管理数据:在目录 '''/mymodule/sql/'''中创建文件 '''data.sql''' 文件中包括增删模改数据的命令。
*不要使用双引号 (如使用 'chaine' 而不使用 "chaine") 因为双引号有特殊意义(PostGreSQL)。
 
data.sql实例
data.sql实例
<source lang="sql">
<source lang="sql">
Line 119: Line 132:
对于MySQL数据库,文件必须是可操作的。REM:其他数据库的文件不被维护。它们将由另一个数据库的驱动程序进行读取和转换。
对于MySQL数据库,文件必须是可操作的。REM:其他数据库的文件不被维护。它们将由另一个数据库的驱动程序进行读取和转换。


=== 测试 .sql 文件 ===
===测试 .sql 文件===


一旦文件准备就绪,您可以返回Dolibarr以禁用该模块,在数据库中将模块使用的表删除,并重新激活模块。应该能通过激活模块来重新创建表。否则,请通过手动传递脚本,或者检查Dolibarr日志。
一旦文件准备就绪,您可以返回Dolibarr以禁用该模块,在数据库中将模块使用的表删除,并重新激活模块。应该能通过激活模块来重新创建表。否则,请通过手动传递脚本,或者检查Dolibarr日志。


=== 生成 PHP DAO 类文件 ===
===生成 PHP DAO 类文件===
一旦将表创建到数据库中,就转到DEV/Skeleto目录
一旦将表创建到数据库中,就转到DEV/Skeleto目录
<source lang="bash">php build_class_from_table.php tablename modulename</source>
<source lang="bash">php build_class_from_table.php tablename modulename</source>
Line 133: Line 146:
已经生成了一个文件'''out.tablename_script.php''',并包含一个示例代码,使用了4个CRUD方法中的每一个。
已经生成了一个文件'''out.tablename_script.php''',并包含一个示例代码,使用了4个CRUD方法中的每一个。


''自从Dolibarr 6.0开,不再提供文件'''dev/skeletons/build_class_from_table.php'''。要从一个表生成一个类,您应该使用'''ModuleBuilder'''模块。
''自从Dolibarr 6.0开,不再提供文件'''dev/skeletons/build_class_from_table.php'''。要从一个表生成一个类,您应该使用'''ModuleBuilder'''模块。''
 
===使用ModuleBuilder生成PHP DAO类文件===
 
*使用ModuleBuilder生成PHP DAO类文件,简单至在下图中选对'对象'选项卡,输入'对象名',然后点击创建,即可生成相关一切文档。


=== 使用ModuleBuilder生成PHP DAO类文件 ===
* 使用ModuleBuilder生成PHP DAO类文件,简单至在下图中选对'对象'选项卡,输入'对象名',然后点击创建,即可生成相关一切文档。
[[File:新对象.png|800px]]
[[File:新对象.png|800px]]


参见[[ModuleBuilder用户手册]]
参见[[ModuleBuilder用户手册]]
== 选项卡管理(可选) ==
==选项卡管理(可选)==


=== 增删对象的选项卡 ===
===增删对象的选项卡===
'''何时''': 增加对象选项卡 (对象是指‘发票’、‘订单’、‘提议’、‘会员’等等)
'''何时''': 增加对象选项卡 (对象是指‘发票’、‘订单’、‘提议’、‘会员’等等)


Line 156: Line 171:
该数据包含一个字符串列表,每个字符串表示一个新选项卡。
该数据包含一个字符串列表,每个字符串表示一个新选项卡。
字符串由":"分隔的6个部分组成。
字符串由":"分隔的6个部分组成。
* Part 1: 选项卡出现在的对象类型(objecttype),只能是以下值:
 
*Part 1: 选项卡出现在的对象类型(objecttype),只能是以下值:
{{TemplateModuleTabs}}
{{TemplateModuleTabs}}
* Part 2: 标识选项卡是添加(以+开始)或移除(以-start)的代码
 
* Part 3: 选项卡的标题。这可以是lang文件中的译文代码或者是一个直接的字符串。
*Part 2: 标识选项卡是添加(以+开始)或移除(以-start)的代码
* Part 4: 文件“*.lang”的名称,包含译文代码和要显示的语言之间的对应关系。如果这个名字跟随 @mymodule,Dolibarr将搜索模块内的翻译文件“*.lang”,即"htdocs/mymodule/langs/code_CODE/mylangfile.lang"。否则Dolibarr将查找文件"htdocs/langs/code_CODE/mylangfile.lang"
*Part 3: 选项卡的标题。这可以是lang文件中的译文代码或者是一个直接的字符串。
* Part 5: 测试选项卡是否必须可见的条件。为1则一直可见。
*Part 4: 文件“*.lang”的名称,包含译文代码和要显示的语言之间的对应关系。如果这个名字跟随 @mymodule,Dolibarr将搜索模块内的翻译文件“*.lang”,即"htdocs/mymodule/langs/code_CODE/mylangfile.lang"。否则Dolibarr将查找文件"htdocs/langs/code_CODE/mylangfile.lang"
* Part 6: 单击选项卡时要显示的页面的URL。字符串__ID__将由相关元素的ID自动替换。
*Part 5: 测试选项卡是否必须可见的条件。为1则一直可见。
*Part 6: 单击选项卡时要显示的页面的URL。字符串__ID__将由相关元素的ID自动替换。


要用数据库中的数据来填充选项卡的内容,请参阅下一章。
要用数据库中的数据来填充选项卡的内容,请参阅下一章。


=== 在你的页上显示选项卡导航 ===
===在你的页上显示选项卡导航===
'''何时''': 在页面上显示对象的所有标准选项卡(产品、第三方等)。
'''何时''': 在页面上显示对象的所有标准选项卡(产品、第三方等)。


Line 177: Line 194:


包含示例 (DOL_DOCUMENT_ROOT 代表 dolibarr/htdocs/) :
包含示例 (DOL_DOCUMENT_ROOT 代表 dolibarr/htdocs/) :
* 对象第三方(thirdparty) :
 
** DOL_DOCUMENT_ROOT/societe/class/societe.class.php
*对象第三方(thirdparty) :
** DOL_DOCUMENT_ROOT/core/lib/company.lib.php
**DOL_DOCUMENT_ROOT/societe/class/societe.class.php
* 对象产品(product) :
**DOL_DOCUMENT_ROOT/core/lib/company.lib.php
** DOL_DOCUMENT_ROOT/product/class/product.class.php
*对象产品(product) :
** DOL_DOCUMENT_ROOT/core/lib/product.lib.php
**DOL_DOCUMENT_ROOT/product/class/product.class.php
* 对象发票 (invoice) :
**DOL_DOCUMENT_ROOT/core/lib/product.lib.php
** DOL_DOCUMENT_ROOT/compta/facture/class/facture.class.php
*对象发票 (invoice) :
** DOL_DOCUMENT_ROOT/core/lib/invoice.lib.php
**DOL_DOCUMENT_ROOT/compta/facture/class/facture.class.php
**DOL_DOCUMENT_ROOT/core/lib/invoice.lib.php
 
...
...


Line 236: Line 255:
This function will show required tabs and open an html element ''< div class="" >'' that correspond to the area under the tabs. To close area of a tab, just use ''< /div >'' into your PHP page.
This function will show required tabs and open an html element ''< div class="" >'' that correspond to the area under the tabs. To close area of a tab, just use ''< /div >'' into your PHP page.


== 创建或修改 PHP 屏显 (可选) ==
==创建或修改 PHP 屏显 (可选)==
'''何时''': 如果模块的目的是为了修改屏显。
'''何时''': 如果模块的目的是为了修改屏显。


=== 创建新 PHP 屏显 ===
===创建新 PHP 屏显===
然后,您必须创建PHP页面,使用目录'''modulebuilder/myobject_page.php'''中提供的框架模板来显示/编辑表中的数据。 (从命令行开发脚本, 见 [[Script development]]).
然后,您必须创建PHP页面,使用目录'''modulebuilder/myobject_page.php'''中提供的框架模板来显示/编辑表中的数据。 (从命令行开发脚本, 见 [[Script development]]).


Line 268: Line 287:
在main.inc.php文件中,加载了技术环境变量和权限。以下变量是位于该文件中的对象:
在main.inc.php文件中,加载了技术环境变量和权限。以下变量是位于该文件中的对象:


* $user    包含用户+ 权限。
*$user    包含用户+ 权限。
* $conf    包含 Dolibarr 设置
*$conf    包含 Dolibarr 设置
* $db      它包含一个打开的数据库连接处理程序。
*$db      它包含一个打开的数据库连接处理程序。
* $langs  包含用户语言
*$langs  包含用户语言


然后输入代码显示页面。
然后输入代码显示页面。


* 包含模块专属的类或库,使用Dolibarr函数dol_include_once()(而不是直接使用 include_once):
*包含模块专属的类或库,使用Dolibarr函数dol_include_once()(而不是直接使用 include_once):
 
''例如 :''
''例如 :''
<source lang="php">
<source lang="php">
Line 281: Line 301:
</source>
</source>


* 若要包含Dolibarr提供的类,请使用以下语法:
*若要包含Dolibarr提供的类,请使用以下语法:
 
''例如 :''
''例如 :''
<source lang="php">
<source lang="php">
Line 287: Line 308:
</source>
</source>


=== 为现存表单增加新字段 ===
===为现存表单增加新字段===
您可能需要提供一个模块,该模块将更多字段添加到一些元素的表单(输入和查看)中。
您可能需要提供一个模块,该模块将更多字段添加到一些元素的表单(输入和查看)中。


Line 296: Line 317:
我们将在这里描述另一种解决方案,它只在现有字段结束时“添加字段”,使用元素“category”作为示例,但您可以将此教程转换为发票、提案…
我们将在这里描述另一种解决方案,它只在现有字段结束时“添加字段”,使用元素“category”作为示例,但您可以将此教程转换为发票、提案…


* 首先,添加一个由您的模块所拥有的表,以存储新字段的值。此表有一个名为“rowid”的列(将包含与元素表的字段rowid相同的值+每一个要添加的新字段的列。然后为这个新表创建一个CRUD(创建/读取/更新/删除)方法类。对于这两个任务,请回到前一章[[#创建数据表和表的PHP类文件 (可选)]]。
*首先,添加一个由您的模块所拥有的表,以存储新字段的值。此表有一个名为“rowid”的列(将包含与元素表的字段rowid相同的值+每一个要添加的新字段的列。然后为这个新表创建一个CRUD(创建/读取/更新/删除)方法类。对于这两个任务,请回到前一章[[#创建数据表和表的PHP类文件 (可选)]]。
*下一步是在模块中添加一个钩子,以将新字段添加到窗体中。有关使用钩子的通用文档,请参见[[Hooks_system#Implement_the_Hook]]章节。
*下一步是在模块中添加一个钩子,以将新字段添加到窗体中。有关使用钩子的通用文档,请参见[[Hooks_system#Implement_the_Hook]]章节。
如果您遵循本教程,以便能够将字段添加到类别窗体中,您必须这样做:
如果您遵循本教程,以便能够将字段添加到类别窗体中,您必须这样做:
{{ToComplete}}
{{ToComplete}}


=== 替换模板的部分内容 (version 3.3+) ===
===替换模板的部分内容 (version 3.3+)===
Dolibarr屏幕的一些部分被隔离到本地PHP模板文件中。
Dolibarr屏幕的一些部分被隔离到本地PHP模板文件中。
您可以开发一个模块来覆盖这样的模板。
您可以开发一个模块来覆盖这样的模板。
{{ToComplete}}
{{ToComplete}}


=== 增/换部分字段(需钩子支持) ===
===增/换部分字段(需钩子支持)===
要知道如何使用Dolibarr现有的钩子来添加/替换Dolibarr 钩子代码,参考 [[钩子系统#实现钩子]] 。
要知道如何使用Dolibarr现有的钩子来添加/替换Dolibarr 钩子代码,参考 [[钩子系统#实现钩子]] 。


=== 数据通道 ===
===数据通道===
如果需要在自己的表中编辑数据库中的一些数据,请使用的PHP类。
如果需要在自己的表中编辑数据库中的一些数据,请使用的PHP类。


Line 348: Line 370:
</source>
</source>


=== 页面风格 ===
===页面风格===
为了让你自己的页面看起来与Dolibarr主题相匹配,必须使用Dolibarr CSS样式。
为了让你自己的页面看起来与Dolibarr主题相匹配,必须使用Dolibarr CSS样式。


例如,您可以使用:
例如,您可以使用:


* class="'''liste_titre'''" on tags ''tr'' and ''td'' for the head row of a table.
*class="'''liste_titre'''" on tags ''tr'' and ''td'' for the head row of a table.
* class="'''pair'''" or class="'''impair'''" on tags ''tr'' and ''td'' of other rows of a table.
*class="'''pair'''" or class="'''impair'''" on tags ''tr'' and ''td'' of other rows of a table.
* class="'''flat'''" on all input fields (''input, select, textarea''...).
*class="'''flat'''" on all input fields (''input, select, textarea''...).
* class="'''button'''" on HTML fields with type ''input type="submit"''.
*class="'''button'''" on HTML fields with type ''input type="submit"''.


=== 使用Dolibarr日期选择器 ===
===使用Dolibarr日期选择器===
如果您的页面使用Dolibarr日期选择器(日历弹出),请使用以下行:
如果您的页面使用Dolibarr日期选择器(日历弹出),请使用以下行:
<source lang="php">
<source lang="php">
Line 376: Line 398:
</source>
</source>


== 新增设置页 (可选) ==
==新增设置页 (可选)==
'''何时''': 如果模块需要用户提供的参数,以正确设置模块。
'''何时''': 如果模块需要用户提供的参数,以正确设置模块。


=== 创建页面以编辑参数 ===
===创建页面以编辑参数===
如果模块需要设置几个参数,则必须创建一个页面来编辑选项。 (这些制作存储于 [[Table llx_const|表 '''llx_const''']]).
如果模块需要设置几个参数,则必须创建一个页面来编辑选项。 (这些制作存储于 [[Table llx_const|表 '''llx_const''']]).


Line 388: Line 410:
把这个PHP页面放到你的模块的''/admin ''(例如mymodule/admin/mymodule_setuppage.php)的目录中。
把这个PHP页面放到你的模块的''/admin ''(例如mymodule/admin/mymodule_setuppage.php)的目录中。


=== 修改模块主文件 ===
===修改模块主文件===
然后,在模块主文件中,将变量“config_page_url”修改为PHP页面的设置名称。
然后,在模块主文件中,将变量“config_page_url”修改为PHP页面的设置名称。


Line 401: Line 423:
</source>
</source>


=== 测试页面 ===
===测试页面===
进入'''首页->安装>模块''',您应该在您的模块行的末尾看到一个图片,以转到您的设置页面。点击它,你就可以从页面中查看/编辑参数。
进入'''首页->安装>模块''',您应该在您的模块行的末尾看到一个图片,以转到您的设置页面。点击它,你就可以从页面中查看/编辑参数。


== 增加菜单条目 (可选) ==
==增加菜单条目 (可选)==
'''何时''': 如果您创建了PHP页面,则必须从Dolibarr菜单中的菜单条目中访问这些页面。
'''何时''': 如果您创建了PHP页面,则必须从Dolibarr菜单中的菜单条目中访问这些页面。


=== 增加菜单条目 ===
===增加菜单条目===
For this, you must define into the module descriptor, the array this->menu that declare all menus added by your module.
For this, you must define into the module descriptor, the array this->menu that declare all menus added by your module.
This array contains entries that will appear once your module is activated.
This array contains entries that will appear once your module is activated.
Line 452: Line 474:
To show menu or not depending on a permission, modify property '''perms''' in array. See chapter on permissions later to see how to add permissions.
To show menu or not depending on a permission, modify property '''perms''' in array. See chapter on permissions later to see how to add permissions.


=== 测试菜单 ===
===测试菜单===
Disable and reenable your module under Dolibarr module setup page, menus entries must appear (if property 'enabled' is declaration array is ok).
Disable and reenable your module under Dolibarr module setup page, menus entries must appear (if property 'enabled' is declaration array is ok).


== 新增权限 (可选) ==
==新增权限 (可选)==
'''When''': If you want to add new permissions.
'''When''': If you want to add new permissions.


Line 485: Line 507:
</source>
</source>


== 信息窗 (可选) ==
==信息窗 (可选)==
'''When''': If your module need to provide one or several new boxes to show on home page.
'''When''': If your module need to provide one or several new boxes to show on home page.


=== 信息窗 ===
===信息窗===
For this, modify the array $this->boxes into the module descriptor file.
For this, modify the array $this->boxes into the module descriptor file.
All you have to do is to add 2 lines for each box file you will create into directory '''htdocs/mymodule/core/boxes'''
All you have to do is to add 2 lines for each box file you will create into directory '''htdocs/mymodule/core/boxes'''
Line 503: Line 525:
Then create files '''htdocs/mymodule/core/boxes/mybox0.php''', '''htdocs/mymodule/core/boxes/mybox1.php'''... by copying an example from an existing box file (found into directory '''htdocs/core/boxes''').
Then create files '''htdocs/mymodule/core/boxes/mybox0.php''', '''htdocs/mymodule/core/boxes/mybox1.php'''... by copying an example from an existing box file (found into directory '''htdocs/core/boxes''').


=== Test if your box is detected by Dolibarr ===
===Test if your box is detected by Dolibarr===
Disable and enabled module.
Disable and enabled module.


Line 510: Line 532:
Your boxes must appear in the list of boxes you can activated. Activate the box and go on home page to see if the box is showing correctly.
Your boxes must appear in the list of boxes you can activated. Activate the box and go on home page to see if the box is showing correctly.


== Define your own export (optional) ==
==Define your own export (optional)==
'''When''': If your module provide new predefined database export profiles (for its own tables or for already existing tables of another module).
'''When''': If your module provide new predefined database export profiles (for its own tables or for already existing tables of another module).


=== 导出 ===
===导出===
For this uncomment and modify arrays $this->export_xxx in your module descriptor file.
For this uncomment and modify arrays $this->export_xxx in your module descriptor file.


=== Test your export ===
===Test your export===
Go into menu Tools -> Export. Your export will appear in the list of available predefined exports (if your module is enabled).
Go into menu Tools -> Export. Your export will appear in the list of available predefined exports (if your module is enabled).
Choose it, you must see list of all possible fields defined in the export arrays.
Choose it, you must see list of all possible fields defined in the export arrays.
Choose on field and try to build an export file. If ok, try again with all fields.
Choose on field and try to build an export file. If ok, try again with all fields.


== Define your CSS styles (optional) ==
==Define your CSS styles (optional)==
'''When''': If in your PHP pages, you use class styles that are not defined inside Dolibarr themes CSS (not recommanded).
'''When''': If in your PHP pages, you use class styles that are not defined inside Dolibarr themes CSS (not recommanded).


=== Create and declare your style sheet ===
===Create and declare your style sheet===
Create a style sheet CSS named '''mymodule.css''' or '''mymodule.css.php''' and put it into directory '''htdocs/mymodule'''. You can have only one CSS file per module.
Create a style sheet CSS named '''mymodule.css''' or '''mymodule.css.php''' and put it into directory '''htdocs/mymodule'''. You can have only one CSS file per module.
Remember it's better to use existing styles already available by default into Dolibarr (The CSS file used by Dolibarr is file '''themes/mytheme/''themename''.css.php'''. Create your own CSS file only if you need absolutely to add not already existing styles.
Remember it's better to use existing styles already available by default into Dolibarr (The CSS file used by Dolibarr is file '''themes/mytheme/''themename''.css.php'''. Create your own CSS file only if you need absolutely to add not already existing styles.
Line 535: Line 557:
</source>
</source>


=== Test your style sheet ===
===Test your style sheet===
Disable and enable your module.
Disable and enable your module.


Line 542: Line 564:
You should see into the HTML header, a line that declare your style sheet.
You should see into the HTML header, a line that declare your style sheet.


== 增加JS函数功能 (可选) ==
==增加JS函数功能 (可选)==
'''When''': If in your PHP pages, you use javascript functions not available in Dolibarr (in file lib_head.js)
'''When''': If in your PHP pages, you use javascript functions not available in Dolibarr (in file lib_head.js)


Line 554: Line 576:
</source>
</source>


== 执行Dolibarr事件代码 (可选) ==
==执行Dolibarr事件代码 (可选)==
'''When''': If you want to execute your own code once a common Dolibarr event has occurred (example: I want to update a table in my module when an invoice is created into Dolibarr), you must create a '''triggers'''.
'''When''': If you want to execute your own code once a common Dolibarr event has occurred (example: I want to update a table in my module when an invoice is created into Dolibarr), you must create a '''triggers'''.


Line 560: Line 582:
and [[Interfaces_from_foreign_systems_toward_Dolibarr]]
and [[Interfaces_from_foreign_systems_toward_Dolibarr]]


== 钩子代码 (可选) ==
==钩子代码 (可选)==
'''When''': When you want to add code or replace Dolibarr code into another situation than a business event (See previous chapter for adding code during a business event).
'''When''': When you want to add code or replace Dolibarr code into another situation than a business event (See previous chapter for adding code during a business event).


Line 566: Line 588:




== 添加编码规则 ==
==添加编码规则==
'''When''': When you need a new rule for generated ref of elements that is not covered by existing rules.
'''When''': When you need a new rule for generated ref of elements that is not covered by existing rules.


See page [[Create numbering module]].
See page [[Create numbering module]].


== 创建文档模板 (optional) ==
==创建文档模板 (optional)==
'''When''': When you want to personalized your own generated PDF or ODT documents.
'''When''': When you want to personalized your own generated PDF or ODT documents.


Line 578: Line 600:
Documentation to add your own template is available on page [[Create_a_PDF_document_template]] or [[Create_an_ODT_document_template]].
Documentation to add your own template is available on page [[Create_a_PDF_document_template]] or [[Create_an_ODT_document_template]].


== 创建主题 (optional) ==
==创建主题 (optional)==
'''When''': When you want to personalized your colors/fonts/images.
'''When''': When you want to personalized your colors/fonts/images.


Line 585: Line 607:
To add your own skin, read page [[Skins]].
To add your own skin, read page [[Skins]].


== 修改开发模块作者名 ==
==修改开发模块作者名==


在myModule.class.php中查找editor_name
在myModule.class.php中查找editor_name
Line 595: Line 617:
</source>
</source>


=一些编码规则和预定义函数 =
=一些编码规则和预定义函数=
The coding rules to be followed are defined in the [[Developer documentation]], under section "General Information - Language and standards development".
The coding rules to be followed are defined in the [[Developer documentation]], under section "General Information - Language and standards development".


A lot of predefined features for developers are also available and described into page [[Developer documentation]] under section "Technical components of Dolibarr".
A lot of predefined features for developers are also available and described into page [[Developer documentation]] under section "Technical components of Dolibarr".


=创建一个安装包来分发和安装您的模块 =
=创建一个安装包来分发和安装您的模块=
This process must be used to generate a package to submit it on the http://www.dolistore.com market place.
This process must be used to generate a package to submit it on the http://www.dolistore.com market place.
But you can use it to have a package easy to distribute on your on network.
But you can use it to have a package easy to distribute on your on network.


* Go into the directory '''/build''' and copy the file '''makepack-dolibarrmodules.conf''' into '''makepack-mymodule.conf'''. Warning, this directory may not be provided in some packages of stable versions. If so, it can be retrieved from the snapshot available for download on the Dolibarr website in area "Development version" (taken in this case the whole build directory which is autonomous and independent directory).
*Go into the directory '''/build''' and copy the file '''makepack-dolibarrmodules.conf''' into '''makepack-mymodule.conf'''. Warning, this directory may not be provided in some packages of stable versions. If so, it can be retrieved from the snapshot available for download on the Dolibarr website in area "Development version" (taken in this case the whole build directory which is autonomous and independent directory).


Edit this file to add list of file names for all new files you created for your module (module descriptor, new sql tables files, php page, images, etc...)
Edit this file to add list of file names for all new files you created for your module (module descriptor, new sql tables files, php page, images, etc...)


* Run the script via Perl (need the Perl version 5.0 or later):
*Run the script via Perl (need the Perl version 5.0 or later):
 
<source lang="bash">
<source lang="bash">
perl makepack-dolibarrmodule.pl
perl makepack-dolibarrmodule.pl
Line 614: Line 637:
The script asks you the name of your module, its major and minor version. A file '''mymodule.zip ''' will then be manufactured containing your module ready to be deployed.
The script asks you the name of your module, its major and minor version. A file '''mymodule.zip ''' will then be manufactured containing your module ready to be deployed.


* The person who receives your module must then place the file in the root directory of a Dolibarr installation and perform the command:
*The person who receives your module must then place the file in the root directory of a Dolibarr installation and perform the command:
 
<source lang="bash">
<source lang="bash">
tar -xvf mymodule.zip
tar -xvf mymodule.zip
</source>
</source>


* If you want your module to be public, you can submit it (the zip file) on Dolibarr market place web site: {{LinkToPluginDownload}} (you must create an account first and be logged to use the link "Submit a module/product").
*If you want your module to be public, you can submit it (the zip file) on Dolibarr market place web site: {{LinkToPluginDownload}} (you must create an account first and be logged to use the link "Submit a module/product").
** If your module was build correctly, file will be validated later.
**If your module was build correctly, file will be validated later.
** If quality is enough and license permits it, code might be added inside main Dolibarr sources (except if you disagree for that).
**If quality is enough and license permits it, code might be added inside main Dolibarr sources (except if you disagree for that).


= Delistor上的外部模块的启用/激活条件 =
=Delistor上的外部模块的启用/激活条件=


See [[Module_Dolistore_Validation_Rules|Validation Rules]]
See [[Module_Dolistore_Validation_Rules|Validation Rules]]
6

edits

Navigation menu