<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.dolibarr.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Thecyyoung</id>
	<title>Dolibarr ERP CRM Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.dolibarr.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Thecyyoung"/>
	<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php/Special:Contributions/Thecyyoung"/>
	<updated>2026-10-22T06:51:52Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.17</generator>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=Module_Stocks_En&amp;diff=50505</id>
		<title>Module Stocks En</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=Module_Stocks_En&amp;diff=50505"/>
		<updated>2021-05-01T09:25:54Z</updated>

		<summary type="html">&lt;p&gt;Thecyyoung: /* Removal strategy */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!-- BEGIN origin interlang links --&amp;gt;&lt;br /&gt;
&amp;lt;!-- You can edit this section but do NOT remove these comments&lt;br /&gt;
     Links below will be automatically replicated on translated pages by PolyglotBot --&amp;gt;&lt;br /&gt;
[[fr:Module_Stock]]&lt;br /&gt;
[[es:Módulo_Stocks]]&lt;br /&gt;
[[de:Modul_Bestände]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Stock]]&lt;br /&gt;
{{TemplateDocUser}}&lt;br /&gt;
{{TemplateModEN}}&lt;br /&gt;
{{BasculeDevUser|&lt;br /&gt;
nom=Stock|&lt;br /&gt;
num=52|&lt;br /&gt;
devdoc=[[Module Stock (developer)]]|&lt;br /&gt;
userdoc=This page|}}&lt;br /&gt;
&lt;br /&gt;
=Introduction=&lt;br /&gt;
The Stock management module can save status for stocks of products into warehouses and edit/correct quantities of products.&lt;br /&gt;
&lt;br /&gt;
It provides also features like Replenishments and Inventories.&lt;br /&gt;
&lt;br /&gt;
=Installation=&lt;br /&gt;
{{NoInstallModuleEn}}&lt;br /&gt;
&lt;br /&gt;
=Configuration=&lt;br /&gt;
{{ActivationModuleEn}}&lt;br /&gt;
&lt;br /&gt;
The setup page allows you to choose from four options, when the stock is automatically incremented or decreased (depending on events in the order or invoice business process).&lt;br /&gt;
&lt;br /&gt;
=Definition=&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Physical stock&#039;&#039;&#039; is the quantity of products in the warehouses.&lt;br /&gt;
*&#039;&#039;&#039;Virtual stock&#039;&#039;&#039; is the physical stock we will have once all pending sale, purchase and manufacturing orders will be done (so current real stock MINUS the number of products ordered by customers (orders with status &amp;quot;validated&amp;quot;) PLUS the quantity ordered from suppliers (orders with status &amp;quot;sent to the supplier&amp;quot;) MINUS quantity of product to consume in Manufacturing Orders PLUS quantity of product to produce in Manufacturing Orders (if you use them).&lt;br /&gt;
&lt;br /&gt;
=Create a warehouse=&lt;br /&gt;
The creation of a warehouse is the mandatory first step for stock management. You can create a warehouse on the &#039;&#039;Products/Services&#039;&#039; tab, clicking &#039;&#039;Stocks&#039;&#039; on the left menu and then &#039;&#039;New warehouse stock&#039;&#039;. The only required information is a reference code and a warehouse name, the other fields are optional. You must then set whether the warehouse is active or not (opened / closed).  A closed warehouse cannot be used by other Dolibarr functions.  This is a good way to prepare a warehouse with stock before you activate it, or to temporarily block stock movements during an inventory.&lt;br /&gt;
&lt;br /&gt;
=Allocate product stocks=&lt;br /&gt;
&lt;br /&gt;
*This has to be done from the &#039;&#039;stock&#039;&#039; tab on the page of the product, which can be found on the &#039;&#039;products&#039;&#039; section of the left menu.&lt;br /&gt;
*You can also do this from the &#039;&#039;stock&#039;&#039; tab on the page of the warehouse.&lt;br /&gt;
&lt;br /&gt;
For multiple updates of stock, the import process should be used.&lt;br /&gt;
&lt;br /&gt;
=Automatic stock updates=&lt;br /&gt;
&lt;br /&gt;
Depending on the module configuration, the stock is updated either at the time of an order, at the time of shipment, at the time of invoice, etc..  A movement of stock is then registered according to the chosen increase/decrease stock option.&lt;br /&gt;
&lt;br /&gt;
=Manual stock updates=&lt;br /&gt;
&lt;br /&gt;
If you wish to make adjustments to the existing stock amounts (because of internal production, theft, loss, aging, ...), you can do it directly via :&lt;br /&gt;
&lt;br /&gt;
*the tab &amp;quot;Stock&amp;quot; of a product.&lt;br /&gt;
*the tab &amp;quot;Stock movement&amp;quot; of a warehouse.&lt;br /&gt;
&lt;br /&gt;
Use the button &amp;quot;Correct Stock&amp;quot; or &amp;quot;Transfer Stock&amp;quot; if you want to manually move some products from one warehouse to another one. Enter a code and label for the moment (for example to set the reason for the change).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Replenishment=&lt;br /&gt;
&lt;br /&gt;
The replenishment is a feature to generate orders for suppliers so your stock will be restored to a desired value.&lt;br /&gt;
&lt;br /&gt;
=Inventories=&lt;br /&gt;
&lt;br /&gt;
From menu Stocks - Inventories, you will find features to make an inventory.&lt;br /&gt;
See page [[Inventories]] for documentation on how to make an inventory.&lt;br /&gt;
&lt;br /&gt;
=Warehouse strategy and valuation=&lt;br /&gt;
&lt;br /&gt;
It is possible to obtain a detailed list of products and movements in a specific warehouse by clicking on the name from the list of warehouses.&lt;br /&gt;
&lt;br /&gt;
==Removal strategy==&lt;br /&gt;
When using stock decrease on shipments, a removal strategy is a removal rule to decide which lot/batch/serial, or from which warehouse you take a product when you are doing a shipment.&lt;br /&gt;
&lt;br /&gt;
*FIFO: First in, first out&lt;br /&gt;
*LIFO: Last in, first out&lt;br /&gt;
*FEFO: First expiry, first out&lt;br /&gt;
&lt;br /&gt;
Currently, Dolibarr does not suggest any product lot or warehouse by priority when you ship a product.&lt;br /&gt;
You choose from the interface which product/lot quantity, from which warehouse you use. So the removal strategy is a manual selection by the user. You can choose according to FIFO, LIFO, or FEFO, at each shipment.&lt;br /&gt;
&lt;br /&gt;
In a future, a removal strategy may be implemented so the application will use a default choice to suggest the lot/serial/warehouse/qty to match a default removal strategy rule.&lt;br /&gt;
&lt;br /&gt;
==Stock valuation==&lt;br /&gt;
With Dolibarr, you can get a valuation of stock in two ways:&lt;br /&gt;
&lt;br /&gt;
*Standard valuation: Current price of product * qty in stock&lt;br /&gt;
*Average Weight Price (AWP): AWP of product * qty in stock&lt;br /&gt;
&lt;br /&gt;
=Related videos=&lt;br /&gt;
&amp;lt;youtube width=&amp;quot;200&amp;quot; height=&amp;quot;120&amp;quot;&amp;gt;a0melQ2WTrY&amp;lt;/youtube&amp;gt;&lt;/div&gt;</summary>
		<author><name>Thecyyoung</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=%E7%94%A8%E6%88%B7%E6%9D%83%E9%99%90&amp;diff=47615</id>
		<title>用户权限</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=%E7%94%A8%E6%88%B7%E6%9D%83%E9%99%90&amp;diff=47615"/>
		<updated>2020-06-17T15:35:51Z</updated>

		<summary type="html">&lt;p&gt;Thecyyoung: 1. 修正 listGroupForUser() 要傳入的是 id 而非物件 2. $listofgroup可能是從[1]開始&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!-- BEGIN interlang links --&amp;gt;&lt;br /&gt;
&amp;lt;!-- Do NOT edit this section&lt;br /&gt;
     Links below are automatically managed by PolyglotBot&lt;br /&gt;
     You can edit links on the English source page : Permissions_En --&amp;gt;&lt;br /&gt;
