Create numbering module: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 1: Line 1:
{{TemplateDocDevEn}}
{{Template开发文档}}
{{Template用户手册}}
{{TemplateMainPageZh}}


For each entity (invoice, proposal, order, etc.) created in the application, Dolibarr assigned a reference number (or text). To adapt the reference to any use, Dolibarr uses numbering modules to define the rule of generation of this reference. The supplied modules are a standard one and a generic on with a configurable mask (numbers on x character, with or without prefix, including the date or not, etc.), which can meet most needs. However, there are still cases where the standard module does not meet the need. In this case it is necessary to develop its own numbering module.
对于在应用程序中创建的每个实体(发票、提案、订单等),Dolibarr分配了一个参考号(或文本)。为了适应任何使用的参考,DoiBar使用编号模块来定义这个引用的生成规则。提供的模块是标准模块和带有可配置掩码(x字符上的数字,带有或不带有前缀,包括日期或不带日期等)的通用模块,可以满足大多数需求。然而,仍然存在标准模块不满足需要的情况。在这种情况下,有必要开发自己的编号模块。


= Create a new module numbering =
= 创建新的自动编号模块 =


For the example, we assume we will create a new numbering module of invoices, we will call it the 'terrebis' and will be a variant of the standard supplier module 'terre'.
例如,我们假设我们将创建一个新的发票编号模块,我们将其称为“terrebis”,并且将是标准供应商模块“terre”的变体。


* Copy and paste htdocs/core/modules/invoice/earth/terre.modules.php in htdocs/core/modules/invoice/terrebis/terrebis.modules.php. You can use the name you want in place of terrebis while he is not already in use and contains only alphabetic characters.
*复制和粘贴htdocs/core/modules/invoice/earth/terre.modules.php于htdocs/core/modules/invoice/terrebis/terrebis.modules.php。你可以用你想要的名字代替terrebis,而他还不可使用,只包含字母字符。
* edit the new file to make the following changes in the code:
*编辑新文件以在代码中进行以下更改:
1. Rename the class name to replace the old class name with the chosen name (keep the same naming conventions).
1. 重命名类名,用选定的名称替换旧类名(保持相同的命名约定)。


2. Modify the code for the info() method to return a text description of your module.
2. 修改info()方法的代码,返回模块的文本说明。


3.Change the method code of getExemple() to return the an example of value for ra eference that might be returned by the module.
3.更改getExemple()的方法代码,返回模块可能返回的引用值示例。


4.Change the method code of canBeActivated() to just do a "return true;"
4.将canBeActivated()的方法代码更改为只执行 "return true;";
 
5.修改方法getNextValue()的代码,以返回下一个可用的引用编号。在这个函数的代码中,可以使用参数 $objsoc或$facture,其中包含参与生成的第三方的信息以及参与生成的对象发票(这些变量的名称可能根据被管理实体模块的性质而不同)。也可以使用对象$langs, $conf和$db,如果您在函数中首先声明它们


5.Modify the code of the method getNextValue() to return the next available reference numbering. Within the code for this function, you can use parameters $objsoc or $facture containing the information of third parties involved in the generation and the object invoice involved in the generation (The name of these variables may differ depending on the nature of the managed entity module). You can also use the objects $langs, $conf and $db if you declare them first in the function with ligne
<source lang="php">
<source lang="php">
global $langs, $db, $conf
global $langs, $db, $conf
</source>
</source>
where
$conf contains all configuration of Dolibarr,
$langs is an object for translation into user language,
$db is a db connection object that allows SQL querying to database).


6. Save: the template 'terrebis' is available in the list of invoice templates into Dolibarr
此处
 
$conf 包含Dolibarr的所有配置,
 
$langs 是翻译成用户语言的对象,
$db 是允许SQL查询到数据库的DB连接对象。
 
6. 保存:模板'terrebis'可在Dolibarr的发票模板列表中获得。


= Test this module =
= 测试模块 =
Test this module by activating the module from configuration page. Verify that the column description, example and next value you get reflect what you should get (referred respectively by function info(), getExample() and getNextValue()).
通过从配置页激活模块来测试此模块。验证列描述,例如,下个值,你得到你应该得到的反映(分别称info(),getExample()和getNextValue()的功能)。
513

edits

Navigation menu