[[en:Permissions_En]]&lt;br /&gt;
[[es:Permisos]]&lt;br /&gt;
[[fr:Permissions]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Core]]&lt;br /&gt;
{{Template开发文档}}&lt;br /&gt;
{{Template用户手册}}&lt;br /&gt;
{{TemplateMainPageZh}}&lt;br /&gt;
&lt;br /&gt;
每个权限都有唯一的ID.&lt;br /&gt;
&lt;br /&gt;
Dolibarr 所管理的所有权限都保存到[[Table llx_rights_def]]中，并有自己的ID。&lt;br /&gt;
&lt;br /&gt;
id用于在用户与权限之间建立链接（链接被保存到[[Table llx_user_rights]]）或在组和权限之间建立链接（链接被保存到[[Table llx_usergroup_rights]]）。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
= 获取用户的权限和组 =&lt;br /&gt;
&lt;br /&gt;
在Dolibarr页面的源代码中，全局对象$user被自动定义。&lt;br /&gt;
&lt;br /&gt;
它包含当前用户的所有信息。&lt;br /&gt;
&lt;br /&gt;
它的权限可以通过测试来测试。&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
if ($user-&amp;gt;rights-&amp;gt;module-&amp;gt;codestringlevel1-&amp;gt;codestringlevel1)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
要知道用户是哪个组的列表，可以使用下面的代码（Dolibarr 2.5或更高）：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$usergroup=new UserGroup($db);&lt;br /&gt;
$listofgroups=$usergroup-&amp;gt;listGroupsForUser($fuser-&amp;gt;id);&lt;br /&gt;
print $listofgroups[0]-&amp;gt;nom;    // $listofgroups[1]-&amp;gt;nom;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$listofgroups是用户$fuser所属的所有对象用户组（组）的数组。&lt;br /&gt;
&lt;br /&gt;
$fuser是加载代码的对象用户&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$fuser=new User($db);&lt;br /&gt;
$fuser-&amp;gt;fetch(&#039;login&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= 可用权限数组 =&lt;br /&gt;
&lt;br /&gt;
每个模块都有它的代码字符串来使用$user-&amp;gt;rights数组来获取用户的相关权限。用于读取权限的代码列表可用于模块开发人员文档。&lt;br /&gt;
&lt;br /&gt;
单击[[:Category:List of Modules|here to get full list of modules]] （并选择模块文档的开发者版本以获得可能的权限列表）。&lt;/div&gt;</summary>
		<author><name>Thecyyoung</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=%E6%A8%A1%E5%9D%97%E5%BC%80%E5%8F%91&amp;diff=47496</id>
		<title>模块开发</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=%E6%A8%A1%E5%9D%97%E5%BC%80%E5%8F%91&amp;diff=47496"/>
		<updated>2020-06-07T16:25:48Z</updated>

		<summary type="html">&lt;p&gt;Thecyyoung: /* 创建模块类 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!-- BEGIN interlang links --&amp;gt;&lt;br /&gt;
&amp;lt;!-- Do NOT edit this section&lt;br /&gt;
     Links below are automatically managed by PolyglotBot&lt;br /&gt;
     You can edit links on the English source page : Module_development --&amp;gt;&lt;br /&gt;
[[en:Module_development]]&lt;br /&gt;
[[fr:Développement_module]]&lt;br /&gt;
[[es:Desarrollo_de_un_módulo]]&lt;br /&gt;
[[de:Modul_Entwicklung]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Core]]&lt;br /&gt;
{{Template用户手册}}&lt;br /&gt;
{{Template开发文档}}&lt;br /&gt;
{{TemplateMainPageZh}}&lt;br /&gt;
&lt;br /&gt;
为开发Dolibarr模块，有以下几个步骤，本向导逐步引导你开发模块，扩展Dolibarr功能。包括以下内容 :&lt;br /&gt;
&lt;br /&gt;
*在数据库中增加新表&lt;br /&gt;
*增加菜单条目&lt;br /&gt;
*为新表增加新的屏显&lt;br /&gt;
*增删对象的选项卡 (发票、产品、订单、事件，...)&lt;br /&gt;
*为导出工具添加预定义导出&lt;br /&gt;
*在主页增加插件（信息框）&lt;br /&gt;
*添加新的替换变量&lt;br /&gt;
*定义新权限&lt;br /&gt;
*执行由特定Dolibarr动作自动触发的代码&lt;br /&gt;
*将代码插入Dolibarr钩子位置&lt;br /&gt;
*添加编号模块（为数据自动编码的模块）&lt;br /&gt;
*添加文件模板&lt;br /&gt;
*添加新主题&lt;br /&gt;
&lt;br /&gt;
等等...&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
下面的章节介绍了如何以简单的方式手动完成所有这些操作。对于有经验的开发人员来说，使用MDA生成的方法也不错。 见最后一章。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=模块实例=&lt;br /&gt;
这里可以找到一个启动外部模块开发的好模型：[https://github.com/Dolibarr/dolibarr/tree/develop/htdocs/modulebuilder/template Github Dolibarr模块]&lt;br /&gt;
&lt;br /&gt;
=创建模块=&lt;br /&gt;
&lt;br /&gt;
==激活ModuleBuilder模块==&lt;br /&gt;
&lt;br /&gt;
从Dolibarr 6.0.0 开始，可以使用ModuleBuilder创建模块，为激活ModuleBuilder，按以下步骤：&lt;br /&gt;
&lt;br /&gt;
*设置参数 MAIN_FEATURES_LEVEL 的值为 2 ( 设置 / 其他 )（或者修改llx_const表中该项的记录的value值为2）&lt;br /&gt;
&lt;br /&gt;
[[File:企业微信截图 20180725114721.png|800px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*在&#039;&#039;&#039;主页-设置-模块&#039;&#039;&#039;中激活 ModuleBuilder.&lt;br /&gt;
&lt;br /&gt;
[[File:激活modulebuilder.png|800px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*点击右上角的&#039;Bug&#039;图标开始使用（或者在浏览器中输入&#039;yourhost/modulebuilder&#039;）&lt;br /&gt;
&lt;br /&gt;
[[File:Buglogo.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*运行的ModuleBuilder界面如下：&lt;br /&gt;
&lt;br /&gt;
[[File:Modulebuilder.png|800px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==创建模块类 (必需)==&lt;br /&gt;
&#039;&#039;&#039;何时&#039;&#039;&#039;: 任何模块（除了主题）开始开发之日起。&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;自Dolibarr 6.0起, 应使用ModuleBuilder创建模块类&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===用ModuleBuilder创建模块类 (新，Dolibarr v6.0起)===&lt;br /&gt;
在下图&#039;模块名&#039;处填入模块名，然后点击右侧的&#039;创建&#039;按键，创建模块类。&lt;br /&gt;
&lt;br /&gt;
*改变模块ID值： $this-&amp;gt;numero = 100000（将此100000变更为你为模块设置的ID值）。为了避免与其他模块发生冲突，您可以查阅列出已保留ID号的页面： [[List of modules id|模块ID列表]].&lt;br /&gt;
*修改模块类的构造函数中的其他变量的值 (参考[[主模块代码框架|类文件代码]]中的注释内容).&lt;br /&gt;
&lt;br /&gt;
您的模块类已准备就绪。请参见下一步[[测试模块]]激活它。&lt;br /&gt;
&lt;br /&gt;
[[file:模块名.png|800px]]&lt;br /&gt;
&lt;br /&gt;
===创建模块类 (舊)===&lt;br /&gt;
&lt;br /&gt;
*创建目录 &#039;&#039;&#039;/htdocs/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039;. 从目录/modulebuilder/template/core/modules拷贝文件modMyModule.class.php到新建目录。&lt;br /&gt;
&lt;br /&gt;
将 modMyModule.class.php 改名，名称对应于您的模块。名称以 &#039;mod&#039;开头，以.class.php结尾。 (例如：要创建模块 &#039;NewName&#039;, 对应的模块名为&#039;modNewName.class.php&#039;).&lt;br /&gt;
接下来修改此文件的内容如下：&lt;br /&gt;
&lt;br /&gt;
*替换所有 &amp;quot;modMyModule&amp;quot;，对应于模块名称。 此值须以&#039;mod&#039;开头且仅含字符 （例如，模块为 &#039;NewName&#039;, 替换所有 &amp;quot;modMyModule&amp;quot; 为 &amp;quot;modNewName&amp;quot;）。&lt;br /&gt;
*改变模块ID值： $this-&amp;gt;numero = 100000（将此100000变更为你为模块设置的ID值）。为了避免与其他模块发生冲突，您可以查阅列出已保留ID号的页面： [[List of modules id|List of modules id]].&lt;br /&gt;
*修改模块类的构造函数中定义的其他变量的值 (参考[[主模块代码框架|类文件代码]]中注释的内容).&lt;br /&gt;
&lt;br /&gt;
您的模块的文件描述符已准备就绪。请参见下一步[[测试模块]]激活它。&lt;br /&gt;
&lt;br /&gt;
===测试模块===&lt;br /&gt;
&lt;br /&gt;
找到 &#039;&#039;&#039;设置-&amp;gt;模块&#039;&#039;&#039;。&lt;br /&gt;
如果正确的设置了版本，你会看到模块及模块的激活开关。如果版本设置为了&amp;quot;develop&amp;quot; 或 &amp;quot;experiental&amp;quot;, 则必须到 &#039;&#039;&#039;设置-&amp;gt;其他&#039;&#039;&#039;中设置MAIN_FEATURES_LEVEL 为 1 来查看 &amp;quot;experimental&amp;quot;版模块或 2 来查看 &amp;quot;development&amp;quot;版模块。&lt;br /&gt;
&lt;br /&gt;
==模块类路径树（必需）==&lt;br /&gt;
&lt;br /&gt;
模块组织文件的方法（zip文件须与此匹配）。&lt;br /&gt;
&lt;br /&gt;
注：只有第二行是强制性的。&lt;br /&gt;
&lt;br /&gt;
{{Template模块目录树}}&lt;br /&gt;
&lt;br /&gt;
==创建数据表和表的PHP类文件 (可选)==&lt;br /&gt;
&#039;&#039;&#039;何时&#039;&#039;&#039;: 模块有自己的数据&lt;br /&gt;
&lt;br /&gt;
===创建.sql文件===&lt;br /&gt;
如果你的模块有自己的数据要管理，而Dolibarr的标准版中没有这些数据，就需要自定义数据库表来存储数据。&lt;br /&gt;
&lt;br /&gt;
创建表和加载数据的脚本文件必须放在你的模块目录中创建子目录“sql”中(如htdocs/mymodule/sql)&lt;br /&gt;
&lt;br /&gt;
检查模块主文件，&amp;quot;init&amp;quot;函数中是否包括行：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;$this-&amp;gt;_load_tables(&#039;/mymodule/sql/&#039;);&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;规则:&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*新建表的命令在文件 &#039;&#039;&#039;llx_mytable.sql&#039;&#039;&#039;中, 或者还有 &#039;&#039;&#039;llx_mytable.key.sql&#039;&#039;&#039; (参见 &#039;&#039;&#039;install/mysql/tables&#039;&#039;&#039; 实例).&lt;br /&gt;
*管理数据：在目录 &#039;&#039;&#039;/mymodule/sql/&#039;&#039;&#039;中创建文件 &#039;&#039;&#039;data.sql&#039;&#039;&#039; 文件中包括增删模改数据的命令。&lt;br /&gt;
*不要使用双引号 (如使用 &#039;chaine&#039; 而不使用 &amp;quot;chaine&amp;quot;) 因为双引号有特殊意义(PostGreSQL)。&lt;br /&gt;
&lt;br /&gt;
data.sql实例&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sql&amp;quot;&amp;gt;&lt;br /&gt;
 delete from llx_const where name=&#039;MYMODULE_IT_WORKS&#039; and entity=&#039;__ENTITY__&#039;;&lt;br /&gt;
 insert into llx_const (name, value, type, note, visible, entity) values (&#039;MYMODULE_IT_WORKS&#039;,&#039;1&#039;,&#039;chaine&#039;,&#039;A constant vor my module&#039;,1,&#039;__ENTITY__&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
对于MySQL数据库，文件必须是可操作的。REM：其他数据库的文件不被维护。它们将由另一个数据库的驱动程序进行读取和转换。&lt;br /&gt;
&lt;br /&gt;
===测试 .sql 文件===&lt;br /&gt;
&lt;br /&gt;
一旦文件准备就绪，您可以返回Dolibarr以禁用该模块，在数据库中将模块使用的表删除，并重新激活模块。应该能通过激活模块来重新创建表。否则，请通过手动传递脚本，或者检查Dolibarr日志。&lt;br /&gt;
&lt;br /&gt;
===生成 PHP DAO 类文件===&lt;br /&gt;
一旦将表创建到数据库中，就转到DEV/Skeleto目录&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;php build_class_from_table.php tablename modulename&amp;lt;/source&amp;gt;&lt;br /&gt;
注意：如果命令不工作，尝试使用PHP-CLI PHP代替。&lt;br /&gt;
这将生成一个文件&#039;&#039;&#039;out.tablename.class.php&#039;&#039;&#039;，它包含管理表tablename的类。&lt;br /&gt;
在这个类中，您可以找到CRUD方法（Create / Read / Update / Delete），在其中进行插入、获取（选择）、更新、删除表中的行。&lt;br /&gt;
从文件名中删除“out”，并将文件放在“模块”的子目录中（例如，在htdocs/mymodule/class中）。&lt;br /&gt;
&lt;br /&gt;
已经生成了一个文件&#039;&#039;&#039;out.tablename_script.php&#039;&#039;&#039;，并包含一个示例代码，使用了4个CRUD方法中的每一个。&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;自从Dolibarr 6.0开，不再提供文件&#039;&#039;&#039;dev/skeletons/build_class_from_table.php&#039;&#039;&#039;。要从一个表生成一个类，您应该使用&#039;&#039;&#039;ModuleBuilder&#039;&#039;&#039;模块。&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===使用ModuleBuilder生成PHP DAO类文件===&lt;br /&gt;
&lt;br /&gt;
*使用ModuleBuilder生成PHP DAO类文件，简单至在下图中选对&#039;对象&#039;选项卡，输入&#039;对象名&#039;，然后点击创建，即可生成相关一切文档。&lt;br /&gt;
&lt;br /&gt;
[[File:新对象.png|800px]]&lt;br /&gt;
&lt;br /&gt;
参见[[ModuleBuilder用户手册]]&lt;br /&gt;
==选项卡管理(可选)==&lt;br /&gt;
&lt;br /&gt;
===增删对象的选项卡===&lt;br /&gt;
&#039;&#039;&#039;何时&#039;&#039;&#039;: 增加对象选项卡 (对象是指‘发票’、‘订单’、‘提议’、‘会员’等等)&lt;br /&gt;
&lt;br /&gt;
为此，进入先前创建的模块主文件，并编辑$this-&amp;gt;tabs数组：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
	// Array to add new pages in new tabs or remove existing one&lt;br /&gt;
	$this-&amp;gt;tabs = array(&#039;objecttype:+tabname1:Title1:mylangfile@mymodule:$user-&amp;gt;rights-&amp;gt;mymodule-&amp;gt;read:/mymodule/mypagetab1.php?id=__ID__&#039;    // To add a new tab identified by code tabname1&lt;br /&gt;
                            &#039;objecttype:+tabname2:Title2:mylangfile@mymodule:$user-&amp;gt;rights-&amp;gt;mymodule-&amp;gt;read:/mymodule/mypagetab2.php?id=__ID__&#039;,   // To add a new tab identified by code tabname2&lt;br /&gt;
                            &#039;objecttype:-tabname&#039;);                                                     // To remove an existing tab identified by code tabname&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
该数据包含一个字符串列表，每个字符串表示一个新选项卡。&lt;br /&gt;
字符串由&amp;quot;:&amp;quot;分隔的6个部分组成。&lt;br /&gt;
&lt;br /&gt;
*Part 1: 选项卡出现在的对象类型（objecttype），只能是以下值：&lt;br /&gt;
{{TemplateModuleTabs}}&lt;br /&gt;
&lt;br /&gt;
*Part 2: 标识选项卡是添加（以+开始）或移除（以-start）的代码&lt;br /&gt;
*Part 3: 选项卡的标题。这可以是lang文件中的译文代码或者是一个直接的字符串。&lt;br /&gt;
*Part 4: 文件“*.lang”的名称，包含译文代码和要显示的语言之间的对应关系。如果这个名字跟随 @mymodule，Dolibarr将搜索模块内的翻译文件“*.lang”，即&amp;quot;htdocs/mymodule/langs/code_CODE/mylangfile.lang&amp;quot;。否则Dolibarr将查找文件&amp;quot;htdocs/langs/code_CODE/mylangfile.lang&amp;quot;&lt;br /&gt;
*Part 5: 测试选项卡是否必须可见的条件。为1则一直可见。&lt;br /&gt;
*Part 6: 单击选项卡时要显示的页面的URL。字符串__ID__将由相关元素的ID自动替换。&lt;br /&gt;
&lt;br /&gt;
要用数据库中的数据来填充选项卡的内容，请参阅下一章。&lt;br /&gt;
&lt;br /&gt;
===在你的页上显示选项卡导航===&lt;br /&gt;
&#039;&#039;&#039;何时&#039;&#039;&#039;: 在页面上显示对象的所有标准选项卡（产品、第三方等）。&lt;br /&gt;
&lt;br /&gt;
你必须遵循这些步骤：&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1. 包含文件中需要的文件&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
对于每个对象类型，有两个文件要包含。&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;require_once($url_fichier) ;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
包含示例 (DOL_DOCUMENT_ROOT 代表 dolibarr/htdocs/) :&lt;br /&gt;
&lt;br /&gt;
*对象第三方(thirdparty) :&lt;br /&gt;
**DOL_DOCUMENT_ROOT/societe/class/societe.class.php&lt;br /&gt;
**DOL_DOCUMENT_ROOT/core/lib/company.lib.php&lt;br /&gt;
*对象产品(product) :&lt;br /&gt;
**DOL_DOCUMENT_ROOT/product/class/product.class.php&lt;br /&gt;
**DOL_DOCUMENT_ROOT/core/lib/product.lib.php&lt;br /&gt;
*对象发票 (invoice) :&lt;br /&gt;
**DOL_DOCUMENT_ROOT/compta/facture/class/facture.class.php&lt;br /&gt;
**DOL_DOCUMENT_ROOT/core/lib/invoice.lib.php&lt;br /&gt;
&lt;br /&gt;
...&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;2. 创建并加载对象以显示在您的选项卡中&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
通过从url(ie : /mytab.php?id=1)获取的id值，使用对象的获取方法，从数据库中创建正确的类和加载对象的实例。&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;例如：&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$id=GETPOST(&#039;id&#039;,&#039;int&#039;);&lt;br /&gt;
$ref=GETPOST(&#039;ref&#039;,&#039;alpha&#039;);&lt;br /&gt;
$product = new Product($db) ;&lt;br /&gt;
$result = $product-&amp;gt;fetch($id,$ref) ; // Test $result to check the database read is ok&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. 为你的对象类型获取所有可显示的选项卡列表&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
使用函数XXX_prepare_head($obj)，其中XXX是对象的名称。这将返回一个数组，包含所有选项卡条目的定义。要放入该方法的参数是要显示选项卡的对象实例。&lt;br /&gt;
&lt;br /&gt;
返回的数组为：&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$head        // Array of tabs&lt;br /&gt;
$head[$h]    // Element to describe one tab.&lt;br /&gt;
$head[$h][0] // Url of page to show when you click on tab&lt;br /&gt;
$head[$h][1] // Title of tab&lt;br /&gt;
$head[$h][2] // Code name to identify the tab&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;例如 :&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$head = product_prepare_head($product, $user) ; // 参数 $user 是要显示选项卡的对象，这就是&amp;quot;产品&amp;quot;对象为&amp;quot;user&amp;quot;对象准备的所有可用的选项卡的数组。&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4. 在你的页面上显示选项卡&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
使用函数dol_fiche_head()显示由函数XX_prepare_head()返回的$head数组定义的定义的所有选项卡。&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
dol_fiche_head($links, $active=&#039;0&#039;, $title=&#039;&#039;, $notab=0, $picto=&#039;&#039;)&lt;br /&gt;
//$links  // Tableau des onglets, appelé $head plus haut.&lt;br /&gt;
//$active // Onglet actif (mettre le nom de l&#039;onglet défini dans votre fichier de module, ou un nom contenu dans $head[$h][2]). Cet onglet sera mis en surbrillance&lt;br /&gt;
//$title  // Title to show (shown into a special tab that you can&#039;t click)&lt;br /&gt;
//$notab&lt;br /&gt;
//$picto  // Name of image to show into title. Possible values are:&lt;br /&gt;
//            product&lt;br /&gt;
//            service&lt;br /&gt;
//            company&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This function will show required tabs and open an html element &#039;&#039;&amp;lt; div class=&amp;quot;&amp;quot; &amp;gt;&#039;&#039; that correspond to the area under the tabs. To close area of a tab, just use &#039;&#039;&amp;lt; /div &amp;gt;&#039;&#039; into your PHP page.&lt;br /&gt;
&lt;br /&gt;
==创建或修改 PHP 屏显 (可选)==&lt;br /&gt;
&#039;&#039;&#039;何时&#039;&#039;&#039;: 如果模块的目的是为了修改屏显。&lt;br /&gt;
&lt;br /&gt;
===创建新 PHP 屏显===&lt;br /&gt;
然后，您必须创建PHP页面，使用目录&#039;&#039;&#039;modulebuilder/myobject_page.php&#039;&#039;&#039;中提供的框架模板来显示/编辑表中的数据。 (从命令行开发脚本， 见 [[Script development]]).&lt;br /&gt;
&lt;br /&gt;
要创建一个新的用户屏幕，创建一个模块名的子目录(若无)  (例如 &#039;&#039;&#039;htdocs/mymodule&#039;&#039;&#039;) 来存储创建的屏幕。&lt;br /&gt;
&lt;br /&gt;
复制 &#039;&#039;&#039;myobject_page.php&#039;&#039;&#039; 做为屏幕页。&lt;br /&gt;
&lt;br /&gt;
编辑该文件，以包括正确的 &#039;&#039;&#039;main.inc.php&#039;&#039;&#039;文件。&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Load Dolibarr environment&lt;br /&gt;
$res=0;&lt;br /&gt;
// Try main.inc.php into web root known defined into CONTEXT_DOCUMENT_ROOT (not always defined)&lt;br /&gt;
if (! $res &amp;amp;&amp;amp; ! empty($_SERVER[&amp;quot;CONTEXT_DOCUMENT_ROOT&amp;quot;])) $res=@include($_SERVER[&amp;quot;CONTEXT_DOCUMENT_ROOT&amp;quot;].&amp;quot;/main.inc.php&amp;quot;);&lt;br /&gt;
// Try main.inc.php into web root detected using web root caluclated from SCRIPT_FILENAME&lt;br /&gt;
$tmp=empty($_SERVER[&#039;SCRIPT_FILENAME&#039;])?&#039;&#039;:$_SERVER[&#039;SCRIPT_FILENAME&#039;];$tmp2=realpath(__FILE__); $i=strlen($tmp)-1; $j=strlen($tmp2)-1;&lt;br /&gt;
while($i &amp;gt; 0 &amp;amp;&amp;amp; $j &amp;gt; 0 &amp;amp;&amp;amp; isset($tmp[$i]) &amp;amp;&amp;amp; isset($tmp2[$j]) &amp;amp;&amp;amp; $tmp[$i]==$tmp2[$j]) { $i--; $j--; }&lt;br /&gt;
if (! $res &amp;amp;&amp;amp; $i &amp;gt; 0 &amp;amp;&amp;amp; file_exists(substr($tmp, 0, ($i+1)).&amp;quot;/main.inc.php&amp;quot;)) $res=@include(substr($tmp, 0, ($i+1)).&amp;quot;/main.inc.php&amp;quot;);&lt;br /&gt;
if (! $res &amp;amp;&amp;amp; $i &amp;gt; 0 &amp;amp;&amp;amp; file_exists(dirname(substr($tmp, 0, ($i+1))).&amp;quot;/main.inc.php&amp;quot;)) $res=@include(dirname(substr($tmp, 0, ($i+1))).&amp;quot;/main.inc.php&amp;quot;);&lt;br /&gt;
// Try main.inc.php using relative path&lt;br /&gt;
if (! $res &amp;amp;&amp;amp; file_exists(&amp;quot;../main.inc.php&amp;quot;)) $res=@include(&amp;quot;../main.inc.php&amp;quot;);&lt;br /&gt;
if (! $res &amp;amp;&amp;amp; file_exists(&amp;quot;../../main.inc.php&amp;quot;)) $res=@include(&amp;quot;../../main.inc.php&amp;quot;);&lt;br /&gt;
if (! $res &amp;amp;&amp;amp; file_exists(&amp;quot;../../../main.inc.php&amp;quot;)) $res=@include(&amp;quot;../../../main.inc.php&amp;quot;);&lt;br /&gt;
if (! $res) die(&amp;quot;Include of main fails&amp;quot;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
注： 你可能增加更多的 &amp;quot;../&amp;quot; 根据你的模块目录的深度。&lt;br /&gt;
在3.2之后，为所有版本的Dolibarr开发的模块应该能够在不同的文件夹中移动，而不是“htdocs”，比如“htdocs/custom”，而不必修改模块的源代码，这就是为什么我们要做几个包含，所以这个规则必须被所有模块应用。&lt;br /&gt;
&lt;br /&gt;
在main.inc.php文件中，加载了技术环境变量和权限。以下变量是位于该文件中的对象：&lt;br /&gt;
&lt;br /&gt;
*$user    包含用户+ 权限。&lt;br /&gt;
*$conf    包含 Dolibarr 设置&lt;br /&gt;
*$db      它包含一个打开的数据库连接处理程序。&lt;br /&gt;
*$langs   包含用户语言&lt;br /&gt;
&lt;br /&gt;
然后输入代码显示页面。&lt;br /&gt;
&lt;br /&gt;
*包含模块专属的类或库，使用Dolibarr函数dol_include_once()（而不是直接使用 include_once）：&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;例如 :&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
dol_include_once(&#039;/mymodule/class/myclass.class.php&#039;, &#039;MyClass&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*若要包含Dolibarr提供的类，请使用以下语法：&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;例如 :&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
require_once DOL_DOCUMENT_ROOT.&#039;/core/class/doli.class.php&#039;;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===为现存表单增加新字段===&lt;br /&gt;
您可能需要提供一个模块，该模块将更多字段添加到一些元素的表单（输入和查看）中。&lt;br /&gt;
&lt;br /&gt;
一个较累的解决方案（但不是很糟糕）是替换所有用于创建元素的页面（这意味着禁用“新元素”菜单条目并添加您的，禁用“显示”元素，用一个选项卡替换该元素，该选项卡是您自己的完整页面（从原始复制/粘贴），以完成与原始页面相同的操作，修改以添加字段并将添加的数据存储到自己的表中）。&lt;br /&gt;
&lt;br /&gt;
转到菜单 [[#Define your entries in menu (optional)]]和[[#The tab management (optional)]]，如果这个解决方案适合你（这个解决方案是更强大的，因为你可以改变你想要的一切进入页面）。&lt;br /&gt;
&lt;br /&gt;
我们将在这里描述另一种解决方案，它只在现有字段结束时“添加字段”，使用元素“category”作为示例，但您可以将此教程转换为发票、提案…&lt;br /&gt;
&lt;br /&gt;
*首先，添加一个由您的模块所拥有的表，以存储新字段的值。此表有一个名为“rowid”的列（将包含与元素表的字段rowid相同的值+每一个要添加的新字段的列。然后为这个新表创建一个CRUD（创建/读取/更新/删除）方法类。对于这两个任务，请回到前一章[[#创建数据表和表的PHP类文件 (可选)]]。&lt;br /&gt;
*下一步是在模块中添加一个钩子，以将新字段添加到窗体中。有关使用钩子的通用文档，请参见[[Hooks_system#Implement_the_Hook]]章节。&lt;br /&gt;
&lt;br /&gt;
如果您遵循本教程，以便能够将字段添加到类别窗体中，您必须这样做：&lt;br /&gt;
{{ToComplete}}&lt;br /&gt;
&lt;br /&gt;
===替换模板的部分内容 (version 3.3+)===&lt;br /&gt;
Dolibarr屏幕的一些部分被隔离到本地PHP模板文件中。&lt;br /&gt;
您可以开发一个模块来覆盖这样的模板。&lt;br /&gt;
{{ToComplete}}&lt;br /&gt;
&lt;br /&gt;
===增/换部分字段（需钩子支持）===&lt;br /&gt;
要知道如何使用Dolibarr现有的钩子来添加/替换Dolibarr 钩子代码，参考 [[钩子系统#实现钩子]] 。&lt;br /&gt;
&lt;br /&gt;
===数据通道===&lt;br /&gt;
如果需要在自己的表中编辑数据库中的一些数据，请使用的PHP类。&lt;br /&gt;
&lt;br /&gt;
如果您要访问没有专用PHP类的表（例如，如果您想获得具有特定连接或筛选器的记录列表）。在这种情况下，这是要遵循的代码示例：&lt;br /&gt;
&lt;br /&gt;
进行插入、更新或删除：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$db-&amp;gt;begin();   // Start transaction&lt;br /&gt;
$db-&amp;gt;query(&amp;quot;My SQL request insert, update or delete&amp;quot;);&lt;br /&gt;
$db-&amp;gt;commit();       // Validate transaction&lt;br /&gt;
or $db-&amp;gt;rollback()  // Cancel transaction&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
读:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$resql=$db-&amp;gt;query(&amp;quot;My select request&amp;quot;);&lt;br /&gt;
if ($resql)&lt;br /&gt;
{&lt;br /&gt;
	$num = $db-&amp;gt;num_rows($resql);&lt;br /&gt;
	$i = 0;&lt;br /&gt;
	if ($num)&lt;br /&gt;
	{&lt;br /&gt;
		while ($i &amp;lt; $num)&lt;br /&gt;
		{&lt;br /&gt;
			$obj = $db-&amp;gt;fetch_object($resql);&lt;br /&gt;
			if ($obj)&lt;br /&gt;
			{&lt;br /&gt;
				// You can use here results&lt;br /&gt;
				print $obj-&amp;gt;field1;&lt;br /&gt;
				print $obj-&amp;gt;field2;&lt;br /&gt;
			}&lt;br /&gt;
			$i++;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===页面风格===&lt;br /&gt;
为了让你自己的页面看起来与Dolibarr主题相匹配，必须使用Dolibarr CSS样式。&lt;br /&gt;
&lt;br /&gt;
例如，您可以使用：&lt;br /&gt;
&lt;br /&gt;
*class=&amp;quot;&#039;&#039;&#039;liste_titre&#039;&#039;&#039;&amp;quot; on tags &#039;&#039;tr&#039;&#039; and &#039;&#039;td&#039;&#039; for the head row of a table.&lt;br /&gt;
*class=&amp;quot;&#039;&#039;&#039;pair&#039;&#039;&#039;&amp;quot; or class=&amp;quot;&#039;&#039;&#039;impair&#039;&#039;&#039;&amp;quot; on tags &#039;&#039;tr&#039;&#039; and &#039;&#039;td&#039;&#039; of other rows of a table.&lt;br /&gt;
*class=&amp;quot;&#039;&#039;&#039;flat&#039;&#039;&#039;&amp;quot; on all input fields (&#039;&#039;input, select, textarea&#039;&#039;...).&lt;br /&gt;
*class=&amp;quot;&#039;&#039;&#039;button&#039;&#039;&#039;&amp;quot; on HTML fields with type &#039;&#039;input type=&amp;quot;submit&amp;quot;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
===使用Dolibarr日期选择器===&lt;br /&gt;
如果您的页面使用Dolibarr日期选择器（日历弹出），请使用以下行：&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
 $form=new Form($db);&lt;br /&gt;
 $form-&amp;gt;select_date(&#039;&#039;,&#039;mykey&#039;,0,0,0,&amp;quot;myform&amp;quot;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
字符串mykey将标识表单中的日期选择器。如果在同一页中使用多个日期选择器，则必须使用不同的值。&lt;br /&gt;
&lt;br /&gt;
字符串myform是包含选择器的表单的名称（在HTML页面中的form name=&amp;quot;myform&amp;quot;）中找到的值。&lt;br /&gt;
&lt;br /&gt;
这意味着日期选择器必须包含在HTML表单中。&lt;br /&gt;
&lt;br /&gt;
要获得表单POST的值，命令是：&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$mydate = dol_mktime(12, 0 , 0, $_POST[&#039;mykeymonth&#039;], $_POST[&#039;mykeyday&#039;], $_POST[&#039;mykeyyear&#039;]);&lt;br /&gt;
print strftime(&#039;%A %d %B %Y&#039;, $mydate);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==新增设置页 (可选)==&lt;br /&gt;
&#039;&#039;&#039;何时&#039;&#039;&#039;: 如果模块需要用户提供的参数，以正确设置模块。&lt;br /&gt;
&lt;br /&gt;
===创建页面以编辑参数===&lt;br /&gt;
如果模块需要设置几个参数，则必须创建一个页面来编辑选项。 (这些制作存储于 [[Table llx_const|表 &#039;&#039;&#039;llx_const&#039;&#039;&#039;]]).&lt;br /&gt;
&lt;br /&gt;
新建 &#039;&#039;&#039;mymodule_setuppage.php&#039;&#039;&#039; 这显示了可能的选项的表单，将它们更新到上面提到的表中。&lt;br /&gt;
&lt;br /&gt;
有必要从目录&#039;&#039;/admin &#039;&#039;的页面中获取一个示例，它将向您展示读取/保存参数的方法。&lt;br /&gt;
&lt;br /&gt;
把这个PHP页面放到你的模块的&#039;&#039;/admin &#039;&#039;（例如mymodule/admin/mymodule_setuppage.php）的目录中。&lt;br /&gt;
&lt;br /&gt;
===修改模块主文件===&lt;br /&gt;
然后，在模块主文件中，将变量“config_page_url”修改为PHP页面的设置名称。&lt;br /&gt;
&lt;br /&gt;
如果页面位于目录&#039;&#039;&#039;admin/&#039;&#039;&#039;中，则不需要路径，例如：&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;config_page_url = array(&amp;quot;mymodule_setuppage.php&amp;quot;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
如果页面在目录 &#039;&#039;&#039;mymodule/admin/&#039;&#039;&#039;中，则像这样：&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;config_page_url = array(&amp;quot;mymodule_setuppage.php@mymodule&amp;quot;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===测试页面===&lt;br /&gt;
进入&#039;&#039;&#039;首页-&amp;gt;安装&amp;gt;模块&#039;&#039;&#039;，您应该在您的模块行的末尾看到一个图片，以转到您的设置页面。点击它，你就可以从页面中查看/编辑参数。&lt;br /&gt;
&lt;br /&gt;
==增加菜单条目 (可选)==&lt;br /&gt;
&#039;&#039;&#039;何时&#039;&#039;&#039;: 如果您创建了PHP页面，则必须从Dolibarr菜单中的菜单条目中访问这些页面。&lt;br /&gt;
&lt;br /&gt;
===增加菜单条目===&lt;br /&gt;
For this, you must define into the module descriptor, the array this-&amp;gt;menu that declare all menus added by your module.&lt;br /&gt;
This array contains entries that will appear once your module is activated.&lt;br /&gt;
The example module descriptor file &#039;&#039;&#039;modMyModule.class.php&#039;&#039;&#039; contains an example to declare a top menu and also its left menu entries.&lt;br /&gt;
&lt;br /&gt;
This is the example of code to declare your own menu entries in a module descriptor file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Main menu entries&lt;br /&gt;
$this-&amp;gt;menu = array();			// List of menus to add&lt;br /&gt;
$r=0;&lt;br /&gt;
&lt;br /&gt;
// Add here entries to declare new menus&lt;br /&gt;
// Example to declare the Top Menu entry:&lt;br /&gt;
$this-&amp;gt;menu[$r]=array(	&#039;fk_menu&#039;=&amp;gt;0,			// Put 0 if this is a top menu&lt;br /&gt;
			&#039;type&#039;=&amp;gt;&#039;top&#039;,			// This is a Top menu entry&lt;br /&gt;
			&#039;titre&#039;=&amp;gt;&#039;MyModule top menu&#039;,&lt;br /&gt;
			&#039;mainmenu&#039;=&amp;gt;&#039;mymodule&#039;,&lt;br /&gt;
			&#039;leftmenu&#039;=&amp;gt;&#039;mymodule&#039;,&lt;br /&gt;
			&#039;url&#039;=&amp;gt;&#039;/mymodule/pagetop.php&#039;,&lt;br /&gt;
			&#039;langs&#039;=&amp;gt;&#039;mylangfile&#039;,	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.&lt;br /&gt;
			&#039;position&#039;=&amp;gt;100,&lt;br /&gt;
			&#039;enabled&#039;=&amp;gt;&#039;1&#039;,			// Define condition to show or hide menu entry. Use &#039;$conf-&amp;gt;mymodule-&amp;gt;enabled&#039; if entry must be visible if module is enabled.&lt;br /&gt;
			&#039;perms&#039;=&amp;gt;&#039;1&#039;,			// Use &#039;perms&#039;=&amp;gt;&#039;$user-&amp;gt;rights-&amp;gt;mymodule-&amp;gt;level1-&amp;gt;level2&#039; if you want your menu with a permission rules&lt;br /&gt;
			&#039;target&#039;=&amp;gt;&#039;&#039;,&lt;br /&gt;
			&#039;user&#039;=&amp;gt;2);				// 0=Menu for internal users, 1=external users, 2=both&lt;br /&gt;
$r++;&lt;br /&gt;
&lt;br /&gt;
// Example to declare a Left Menu entry:&lt;br /&gt;
$this-&amp;gt;menu[$r]=array(	&#039;fk_menu&#039;=&amp;gt;&#039;fk_mainmenu=xxx&#039;,		    // Use &#039;fk_mainmenu=xxx&#039; or &#039;fk_mainmenu=xxx,fk_leftmenu=yyy&#039; where xxx is mainmenucode and yyy is a leftmenucode of parent menu&lt;br /&gt;
			&#039;type&#039;=&amp;gt;&#039;left&#039;,			        // This is a Left menu entry&lt;br /&gt;
			&#039;titre&#039;=&amp;gt;&#039;MyModule left menu 1&#039;,&lt;br /&gt;
			&#039;mainmenu&#039;=&amp;gt;&#039;xxx&#039;,&lt;br /&gt;
                        &#039;leftmenu&#039;=&amp;gt;&#039;yyy&#039;,&lt;br /&gt;
			&#039;url&#039;=&amp;gt;&#039;/mymodule/pagelevel1.php&#039;,&lt;br /&gt;
			&#039;langs&#039;=&amp;gt;&#039;mylangfile&#039;,	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.&lt;br /&gt;
			&#039;position&#039;=&amp;gt;100,&lt;br /&gt;
			&#039;enabled&#039;=&amp;gt;&#039;1&#039;,			// Define condition to show or hide menu entry. Use &#039;$conf-&amp;gt;mymodule-&amp;gt;enabled&#039; if entry must be visible if module is enabled.&lt;br /&gt;
			&#039;perms&#039;=&amp;gt;&#039;1&#039;,			// Use &#039;perms&#039;=&amp;gt;&#039;$user-&amp;gt;rights-&amp;gt;mymodule-&amp;gt;level1-&amp;gt;level2&#039; if you want your menu with a permission rules&lt;br /&gt;
			&#039;target&#039;=&amp;gt;&#039;&#039;,&lt;br /&gt;
			&#039;user&#039;=&amp;gt;2);				// 0=Menu for internal users,1=external users, 2=both&lt;br /&gt;
$r++;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To show menu or not depending on a permission, modify property &#039;&#039;&#039;perms&#039;&#039;&#039; in array. See chapter on permissions later to see how to add permissions.&lt;br /&gt;
&lt;br /&gt;
===测试菜单===&lt;br /&gt;
Disable and reenable your module under Dolibarr module setup page, menus entries must appear (if property &#039;enabled&#039; is declaration array is ok).&lt;br /&gt;
&lt;br /&gt;
==新增权限 (可选)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If you want to add new permissions.&lt;br /&gt;
&lt;br /&gt;
The way to define permissions that will manage your module is done inside the module descriptor created previously.&lt;br /&gt;
Modify line &lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;rights_class = &#039;mymodule&#039;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
with correct value for mymodule.&lt;br /&gt;
&lt;br /&gt;
Then you must fill the array $this-&amp;gt;rights with as many entries than different permissions you need to manage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;rights[$r][0] = 10001;&lt;br /&gt;
$this-&amp;gt;rights[$r][1] = &#039;Label by default of permission&#039;;&lt;br /&gt;
$this-&amp;gt;rights[$r][3] = 1;&lt;br /&gt;
$this-&amp;gt;rights[$r][4] = &#039;action&#039;;&lt;br /&gt;
$this-&amp;gt;rights[$r][5] = &#039;subaction&#039;;&lt;br /&gt;
$r++;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Into $this-&amp;gt;rights[$r][0], put a permission id not already used (See into menu &#039;&#039;&#039;System info&#039;&#039;&#039; on a working installation of Dolibarr to know list of id already used by standard modules.&lt;br /&gt;
Into $this-&amp;gt;rights[$r][3], put 1 if this permission must be granted automatically by default to any new created user.&lt;br /&gt;
Into $this-&amp;gt;rights[$r][1], put a label by default for permission (This label will be used if no translation can be found into the file &#039;&#039;&#039;admin.lang&#039;&#039;&#039;).&lt;br /&gt;
Into $this-&amp;gt;rights[$r][4] and $this-&amp;gt;rights[$r][5], put an action and subaction string without spaces. You will be able to test if a user has the permission in your PHP source code with the sequence:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
if ($user-&amp;gt;rights-&amp;gt;mymodule-&amp;gt;action-&amp;gt;subaction) ...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==信息窗 (可选)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module need to provide one or several new boxes to show on home page.&lt;br /&gt;
&lt;br /&gt;
===信息窗===&lt;br /&gt;
For this, modify the array $this-&amp;gt;boxes into the module descriptor file.&lt;br /&gt;
All you have to do is to add 2 lines for each box file you will create into directory &#039;&#039;&#039;htdocs/mymodule/core/boxes&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example:&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;boxes[0][&#039;file&#039;]=&#039;mybox0.php@mymodule&#039;&lt;br /&gt;
$this-&amp;gt;boxes[0][&#039;note&#039;]=&#039;My box 0&#039;&lt;br /&gt;
 ...&lt;br /&gt;
$this-&amp;gt;boxes[n][&#039;file&#039;]=&#039;myboxn.php@mymodule&#039;&lt;br /&gt;
$this-&amp;gt;boxes[n][&#039;note&#039;]=&#039;My box n&#039;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create files &#039;&#039;&#039;htdocs/mymodule/core/boxes/mybox0.php&#039;&#039;&#039;, &#039;&#039;&#039;htdocs/mymodule/core/boxes/mybox1.php&#039;&#039;&#039;... by copying an example from an existing box file (found into directory &#039;&#039;&#039;htdocs/core/boxes&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
===Test if your box is detected by Dolibarr===&lt;br /&gt;
Disable and enabled module.&lt;br /&gt;
&lt;br /&gt;
Go into menu &#039;&#039;&#039;Home - Setup - Boxes&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
==Define your own export (optional)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module provide new predefined database export profiles (for its own tables or for already existing tables of another module).&lt;br /&gt;
&lt;br /&gt;
===导出===&lt;br /&gt;
For this uncomment and modify arrays $this-&amp;gt;export_xxx in your module descriptor file.&lt;br /&gt;
&lt;br /&gt;
===Test your export===&lt;br /&gt;
Go into menu Tools -&amp;gt; Export. Your export will appear in the list of available predefined exports (if your module is enabled).&lt;br /&gt;
Choose it, you must see list of all possible fields defined in the export arrays.&lt;br /&gt;
Choose on field and try to build an export file. If ok, try again with all fields.&lt;br /&gt;
&lt;br /&gt;
==Define your CSS styles (optional)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If in your PHP pages, you use class styles that are not defined inside Dolibarr themes CSS (not recommanded).&lt;br /&gt;
&lt;br /&gt;
===Create and declare your style sheet===&lt;br /&gt;
Create a style sheet CSS named &#039;&#039;&#039;mymodule.css&#039;&#039;&#039; or &#039;&#039;&#039;mymodule.css.php&#039;&#039;&#039; and put it into directory &#039;&#039;&#039;htdocs/mymodule&#039;&#039;&#039;. You can have only one CSS file per module.&lt;br /&gt;
Remember it&#039;s better to use existing styles already available by default into Dolibarr (The CSS file used by Dolibarr is file &#039;&#039;&#039;themes/mytheme/&#039;&#039;themename&#039;&#039;.css.php&#039;&#039;&#039;. Create your own CSS file only if you need absolutely to add not already existing styles.&lt;br /&gt;
&lt;br /&gt;
Once your style sheet is ready, declare it into your module descriptor file by modifying the property &#039;&#039;&#039;$this-&amp;gt;modules_parts&#039;&#039;&#039;.&lt;br /&gt;
Value to put here must be a relative URL to your CSS file.&lt;br /&gt;
For example&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;module_parts = array(&#039;css&#039; =&amp;gt; array(&#039;/mymodule/css/mymodule.css.php&#039;));&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test your style sheet===&lt;br /&gt;
Disable and enable your module.&lt;br /&gt;
&lt;br /&gt;
Go on home page (index.php). Show the HTML source of the page.&lt;br /&gt;
&lt;br /&gt;
You should see into the HTML header, a line that declare your style sheet.&lt;br /&gt;
&lt;br /&gt;
==增加JS函数功能 (可选)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If in your PHP pages, you use javascript functions not available in Dolibarr (in file lib_head.js)&lt;br /&gt;
&lt;br /&gt;
If you need to use your own javascript functions inside your PHP pages, it is necessary to have your functions, defined into your  javascript file &#039;&#039;&#039;htdocs/mymodule/js/mymodule.js&#039;&#039;&#039;, included into the HTML HEAD section.&lt;br /&gt;
To ask Dolibarr that forge this header to include your own javascript file, you must just provide it to the llxHeader() function called by your page.&lt;br /&gt;
&lt;br /&gt;
Example for page /htdocs/mymodule/mypage.php :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$morejs=array(&amp;quot;/mymodule/js/mymodule.js&amp;quot;);&lt;br /&gt;
llxHeader(&#039;&#039;,&#039;Titre&#039;,&#039;&#039;,&#039;&#039;,&#039;&#039;,&#039;&#039;,$morejs,&#039;&#039;,0,0); &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==执行Dolibarr事件代码 (可选)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: 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 &#039;&#039;&#039;triggers&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
See also [[Interfaces_Dolibarr_toward_foreign_systems]]&lt;br /&gt;
and [[Interfaces_from_foreign_systems_toward_Dolibarr]]&lt;br /&gt;
&lt;br /&gt;
==钩子代码 (可选)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: 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).&lt;br /&gt;
&lt;br /&gt;
See page [[Hooks_system]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==添加编码规则==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: When you need a new rule for generated ref of elements that is not covered by existing rules.&lt;br /&gt;
&lt;br /&gt;
See page [[Create numbering module]].&lt;br /&gt;
&lt;br /&gt;
==创建文档模板 (optional)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: When you want to personalized your own generated PDF or ODT documents.&lt;br /&gt;
&lt;br /&gt;
Note: To add this feature you don&#039;t need to create a module descriptor.&lt;br /&gt;
&lt;br /&gt;
Documentation to add your own template is available on page [[Create_a_PDF_document_template]] or [[Create_an_ODT_document_template]].&lt;br /&gt;
&lt;br /&gt;
==创建主题 (optional)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: When you want to personalized your colors/fonts/images.&lt;br /&gt;
&lt;br /&gt;
Note: To add this feature you don&#039;t need to create a module descriptor.&lt;br /&gt;
&lt;br /&gt;
To add your own skin, read page [[Skins]].&lt;br /&gt;
&lt;br /&gt;
==修改开发模块作者名==&lt;br /&gt;
&lt;br /&gt;
在myModule.class.php中查找editor_name&lt;br /&gt;
&lt;br /&gt;
修改以下变量的值以修改作者名称&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;editor_name = &#039;Roger@QQ:12464313&#039;;&lt;br /&gt;
$this-&amp;gt;editor_url = &#039;https://www.ivnun.cn&#039;;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=一些编码规则和预定义函数=&lt;br /&gt;
The coding rules to be followed are defined in the [[Developer documentation]], under section &amp;quot;General Information - Language and standards development&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
A lot of predefined features for developers are also available and described into page [[Developer documentation]] under section &amp;quot;Technical components of Dolibarr&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
=创建一个安装包来分发和安装您的模块=&lt;br /&gt;
This process must be used to generate a package to submit it on the http://www.dolistore.com market place.&lt;br /&gt;
But you can use it to have a package easy to distribute on your on network.&lt;br /&gt;
&lt;br /&gt;
*Go into the directory &#039;&#039;&#039;/build&#039;&#039;&#039; and copy the file &#039;&#039;&#039;makepack-dolibarrmodules.conf&#039;&#039;&#039; into &#039;&#039;&#039;makepack-mymodule.conf&#039;&#039;&#039;. 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 &amp;quot;Development version&amp;quot; (taken in this case the whole build directory which is autonomous and independent directory).&lt;br /&gt;
&lt;br /&gt;
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...)&lt;br /&gt;
&lt;br /&gt;
*Run the script via Perl (need the Perl version 5.0 or later):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
perl makepack-dolibarrmodule.pl&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The script asks you the name of your module, its major and minor version. A file &#039;&#039;&#039;mymodule.zip &#039;&#039;&#039; will then be manufactured containing your module ready to be deployed.&lt;br /&gt;
&lt;br /&gt;
*The person who receives your module must then place the file in the root directory of a Dolibarr installation and perform the command:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
tar -xvf mymodule.zip&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*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 &amp;quot;Submit a module/product&amp;quot;).&lt;br /&gt;
**If your module was build correctly, file will be validated later.&lt;br /&gt;
**If quality is enough and license permits it, code might be added inside main Dolibarr sources (except if you disagree for that).&lt;br /&gt;
&lt;br /&gt;
=Delistor上的外部模块的启用/激活条件=&lt;br /&gt;
&lt;br /&gt;
See [[Module_Dolistore_Validation_Rules|Validation Rules]]&lt;/div&gt;</summary>
		<author><name>Thecyyoung</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=%E7%BF%BB%E8%AF%91%E6%96%87%E6%A1%A3&amp;diff=47018</id>
		<title>翻译文档</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=%E7%BF%BB%E8%AF%91%E6%96%87%E6%A1%A3&amp;diff=47018"/>
		<updated>2020-05-05T14:03:45Z</updated>

		<summary type="html">&lt;p&gt;Thecyyoung: /* 手动翻译（不推荐） */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;!-- BEGIN interlang links --&amp;gt;&lt;br /&gt;
&amp;lt;!-- Do NOT edit this section&lt;br /&gt;
     Links below are automatically managed by PolyglotBot&lt;br /&gt;
     You can edit links on the English source page : Translator_documentation --&amp;gt;&lt;br /&gt;
[[en:Translator_documentation]]&lt;br /&gt;
[[fr:Documentation_traducteur]]&lt;br /&gt;
[[es:Documentación_traductores]]&lt;br /&gt;
[[de:Dokumentation_Uebersetzung]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;seo metak=&amp;quot;translation, documentation, translator, localize, localization, i18n, internationalization, language&amp;quot; /&amp;gt;&lt;br /&gt;
{{Template用户手册}}&lt;br /&gt;
{{TemplateMainPageZh}}&lt;br /&gt;
&lt;br /&gt;
= [[File:Language.png]] 翻译 Dolibarr =&lt;br /&gt;
&lt;br /&gt;
Dolibarr语言文件已经用几种语言翻译了。&lt;br /&gt;
英语是默认的语言会首先完成翻译。其他语言依赖于自愿者的贡献。 本教程帮助您完成一个未译的或错译的语言。&lt;br /&gt;
Dolibarr可以用三种不同的方式翻译：&lt;br /&gt;
&lt;br /&gt;
# 手动使用Transifex （官方和推荐的方法）&lt;br /&gt;
# 手动编辑语言文件&lt;br /&gt;
# 全自动：自动翻译机&lt;br /&gt;
&lt;br /&gt;
== 使用Transifex在线服务进行手动翻译（推荐）==&lt;br /&gt;
&lt;br /&gt;
Transifex 是一个为翻译项目提供在线平台的Web应用程序。它包括团队和讨论工具、翻译记忆、词汇表、校对和许多其他特征。&lt;br /&gt;
它非常容易使用，所有翻译都可以通过Web界面上传或下载，或者使用来自终端的TX客户端。&lt;br /&gt;
Transifex 是一个开源项目，“社区版”可以免费下载和安装，但我们将使用在线托管服务。&lt;br /&gt;
&lt;br /&gt;
===使用Web界面（译者）===&lt;br /&gt;
如果你想用自己的语言帮助翻译Dolibarr，请检查项目的页面。 https://www.transifex.com/dolibarr-association/dolibarr/&lt;br /&gt;
&lt;br /&gt;
然后，您可以注册一个帐户，并请求加入项目团队，以您的语言为目标。管理员会接受你的要求，所以请耐心等待。&lt;br /&gt;
&lt;br /&gt;
一旦被接受，你就可以马上开始翻译了。&lt;br /&gt;
&lt;br /&gt;
欲了解更多信息，请检查Transifex“入门”介绍规范 http://docs.transifex.com/introduction/translators/ 和网络编辑器向导于 http://docs.transifex.com/tutorials/txeditor/&lt;br /&gt;
&lt;br /&gt;
====&#039;&#039;&#039;备注关于 en_US&#039;&#039;&#039;====&lt;br /&gt;
Web界面不能用来翻译源代码的en_US语言。&lt;br /&gt;
&lt;br /&gt;
任何更改都必须在Dolibarr源代码中完成，并在GitHub存储库上使用Pull请求提交。&lt;br /&gt;
&lt;br /&gt;
=== 使用TX 命令行客户端 (for Dolibarr [[:Category:Yoda]] team) ===&lt;br /&gt;
这描述了如何从命令行中使用Transifex。然而，这是保留给Dolibarr管理员用户，以同步Transifex与Dolibarr主源码。&lt;br /&gt;
&lt;br /&gt;
[http://docs.transifex.com/developer/client/ 官方文档]&lt;br /&gt;
&lt;br /&gt;
====TX 客户端设置====&lt;br /&gt;
安装 TX 客户端&lt;br /&gt;
使用 Debian/Ubuntu/Mint:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
apt-get install python-pip&lt;br /&gt;
pip install transifex-client&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
然后你必须初始化你的TX环境。这是通过进入Dolibarr项目根目录运行&#039;tx init &#039;&#039;来完成的。&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
cd git/dolibarr&lt;br /&gt;
tx init&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
接受改写配置文件。保持Transifex实例的默认值，然后输入您的Transifex登录和密码。&lt;br /&gt;
&lt;br /&gt;
在此之后，一个.transifexrc已经创建到您的主页目录，并且一个通用配置文件被创建于项目根目录中的&#039;&#039;&#039;.tx/config&#039;&#039;&#039;。&lt;br /&gt;
所以目录的内容会是这样的：&lt;br /&gt;
所以目录的内容会是这样的：&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
.&lt;br /&gt;
|-- build&lt;br /&gt;
|-- build.xml&lt;br /&gt;
|-- ChangeLog&lt;br /&gt;
|-- COPYING&lt;br /&gt;
|-- COPYRIGHT&lt;br /&gt;
|-- dev&lt;br /&gt;
|-- doc&lt;br /&gt;
|-- .gitignore&lt;br /&gt;
|-- htdocs&lt;br /&gt;
|-- INSTALL&lt;br /&gt;
|-- pom.xml&lt;br /&gt;
|-- quickbuild.xml&lt;br /&gt;
|-- README&lt;br /&gt;
|-- README-FR&lt;br /&gt;
|-- README.md&lt;br /&gt;
|-- robots.txt&lt;br /&gt;
|-- scripts&lt;br /&gt;
|-- test&lt;br /&gt;
`-- .tx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
当前配置文件可以从 https://github.com/Dolibarr/dolibarr/tree/develop/.tx 下载，放入.tx目录，重写由&#039;tx init &#039;&#039;创建的目录。&lt;br /&gt;
&lt;br /&gt;
此项目配置文件用于将项目的详细信息和文件存储到资源映射。&lt;br /&gt;
&lt;br /&gt;
这是配置文件包含内容的示例：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;ini&amp;quot;&amp;gt;&lt;br /&gt;
[main]&lt;br /&gt;
host = https://www.transifex.com&lt;br /&gt;
lang_map = uz: uz_UZ&lt;br /&gt;
&lt;br /&gt;
[dolibarr.admin]&lt;br /&gt;
file_filter = htdocs/langs/&amp;lt;lang&amp;gt;/admin.lang&lt;br /&gt;
source_file = htdocs/langs/en_US/admin.lang&lt;br /&gt;
source_lang = en_US&lt;br /&gt;
type = MOZILLAPROPERTIES&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
下面是配置文件中使用的部件和选项的说明：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;[main] section&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
在本节中，我们有项目范围的选项，例如：所有项目的默认transifex主机。如果需要的话，这些资源可以被每个资源重写。&lt;br /&gt;
&lt;br /&gt;
&amp;lt;nowiki&amp;gt;[dolibarr.resource]&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
source_lang: this is the source language of the resource.&amp;lt;br/&amp;gt;&lt;br /&gt;
source_file: this points to the source file directly.&amp;lt;br/&amp;gt;&lt;br /&gt;
file_filter: here we hold the expression used to identify translation files under the specific project. &#039;&#039;not mandatory&#039;&#039;&amp;lt;br/&amp;gt;&lt;br /&gt;
trans.&amp;lt;lang&amp;gt;: this is used for translation files that don’t follow a common naming schema and the file expression cannot be used to track them. &#039;&#039;not mandatory&#039;&#039;&amp;lt;br/&amp;gt;&lt;br /&gt;
host: in case the project doesn’t use the default Transifex server as specified in the [main] section, it can override it using this option. &#039;&#039;not mandatory&#039;&#039;&amp;lt;br/&amp;gt;&lt;br /&gt;
&lt;br /&gt;
====TX 客户端使用====&lt;br /&gt;
&#039;&#039;&#039;tx&#039;&#039;&#039; 命令有用的信息。&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tx status&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
显示翻译状态&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tx push&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
用于推送更改，从你的计算机到Transifex服务器&lt;br /&gt;
&lt;br /&gt;
TX推送命令的其他选项是：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
-h - 显示命令行帮助&lt;br /&gt;
-l &amp;lt;lang&amp;gt; - 指定要推送哪些翻译（默认为所有）&lt;br /&gt;
-r &amp;lt;resource&amp;gt; - 指定要向其推送翻译的资源（默认为所有）&lt;br /&gt;
-f - 在不修改修改时间的情况下推送源文件&lt;br /&gt;
--skip - 错误时不要停止。当同时推多个文件时很有用。&lt;br /&gt;
-s - 将源文件推送到服务器&lt;br /&gt;
-t - 将翻译文件推送到服务器&lt;br /&gt;
--no-interactive - 强制推送时不需要用户输入。&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;tx pull&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
用于从Transifex服务器将更改拉到您的计算机上&amp;lt;br/&amp;gt;&lt;br /&gt;
TX拉动命令的其他选项是：&lt;br /&gt;
&amp;lt;code&amp;gt;&amp;lt;pre&amp;gt;&lt;br /&gt;
-h - Shows the help screen for the command&lt;br /&gt;
-l &amp;lt;lang&amp;gt; - Specify which translations you want to pull (defaults to all)&lt;br /&gt;
-r &amp;lt;resource&amp;gt; - Specify the resource for which you want to pull the translations (defaults to all)&lt;br /&gt;
-a - Fetch all translation files from server (even new ones)&lt;br /&gt;
-s - Force the fetching of the source file (default: False)&lt;br /&gt;
-f - Force download of translations files&lt;br /&gt;
--skip - Don&#039;t stop on errors. Useful when pushing many files concurrently.&lt;br /&gt;
--disable-overwrite - By default Transifex will fetch new translations files and replace existing ones. Use this flag if you want to disable this feature.&lt;br /&gt;
--minimum_perc=VALUE - Specify the minimum acceptable percentage of a translation in order to download it.&amp;lt;/pre&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;例&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
要取得翻译文档,使用:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
tx -d pull -l it_IT  # Get italian language only&lt;br /&gt;
tx -d pull -a   # Get all languages&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
要上传源文件,键入:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
tx -d push -t -l it_IT [-r dolibarr.file]   # To push only a specific translation file&lt;br /&gt;
tx -d push -s  # To push source file&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== transifex流程的其他问题 ===&lt;br /&gt;
这是一个简短的Q&amp;amp;A，你也可以问一下transifex翻译过程：&lt;br /&gt;
&lt;br /&gt;
1) 是在一个固定的时间间隔上的同步?&lt;br /&gt;
&lt;br /&gt;
不，它是在有足够的翻译提交的地方完成的。在创建最终发布包之前，它也在beta分支上完成。&lt;br /&gt;
 &lt;br /&gt;
2) 是否所有的翻译同步到Git，或者仅仅是经过审查的翻译。在同步完成之前我需要复习吗？ ?&lt;br /&gt;
&lt;br /&gt;
当同步完成时，transifex文件将文件覆盖到Git中，但前提是至少为文件修改了记录。&lt;br /&gt;
在同步完成之前，您不必进行复查。最重要的是，要知道哪些线是手工评审的，哪些是最初用机器人翻译的。&lt;br /&gt;
 &lt;br /&gt;
3) Dolibarr发布的版本将有翻译吗？transifex 翻译也与维护版本同步?&lt;br /&gt;
&lt;br /&gt;
同步总是在开发和/或beta上完成。&lt;br /&gt;
因此，transifex更改出现在所有版本中，其分支是在transifex更改之后创建的（在创建新分支之前总是进行同步）。&lt;br /&gt;
&lt;br /&gt;
一旦创建了一个分支，那么新的过渡到transifex将只适用于下一个分支。这是因为transifex无法管理分支/版本（还没有）。&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== 手动翻译（不推荐） ==&lt;br /&gt;
&lt;br /&gt;
要将Dolibarr翻译成另一种语言，请转到Langs目录，并创建一个用代码语言命名的文件夹/目录来翻译（遵循现有格式，例如en_US, en_GB, es_ES, de_DE, 等）。然后将文件从现有的语言目录（例如en_US/main.lang, en_GB/bills.lang）复制到刚刚创建的新语言目录中。&lt;br /&gt;
&lt;br /&gt;
这些文件在每行中具有键/值对的格式，如下所示：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;ini&amp;quot;&amp;gt;&lt;br /&gt;
Code1 = translate phrase 1&lt;br /&gt;
Code2 = translate phrase 2&lt;br /&gt;
...&lt;br /&gt;
Coden = translate phrase n&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
将短语（键值对的值部分）翻译你的语言，“=”的左边的代码（键部分）应该保持不变。&lt;br /&gt;
&lt;br /&gt;
可以逐个翻译这些文件，而不必一次就把它们全部翻译出来。&lt;br /&gt;
&lt;br /&gt;
如果文件没有被翻译成新的语言，Dolibarr将使用英语。&lt;br /&gt;
&lt;br /&gt;
要在PHP代码中有一个本地化的（翻译的）字符串，你所要做的就是加载语言文件并使用该方法得到翻译值，如下所示：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$langs-&amp;gt;load(&amp;quot;myfile&amp;quot;); // or use $langs-&amp;gt;load(&amp;quot;myfile@mymodule&amp;quot;) if myfile.lang is inside directory htdocs/mymodule/langs/xx_XX   &lt;br /&gt;
&lt;br /&gt;
print $langs-&amp;gt;trans(&amp;quot;CodeX&amp;quot;)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
条目类型;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;ini&amp;quot;&amp;gt;&lt;br /&gt;
CodeX = phrase X&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
必须存在或添加到myfile.lang文件。&lt;br /&gt;
&lt;br /&gt;
== 使用autotranslator.php工具自动翻译 ==&lt;br /&gt;
&lt;br /&gt;
* Translator OS: All&lt;br /&gt;
* Tool: &#039;&#039;&#039;autotranslator.php&#039;&#039;&#039; provided with Dolibarr in directory &#039;&#039;&#039;dev/translation&#039;&#039;&#039;.&lt;br /&gt;
This method is recommended when starting translation for a language not already initialized. If there is already a translation available but you need to add missing key or correct errors, try to use method using Transifex (see later).&lt;br /&gt;
&lt;br /&gt;
To make or update all files of a language code, just run the script:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
php autotranslator.php lang_code_source lang_code_target GOOGLEAPIKEY&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
For example :&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
php autotranslator.php en_US pt_PT GOOGLEAPIKEY&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
to translate into Portuguese (pt_PT) using English (en_US) files.&lt;br /&gt;
&lt;br /&gt;
All non existing files will be created, all existing files will be updated.&lt;br /&gt;
The tool use [http://translate.google.com Google translation] service to find the translation value of a string, so a working Internet connection is required from station running the script. Also a GOOGLEAPIKEY is required and Google charges a fee for using this service (20 euros / 1 000 000 of translated chars).&lt;br /&gt;
Your PHP must also have permissions to write into &#039;&#039;&#039;htdocs/langs&#039;&#039;&#039; directory and must have curl functions available.&lt;br /&gt;
&lt;br /&gt;
= [[File:Language.png]] 将你的翻译分发到核心资源中 =&lt;br /&gt;
&lt;br /&gt;
Once you start translating, it&#039;s a smart decision to share it, so it can be included into the official code of Dolibarr.&lt;br /&gt;
If you keep it for you, others will not be able to improve it when new terms are added or previous terms are modified, and you will still have to manage the translation on your own.&lt;br /&gt;
&lt;br /&gt;
If you translated through the Transifex system, there&#039;s nothing to be done. Your translation will be included in the next version of Dolibarr. No additional work! In technical terms, the translation will be exported from Transifex and imported into Dolibarr by our developers, at least once every month.&lt;br /&gt;
&lt;br /&gt;
If, however, you translated directly in Dolibarr files, then you will first have to transfer those translations to Transifex before they can be included. So, really, you should start translating into Transifex.&lt;br /&gt;
If you send us your translation through a Pull Request on Github, sadly, it will be overwritten by the next import from Transifex, so it would be very short-lived.&lt;br /&gt;
&lt;br /&gt;
Note:&lt;br /&gt;
&lt;br /&gt;
The reference language is en_US and is always complete. You can find it in the htdocs/langs/en_US/ folder. All other language files are likely to be slightly or highly incomplete, depending on the language.&lt;br /&gt;
&lt;br /&gt;
If you are developing a new module, you are likely going to need the addition of new language variables. This is done exclusively through the update of the en_US language (htdocs/langs/en_US/ folder). Just modify these files to add the variable you need and send the resulting folder as part of your Pull Request. Refer to the developer documentation to learn how to contribute code (you will need an account on {{TemplateUrlSCM}}.&lt;br /&gt;
&lt;br /&gt;
= [[File:Language.png]] 翻译Wiki文档 =&lt;br /&gt;
维基是用3种语言写成的：英语、法语和西班牙语。&lt;br /&gt;
&lt;br /&gt;
如果你想增强这些语言中的一种语言，你所要做的就是在Wiki上创建一个帐户。&lt;br /&gt;
&lt;br /&gt;
然后，您可以编辑现有的页面来纠正错误的翻译或翻译等待翻译的页面。 [[:Category:Page_waiting_for_translation]].&lt;/div&gt;</summary>
		<author><name>Thecyyoung</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=User_talk:Thecyyoung&amp;diff=46986</id>
		<title>User talk:Thecyyoung</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=User_talk:Thecyyoung&amp;diff=46986"/>
		<updated>2020-05-03T12:11:32Z</updated>

		<summary type="html">&lt;p&gt;Thecyyoung: A confusing issue of accounts.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The account of Dolibarr Form doesn&#039;t connect to the account of Dolibarr Wiki.&lt;/div&gt;</summary>
		<author><name>Thecyyoung</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=User:Thecyyoung&amp;diff=46985</id>
		<title>User:Thecyyoung</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=User:Thecyyoung&amp;diff=46985"/>
		<updated>2020-05-03T12:08:27Z</updated>

		<summary type="html">&lt;p&gt;Thecyyoung: Describe myself.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I am The Cy Young from Taiwan.&lt;/div&gt;</summary>
		<author><name>Thecyyoung</name></author>
	</entry>
</feed>