<?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=Cin+TAKE</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=Cin+TAKE"/>
	<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php/Special:Contributions/Cin_TAKE"/>
	<updated>2026-10-22T08:01:25Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.17</generator>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=JA_First_setup&amp;diff=58795</id>
		<title>JA First setup</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=JA_First_setup&amp;diff=58795"/>
		<updated>2023-11-21T07:01:32Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:初期設定}}&lt;br /&gt;
&lt;br /&gt;
{{TemplateDocUserJa}}&lt;br /&gt;
&lt;br /&gt;
初回インストール後、自分の要件に合わせて Dolibarr のパラメータ設定をすること.&lt;br /&gt;
&lt;br /&gt;
=法人/組織=&lt;br /&gt;
最初必須ステップは自分の 法人/組織 情報を定義すること. このため、ホームページから、メニュー選択  &amp;quot;&#039;&#039;&#039;ホーム-&amp;gt;設定-&amp;gt;法人/組織&#039;&#039;&#039;&amp;quot; して自分の法人/組織の情報を追加する.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;名:&#039;&#039;&#039; 自分の法人/組織の名前&lt;br /&gt;
*[[File:Logo size.jpg|thumb]]&#039;&#039;&#039;ロゴ:&#039;&#039;&#039; Add here a logo of your company (.png, .jpg or .gif). It can accept any size but it is recommended to use a logo with 130 pixels height and up to 800 pixels width. Here is a little scheme on what will be the result on the PDF. The recommended format is png.&lt;br /&gt;
*&#039;&#039;&#039;ロゴ (正方形):&#039;&#039;&#039; Add here your squared logo (.png or .jpg) that will be used in the top right corner of the application&lt;br /&gt;
*&#039;&#039;&#039;会計年度:&#039;&#039;&#039; 自分の会計開始月を定義&lt;br /&gt;
*&#039;&#039;&#039;国:&#039;&#039;&#039; Define your country: other options depend on this selection.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;職業分類ID X:&#039;&#039;&#039; The fields Prof ID are used to store the professional IDs of a company. Each country requires its own professional ID. For example, for a company in France you may find a SIRET, SIREN, NAF, RCS and EORI number, and for a company in Argentia, you will find CUIT/CUIL, Ingresos Brutos, CIF Intra. Dolibarr is able to manage 6 Professional ID. The label of each of them is defined with the translation key ProfIdXCC (where X is 1 to 6 and XX the country code of the company, for example XX=FR). To add a new Professional ID, you can add a new translation from menu Home - Setup - Translation for the key ProfIdXCC. If you set the value of translation to &amp;quot;-&amp;quot;, it means that the professional ID is hidden when using the application in the language of translation on every company that has the country code XX.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;消費税(VAT)管理:&#039;&#039;&#039; Define how you manage Sales Tax (or not).&lt;br /&gt;
*&#039;&#039;&#039;2種目の税金:&#039;&#039;&#039; Define if you would like to use second type of taxe (or not).&lt;br /&gt;
*&#039;&#039;&#039;3種目の税金:&#039;&#039;&#039; Define if you would like to use third type of taxe (or not).&lt;br /&gt;
&lt;br /&gt;
=モジュールs=&lt;br /&gt;
[[File:List of modules en.png|alt=List of modules|thumb|List of modules]]&lt;br /&gt;
The activation of modules is the second mandatory step. Which modules you will activate depends on what you want to do with Dolibarr. In most cases, you may want to use all modules. You have to activate each module one by one. For example, to manage a company, you might activate at least modules Third party, Invoices, and Products, but probably many more.&lt;br /&gt;
&lt;br /&gt;
To activate a module, go to page &amp;quot;&#039;&#039;&#039;Home-&amp;gt;Setup-&amp;gt;Modules&#039;&#039;&#039;&amp;quot; and click the button &#039;on/off&#039; in the &amp;quot;Status&amp;quot; column to enable it.&lt;br /&gt;
&lt;br /&gt;
*The module is &#039;&#039;&#039;on&#039;&#039;&#039; if the &#039;on/off&#039; button is like [[File:On off button on.png|alt=&#039;on/off&#039; button in on position|&#039;on/off&#039; button in on position]]&lt;br /&gt;
*The module is &#039;&#039;&#039;off&#039;&#039;&#039; if the &#039;on/off&#039; button is like [[File:On off button off.png|alt=&#039;on/off&#039; button in off position|&#039;on/off&#039; button in off position]]&lt;br /&gt;
&lt;br /&gt;
The list of standard modules is defined on page [[:Category:List of Modules|List of Modules]].&lt;br /&gt;
&lt;br /&gt;
If you are unsure of the function of a module, you may activate it and see what new menu item appears in Dolibarr (the horizontal bar), also after activating a module, check that you grant to yourself permissions on new features that were enabled. You can activate or deactivate a module when you want.&lt;br /&gt;
&lt;br /&gt;
Once a module has been activated, it may need further configuration (click on the setup icon that appears on the right of module line if a module needs its own setup). See [[:Category:List of Modules|documentation of module]] for more information.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Related videos:&lt;br /&gt;
&lt;br /&gt;
Modules:&lt;br /&gt;
(vocal in french but subtitles are available and review in this language)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;youtube width=&amp;quot;200&amp;quot; height=&amp;quot;120&amp;quot;&amp;gt;qfYP-iKWd7U&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Module settings:&lt;br /&gt;
(vocal in french but subtitles are available and review in this language)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;youtube width=&amp;quot;200&amp;quot; height=&amp;quot;120&amp;quot;&amp;gt;toT0jfmMCoU&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=表示=&lt;br /&gt;
[[File:Display settings EN.png|alt=Display settings|thumb|Display settings]]&lt;br /&gt;
On this page, you can set the default language of application and the look and feel of screens. In a first use, you can keep everything with default values.&lt;br /&gt;
&lt;br /&gt;
==言語==&lt;br /&gt;
In the language settings, you can set the Default Language. By default it is set to &amp;quot;Auto Detect&amp;quot;.&lt;br /&gt;
&#039;&#039;Note:&#039;&#039; Activating multilanguage option will allow you to be able to set the preferred language of customers, to print their Invoice/Proposal/Order in their own language. Product translations will also be available.&lt;br /&gt;
&lt;br /&gt;
==Default skin theme==&lt;br /&gt;
In Dolibarr you have two different skins : &lt;br /&gt;
&lt;br /&gt;
*eldy [[File:Eldy Theme thumb.png]]&lt;br /&gt;
*md [[File:Md theme thumb.png]]&lt;br /&gt;
&lt;br /&gt;
More skins can be downloaded on the dolistore [https://www.dolistore.com/4-skins]&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
You can also personalize the skin color, and look in this setup&lt;br /&gt;
&lt;br /&gt;
==Miscellaneous==&lt;br /&gt;
On this section, you have all the default values of features like, javascript functions, length of lists, first day of the week, etc.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
You can also put a &amp;quot;Message of day&amp;quot; that will be displayed for all the users. In this message, you can use the [[Variable substitution system]]&lt;br /&gt;
&lt;br /&gt;
==ログインページ==&lt;br /&gt;
On this section, you can customize the login page with a message and a background image. In this message, you can use the [[Variable substitution system]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
It is also possible to hide/show the &amp;quot;&#039;&#039;&#039;Need help or support&#039;&#039;&#039;&amp;quot; link on login page&lt;br /&gt;
&lt;br /&gt;
=メニューs=&lt;br /&gt;
[[File:Menu Setup.png|alt=Menu Setup|thumb|Menu Setup]]&lt;br /&gt;
Choose here which menu manager you want to use for internal and external users and for computer or smartphone. The menu manager changes the labels, orders and organization of the left and top menus.&lt;br /&gt;
See page [[Menus system]] for more information.&lt;br /&gt;
&lt;br /&gt;
==Menu handlers==&lt;br /&gt;
The software comes with two different menu handler :&lt;br /&gt;
&lt;br /&gt;
*Eldy : It is the default menu, the menu entries are centralized and hard coded. You can add entries on this menu but not change the default menu entries.&lt;br /&gt;
*Auguria : It is a database  menu manager. This menu can be fully customized to your needs.&lt;br /&gt;
&lt;br /&gt;
In the Menu handlers tab, you can choose the menu for internal and external users and for computer or smartphone.&lt;br /&gt;
&lt;br /&gt;
==Menu Editor==&lt;br /&gt;
In this tab, you can customize each menu entry of &#039;&#039;&#039;auguria&#039;&#039;&#039; menu or the additional entries of &#039;&#039;&#039;eldy &#039;&#039;&#039;menu and create new entries&lt;br /&gt;
&lt;br /&gt;
==Miscellaneous==&lt;br /&gt;
In this tab, you can choose the behavior of the unauthorized menu entry. By default, the unauthorized menu entry are in gray, but can be hidden.&lt;br /&gt;
&lt;br /&gt;
=その他 (Widgets, Alerts, Security, Limits and accuracy, Emails, SMS, Dictionary setup...)=&lt;br /&gt;
Other entries in Setup menu are advanced options. You can ignore them if you want.&lt;br /&gt;
&lt;br /&gt;
*[[Setup Translation]]&lt;br /&gt;
*[[Setup Default values/filters/sorting]]&lt;br /&gt;
*[[Setup Widgets]]&lt;br /&gt;
*[[Setup Alerts]]&lt;br /&gt;
*[[Setup Security]]&lt;br /&gt;
*[[Setup Limits and accuracy]]&lt;br /&gt;
*[[Setup PDF]]&lt;br /&gt;
*[[Setup EMails]]&lt;br /&gt;
*[[Setup SMS]]&lt;br /&gt;
*[[Setup Dictionnary|Setup Dictionary]]&lt;br /&gt;
*[[Setup Other]]&lt;br /&gt;
&lt;br /&gt;
=利用者s=&lt;br /&gt;
The last step is to create users and assign permissions. Almost all the modules even activated earlier, are not accessible if you do not give permissions. To do this, you can go to the menu &#039;&#039;&#039;Home -&amp;gt; Users &amp;amp; Groups&#039;&#039;&#039; to define users and their rights. Attention, you should consider to check and reset the user rights when you enable a new module. The list of rights available depends on the activated modules (see above). It is recommended to configure permissions after activating the modules you want to use. For certain actions, if you do not have the rights to do an action, Dolibarr will not show you the action. You might miss some useful or important features. &#039;&#039;&#039;To give rights to a user or yourself, if you are an administrator, go to Home -&amp;gt; Users &amp;amp; Groups, select the desired user, then click on its &#039;Permission&#039; tab.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You can avoid these configuration steps for each newly created user, by configuring the default rights (understand rights allocated automatically each time a new user created) by configuring the default permissions on the menu [[Setup Security]].&lt;br /&gt;
&lt;br /&gt;
=関連ビデオs=&lt;br /&gt;
Basic setup : &lt;br /&gt;
(vocal in french but subtitles are available and review in this language)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;youtube width=&amp;quot;200&amp;quot; height=&amp;quot;120&amp;quot;&amp;gt;S5Rm9ixHNRA&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configuration options : &lt;br /&gt;
(vocal in french but subtitles are available and review in this language)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;youtube width=&amp;quot;200&amp;quot; height=&amp;quot;120&amp;quot;&amp;gt;o5VOYomd_Ns&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Visual setup : Darkmode :&lt;br /&gt;
(vocal in french but subtitles are available and review in this language)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;youtube width=&amp;quot;200&amp;quot; height=&amp;quot;120&amp;quot;&amp;gt;cdhWVmTg54U&amp;lt;/youtube&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=First_setup&amp;diff=58793</id>
		<title>First setup</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=First_setup&amp;diff=58793"/>
		<updated>2023-11-21T07:00:42Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: &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 : Configuração_inicial --&amp;gt;&lt;br /&gt;
[[fr:Premiers_paramétrages]]&lt;br /&gt;
[[de:Grundeinstellungen]]&lt;br /&gt;
[[es:Primeras_configuraciones]]&lt;br /&gt;
[[zh:设置]]&lt;br /&gt;
[[ja:JA_First_setup]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Admin_en]]&lt;br /&gt;
{{TemplateDocUser}}&lt;br /&gt;
&lt;br /&gt;
After completing the initial installation, you must configure parameters in Dolibarr to match your needs.&lt;br /&gt;
&lt;br /&gt;
=Company/Organization=&lt;br /&gt;
The first mandatory step is to define your company/organization information. For this, from home page, choose menu  &amp;quot;&#039;&#039;&#039;Home-&amp;gt;Setup-&amp;gt;Company/Organization&#039;&#039;&#039;&amp;quot; and add the information for your company/organization.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Name:&#039;&#039;&#039; Name of your company/organization&lt;br /&gt;
*[[File:Logo size.jpg|thumb]]&#039;&#039;&#039;Logo:&#039;&#039;&#039; Add here a logo of your company (.png, .jpg or .gif). It can accept any size but it is recommended to use a logo with 130 pixels height and up to 800 pixels width. Here is a little scheme on what will be the result on the PDF. The recommended format is png.&lt;br /&gt;
*&#039;&#039;&#039;Logo (squared):&#039;&#039;&#039; Add here your squared logo (.png or .jpg) that will be used in the top right corner of the application&lt;br /&gt;
*&#039;&#039;&#039;Fiscal Year:&#039;&#039;&#039; Define your starting month of yiscal Year&lt;br /&gt;
*&#039;&#039;&#039;Country:&#039;&#039;&#039; Define your country: other options depend on this selection.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Prof ID X:&#039;&#039;&#039; The fields Prof ID are used to store the professional IDs of a company. Each country requires its own professional ID. For example, for a company in France you may find a SIRET, SIREN, NAF, RCS and EORI number, and for a company in Argentia, you will find CUIT/CUIL, Ingresos Brutos, CIF Intra. Dolibarr is able to manage 6 Professional ID. The label of each of them is defined with the translation key ProfIdXCC (where X is 1 to 6 and XX the country code of the company, for example XX=FR). To add a new Professional ID, you can add a new translation from menu Home - Setup - Translation for the key ProfIdXCC. If you set the value of translation to &amp;quot;-&amp;quot;, it means that the professional ID is hidden when using the application in the language of translation on every company that has the country code XX.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;Sales Tax (VAT) Management:&#039;&#039;&#039; Define how you manage Sales Tax (or not).&lt;br /&gt;
*&#039;&#039;&#039;Second type of tax:&#039;&#039;&#039; Define if you would like to use second type of taxe (or not).&lt;br /&gt;
*&#039;&#039;&#039;Third type of tax:&#039;&#039;&#039; Define if you would like to use third type of taxe (or not).&lt;br /&gt;
&lt;br /&gt;
=Modules=&lt;br /&gt;
[[File:List of modules en.png|alt=List of modules|thumb|List of modules]]&lt;br /&gt;
The activation of modules is the second mandatory step. Which modules you will activate depends on what you want to do with Dolibarr. In most cases, you may want to use all modules. You have to activate each module one by one. For example, to manage a company, you might activate at least modules Third party, Invoices, and Products, but probably many more.&lt;br /&gt;
&lt;br /&gt;
To activate a module, go to page &amp;quot;&#039;&#039;&#039;Home-&amp;gt;Setup-&amp;gt;Modules&#039;&#039;&#039;&amp;quot; and click the button &#039;on/off&#039; in the &amp;quot;Status&amp;quot; column to enable it.&lt;br /&gt;
*The module is &#039;&#039;&#039;on&#039;&#039;&#039; if the &#039;on/off&#039; button is like [[File:On off button on.png|alt=&#039;on/off&#039; button in on position|&#039;on/off&#039; button in on position]]&lt;br /&gt;
*The module is &#039;&#039;&#039;off&#039;&#039;&#039; if the &#039;on/off&#039; button is like [[File:On off button off.png|alt=&#039;on/off&#039; button in off position|&#039;on/off&#039; button in off position]]&lt;br /&gt;
&lt;br /&gt;
The list of standard modules is defined on page [[:Category:List of Modules|List of Modules]].&lt;br /&gt;
&lt;br /&gt;
If you are unsure of the function of a module, you may activate it and see what new menu item appears in Dolibarr (the horizontal bar), also after activating a module, check that you grant to yourself permissions on new features that were enabled. You can activate or deactivate a module when you want.&lt;br /&gt;
&lt;br /&gt;
Once a module has been activated, it may need further configuration (click on the setup icon that appears on the right of module line if a module needs its own setup). See [[:Category:List of Modules|documentation of module]] for more information.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Related videos:&lt;br /&gt;
&lt;br /&gt;
Modules:&lt;br /&gt;
(vocal in french but subtitles are available and review in this language)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;youtube width=&amp;quot;200&amp;quot; height=&amp;quot;120&amp;quot;&amp;gt;qfYP-iKWd7U&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Module settings:&lt;br /&gt;
(vocal in french but subtitles are available and review in this language)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;youtube width=&amp;quot;200&amp;quot; height=&amp;quot;120&amp;quot;&amp;gt;toT0jfmMCoU&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Display=&lt;br /&gt;
[[File:Display settings EN.png|alt=Display settings|thumb|Display settings]]&lt;br /&gt;
On this page, you can set the default language of application and the look and feel of screens. In a first use, you can keep everything with default values.&lt;br /&gt;
&lt;br /&gt;
==Language==&lt;br /&gt;
In the language settings, you can set the Default Language. By default it is set to &amp;quot;Auto Detect&amp;quot;.&lt;br /&gt;
&#039;&#039;Note:&#039;&#039; Activating multilanguage option will allow you to be able to set the preferred language of customers, to print their Invoice/Proposal/Order in their own language. Product translations will also be available.&lt;br /&gt;
&lt;br /&gt;
==Default skin theme==&lt;br /&gt;
In Dolibarr you have two different skins : &lt;br /&gt;
* eldy [[File:Eldy Theme thumb.png]]&lt;br /&gt;
* md [[File:Md theme thumb.png]]&lt;br /&gt;
More skins can be downloaded on the dolistore [https://www.dolistore.com/4-skins]&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
You can also personalize the skin color, and look in this setup&lt;br /&gt;
&lt;br /&gt;
==Miscellaneous==&lt;br /&gt;
On this section, you have all the default values of features like, javascript functions, length of lists, first day of the week, etc.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
You can also put a &amp;quot;Message of day&amp;quot; that will be displayed for all the users. In this message, you can use the [[Variable substitution system]]&lt;br /&gt;
&lt;br /&gt;
==Login page==&lt;br /&gt;
On this section, you can customize the login page with a message and a background image. In this message, you can use the [[Variable substitution system]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
It is also possible to hide/show the &amp;quot;&#039;&#039;&#039;Need help or support&#039;&#039;&#039;&amp;quot; link on login page&lt;br /&gt;
&lt;br /&gt;
=Menus=&lt;br /&gt;
[[File:Menu Setup.png|alt=Menu Setup|thumb|Menu Setup]]&lt;br /&gt;
Choose here which menu manager you want to use for internal and external users and for computer or smartphone. The menu manager changes the labels, orders and organization of the left and top menus.&lt;br /&gt;
See page [[Menus system]] for more information.&lt;br /&gt;
&lt;br /&gt;
==Menu handlers==&lt;br /&gt;
The software comes with two different menu handler :&lt;br /&gt;
* Eldy : It is the default menu, the menu entries are centralized and hard coded. You can add entries on this menu but not change the default menu entries.&lt;br /&gt;
* Auguria : It is a database  menu manager. This menu can be fully customized to your needs.&lt;br /&gt;
In the Menu handlers tab, you can choose the menu for internal and external users and for computer or smartphone.&lt;br /&gt;
&lt;br /&gt;
==Menu Editor==&lt;br /&gt;
In this tab, you can customize each menu entry of &#039;&#039;&#039;auguria&#039;&#039;&#039; menu or the additional entries of &#039;&#039;&#039;eldy &#039;&#039;&#039;menu and create new entries&lt;br /&gt;
&lt;br /&gt;
==Miscellaneous==&lt;br /&gt;
In this tab, you can choose the behavior of the unauthorized menu entry. By default, the unauthorized menu entry are in gray, but can be hidden.&lt;br /&gt;
&lt;br /&gt;
=Other (Widgets, Alerts, Security, Limits and accuracy, Emails, SMS, Dictionary setup...)=&lt;br /&gt;
Other entries in Setup menu are advanced options. You can ignore them if you want.&lt;br /&gt;
&lt;br /&gt;
*[[Setup Translation]]&lt;br /&gt;
*[[Setup Default values/filters/sorting]]&lt;br /&gt;
*[[Setup Widgets]]&lt;br /&gt;
*[[Setup Alerts]]&lt;br /&gt;
*[[Setup Security]]&lt;br /&gt;
*[[Setup Limits and accuracy]]&lt;br /&gt;
*[[Setup PDF]]&lt;br /&gt;
*[[Setup EMails]]&lt;br /&gt;
*[[Setup SMS]]&lt;br /&gt;
*[[Setup Dictionnary|Setup Dictionary]]&lt;br /&gt;
*[[Setup Other]]&lt;br /&gt;
&lt;br /&gt;
=Users=&lt;br /&gt;
The last step is to create users and assign permissions. Almost all the modules even activated earlier, are not accessible if you do not give permissions. To do this, you can go to the menu &#039;&#039;&#039;Home -&amp;gt; Users &amp;amp; Groups&#039;&#039;&#039; to define users and their rights. Attention, you should consider to check and reset the user rights when you enable a new module. The list of rights available depends on the activated modules (see above). It is recommended to configure permissions after activating the modules you want to use. For certain actions, if you do not have the rights to do an action, Dolibarr will not show you the action. You might miss some useful or important features. &#039;&#039;&#039;To give rights to a user or yourself, if you are an administrator, go to Home -&amp;gt; Users &amp;amp; Groups, select the desired user, then click on its &#039;Permission&#039; tab.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You can avoid these configuration steps for each newly created user, by configuring the default rights (understand rights allocated automatically each time a new user created) by configuring the default permissions on the menu [[Setup Security]].&lt;br /&gt;
&lt;br /&gt;
=Related videos=&lt;br /&gt;
Basic setup : &lt;br /&gt;
(vocal in french but subtitles are available and review in this language)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;youtube width=&amp;quot;200&amp;quot; height=&amp;quot;120&amp;quot;&amp;gt;S5Rm9ixHNRA&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configuration options : &lt;br /&gt;
(vocal in french but subtitles are available and review in this language)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;youtube width=&amp;quot;200&amp;quot; height=&amp;quot;120&amp;quot;&amp;gt;o5VOYomd_Ns&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Visual setup : Darkmode :&lt;br /&gt;
(vocal in french but subtitles are available and review in this language)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;youtube width=&amp;quot;200&amp;quot; height=&amp;quot;120&amp;quot;&amp;gt;cdhWVmTg54U&amp;lt;/youtube&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=%E3%83%9B%E3%83%BC%E3%83%A0%E3%83%9A%E3%83%BC%E3%82%B8&amp;diff=58790</id>
		<title>ホームページ</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=%E3%83%9B%E3%83%BC%E3%83%A0%E3%83%9A%E3%83%BC%E3%82%B8&amp;diff=58790"/>
		<updated>2023-11-21T06:49:23Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: &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 : Home --&amp;gt;&lt;br /&gt;
[[en:Home]]&lt;br /&gt;
[[fr:Accueil]]&lt;br /&gt;
[[es:Portada]]&lt;br /&gt;
[[de:Hauptseite]]&lt;br /&gt;
[[el:Αρχική]]&lt;br /&gt;
[[pt:Página Principal]]&lt;br /&gt;
[[zh:简体中文官方文档]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
{{DISPLAYTITLE:Easy to use Open-Source software for business}}&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[File:Dolibarr logo.png|180px|link=]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be free to manage your company, freelancer or foundation activity&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
このWikiには、Dolibarr ERP/CRMに関するすべての文章（ユーザー向け、開発者向け、翻訳者向けの文章）とリソースが含まれる。ダウンロードは、Dolibarrプロジェクトのウェブポータル（https://www.dolibarr.org）から可能。&lt;br /&gt;
&lt;br /&gt;
{{Info}}{{InfoJa}}&lt;br /&gt;
&lt;br /&gt;
=[[File:art.png|link=]] Dolibarrプロジェクト=&lt;br /&gt;
&lt;br /&gt;
*[[JA_What_Dolibarr_Does|Dolibarrとは？]] - [[JA_FAQ_Who_uses_Dolibarr|Dolibarrのユーザは誰?]]&lt;br /&gt;
*[[Dolibarr Project|資料、経緯、プロジェクト組織]]&lt;br /&gt;
*[[Dolibarr foundation|Dolibarr 基金]]&lt;br /&gt;
*[https://www.dolibarr.org/onlinedemo オンラインデモ]&lt;br /&gt;
*[https://www.dolibarr.org/downloads/ ダウンロード]&lt;br /&gt;
&lt;br /&gt;
=[[File:File_Doc_user.png|link=]] 利用者文書=&lt;br /&gt;
&lt;br /&gt;
*[[User_documentation_JA|利用者手引き]] と [[User FAQ|利用者FAQ]]&lt;br /&gt;
*[https://www.youtube.com/playlist?list=PL317BA167DF5A1D3E ビデオ学習(英語)]&lt;br /&gt;
*[[Dolibarr help and support|ヘルプとサポートセンター]] (コミュニティフォーラム、有償サポート等)&lt;br /&gt;
*[[Screenshots|スクリーンショット]]&lt;br /&gt;
*[[Security informations|セキュリティ情報]]&lt;br /&gt;
&lt;br /&gt;
=[[File:File_Doc_dev.png|link=]] 開発者文書=&lt;br /&gt;
&lt;br /&gt;
*[[JA Developer documentation|開発者手引き]]&lt;br /&gt;
*[[JA Developer FAQ|開発者FAQ]]&lt;br /&gt;
*[[JA Dolibarr Project|資料、プロジェクト組織]]&lt;br /&gt;
&lt;br /&gt;
=[[File:File_Doc_trans.png|link=]] 翻訳者文書=&lt;br /&gt;
&lt;br /&gt;
*[[Translator documentation|翻訳者手引き]]&lt;br /&gt;
&lt;br /&gt;
=[[File:File_Doc_tester.png|link=]] テスター文書=&lt;br /&gt;
&lt;br /&gt;
*[[JA Tester documentation|テスター手引き]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
__NOEDITSECTION__&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=User_documentation_JA&amp;diff=58789</id>
		<title>User documentation JA</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=User_documentation_JA&amp;diff=58789"/>
		<updated>2023-11-21T06:38:47Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=利用者手引き=&lt;br /&gt;
&lt;br /&gt;
このページは利用者手引きに関連する主たる索引である。 文書類の開発者は、[[JA Developer documentation|ここを参照]].&lt;br /&gt;
&lt;br /&gt;
=特徴の速攻概説=&lt;br /&gt;
&lt;br /&gt;
*[[What Dolibarr Do|Dolibarrとは何か, Dolibarrにできることは]]&lt;br /&gt;
*[[What Dolibarr can&#039;t do|Dolibarrと違うものは, Dolibarrにできないことは]]&lt;br /&gt;
&lt;br /&gt;
=インストール | アップグレード | 設定=&lt;br /&gt;
&lt;br /&gt;
*[[Prerequisite|前提条件]]&lt;br /&gt;
*[[Installation - Upgrade|インストール - アップグレード]]&lt;br /&gt;
*[[First setup|設定]]&lt;br /&gt;
&lt;br /&gt;
Dolibarrの使用法は以下の章で提供する&lt;br /&gt;
&lt;br /&gt;
=管理運営=&lt;br /&gt;
&lt;br /&gt;
*マイグレーション: [[Mass_imports|Mass imports]] / [[ExportsEn|Exports]]&lt;br /&gt;
*[[Backups]] / [[Restores]]&lt;br /&gt;
*[[About_pages|About pages]]&lt;br /&gt;
*[[Upgrade]]&lt;br /&gt;
*[[Purge]]&lt;br /&gt;
*[[Audit]]&lt;br /&gt;
*[[Users_Sessions|Users Sessions]]&lt;br /&gt;
*[[Global_VAT_Update|Global VAT Update]]&lt;br /&gt;
*[[Module_Scheduled_jobs|Scheduled Jobs]]&lt;br /&gt;
*[[Direct_Printing_jobs|Direct Printing jobs]]&lt;br /&gt;
*[[Mass_barcode_init|Mass barcode init]]&lt;br /&gt;
&lt;br /&gt;
関連ビデオs:&lt;br /&gt;
(フランス語音声、字幕が利用可能)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;youtube width=&amp;quot;200&amp;quot; height=&amp;quot;120&amp;quot;&amp;gt;lTriUeIdiNs&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=ダッシュボード=&lt;br /&gt;
&lt;br /&gt;
Related videos:&lt;br /&gt;
(vocal in french but subtitles are available and review in this language)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;youtube width=&amp;quot;200&amp;quot; height=&amp;quot;120&amp;quot;&amp;gt;VieSairH_ZQ&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=使用法 (於 モジュールs / アプリs)=&lt;br /&gt;
&lt;br /&gt;
Dolibarr の利用法を知ることはそのモジュールの利用法と特徴を知ること. &lt;br /&gt;
最初に, インストールステップが完了したら (前章参照), 利用法に関する一般的情報を見てみよう:&lt;br /&gt;
&lt;br /&gt;
*[[General information on usage]] (First steps).&lt;br /&gt;
&lt;br /&gt;
一般的利用法を理解したら, 標準的ビジネスモジュールに関する文章を見るとよい. 興味のあるモジュールを選択し、その文章を見よう. 標準的モジュールは、すべてのインストールにおいてデフォルトで利用可能なものである. これが主要モジュールのリスト (ページ [[:Category:List of Modules|List of Modules]] でも見れる) :&lt;br /&gt;
&lt;br /&gt;
==人事管理 (HR)==&lt;br /&gt;
{| style=&amp;quot;margin-left: 20px; margin-right: auto;&amp;quot;&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-users&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Users|Users &amp;amp; Groups]]&#039;&#039;&#039; : Users / Employees and Groups management&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-user-alt&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Membership management|Members]]&#039;&#039;&#039; : Foundation members management&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-umbrella-beach&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Leaves|Leave Request Management]]&#039;&#039;&#039; : Define and track employee leave requests&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-wallet&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Expense Reports|Expense Reports]]&#039;&#039;&#039; : Manage expense reports claims (transportation, meal, ...)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-id-card-alt&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Recruitment &#039;&#039;&#039; : Manage and follow recruitment campaigns for new job positions&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-user-tie&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module HRM|HRM]]&#039;&#039;&#039; : Human resources management (management of department, employee contracts and feelings)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Customer Relationship Management (CRM)==&lt;br /&gt;
{| style=&amp;quot;margin-left: 20px; margin-right: auto;&amp;quot;&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-building&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Third Parties|Third Parties]]&#039;&#039;&#039; : Companies and contacts management (customers, prospects...)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-file-signature&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Commercial Proposals - Quotes|Proposals]]&#039;&#039;&#039; : Commercial proposal management&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-file-invoice&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Sales Orders|Sales Orders]]&#039;&#039;&#039; : Sales order management&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-dolly&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Shipments|Shipments]]&#039;&#039;&#039; : Shipments and delivery note management&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-suitcase&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Contracts|Contracts/Subscriptions]]&#039;&#039;&#039; : Management of contracts (services or recurring subscriptions)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-ambulance&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Interventions En|Interventions]]&#039;&#039;&#039; : Intervention management&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-ticket-alt&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Ticket|Tickets]]&#039;&#039;&#039; : Ticket system for issue or request management&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-ticket-alt rotate90&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Knowledge Management|Knowledge Management System]]&#039;&#039;&#039; : Manage a Knowledge Management (KM) or Help-Desk base&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-handshake&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Partnership Management&#039;&#039;&#039; : Module Partnership management&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Vendor Relationship Management (VRM)==&lt;br /&gt;
{| style=&amp;quot;margin-left: 20px; margin-right: auto;&amp;quot;&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-building&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Suppliers Orders|Vendors]]&#039;&#039;&#039; : Vendors and purchase management (purchase orders and billing of supplier invoices)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-file-signature&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Vendor Commercial Proposals&#039;&#039;&#039; : Request vendor commercial proposal and prices&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-dolly&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Reception&#039;&#039;&#039; : Vendor reception management (Create reception documents)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-truck-loading&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Incoterms&#039;&#039;&#039; : Add features to manage Incoterms&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Financial Modules (Accounting/Treasury)==&lt;br /&gt;
{| style=&amp;quot;margin-left: 20px; margin-right: auto;&amp;quot;&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-file-invoice-dollar&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Invoice|Invoices]]&#039;&#039;&#039; : Management of invoices and credit notes for customers. Management of invoices and credit notes for suppliers&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-file-invoice-dollar&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Taxes and social contributions|Taxes &amp;amp; Special Expenses]]&#039;&#039;&#039; : Management of other expenses (sales taxes, social or fiscal taxes, dividends, ...)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-money-check-alt&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Salaries&#039;&#039;&#039; : Record and track employee payments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-money-bill-alt&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Loans&#039;&#039;&#039; : Management of loans&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-file-alt&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Donations|Donations]]&#039;&#039;&#039; : Donation management&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-university&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Banks and Cash|Banks &amp;amp; Cash]]&#039;&#039;&#039; : Management of bank or cash accounts&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-money-check-alt&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Payment By Credit Transfer&#039;&#039;&#039; : Management of payment of suppliers by Credit Transfer orders. It includes generation of SEPA file for European countries.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-money-check-alt&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Standing Orders|Payment By Direct Debit]]&#039;&#039;&#039; : Management of Direct Debit orders. It includes generation of SEPA file for European countries.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-calculator&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Margins|Margins]]&#039;&#039;&#039; : Module to follow margins&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-search-dollar&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Accounting Simplified|Accounting (simplified)]]&#039;&#039;&#039; : Simple accounting reports (journals, turnover) based on database content. Does not use any ledger table.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-search-dollar&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Double Entry Accounting|Accounting (double entry)]]&#039;&#039;&#039; : Accounting management (double entries, support General and Subsidiary Ledgers). Export the ledger in several other accounting software formats.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-globe-europe&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Intracomm report&#039;&#039;&#039; : Intracomm report management (Support for French DEB/DES format) (&amp;lt;span class=&amp;quot;fas fa-question-circle&amp;quot; style=&amp;quot;color:orange;&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color:orange;&amp;quot;&amp;gt;Experimental&amp;lt;/span&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-money-check-alt&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Asset&#039;&#039;&#039; : Asset module (&amp;lt;span class=&amp;quot;fas fa-exclamation-triangle&amp;quot; style=&amp;quot;color:red;&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;In Development&amp;lt;/span&amp;gt;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Product Management (PM)==&lt;br /&gt;
{| style=&amp;quot;margin-left: 20px; margin-right: auto;&amp;quot;&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-cube&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Products|Products]]&#039;&#039;&#039; : Management of Products&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-concierge-bell&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Services En|Services]]&#039;&#039;&#039; : Management of Services&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-box-open&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Stocks En|Stocks]]&#039;&#039;&#039; : Stock management&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-barcode&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Lot / Serial|Product Lots]]&#039;&#039;&#039; : Lots, serial numbers, eat-by/sell-by date management for products&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-cube&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Product Variants&#039;&#039;&#039; : Creation of product variants (color, size etc.)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-shapes&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module BOM|Bills of Material]]&#039;&#039;&#039; : Module to define your Bills Of Materials (BOM). Can be used for Manufacturing Resource Planning by the module Manufacturing Orders (MO)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-cubes&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Manufacturing Orders|Manufacturing Orders]]&#039;&#039;&#039; : Module to Manage Manufacturing Orders (MO)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-hand-holding-usd&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Dynamic Prices|Dynamic Prices]]&#039;&#039;&#039; : Use maths expressions for auto-generation of prices (&amp;lt;span class=&amp;quot;fas fa-question-circle&amp;quot; style=&amp;quot;color:orange;&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color:orange;&amp;quot;&amp;gt;Experimental&amp;lt;/span&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-pallet&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Workstation|Workstation]]&#039;&#039;&#039; : Workstations management (&amp;lt;span class=&amp;quot;fas fa-exclamation-triangle&amp;quot; style=&amp;quot;color:red;&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;In Development&amp;lt;/span&amp;gt;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Projects/Collaborative work==&lt;br /&gt;
{| style=&amp;quot;margin-left: 20px; margin-right: auto;&amp;quot;&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-project-diagram&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Projects|Projects or Leads]]&#039;&#039;&#039; : Management of projects, leads/opportunities and/or tasks. You can also assign any element (invoice, order, proposal, intervention, ...) to a project and get a transversal view from the project view.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-calendar-alt&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Agenda En|Events/Agenda]]&#039;&#039;&#039; : Track events. Log automatic events for tracking purposes or record manual events or meetings. This is the principal module for good Customer or Vendor Relationship Management.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-laptop-house&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Resources|Resources]]&#039;&#039;&#039; : Manage resources (printers, cars, rooms, ...) for allocating to events&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-calendar-alt&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Event Organization|Event Organization]]&#039;&#039;&#039; : Event Organization through Module Project&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Electronic Content Management (ECM)==&lt;br /&gt;
{| style=&amp;quot;margin-left: 20px; margin-right: auto;&amp;quot;&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-folder-open&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;DMS / ECM&#039;&#039;&#039; : Document Management System / Electronic Content Management. Automatic organization of your generated or stored documents. Share them when you need.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Multi-modules tools==&lt;br /&gt;
{| style=&amp;quot;margin-left: 20px; margin-right: auto;&amp;quot;&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-tag&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Categories|Tags / Categories]]&#039;&#039;&#039; : Create tags/category (products, customers, suppliers, contacts or members)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-paragraph&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;WYSIWYG Editor&#039;&#039;&#039; : Allow text fields to be edited/formatted using CKEditor (html)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-dollar-sign&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Multicurrency&#039;&#039;&#039; : Use alternative currencies in prices and documents&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-rss&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;RSS Feed&#039;&#039;&#039; : Add a RSS feed to Dolibarr pages&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-star&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Bookmarks|Bookmarks &amp;amp; Shortcuts]]&#039;&#039;&#039; : Create shortcuts, always accessible, to the internal or external pages to which you frequently access&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-barcode&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Barcode|Barcodes]]&#039;&#039;&#039; : Barcode or QR code management&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-cogs&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Workflow En|Inter-modules Workflow]]&#039;&#039;&#039; : Workflow management between different modules (automatic creation of object and/or automatic status change)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-cogs&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Imports En|Data imports]]&#039;&#039;&#039; : Tool to import data into Dolibarr (with assistance)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-cogs&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Exports En|Data exports]]&#039;&#039;&#039; : Tool to export Dolibarr data (with assistance)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-file&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Stickers&#039;&#039;&#039; : Management of stickers (&amp;lt;span class=&amp;quot;fas fa-exclamation-triangle&amp;quot; style=&amp;quot;color:red;&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;In Development&amp;lt;/span&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-at&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Document Generation&#039;&#039;&#039;: Mass email document generation (&amp;lt;span class=&amp;quot;fas fa-exclamation-triangle&amp;quot; style=&amp;quot;color:red;&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;In Development&amp;lt;/span&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-file&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Data Privacy Policy&#039;&#039;&#039; : Module to manage Data Privacy (Conformity with the GDPR) (&amp;lt;span class=&amp;quot;fas fa-question-circle&amp;quot; style=&amp;quot;color:orange;&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color:orange;&amp;quot;&amp;gt;Experimental&amp;lt;/span&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-bug&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module ModuleBuilder|Module and Application Builder]]&#039;&#039;&#039; : A RAD (Rapid Application Development) tool to help developers to build their own module.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Websites and other frontal application==&lt;br /&gt;
{| style=&amp;quot;margin-left: 20px; margin-right: auto;&amp;quot;&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-check-double&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Poll, Survey or Vote&#039;&#039;&#039; : Create online polls, surveys or votes (like Doodle, Studs, RDVz etc...)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-globe-americas&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Website|Websites]]&#039;&#039;&#039; : Create websites (public) with a WYSIWYG editor. This is a webmaster or developer oriented CMS (it is better to know HTML and CSS language). Just setup your web server (Apache, Nginx, ...) to point to the dedicated Dolibarr directory to have it online on the internet with your own domain name.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-people-arrows&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Collab&#039;&#039;&#039; : Enable the public collaboration features, like shared pad, shared online sheets, etc... (&amp;lt;span class=&amp;quot;fas fa-exclamation-triangle&amp;quot; style=&amp;quot;color:red;&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;In Development&amp;lt;/span&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-cash-register&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Point of sale (TakePOS)|POS TakePOS]]&#039;&#039;&#039; : Point of Sale module TakePOS (touchscreen POS, for shops, bars or restaurants).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Interfaces with external systems==&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;margin-left: 20px; margin-right: auto;&amp;quot;&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-share-alt&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Social Networks&#039;&#039;&#039; : Enable Social Networks fields into third parties and addresses (skype, twitter, facebook, ...).&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-at&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Notification|Notifications on business event]]&#039;&#039;&#039; : Send email notifications triggered by a business event: per user (setup defined on each user), per third-party contacts (setup defined on each third party) or by specific emails&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-at&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module EMailing|Mass Emailings]]&#039;&#039;&#039; : Manage bulk emailing&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-at&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module EMail Collector|Email collector]]&#039;&#039;&#039; : Add a scheduled job and a setup page to scan regularly email boxes (using IMAP protocol) and record emails received into your application, at the right place and/or create some records automatically (like leads).&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-cogs&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Web Services API REST (developer)|API/Web services (REST server)]]&#039;&#039;&#039; : Enable the Dolibarr REST server providing API services&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-cogs&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Web Services API SOAP|API/Web services (SOAP server)]]&#039;&#039;&#039; : Enable the Dolibarr SOAP server providing API services&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-cogs&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Call WebServices (SOAP client)&#039;&#039;&#039; : Enable the Dolibarr web services client (Can be used to push data/requests to external servers. Only Purchase orders are currently supported.) (&amp;lt;span class=&amp;quot;fas fa-question-circle&amp;quot; style=&amp;quot;color:orange;&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color:orange;&amp;quot;&amp;gt;Experimental&amp;lt;/span&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas&amp;quot;&amp;gt;[[File:Object zapier.png]]&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Zapier|Zapier]]&#039;&#039;&#039; : Interface with Zapier (&amp;lt;span class=&amp;quot;fas fa-exclamation-triangle&amp;quot; style=&amp;quot;color:red;&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;In Development&amp;lt;/span&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-cogs&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module LDAP En|LDAP]]&#039;&#039;&#039; : LDAP directory synchronization&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-cogs&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module OAuth|OAuth]]&#039;&#039;&#039; : Enable OAuth authentication&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-globe-americas&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;External Site&#039;&#039;&#039; : Add a link to an external website as a main menu icon. Website is shown in a frame under the top menu.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-folder&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module FTP En|FTP]]&#039;&#039;&#039; : FTP Client&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas&amp;quot;&amp;gt;[[File:IP address icon.png|frameless|32px]]&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;GeoIPMaxmind&#039;&#039;&#039; : GeoIP Maxmind conversions capabilities&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas&amp;quot;&amp;gt;[[File:Object paybox.png|frameless|32px]]&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;PayBox&#039;&#039;&#039; : Offer customers a PayBox online payment page (credit/debit cards). This can be used to allow your customers to make ad-hoc payments or payments related to a specific Dolibarr object (invoice, order etc...)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas&amp;quot;&amp;gt;[[File:Object paypal.png|frameless|32px]]&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module PayPal En|Paypal]]&#039;&#039;&#039; : Offer customers a PayPal online payment page (PayPal account or credit/debit cards). This can be used to allow your customers to make ad-hoc payments or payments related to a specific Dolibarr object (invoice, order etc...)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fab fa-stripe-s&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Stripe|Stripe]]&#039;&#039;&#039; : Offer customers a Stripe online payment page (credit/debit cards). This can be used to allow your customers to make ad-hoc payments or payments related to a specific Dolibarr object (invoice, order etc...)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-phone&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module ClickToDial En|ClickToDial]]&#039;&#039;&#039; : Integration of a ClickToDial system (Asterisk, ...)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-print&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;One click Printing&#039;&#039;&#039; : Enable One click Printing System&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-print&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Receipt printers&#039;&#039;&#039; : Setup of receipt printers&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-cogs&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Mailman and SPIP&#039;&#039;&#039; : Mailman or SPIP interface for member module&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas&amp;quot;&amp;gt;[[File:Object gravatar.png|frameless|32px]]&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Gravatar&#039;&#039;&#039; : Use online Gravatar service (www.gravatar.com) to show photo of users/members (found with their emails). Needs Internet access&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-file&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module DAV|Dav]]&#039;&#039;&#039; : Setup a WebDAV server&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-bullseye&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Webhook|Webhook]]&#039;&#039;&#039; : Interface to catch dolibarr triggers and send it to an URL&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==System==&lt;br /&gt;
{| style=&amp;quot;margin-left: 20px; margin-right: auto;&amp;quot;&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-business-time&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Scheduled jobs|Scheduled jobs]]&#039;&#039;&#039; : Scheduled jobs management (alias cron or chrono table)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-bug&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Debug Logs&#039;&#039;&#039; : Logging facilities (file, syslog, ...). Such logs are for technical/debug purposes&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-bug&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Debug Bar&#039;&#039;&#039; : A tool for developper adding a debug bar in your browser.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-cogs&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Unalterable Archives - Logs|Unalterable Archives]]&#039;&#039;&#039; : Enable an unalterable log of business events. Events are archived in real-time. The log is a read-only table of chained events that can be exported. This module may be mandatory for some countries.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==System==&lt;br /&gt;
{| style=&amp;quot;margin-left: 20px; margin-right: auto;&amp;quot;&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-box-open&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Advanced Stock Transfer&#039;&#039;&#039; : Advanced management of Stock Transfer, with generation of transfer sheet (&amp;lt;span class=&amp;quot;fas fa-exclamation-triangle&amp;quot; style=&amp;quot;color:red;&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;In Development&amp;lt;/span&amp;gt;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==External Modules==&lt;br /&gt;
External modules are modules you can get on other sources than official sources. They are provided by third parties. Most of them can be found in the marketplace https://www.dolistore.com. List of external modules is defined on the page [[:Category:Complementary modules|Complementary modules]].&lt;br /&gt;
&lt;br /&gt;
=Glossary=&lt;br /&gt;
See page [[Glossary]]&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
All FAQ are available through the index page [[:Category:FAQ EN|FAQ EN]]&lt;br /&gt;
&lt;br /&gt;
=Video Tutorials=&lt;br /&gt;
The association Dolibarr has started making video tutorials on the basic functions of Dolibarr [[Video Tutorials]]&lt;br /&gt;
[[Category:Page waiting for translation]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=Template:TemplateDocUserJa&amp;diff=58775</id>
		<title>Template:TemplateDocUserJa</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=Template:TemplateDocUserJa&amp;diff=58775"/>
		<updated>2023-11-20T05:25:36Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div class=&amp;quot;wikibox&amp;quot;&amp;gt;&lt;br /&gt;
[[User documentation JA|利用者手引き&amp;lt;br&amp;gt;索引に戻る]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:File_Doc_user.png|link=User documentation JA]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=JA_First_setup&amp;diff=58774</id>
		<title>JA First setup</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=JA_First_setup&amp;diff=58774"/>
		<updated>2023-11-20T05:24:00Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: start Japanese translation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TemplateDocUserJa}}&lt;br /&gt;
&lt;br /&gt;
初回インストール後、自分の要件に合わせて Dolibarr のパラメータ設定をすること.&lt;br /&gt;
&lt;br /&gt;
=法人/組織=&lt;br /&gt;
最初必須ステップは自分の 法人/組織 情報を定義すること. このため、ホームページから、メニュー選択  &amp;quot;&#039;&#039;&#039;ホーム-&amp;gt;設定-&amp;gt;法人/組織&#039;&#039;&#039;&amp;quot; して自分の法人/組織の情報を追加する.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;名:&#039;&#039;&#039; 自分の法人/組織の名前&lt;br /&gt;
*[[File:Logo size.jpg|thumb]]&#039;&#039;&#039;ロゴ:&#039;&#039;&#039; Add here a logo of your company (.png, .jpg or .gif). It can accept any size but it is recommended to use a logo with 130 pixels height and up to 800 pixels width. Here is a little scheme on what will be the result on the PDF. The recommended format is png.&lt;br /&gt;
*&#039;&#039;&#039;ロゴ (正方形):&#039;&#039;&#039; Add here your squared logo (.png or .jpg) that will be used in the top right corner of the application&lt;br /&gt;
*&#039;&#039;&#039;会計年度:&#039;&#039;&#039; 自分の会計開始月を定義&lt;br /&gt;
*&#039;&#039;&#039;国:&#039;&#039;&#039; Define your country: other options depend on this selection.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;職業分類ID X:&#039;&#039;&#039; The fields Prof ID are used to store the professional IDs of a company. Each country requires its own professional ID. For example, for a company in France you may find a SIRET, SIREN, NAF, RCS and EORI number, and for a company in Argentia, you will find CUIT/CUIL, Ingresos Brutos, CIF Intra. Dolibarr is able to manage 6 Professional ID. The label of each of them is defined with the translation key ProfIdXCC (where X is 1 to 6 and XX the country code of the company, for example XX=FR). To add a new Professional ID, you can add a new translation from menu Home - Setup - Translation for the key ProfIdXCC. If you set the value of translation to &amp;quot;-&amp;quot;, it means that the professional ID is hidden when using the application in the language of translation on every company that has the country code XX.&lt;br /&gt;
&lt;br /&gt;
*&#039;&#039;&#039;消費税(VAT)管理:&#039;&#039;&#039; Define how you manage Sales Tax (or not).&lt;br /&gt;
*&#039;&#039;&#039;2種目の税金:&#039;&#039;&#039; Define if you would like to use second type of taxe (or not).&lt;br /&gt;
*&#039;&#039;&#039;3種目の税金:&#039;&#039;&#039; Define if you would like to use third type of taxe (or not).&lt;br /&gt;
&lt;br /&gt;
=モジュールs=&lt;br /&gt;
[[File:List of modules en.png|alt=List of modules|thumb|List of modules]]&lt;br /&gt;
The activation of modules is the second mandatory step. Which modules you will activate depends on what you want to do with Dolibarr. In most cases, you may want to use all modules. You have to activate each module one by one. For example, to manage a company, you might activate at least modules Third party, Invoices, and Products, but probably many more.&lt;br /&gt;
&lt;br /&gt;
To activate a module, go to page &amp;quot;&#039;&#039;&#039;Home-&amp;gt;Setup-&amp;gt;Modules&#039;&#039;&#039;&amp;quot; and click the button &#039;on/off&#039; in the &amp;quot;Status&amp;quot; column to enable it.&lt;br /&gt;
&lt;br /&gt;
*The module is &#039;&#039;&#039;on&#039;&#039;&#039; if the &#039;on/off&#039; button is like [[File:On off button on.png|alt=&#039;on/off&#039; button in on position|&#039;on/off&#039; button in on position]]&lt;br /&gt;
*The module is &#039;&#039;&#039;off&#039;&#039;&#039; if the &#039;on/off&#039; button is like [[File:On off button off.png|alt=&#039;on/off&#039; button in off position|&#039;on/off&#039; button in off position]]&lt;br /&gt;
&lt;br /&gt;
The list of standard modules is defined on page [[:Category:List of Modules|List of Modules]].&lt;br /&gt;
&lt;br /&gt;
If you are unsure of the function of a module, you may activate it and see what new menu item appears in Dolibarr (the horizontal bar), also after activating a module, check that you grant to yourself permissions on new features that were enabled. You can activate or deactivate a module when you want.&lt;br /&gt;
&lt;br /&gt;
Once a module has been activated, it may need further configuration (click on the setup icon that appears on the right of module line if a module needs its own setup). See [[:Category:List of Modules|documentation of module]] for more information.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Related videos:&lt;br /&gt;
&lt;br /&gt;
Modules:&lt;br /&gt;
(vocal in french but subtitles are available and review in this language)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;youtube width=&amp;quot;200&amp;quot; height=&amp;quot;120&amp;quot;&amp;gt;qfYP-iKWd7U&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Module settings:&lt;br /&gt;
(vocal in french but subtitles are available and review in this language)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;youtube width=&amp;quot;200&amp;quot; height=&amp;quot;120&amp;quot;&amp;gt;toT0jfmMCoU&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=表示=&lt;br /&gt;
[[File:Display settings EN.png|alt=Display settings|thumb|Display settings]]&lt;br /&gt;
On this page, you can set the default language of application and the look and feel of screens. In a first use, you can keep everything with default values.&lt;br /&gt;
&lt;br /&gt;
==言語==&lt;br /&gt;
In the language settings, you can set the Default Language. By default it is set to &amp;quot;Auto Detect&amp;quot;.&lt;br /&gt;
&#039;&#039;Note:&#039;&#039; Activating multilanguage option will allow you to be able to set the preferred language of customers, to print their Invoice/Proposal/Order in their own language. Product translations will also be available.&lt;br /&gt;
&lt;br /&gt;
==Default skin theme==&lt;br /&gt;
In Dolibarr you have two different skins : &lt;br /&gt;
&lt;br /&gt;
*eldy [[File:Eldy Theme thumb.png]]&lt;br /&gt;
*md [[File:Md theme thumb.png]]&lt;br /&gt;
&lt;br /&gt;
More skins can be downloaded on the dolistore [https://www.dolistore.com/4-skins]&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
You can also personalize the skin color, and look in this setup&lt;br /&gt;
&lt;br /&gt;
==Miscellaneous==&lt;br /&gt;
On this section, you have all the default values of features like, javascript functions, length of lists, first day of the week, etc.&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
You can also put a &amp;quot;Message of day&amp;quot; that will be displayed for all the users. In this message, you can use the [[Variable substitution system]]&lt;br /&gt;
&lt;br /&gt;
==ログインページ==&lt;br /&gt;
On this section, you can customize the login page with a message and a background image. In this message, you can use the [[Variable substitution system]]&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
It is also possible to hide/show the &amp;quot;&#039;&#039;&#039;Need help or support&#039;&#039;&#039;&amp;quot; link on login page&lt;br /&gt;
&lt;br /&gt;
=メニューs=&lt;br /&gt;
[[File:Menu Setup.png|alt=Menu Setup|thumb|Menu Setup]]&lt;br /&gt;
Choose here which menu manager you want to use for internal and external users and for computer or smartphone. The menu manager changes the labels, orders and organization of the left and top menus.&lt;br /&gt;
See page [[Menus system]] for more information.&lt;br /&gt;
&lt;br /&gt;
==Menu handlers==&lt;br /&gt;
The software comes with two different menu handler :&lt;br /&gt;
&lt;br /&gt;
*Eldy : It is the default menu, the menu entries are centralized and hard coded. You can add entries on this menu but not change the default menu entries.&lt;br /&gt;
*Auguria : It is a database  menu manager. This menu can be fully customized to your needs.&lt;br /&gt;
&lt;br /&gt;
In the Menu handlers tab, you can choose the menu for internal and external users and for computer or smartphone.&lt;br /&gt;
&lt;br /&gt;
==Menu Editor==&lt;br /&gt;
In this tab, you can customize each menu entry of &#039;&#039;&#039;auguria&#039;&#039;&#039; menu or the additional entries of &#039;&#039;&#039;eldy &#039;&#039;&#039;menu and create new entries&lt;br /&gt;
&lt;br /&gt;
==Miscellaneous==&lt;br /&gt;
In this tab, you can choose the behavior of the unauthorized menu entry. By default, the unauthorized menu entry are in gray, but can be hidden.&lt;br /&gt;
&lt;br /&gt;
=その他 (Widgets, Alerts, Security, Limits and accuracy, Emails, SMS, Dictionary setup...)=&lt;br /&gt;
Other entries in Setup menu are advanced options. You can ignore them if you want.&lt;br /&gt;
&lt;br /&gt;
*[[Setup Translation]]&lt;br /&gt;
*[[Setup Default values/filters/sorting]]&lt;br /&gt;
*[[Setup Widgets]]&lt;br /&gt;
*[[Setup Alerts]]&lt;br /&gt;
*[[Setup Security]]&lt;br /&gt;
*[[Setup Limits and accuracy]]&lt;br /&gt;
*[[Setup PDF]]&lt;br /&gt;
*[[Setup EMails]]&lt;br /&gt;
*[[Setup SMS]]&lt;br /&gt;
*[[Setup Dictionnary|Setup Dictionary]]&lt;br /&gt;
*[[Setup Other]]&lt;br /&gt;
&lt;br /&gt;
=利用者s=&lt;br /&gt;
The last step is to create users and assign permissions. Almost all the modules even activated earlier, are not accessible if you do not give permissions. To do this, you can go to the menu &#039;&#039;&#039;Home -&amp;gt; Users &amp;amp; Groups&#039;&#039;&#039; to define users and their rights. Attention, you should consider to check and reset the user rights when you enable a new module. The list of rights available depends on the activated modules (see above). It is recommended to configure permissions after activating the modules you want to use. For certain actions, if you do not have the rights to do an action, Dolibarr will not show you the action. You might miss some useful or important features. &#039;&#039;&#039;To give rights to a user or yourself, if you are an administrator, go to Home -&amp;gt; Users &amp;amp; Groups, select the desired user, then click on its &#039;Permission&#039; tab.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
You can avoid these configuration steps for each newly created user, by configuring the default rights (understand rights allocated automatically each time a new user created) by configuring the default permissions on the menu [[Setup Security]].&lt;br /&gt;
&lt;br /&gt;
=関連ビデオs=&lt;br /&gt;
Basic setup : &lt;br /&gt;
(vocal in french but subtitles are available and review in this language)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;youtube width=&amp;quot;200&amp;quot; height=&amp;quot;120&amp;quot;&amp;gt;S5Rm9ixHNRA&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Configuration options : &lt;br /&gt;
(vocal in french but subtitles are available and review in this language)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;youtube width=&amp;quot;200&amp;quot; height=&amp;quot;120&amp;quot;&amp;gt;o5VOYomd_Ns&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Visual setup : Darkmode :&lt;br /&gt;
(vocal in french but subtitles are available and review in this language)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;youtube width=&amp;quot;200&amp;quot; height=&amp;quot;120&amp;quot;&amp;gt;cdhWVmTg54U&amp;lt;/youtube&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=Template:TemplateDocUserJa&amp;diff=58773</id>
		<title>Template:TemplateDocUserJa</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=Template:TemplateDocUserJa&amp;diff=58773"/>
		<updated>2023-11-20T04:11:40Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: 日本語翻訳&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;div class=&amp;quot;wikibox&amp;quot;&amp;gt;&lt;br /&gt;
[[User documentation JA|Return to user&amp;lt;br&amp;gt;documentation index]]&amp;lt;br&amp;gt;&lt;br /&gt;
[[File:File_Doc_user.png|link=User documentation JA]]&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=User_documentation_JA&amp;diff=58771</id>
		<title>User documentation JA</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=User_documentation_JA&amp;diff=58771"/>
		<updated>2023-11-20T03:27:49Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: 日本語翻訳開始&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=利用者手引き=&lt;br /&gt;
&lt;br /&gt;
このページは利用者手引きに関連する主たる索引である。 文書類の開発者は、[[JA Developer documentation|ここを参照]].&lt;br /&gt;
&lt;br /&gt;
=特徴の速攻概説=&lt;br /&gt;
&lt;br /&gt;
*[[What Dolibarr Do|Dolibarrとは何か, Dolibarrにできることは]]&lt;br /&gt;
*[[What Dolibarr can&#039;t do|Dolibarrと違うものは, Dolibarrにできないことは]]&lt;br /&gt;
&lt;br /&gt;
=インストール | アップグレード | 設定=&lt;br /&gt;
&lt;br /&gt;
*[[Prerequisite|前提条件]]&lt;br /&gt;
*[[Installation - Upgrade|インストール - アップグレード]]&lt;br /&gt;
*[[First setup|設定]]&lt;br /&gt;
&lt;br /&gt;
Dolibarrの使用法は以下の章で提供する&lt;br /&gt;
&lt;br /&gt;
=Administration=&lt;br /&gt;
&lt;br /&gt;
*Migration: [[Mass_imports|Mass imports]] / [[ExportsEn|Exports]]&lt;br /&gt;
*[[Backups]] / [[Restores]]&lt;br /&gt;
*[[About_pages|About pages]]&lt;br /&gt;
*[[Upgrade]]&lt;br /&gt;
*[[Purge]]&lt;br /&gt;
*[[Audit]]&lt;br /&gt;
*[[Users_Sessions|Users Sessions]]&lt;br /&gt;
*[[Global_VAT_Update|Global VAT Update]]&lt;br /&gt;
*[[Module_Scheduled_jobs|Scheduled Jobs]]&lt;br /&gt;
*[[Direct_Printing_jobs|Direct Printing jobs]]&lt;br /&gt;
*[[Mass_barcode_init|Mass barcode init]]&lt;br /&gt;
&lt;br /&gt;
Related videos:&lt;br /&gt;
(vocal in french but subtitles are available and review in this language)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;youtube width=&amp;quot;200&amp;quot; height=&amp;quot;120&amp;quot;&amp;gt;lTriUeIdiNs&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=ダッシュボード=&lt;br /&gt;
&lt;br /&gt;
Related videos:&lt;br /&gt;
(vocal in french but subtitles are available and review in this language)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;youtube width=&amp;quot;200&amp;quot; height=&amp;quot;120&amp;quot;&amp;gt;VieSairH_ZQ&amp;lt;/youtube&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=使用法 (by modules / applications)=&lt;br /&gt;
&lt;br /&gt;
Knowing how to use Dolibarr is knowing how to use its modules, menus, and features. &lt;br /&gt;
First, once the installation step is complete (see previous chapters), let&#039;s have a look at general information on usage:&lt;br /&gt;
&lt;br /&gt;
*[[General information on usage]] (First steps).&lt;br /&gt;
&lt;br /&gt;
Once general usage is understood, you can have a look at the documentation about all standard business modules. Choose the module you are interested in to see its documentation. Standard modules are modules available by default in all common installation. This is a list of main modules (also available on page [[:Category:List of Modules|List of Modules]]) :&lt;br /&gt;
&lt;br /&gt;
==人事管理 (HR)==&lt;br /&gt;
{| style=&amp;quot;margin-left: 20px; margin-right: auto;&amp;quot;&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-users&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Users|Users &amp;amp; Groups]]&#039;&#039;&#039; : Users / Employees and Groups management&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-user-alt&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Membership management|Members]]&#039;&#039;&#039; : Foundation members management&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-umbrella-beach&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Leaves|Leave Request Management]]&#039;&#039;&#039; : Define and track employee leave requests&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-wallet&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Expense Reports|Expense Reports]]&#039;&#039;&#039; : Manage expense reports claims (transportation, meal, ...)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-id-card-alt&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Recruitment &#039;&#039;&#039; : Manage and follow recruitment campaigns for new job positions&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-user-tie&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module HRM|HRM]]&#039;&#039;&#039; : Human resources management (management of department, employee contracts and feelings)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Customer Relationship Management (CRM)==&lt;br /&gt;
{| style=&amp;quot;margin-left: 20px; margin-right: auto;&amp;quot;&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-building&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Third Parties|Third Parties]]&#039;&#039;&#039; : Companies and contacts management (customers, prospects...)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-file-signature&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Commercial Proposals - Quotes|Proposals]]&#039;&#039;&#039; : Commercial proposal management&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-file-invoice&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Sales Orders|Sales Orders]]&#039;&#039;&#039; : Sales order management&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-dolly&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Shipments|Shipments]]&#039;&#039;&#039; : Shipments and delivery note management&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-suitcase&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Contracts|Contracts/Subscriptions]]&#039;&#039;&#039; : Management of contracts (services or recurring subscriptions)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-ambulance&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Interventions En|Interventions]]&#039;&#039;&#039; : Intervention management&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-ticket-alt&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Ticket|Tickets]]&#039;&#039;&#039; : Ticket system for issue or request management&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-ticket-alt rotate90&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Knowledge Management|Knowledge Management System]]&#039;&#039;&#039; : Manage a Knowledge Management (KM) or Help-Desk base&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-handshake&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Partnership Management&#039;&#039;&#039; : Module Partnership management&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Vendor Relationship Management (VRM)==&lt;br /&gt;
{| style=&amp;quot;margin-left: 20px; margin-right: auto;&amp;quot;&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-building&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Suppliers Orders|Vendors]]&#039;&#039;&#039; : Vendors and purchase management (purchase orders and billing of supplier invoices)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-file-signature&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Vendor Commercial Proposals&#039;&#039;&#039; : Request vendor commercial proposal and prices&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-dolly&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Reception&#039;&#039;&#039; : Vendor reception management (Create reception documents)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-truck-loading&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Incoterms&#039;&#039;&#039; : Add features to manage Incoterms&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Financial Modules (Accounting/Treasury)==&lt;br /&gt;
{| style=&amp;quot;margin-left: 20px; margin-right: auto;&amp;quot;&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-file-invoice-dollar&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Invoice|Invoices]]&#039;&#039;&#039; : Management of invoices and credit notes for customers. Management of invoices and credit notes for suppliers&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-file-invoice-dollar&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Taxes and social contributions|Taxes &amp;amp; Special Expenses]]&#039;&#039;&#039; : Management of other expenses (sales taxes, social or fiscal taxes, dividends, ...)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-money-check-alt&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Salaries&#039;&#039;&#039; : Record and track employee payments&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-money-bill-alt&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Loans&#039;&#039;&#039; : Management of loans&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-file-alt&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Donations|Donations]]&#039;&#039;&#039; : Donation management&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-university&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Banks and Cash|Banks &amp;amp; Cash]]&#039;&#039;&#039; : Management of bank or cash accounts&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-money-check-alt&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Payment By Credit Transfer&#039;&#039;&#039; : Management of payment of suppliers by Credit Transfer orders. It includes generation of SEPA file for European countries.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-money-check-alt&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Standing Orders|Payment By Direct Debit]]&#039;&#039;&#039; : Management of Direct Debit orders. It includes generation of SEPA file for European countries.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-calculator&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Margins|Margins]]&#039;&#039;&#039; : Module to follow margins&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-search-dollar&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Accounting Simplified|Accounting (simplified)]]&#039;&#039;&#039; : Simple accounting reports (journals, turnover) based on database content. Does not use any ledger table.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-search-dollar&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Double Entry Accounting|Accounting (double entry)]]&#039;&#039;&#039; : Accounting management (double entries, support General and Subsidiary Ledgers). Export the ledger in several other accounting software formats.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-globe-europe&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Intracomm report&#039;&#039;&#039; : Intracomm report management (Support for French DEB/DES format) (&amp;lt;span class=&amp;quot;fas fa-question-circle&amp;quot; style=&amp;quot;color:orange;&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color:orange;&amp;quot;&amp;gt;Experimental&amp;lt;/span&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-money-check-alt&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Asset&#039;&#039;&#039; : Asset module (&amp;lt;span class=&amp;quot;fas fa-exclamation-triangle&amp;quot; style=&amp;quot;color:red;&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;In Development&amp;lt;/span&amp;gt;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Product Management (PM)==&lt;br /&gt;
{| style=&amp;quot;margin-left: 20px; margin-right: auto;&amp;quot;&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-cube&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Products|Products]]&#039;&#039;&#039; : Management of Products&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-concierge-bell&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Services En|Services]]&#039;&#039;&#039; : Management of Services&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-box-open&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Stocks En|Stocks]]&#039;&#039;&#039; : Stock management&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-barcode&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Lot / Serial|Product Lots]]&#039;&#039;&#039; : Lots, serial numbers, eat-by/sell-by date management for products&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-cube&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Product Variants&#039;&#039;&#039; : Creation of product variants (color, size etc.)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-shapes&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module BOM|Bills of Material]]&#039;&#039;&#039; : Module to define your Bills Of Materials (BOM). Can be used for Manufacturing Resource Planning by the module Manufacturing Orders (MO)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-cubes&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Manufacturing Orders|Manufacturing Orders]]&#039;&#039;&#039; : Module to Manage Manufacturing Orders (MO)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-hand-holding-usd&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Dynamic Prices|Dynamic Prices]]&#039;&#039;&#039; : Use maths expressions for auto-generation of prices (&amp;lt;span class=&amp;quot;fas fa-question-circle&amp;quot; style=&amp;quot;color:orange;&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color:orange;&amp;quot;&amp;gt;Experimental&amp;lt;/span&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-pallet&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Workstation|Workstation]]&#039;&#039;&#039; : Workstations management (&amp;lt;span class=&amp;quot;fas fa-exclamation-triangle&amp;quot; style=&amp;quot;color:red;&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;In Development&amp;lt;/span&amp;gt;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Projects/Collaborative work==&lt;br /&gt;
{| style=&amp;quot;margin-left: 20px; margin-right: auto;&amp;quot;&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-project-diagram&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Projects|Projects or Leads]]&#039;&#039;&#039; : Management of projects, leads/opportunities and/or tasks. You can also assign any element (invoice, order, proposal, intervention, ...) to a project and get a transversal view from the project view.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-calendar-alt&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Agenda En|Events/Agenda]]&#039;&#039;&#039; : Track events. Log automatic events for tracking purposes or record manual events or meetings. This is the principal module for good Customer or Vendor Relationship Management.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-laptop-house&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Resources|Resources]]&#039;&#039;&#039; : Manage resources (printers, cars, rooms, ...) for allocating to events&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-calendar-alt&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Event Organization|Event Organization]]&#039;&#039;&#039; : Event Organization through Module Project&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Electronic Content Management (ECM)==&lt;br /&gt;
{| style=&amp;quot;margin-left: 20px; margin-right: auto;&amp;quot;&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-folder-open&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;DMS / ECM&#039;&#039;&#039; : Document Management System / Electronic Content Management. Automatic organization of your generated or stored documents. Share them when you need.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Multi-modules tools==&lt;br /&gt;
{| style=&amp;quot;margin-left: 20px; margin-right: auto;&amp;quot;&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-tag&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Categories|Tags / Categories]]&#039;&#039;&#039; : Create tags/category (products, customers, suppliers, contacts or members)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-paragraph&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;WYSIWYG Editor&#039;&#039;&#039; : Allow text fields to be edited/formatted using CKEditor (html)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-dollar-sign&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Multicurrency&#039;&#039;&#039; : Use alternative currencies in prices and documents&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-rss&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;RSS Feed&#039;&#039;&#039; : Add a RSS feed to Dolibarr pages&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-star&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Bookmarks|Bookmarks &amp;amp; Shortcuts]]&#039;&#039;&#039; : Create shortcuts, always accessible, to the internal or external pages to which you frequently access&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-barcode&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Barcode|Barcodes]]&#039;&#039;&#039; : Barcode or QR code management&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-cogs&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Workflow En|Inter-modules Workflow]]&#039;&#039;&#039; : Workflow management between different modules (automatic creation of object and/or automatic status change)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-cogs&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Imports En|Data imports]]&#039;&#039;&#039; : Tool to import data into Dolibarr (with assistance)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-cogs&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Exports En|Data exports]]&#039;&#039;&#039; : Tool to export Dolibarr data (with assistance)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-file&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Stickers&#039;&#039;&#039; : Management of stickers (&amp;lt;span class=&amp;quot;fas fa-exclamation-triangle&amp;quot; style=&amp;quot;color:red;&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;In Development&amp;lt;/span&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-at&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Document Generation&#039;&#039;&#039;: Mass email document generation (&amp;lt;span class=&amp;quot;fas fa-exclamation-triangle&amp;quot; style=&amp;quot;color:red;&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;In Development&amp;lt;/span&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-file&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Data Privacy Policy&#039;&#039;&#039; : Module to manage Data Privacy (Conformity with the GDPR) (&amp;lt;span class=&amp;quot;fas fa-question-circle&amp;quot; style=&amp;quot;color:orange;&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color:orange;&amp;quot;&amp;gt;Experimental&amp;lt;/span&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-bug&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module ModuleBuilder|Module and Application Builder]]&#039;&#039;&#039; : A RAD (Rapid Application Development) tool to help developers to build their own module.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Websites and other frontal application==&lt;br /&gt;
{| style=&amp;quot;margin-left: 20px; margin-right: auto;&amp;quot;&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-check-double&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Poll, Survey or Vote&#039;&#039;&#039; : Create online polls, surveys or votes (like Doodle, Studs, RDVz etc...)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-globe-americas&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Website|Websites]]&#039;&#039;&#039; : Create websites (public) with a WYSIWYG editor. This is a webmaster or developer oriented CMS (it is better to know HTML and CSS language). Just setup your web server (Apache, Nginx, ...) to point to the dedicated Dolibarr directory to have it online on the internet with your own domain name.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-people-arrows&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Collab&#039;&#039;&#039; : Enable the public collaboration features, like shared pad, shared online sheets, etc... (&amp;lt;span class=&amp;quot;fas fa-exclamation-triangle&amp;quot; style=&amp;quot;color:red;&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;In Development&amp;lt;/span&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-cash-register&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Point of sale (TakePOS)|POS TakePOS]]&#039;&#039;&#039; : Point of Sale module TakePOS (touchscreen POS, for shops, bars or restaurants).&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Interfaces with external systems==&lt;br /&gt;
&lt;br /&gt;
{| style=&amp;quot;margin-left: 20px; margin-right: auto;&amp;quot;&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-share-alt&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Social Networks&#039;&#039;&#039; : Enable Social Networks fields into third parties and addresses (skype, twitter, facebook, ...).&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-at&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Notification|Notifications on business event]]&#039;&#039;&#039; : Send email notifications triggered by a business event: per user (setup defined on each user), per third-party contacts (setup defined on each third party) or by specific emails&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-at&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module EMailing|Mass Emailings]]&#039;&#039;&#039; : Manage bulk emailing&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-at&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module EMail Collector|Email collector]]&#039;&#039;&#039; : Add a scheduled job and a setup page to scan regularly email boxes (using IMAP protocol) and record emails received into your application, at the right place and/or create some records automatically (like leads).&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-cogs&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Web Services API REST (developer)|API/Web services (REST server)]]&#039;&#039;&#039; : Enable the Dolibarr REST server providing API services&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-cogs&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Web Services API SOAP|API/Web services (SOAP server)]]&#039;&#039;&#039; : Enable the Dolibarr SOAP server providing API services&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-cogs&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Call WebServices (SOAP client)&#039;&#039;&#039; : Enable the Dolibarr web services client (Can be used to push data/requests to external servers. Only Purchase orders are currently supported.) (&amp;lt;span class=&amp;quot;fas fa-question-circle&amp;quot; style=&amp;quot;color:orange;&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color:orange;&amp;quot;&amp;gt;Experimental&amp;lt;/span&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas&amp;quot;&amp;gt;[[File:Object zapier.png]]&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Zapier|Zapier]]&#039;&#039;&#039; : Interface with Zapier (&amp;lt;span class=&amp;quot;fas fa-exclamation-triangle&amp;quot; style=&amp;quot;color:red;&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;In Development&amp;lt;/span&amp;gt;)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-cogs&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module LDAP En|LDAP]]&#039;&#039;&#039; : LDAP directory synchronization&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-cogs&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module OAuth|OAuth]]&#039;&#039;&#039; : Enable OAuth authentication&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-globe-americas&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;External Site&#039;&#039;&#039; : Add a link to an external website as a main menu icon. Website is shown in a frame under the top menu.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-folder&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module FTP En|FTP]]&#039;&#039;&#039; : FTP Client&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas&amp;quot;&amp;gt;[[File:IP address icon.png|frameless|32px]]&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;GeoIPMaxmind&#039;&#039;&#039; : GeoIP Maxmind conversions capabilities&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas&amp;quot;&amp;gt;[[File:Object paybox.png|frameless|32px]]&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;PayBox&#039;&#039;&#039; : Offer customers a PayBox online payment page (credit/debit cards). This can be used to allow your customers to make ad-hoc payments or payments related to a specific Dolibarr object (invoice, order etc...)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas&amp;quot;&amp;gt;[[File:Object paypal.png|frameless|32px]]&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module PayPal En|Paypal]]&#039;&#039;&#039; : Offer customers a PayPal online payment page (PayPal account or credit/debit cards). This can be used to allow your customers to make ad-hoc payments or payments related to a specific Dolibarr object (invoice, order etc...)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fab fa-stripe-s&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Stripe|Stripe]]&#039;&#039;&#039; : Offer customers a Stripe online payment page (credit/debit cards). This can be used to allow your customers to make ad-hoc payments or payments related to a specific Dolibarr object (invoice, order etc...)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-phone&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module ClickToDial En|ClickToDial]]&#039;&#039;&#039; : Integration of a ClickToDial system (Asterisk, ...)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-print&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;One click Printing&#039;&#039;&#039; : Enable One click Printing System&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-print&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Receipt printers&#039;&#039;&#039; : Setup of receipt printers&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-cogs&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Mailman and SPIP&#039;&#039;&#039; : Mailman or SPIP interface for member module&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas&amp;quot;&amp;gt;[[File:Object gravatar.png|frameless|32px]]&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Gravatar&#039;&#039;&#039; : Use online Gravatar service (www.gravatar.com) to show photo of users/members (found with their emails). Needs Internet access&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-file&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module DAV|Dav]]&#039;&#039;&#039; : Setup a WebDAV server&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-bullseye&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Webhook|Webhook]]&#039;&#039;&#039; : Interface to catch dolibarr triggers and send it to an URL&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==System==&lt;br /&gt;
{| style=&amp;quot;margin-left: 20px; margin-right: auto;&amp;quot;&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-business-time&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Scheduled jobs|Scheduled jobs]]&#039;&#039;&#039; : Scheduled jobs management (alias cron or chrono table)&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-bug&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Debug Logs&#039;&#039;&#039; : Logging facilities (file, syslog, ...). Such logs are for technical/debug purposes&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-bug&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Debug Bar&#039;&#039;&#039; : A tool for developper adding a debug bar in your browser.&lt;br /&gt;
|-&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-cogs&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;[[Module Unalterable Archives - Logs|Unalterable Archives]]&#039;&#039;&#039; : Enable an unalterable log of business events. Events are archived in real-time. The log is a read-only table of chained events that can be exported. This module may be mandatory for some countries.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==System==&lt;br /&gt;
{| style=&amp;quot;margin-left: 20px; margin-right: auto;&amp;quot;&lt;br /&gt;
| style=&amp;quot;text-align:center;&amp;quot; |&amp;lt;span class=&amp;quot;fas fa-box-open&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&lt;br /&gt;
|&#039;&#039;&#039;Advanced Stock Transfer&#039;&#039;&#039; : Advanced management of Stock Transfer, with generation of transfer sheet (&amp;lt;span class=&amp;quot;fas fa-exclamation-triangle&amp;quot; style=&amp;quot;color:red;&amp;quot;&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;span style=&amp;quot;color:red;&amp;quot;&amp;gt;In Development&amp;lt;/span&amp;gt;)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==External Modules==&lt;br /&gt;
External modules are modules you can get on other sources than official sources. They are provided by third parties. Most of them can be found in the marketplace https://www.dolistore.com. List of external modules is defined on the page [[:Category:Complementary modules|Complementary modules]].&lt;br /&gt;
&lt;br /&gt;
=Glossary=&lt;br /&gt;
See page [[Glossary]]&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
All FAQ are available through the index page [[:Category:FAQ EN|FAQ EN]]&lt;br /&gt;
&lt;br /&gt;
=Video Tutorials=&lt;br /&gt;
The association Dolibarr has started making video tutorials on the basic functions of Dolibarr [[Video Tutorials]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Proofreading done]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=%E3%83%9B%E3%83%BC%E3%83%A0%E3%83%9A%E3%83%BC%E3%82%B8&amp;diff=58770</id>
		<title>ホームページ</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=%E3%83%9B%E3%83%BC%E3%83%A0%E3%83%9A%E3%83%BC%E3%82%B8&amp;diff=58770"/>
		<updated>2023-11-20T03:14:47Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: &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 : Home --&amp;gt;&lt;br /&gt;
[[en:Home]]&lt;br /&gt;
[[fr:Accueil]]&lt;br /&gt;
[[es:Portada]]&lt;br /&gt;
[[de:Hauptseite]]&lt;br /&gt;
[[el:Αρχική]]&lt;br /&gt;
[[pt:Página Principal]]&lt;br /&gt;
[[zh:简体中文官方文档]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
{{DISPLAYTITLE:Easy to use Open-Source software for business}}&lt;br /&gt;
&amp;lt;center&amp;gt;&lt;br /&gt;
[[File:Dolibarr logo.png|180px|link=]]&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Be free to manage your company, freelancer or foundation activity&#039;&#039;&#039;&lt;br /&gt;
&amp;lt;/center&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
このWikiには、Dolibarr ERP/CRMに関するすべてのドキュメント（ユーザー向け、開発者向け、翻訳者向けのドキュメント）とリソースが含まれています。ダウンロードは、Dolibarrプロジェクトのウェブポータル（https://www.dolibarr.org）から可能です。&lt;br /&gt;
&lt;br /&gt;
{{Info}}{{InfoJa}}&lt;br /&gt;
&lt;br /&gt;
=[[File:art.png|link=]] Dolibarrプロジェクト=&lt;br /&gt;
&lt;br /&gt;
*[[JA_What_Dolibarr_Does|Dolibarrとは？]] - [[JA_FAQ_Who_uses_Dolibarr|Dolibarrのユーザは誰?]]&lt;br /&gt;
*[[Dolibarr Project|資料、経緯、プロジェクト組織]]&lt;br /&gt;
*[[Dolibarr foundation|Dolibarr 基金]]&lt;br /&gt;
*[https://www.dolibarr.org/onlinedemo オンラインデモ]&lt;br /&gt;
*[https://www.dolibarr.org/downloads/ ダウンロード]&lt;br /&gt;
&lt;br /&gt;
=[[File:File_Doc_user.png|link=]] 利用者文書=&lt;br /&gt;
&lt;br /&gt;
*[[User_documentation_JA|利用者手引き]] と [[User FAQ|利用者FAQ]]&lt;br /&gt;
*[https://www.youtube.com/playlist?list=PL317BA167DF5A1D3E ビデオ学習(英語)]&lt;br /&gt;
*[[Dolibarr help and support|ヘルプとサポートセンター]] (コミュニティフォーラム、有償サポート等)&lt;br /&gt;
*[[Screenshots|スクリーンショット]]&lt;br /&gt;
*[[Security informations|セキュリティ情報]]&lt;br /&gt;
&lt;br /&gt;
=[[File:File_Doc_dev.png|link=]] 開発者文書=&lt;br /&gt;
&lt;br /&gt;
*[[JA Developer documentation|開発者手引き]]&lt;br /&gt;
*[[JA Developer FAQ|開発者FAQ]]&lt;br /&gt;
*[[JA Dolibarr Project|資料、プロジェクト組織]]&lt;br /&gt;
&lt;br /&gt;
=[[File:File_Doc_trans.png|link=]] 翻訳者文書=&lt;br /&gt;
&lt;br /&gt;
*[[Translator documentation|翻訳者手引き]]&lt;br /&gt;
&lt;br /&gt;
=[[File:File_Doc_tester.png|link=]] テスター文書=&lt;br /&gt;
&lt;br /&gt;
*[[JA Tester documentation|テスター手引き]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
__NOTOC__&lt;br /&gt;
__NOEDITSECTION__&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=Category:Page_waiting_for_translation&amp;diff=58769</id>
		<title>Category:Page waiting for translation</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=Category:Page_waiting_for_translation&amp;diff=58769"/>
		<updated>2023-11-20T03:05:56Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: Add Janaese description&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{flag_en}} Index of pages waiting for translation (english, french, spanish or italian).&lt;br /&gt;
&lt;br /&gt;
{{flag_fr}} Index des pages en attentes de traduction (anglais, français, espagnol ou italien).&lt;br /&gt;
&lt;br /&gt;
{{flag_sp}} Indice de páginas en espera de traducción (inglés, francés, español o italiano).&lt;br /&gt;
&lt;br /&gt;
{{flag_it}} Indice delle pagine in attesa di traduzione (inglese, francese, spagnolo o italiano).&lt;br /&gt;
&lt;br /&gt;
{{flag_pt}} Índex das páginas a aguardar por tradução (inglês, francês, espanhol ou italiano).&lt;br /&gt;
&lt;br /&gt;
{{flag_zh}} 等待翻译的页面索引（中文、英文、法文、西班牙文或意大利文）。&lt;br /&gt;
&lt;br /&gt;
{{Flag jp}} 翻訳待ちページの索引 (日本語、英語、仏語、西語、伊語)&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=57459</id>
		<title>モジュール 開発</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=57459"/>
		<updated>2023-08-26T07:51:08Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: /* Database access */&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:Développement_module]]&lt;br /&gt;
[[es:Desarrollo_de_un_módulo]]&lt;br /&gt;
[[de:Modul_Entwicklung]]&lt;br /&gt;
[[zh:模块开发]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Core]]&lt;br /&gt;
{{TemplateDocDevEn}}&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;
etc...&lt;br /&gt;
&lt;br /&gt;
以下の章では、これらすべてを手作業で簡単に行う方法を示す.&lt;br /&gt;
&lt;br /&gt;
=モジュールビルダ によるモジュールの生成=&lt;br /&gt;
Dolibarr 9.0 から、モジュールビルダにより、自前モジュールのメインページ作成が可能. 起動方法は:&lt;br /&gt;
&lt;br /&gt;
*モジュールリストにて、&amp;quot;モジュールビルダ(Module Builder)&amp;quot;を有効化する,&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_2.png|400px]]&lt;br /&gt;
&lt;br /&gt;
*その後 &amp;quot;バグ(bug)&amp;quot; 画像をクリック、場所は画面右上.&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_3.png|400px]]&lt;br /&gt;
&lt;br /&gt;
=テンプレート外部モジュールの例=&lt;br /&gt;
外部モジュールの開発を開始するのによいお手本は、ここで見つかるだろう : [https://github.com/Dolibarr/dolibarr/tree/develop/htdocs/modulebuilder/template GitHub Dolibarr Module Modèle]&lt;br /&gt;
&lt;br /&gt;
=自前モジュールを作る=&lt;br /&gt;
==自前モジュールに関するモジュール記述(Module descriptor)を作る (必須)==&lt;br /&gt;
&#039;&#039;&#039;必須となる時期&#039;&#039;&#039;: アドオンを開発すると早急に必要、たとえゴールが何であれ (例外はスキンの追加).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Dolibarr 9.0 から, モジュールビルダ (ModuleBuilder) モジュールを使用すべきだ、モジュール記述を生成するための標準モデルとして使える&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===自前のモジュール記述 (module descriptor) を作成する===&lt;br /&gt;
最初のステップは、モジュールに対するファイル記述 (file descriptor) を作成すること. (訳者注： 以下の内容は&#039;&#039;&#039;モジュールビルダを使うことで自動設定&#039;&#039;&#039;される) &lt;br /&gt;
&lt;br /&gt;
*ディレクトリ作成： &#039;&#039;&#039;/htdocs/custom/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; (外部モジュール向け) または &#039;&#039;&#039;/htdocs/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; ここはDolibarr の公式コアモジュール (official core module) とする場合. 次にファイル modMyModule.class.php をディレクトリ &#039;&#039;&#039;htdocs/modulebuilder/template&#039;&#039;&#039; からコピーして上記のディレクトリに作成. ファイルの名称を modMyModule.class.php から 自前モジュールの目的に合致した名称に変更. ファイル名は、先頭に &#039;mod&#039; があり、最後が .class.php で終わる (例えば、ファイル名を &#039;新名&#039; にするなら, &#039;mod新名.class.php&#039; となる).&lt;br /&gt;
&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;
*番号を変更: $this-&amp;gt;numero = 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;
Dolibarrを起動し、&#039;&#039;&#039;設定-&amp;gt;モジュール (Setup-&amp;gt;module&#039;&#039;&#039;?) ページを表示.&lt;br /&gt;
モジュール記述でプロパティバージョン (property version) を設定すると、自前の新規モジュールを載せた新規行とそれを有効化するかどうかの選択が表示されるはず. プロパティバージョンを &amp;quot;develop&amp;quot; または &amp;quot;experimental&amp;quot; に設定した場合、自前モジュールを見るには、まず &#039;&#039;&#039;設定-&amp;gt;その他 (Setup-Others)&#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;
これは、新しいモジュールを構築する際に、ファイルをどう整理するかを示している (ZIPファイルもこのルールに合わせる必要あり).&lt;br /&gt;
注：2行目だけが必須.&lt;br /&gt;
&lt;br /&gt;
{{TemplateModuleTreeSimpleJA}}&lt;br /&gt;
&lt;br /&gt;
==自前 SQL テーブル と PHP DAO クラス (任意)==&lt;br /&gt;
&#039;&#039;&#039;使用場面&#039;&#039;&#039;: 自前モジュールがそれ自身のデータを管理する必要がある場合&lt;br /&gt;
&lt;br /&gt;
===自前の .sql ファイルを作成===&lt;br /&gt;
自前モジュールが、Dolibarr標準版では利用できない独自データを管理する設計である場合、そのデータを格納するためのSQLテーブルを定義する必要がある.&lt;br /&gt;
&lt;br /&gt;
自前モジュールでテーブルを作成したり、データを読込むためのスクリプトは、自前モジュールのsqlサブディレクトリ (&amp;quot;&#039;&#039;&#039;mymodule/sql&#039;&#039;&#039;&amp;quot;) に保存される。(ModuleBuilder では、オブジェクト タブから新しいオブジェクトを作成するとき、このディレクトリとすべての sql ファイルが自動作成される）.&lt;br /&gt;
&lt;br /&gt;
次に、記述ファイルでの、&#039;&#039;&#039;init&#039;&#039;&#039; 関数にて、次の行&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;$this-&amp;gt;_load_tables(&#039;/mymodule/sql/&#039;);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
が、コメントでないことを確認する.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;従うべきルール:&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*テーブルごとに &#039;&#039;&#039;llx_matable.sql&#039;&#039;&#039; ファイルを１つ、&#039;&#039;&#039;llx_matable.key.sql&#039;&#039;&#039; ファイルを可能なら１つ、作成するという原則に基づき、テーブル作成コマンドのファイルを追加する（例として、 &#039;&#039;&#039;install/mysql/tables&#039;&#039;&#039; にあるファイルを参照）.&lt;br /&gt;
*SQLフィールドの推奨される型と名前は、このページに定義されてる [[Language_and_development_rules#Table_and_fields_structures]].&lt;br /&gt;
*データ管理のため、 &#039;&#039;&#039;/mymodule/sql/&#039;&#039;&#039;  ディレクトリ内に  &#039;&#039;&#039;data.sql&#039;&#039;&#039;  というファイルを作成し、データの追加/編集/削除を行う SQL コマンドを記述すること.&lt;br /&gt;
*文字列にダブルクォートを使わない（例： &amp;quot;chaine&amp;quot; でなく &#039;chaine&#039;） ダブルクォートは PostGreSQL では特定の意味を持つ&lt;br /&gt;
&lt;br /&gt;
例としてファイル data.sql の中身は&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ファイルは、mysql データベースで動作可能であること. 備考: 他データベースのファイルはメンテナンスされない. 他データベースのドライバによって、その場で読込まれ変換さる.&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;
DAO PHPファイルは、オブジェクトを作成した後にモジュールビルダによって生成されているはず.&lt;br /&gt;
&lt;br /&gt;
だとしても、既存オブジェクトをコピーして手動作成することもできる、しかし、モジュールビルダの使用を強く勧める。実例がここにあるはず &#039;&#039;&#039;htdocs/modulebuilder/templates/class/myobject.class.php&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
このクラスでは、テーブル行の挿入、取得（選択）、更新、削除を実行するためのCRUD（作成/読込/更新/削除）メソッドがすでに実行可能となっている。正しいモジュール名、テーブルを使用するようにファイルを編集し、このファイルをモジュールのクラスサブディレクトリに配置する。モジュールビルダを使用すると、マウスを数回クリックするだけで、この作業を実行できる.&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;
そのためには、先に作成したモジュールのファイル記述に行って、$this-&amp;gt;tabs 配列を編集する:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
テーブルには文字列のリストが含まれ、各文字列は新しいタブを表す．文字列の形式は &amp;quot;: &amp;quot; で区切られた5つの部分からなる．&lt;br /&gt;
&lt;br /&gt;
*Part 1: タブを表示するエレメントタイプ（オブジェクトタイプ）で、以下の値:&lt;br /&gt;
{{TemplateModuleTabsJA}}&lt;br /&gt;
&lt;br /&gt;
*Part 2: タブのコードで、タブの追加（+で始まる）または削除（-で始まる）を識別する．&lt;br /&gt;
*Part 3: タブのタイトル．タイトルが読みずらいなら、コードにして言語ファイルで翻訳するとよい．&lt;br /&gt;
*Part 4: ファイル名 &amp;quot;*.lang&amp;quot; は、コード翻訳と表示する言語の対応を含む．この名前の後に@mymoduleが続く場合、 Dolibarrはモジュール内の翻訳ファイル &amp;quot;*.lang &amp;quot;を検索するので、htdocs/mymodule/langs/code_CODE/mylangfile.langとなり、そうでない場合はhtdocs/langs/code_CODE/mylangfile.langとなる．&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;
既存タブの名前 &#039;tabname&#039; を取得するには、ファイル &#039;core/lib/module.lib.php&#039; の関数 &#039;product_prepare_head&#039; で使用されている名前で、セクション &#039;$head[$h][2]&#039; に対応するものをチェックする必要がある．&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. Include files you need into your file&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each object type, there are two files to include with line&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;require_once($url_fichier) ;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is example of files to include (DOL_DOCUMENT_ROOT is often dolibarr/htdocs/) :&lt;br /&gt;
&lt;br /&gt;
*Object thirdparty (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;
*Object product (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;
*Object invoice (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. Create and load the object to show into your tab&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create an instance of an object of the correct class and load object from the database by using the fetch method of an object in providing to this method the id you get from URL (ie : /mytab.php?id=1).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Get a list of all tabs to show for your object type&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function XXX_prepare_head($obj), where XXX is name of object. This will return an array with all definition of tab entries to show. The parameter to put into this method is the instance of an object you want tabs.&lt;br /&gt;
&lt;br /&gt;
The resulting array has the following structure&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$head = product_prepare_head($product, $user) ; // parameter $user is present for some function anly&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4. show tabs into your page&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function dol_fiche_head() to show all tabs defined into array $head returned by XX_prepare_head().&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&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;
使用場面: モジュールの目的が、画面の新規作成または変更を必要とする機能の追加である場合.&lt;br /&gt;
&lt;br /&gt;
===新規 PHP 画面の作成===&lt;br /&gt;
次に、 &#039;&#039;&#039;modulebuilder/myobject_page.php&#039;&#039;&#039;  ディレクトリに例として提示されているスケルトンテンプレートを使用して、テーブルのデータを表示/編集するPHPページを作成する必要がある (コマンドラインからのスクリプト開発については、 [[Script development]] を参照).&lt;br /&gt;
&lt;br /&gt;
新しいユーザー画面を作成するには、&#039;&#039;&#039;htdocs&#039;&#039;&#039; のサブディレクトリを作成し（まだ作成されていない場合）、作成するページを保存するために、モジュール（例えば、&#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;
main.inc.phpファイルへの相対パスが正しくなるようにファイルを編集する. &lt;br /&gt;
&amp;lt;syntaxhighlight 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 calculated 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
ご覧のように、main.inc.php（または master.inc.php）のロードは何回か試行される。目標は、大抵のケースで成功すること。最小は2行: master/main.inc.phpをdolibarrルートディレクトリにロードしようとする行と、モジュールが &amp;quot;custom &amp;quot;ディレクトリにデプロイされるケースをサポートするためにファイルをロードしようとする行。しかし、より多くの状況に対応するため、より多くを持つことができる。提供された例は、ほぼすべての状況/セットアップで main/master.inc.php ファイルをロードできるはず。&lt;br /&gt;
&lt;br /&gt;
注意： モジュール・ディレクトリ・ツリーに対するファイルの深さによっては、さらに&amp;quot;../&amp;quot;を追加する。&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;
*モジュール専用クラスやライブラリをインクルードするには、（include_onceを直接使わず）Dolibarr関数を使う：&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Dolibarrで提供されているクラスをインクルードするには、以下の構文を使う:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add some fields into existing forms===&lt;br /&gt;
You may want to provide a module that adds more fields into forms (input and view) of some elements. &lt;br /&gt;
&lt;br /&gt;
A heavy solution (but not so bad) may be to replace all pages used to create element (this means to disable the &amp;quot;New element&amp;quot; menu entry and adding yours, and disable tab that shows element to replace with a tab that is your own full page (copied/pasted from original) to do same than original page but modified to add your fields and stored added data into your own table). Go to menu [[#Define your entries in the menu (optional)]] and [[#The tab management (optional)]] if this solution suits you (this solution is more powerful since you can change everything you want into the page). &lt;br /&gt;
&lt;br /&gt;
We will describe here another solution, that works only to &amp;quot;add fields&amp;quot; at end of existing fields, using the element &amp;quot;category&amp;quot; as an example but you can convert this tutorial for invoice, proposal ...&lt;br /&gt;
&lt;br /&gt;
*First thing is to add a table, owned by your module, to store the value of new fields. This table will have only one column called &amp;quot;rowid&amp;quot; (will contain the same value than field rowid of element table) + one column for each new field you want to add. Then create a class with CRUD (Create/Read/Update/Delete) methods for this new table. For this two tasks, go back to previous chapter [[#Create your SQL tables and the PHP DAO class]].&lt;br /&gt;
*Next step is to add a hook into your module to add the new fields into the form. See chapter [[Hooks_system#Implement_the_Hook]] for generic documentation to use hooks.&lt;br /&gt;
&lt;br /&gt;
If you follow this tutorial, to be able to add fields into category forms, you must do:&lt;br /&gt;
{{ToComplete}}&lt;br /&gt;
&lt;br /&gt;
===Add/replace part of fields supported by hooks===&lt;br /&gt;
See chapter [[Hooks_system#Implement_the_Hook]] to know how to use Dolibarr existing hooks to add/replace code at Dolibarr hooks place.&lt;br /&gt;
&lt;br /&gt;
===データベース アクセス===&lt;br /&gt;
自前テーブルの中でデータベースのデータを編集する必要がある場合、前に生成されたPHPクラスを使うこと。&lt;br /&gt;
&lt;br /&gt;
専用の PHP クラスがないテーブルにアクセスしたい場合 (たとえば、特定の結合やフィルタを使用したレコードの一覧を取得したい場合など) 、これはいつでも可能。この場合に、倣うべきコード例は：&lt;br /&gt;
&lt;br /&gt;
操作が、 insert, update または delete:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
操作が read:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Define style of your pages===&lt;br /&gt;
To have the look of your own pages to match the Dolibarr theme, it is necessary to use the Dolibarr CSS styles.&lt;br /&gt;
&lt;br /&gt;
You can use for example:&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;
===Use the Dolibarr date picker===&lt;br /&gt;
If you want to use the Dolibarr date selector (with its calendar popup) into your pages, use the following line:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
The string mykey will identify the date selector in the form. You must use different values if you use several date selectors in same page.&lt;br /&gt;
The string myform is the name of the FORM in which the selector is included (value found in the form name=&amp;quot;myform&amp;quot; in HTML page).&lt;br /&gt;
This means a date selector must be included necessarily into an html FORM.&lt;br /&gt;
&lt;br /&gt;
To get value after the POST of your form, the command is:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$mydate = dol_mktime(12, 0 , 0, $GETPOST(&#039;mykeymonth&#039;, &#039;int&#039;), GETPOST(&#039;mykeyday&#039;, &#039;int&#039;), GETPOST(&#039;mykeyyear&#039;, &#039;int&#039;));&lt;br /&gt;
print strftime(&#039;%A %d %B %Y&#039;, $mydate);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Overwrite template file (tpl)===&lt;br /&gt;
If you want to overwrite tpl file on your module, you need to declare it on the module_parts :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
&#039;tpl&#039; =&amp;gt; 1,&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Then you can put any tpl file on &#039;&#039;&#039;mymodule/core/tpl&#039;&#039;&#039;&lt;br /&gt;
as soon as the module is activate, the tpl will be overwrited&lt;br /&gt;
&lt;br /&gt;
==自前の準備ページを追加 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs parameters, which are to be provided by the user, for proper setting up of the module.&lt;br /&gt;
&lt;br /&gt;
===Create your page to edit parameters===&lt;br /&gt;
If your module needs several parameters to be setup, you must create a page to edit options (these options will be saved in the [[Table llx_const|table &#039;&#039;&#039;llx_const&#039;&#039;&#039;]]).&lt;br /&gt;
Create a page named &#039;&#039;&#039;mymodule_setuppage.php&#039;&#039;&#039; that shows a form for possible options to update them into the above-mentioned table.&lt;br /&gt;
It is necessary to take an example from a page of the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; that will show you the way to read/save your parameters.&lt;br /&gt;
Put this PHP page into the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; of your module (e.g. mymodule/admin/mymodule_setuppage.php).&lt;br /&gt;
&lt;br /&gt;
===Modify the descriptor file of your module===&lt;br /&gt;
Then, within the descriptor file of your module, modify the variable &#039;&#039;&#039;config_page_url&#039;&#039;&#039; to set the name of this PHP page.&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;admin/&#039;&#039;&#039;, then the path is not required, e.g. like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;mymodule/admin/&#039;&#039;&#039;, then like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test your page===&lt;br /&gt;
Go into page &#039;&#039;&#039;Home-&amp;gt;Setup-&amp;gt;Modules&#039;&#039;&#039;, you should see a picture at the end of the line of your module to reach your setup page. Click on it, you should be able to view/edit parameters from your page.&lt;br /&gt;
&lt;br /&gt;
==メニューに自前項目を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If you have created PHP pages, it is necessary that those pages can be reached from menu entries in Dolibarr menu.&lt;br /&gt;
&lt;br /&gt;
===Define your menu entries===&lt;br /&gt;
For this, you must define into the module descriptor, the array this-&amp;gt;menu that declares 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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To show the menu or not depending on a permission, modify property &#039;&#039;&#039;perms&#039;&#039;&#039; in the array. See chapter on permissions later to see how to add permissions.&lt;br /&gt;
&lt;br /&gt;
===Test your menu entries===&lt;br /&gt;
Disable and re-enable your module under the 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;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;rights_class = &#039;mymodule&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight 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][2] = &#039;r&#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;/syntaxhighlight&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][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; Translation key should be &amp;quot;Permission10001=My permission Label&amp;quot;).&lt;br /&gt;
Into $this-&amp;gt;rights[$r][2], types of the permission. There are three type of permission, &#039;r&#039; for read, list or expert permission, &#039;w&#039; for write or update permission and &#039;d&#039; for delete permission.&lt;br /&gt;
Into $this-&amp;gt;rights[$r][3], put 1 if this permission must be granted automatically by default to any newly created user.&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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==自前の box を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs to provide one or several new boxes to show on home page.&lt;br /&gt;
&lt;br /&gt;
===Define your box===&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;syntaxhighlight 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;/syntaxhighlight&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 activate. Activate the box and go on the home page to see if the box is showing correctly.&lt;br /&gt;
&lt;br /&gt;
==自前のエキスポートを定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module provides new predefined database export profiles (for its own tables or for already existing tables of another module).&lt;br /&gt;
&lt;br /&gt;
===Define export===&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 a 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;
==自前の CSS スタイルを定義 (任意)==&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 several CSS files 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 files only if you need absolutely to add not already existing styles.&lt;br /&gt;
&lt;br /&gt;
Once your style sheets are ready, declare them 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 an array of relative URLs to your CSS files.&lt;br /&gt;
For example&lt;br /&gt;
&amp;lt;syntaxhighlight 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;,&#039;/mymodule/css/myother.css&#039;));&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 the 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 declares your style sheet.&lt;br /&gt;
&lt;br /&gt;
==自前の Javascript 関数を追加 (任意)==&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;syntaxhighlight 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;/syntaxhighlight&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;
==Dolibarr フックポジションの内部に、自前コードを挿入 (任意)==&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 the 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 are not covered by existing rules.&lt;br /&gt;
&lt;br /&gt;
See page [[Create numbering module]].&lt;br /&gt;
&lt;br /&gt;
==自前の文書テンプレートを追加 (任意)==&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;
==自前のスキンを追加 (任意)==&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;
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 marketplace.&lt;br /&gt;
But you can use it to have a package easy to distribute on your own 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 a 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
perl makepack-dolibarrmodule.pl&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
tar -xvf mymodule.zip&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 marketplace website: {{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 built correctly, the file will be validated later.&lt;br /&gt;
**If quality is enough and license permits it, the code might be added inside main Dolibarr sources (except if you disagree for that).&lt;br /&gt;
&lt;br /&gt;
=DoliStore での外部モジュール 有効化/活性化 条件=&lt;br /&gt;
&lt;br /&gt;
See [[Module_Dolistore_Validation_Rules|Validation Rules]]&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=57458</id>
		<title>モジュール 開発</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=57458"/>
		<updated>2023-08-26T07:40:19Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: /* PHP 画面の作成や更新 (任意) */&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:Développement_module]]&lt;br /&gt;
[[es:Desarrollo_de_un_módulo]]&lt;br /&gt;
[[de:Modul_Entwicklung]]&lt;br /&gt;
[[zh:模块开发]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Core]]&lt;br /&gt;
{{TemplateDocDevEn}}&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;
etc...&lt;br /&gt;
&lt;br /&gt;
以下の章では、これらすべてを手作業で簡単に行う方法を示す.&lt;br /&gt;
&lt;br /&gt;
=モジュールビルダ によるモジュールの生成=&lt;br /&gt;
Dolibarr 9.0 から、モジュールビルダにより、自前モジュールのメインページ作成が可能. 起動方法は:&lt;br /&gt;
&lt;br /&gt;
*モジュールリストにて、&amp;quot;モジュールビルダ(Module Builder)&amp;quot;を有効化する,&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_2.png|400px]]&lt;br /&gt;
&lt;br /&gt;
*その後 &amp;quot;バグ(bug)&amp;quot; 画像をクリック、場所は画面右上.&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_3.png|400px]]&lt;br /&gt;
&lt;br /&gt;
=テンプレート外部モジュールの例=&lt;br /&gt;
外部モジュールの開発を開始するのによいお手本は、ここで見つかるだろう : [https://github.com/Dolibarr/dolibarr/tree/develop/htdocs/modulebuilder/template GitHub Dolibarr Module Modèle]&lt;br /&gt;
&lt;br /&gt;
=自前モジュールを作る=&lt;br /&gt;
==自前モジュールに関するモジュール記述(Module descriptor)を作る (必須)==&lt;br /&gt;
&#039;&#039;&#039;必須となる時期&#039;&#039;&#039;: アドオンを開発すると早急に必要、たとえゴールが何であれ (例外はスキンの追加).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Dolibarr 9.0 から, モジュールビルダ (ModuleBuilder) モジュールを使用すべきだ、モジュール記述を生成するための標準モデルとして使える&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===自前のモジュール記述 (module descriptor) を作成する===&lt;br /&gt;
最初のステップは、モジュールに対するファイル記述 (file descriptor) を作成すること. (訳者注： 以下の内容は&#039;&#039;&#039;モジュールビルダを使うことで自動設定&#039;&#039;&#039;される) &lt;br /&gt;
&lt;br /&gt;
*ディレクトリ作成： &#039;&#039;&#039;/htdocs/custom/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; (外部モジュール向け) または &#039;&#039;&#039;/htdocs/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; ここはDolibarr の公式コアモジュール (official core module) とする場合. 次にファイル modMyModule.class.php をディレクトリ &#039;&#039;&#039;htdocs/modulebuilder/template&#039;&#039;&#039; からコピーして上記のディレクトリに作成. ファイルの名称を modMyModule.class.php から 自前モジュールの目的に合致した名称に変更. ファイル名は、先頭に &#039;mod&#039; があり、最後が .class.php で終わる (例えば、ファイル名を &#039;新名&#039; にするなら, &#039;mod新名.class.php&#039; となる).&lt;br /&gt;
&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;
*番号を変更: $this-&amp;gt;numero = 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;
Dolibarrを起動し、&#039;&#039;&#039;設定-&amp;gt;モジュール (Setup-&amp;gt;module&#039;&#039;&#039;?) ページを表示.&lt;br /&gt;
モジュール記述でプロパティバージョン (property version) を設定すると、自前の新規モジュールを載せた新規行とそれを有効化するかどうかの選択が表示されるはず. プロパティバージョンを &amp;quot;develop&amp;quot; または &amp;quot;experimental&amp;quot; に設定した場合、自前モジュールを見るには、まず &#039;&#039;&#039;設定-&amp;gt;その他 (Setup-Others)&#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;
これは、新しいモジュールを構築する際に、ファイルをどう整理するかを示している (ZIPファイルもこのルールに合わせる必要あり).&lt;br /&gt;
注：2行目だけが必須.&lt;br /&gt;
&lt;br /&gt;
{{TemplateModuleTreeSimpleJA}}&lt;br /&gt;
&lt;br /&gt;
==自前 SQL テーブル と PHP DAO クラス (任意)==&lt;br /&gt;
&#039;&#039;&#039;使用場面&#039;&#039;&#039;: 自前モジュールがそれ自身のデータを管理する必要がある場合&lt;br /&gt;
&lt;br /&gt;
===自前の .sql ファイルを作成===&lt;br /&gt;
自前モジュールが、Dolibarr標準版では利用できない独自データを管理する設計である場合、そのデータを格納するためのSQLテーブルを定義する必要がある.&lt;br /&gt;
&lt;br /&gt;
自前モジュールでテーブルを作成したり、データを読込むためのスクリプトは、自前モジュールのsqlサブディレクトリ (&amp;quot;&#039;&#039;&#039;mymodule/sql&#039;&#039;&#039;&amp;quot;) に保存される。(ModuleBuilder では、オブジェクト タブから新しいオブジェクトを作成するとき、このディレクトリとすべての sql ファイルが自動作成される）.&lt;br /&gt;
&lt;br /&gt;
次に、記述ファイルでの、&#039;&#039;&#039;init&#039;&#039;&#039; 関数にて、次の行&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;$this-&amp;gt;_load_tables(&#039;/mymodule/sql/&#039;);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
が、コメントでないことを確認する.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;従うべきルール:&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*テーブルごとに &#039;&#039;&#039;llx_matable.sql&#039;&#039;&#039; ファイルを１つ、&#039;&#039;&#039;llx_matable.key.sql&#039;&#039;&#039; ファイルを可能なら１つ、作成するという原則に基づき、テーブル作成コマンドのファイルを追加する（例として、 &#039;&#039;&#039;install/mysql/tables&#039;&#039;&#039; にあるファイルを参照）.&lt;br /&gt;
*SQLフィールドの推奨される型と名前は、このページに定義されてる [[Language_and_development_rules#Table_and_fields_structures]].&lt;br /&gt;
*データ管理のため、 &#039;&#039;&#039;/mymodule/sql/&#039;&#039;&#039;  ディレクトリ内に  &#039;&#039;&#039;data.sql&#039;&#039;&#039;  というファイルを作成し、データの追加/編集/削除を行う SQL コマンドを記述すること.&lt;br /&gt;
*文字列にダブルクォートを使わない（例： &amp;quot;chaine&amp;quot; でなく &#039;chaine&#039;） ダブルクォートは PostGreSQL では特定の意味を持つ&lt;br /&gt;
&lt;br /&gt;
例としてファイル data.sql の中身は&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ファイルは、mysql データベースで動作可能であること. 備考: 他データベースのファイルはメンテナンスされない. 他データベースのドライバによって、その場で読込まれ変換さる.&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;
DAO PHPファイルは、オブジェクトを作成した後にモジュールビルダによって生成されているはず.&lt;br /&gt;
&lt;br /&gt;
だとしても、既存オブジェクトをコピーして手動作成することもできる、しかし、モジュールビルダの使用を強く勧める。実例がここにあるはず &#039;&#039;&#039;htdocs/modulebuilder/templates/class/myobject.class.php&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
このクラスでは、テーブル行の挿入、取得（選択）、更新、削除を実行するためのCRUD（作成/読込/更新/削除）メソッドがすでに実行可能となっている。正しいモジュール名、テーブルを使用するようにファイルを編集し、このファイルをモジュールのクラスサブディレクトリに配置する。モジュールビルダを使用すると、マウスを数回クリックするだけで、この作業を実行できる.&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;
そのためには、先に作成したモジュールのファイル記述に行って、$this-&amp;gt;tabs 配列を編集する:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
テーブルには文字列のリストが含まれ、各文字列は新しいタブを表す．文字列の形式は &amp;quot;: &amp;quot; で区切られた5つの部分からなる．&lt;br /&gt;
&lt;br /&gt;
*Part 1: タブを表示するエレメントタイプ（オブジェクトタイプ）で、以下の値:&lt;br /&gt;
{{TemplateModuleTabsJA}}&lt;br /&gt;
&lt;br /&gt;
*Part 2: タブのコードで、タブの追加（+で始まる）または削除（-で始まる）を識別する．&lt;br /&gt;
*Part 3: タブのタイトル．タイトルが読みずらいなら、コードにして言語ファイルで翻訳するとよい．&lt;br /&gt;
*Part 4: ファイル名 &amp;quot;*.lang&amp;quot; は、コード翻訳と表示する言語の対応を含む．この名前の後に@mymoduleが続く場合、 Dolibarrはモジュール内の翻訳ファイル &amp;quot;*.lang &amp;quot;を検索するので、htdocs/mymodule/langs/code_CODE/mylangfile.langとなり、そうでない場合はhtdocs/langs/code_CODE/mylangfile.langとなる．&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;
既存タブの名前 &#039;tabname&#039; を取得するには、ファイル &#039;core/lib/module.lib.php&#039; の関数 &#039;product_prepare_head&#039; で使用されている名前で、セクション &#039;$head[$h][2]&#039; に対応するものをチェックする必要がある．&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. Include files you need into your file&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each object type, there are two files to include with line&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;require_once($url_fichier) ;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is example of files to include (DOL_DOCUMENT_ROOT is often dolibarr/htdocs/) :&lt;br /&gt;
&lt;br /&gt;
*Object thirdparty (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;
*Object product (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;
*Object invoice (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. Create and load the object to show into your tab&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create an instance of an object of the correct class and load object from the database by using the fetch method of an object in providing to this method the id you get from URL (ie : /mytab.php?id=1).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Get a list of all tabs to show for your object type&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function XXX_prepare_head($obj), where XXX is name of object. This will return an array with all definition of tab entries to show. The parameter to put into this method is the instance of an object you want tabs.&lt;br /&gt;
&lt;br /&gt;
The resulting array has the following structure&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$head = product_prepare_head($product, $user) ; // parameter $user is present for some function anly&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4. show tabs into your page&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function dol_fiche_head() to show all tabs defined into array $head returned by XX_prepare_head().&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&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;
使用場面: モジュールの目的が、画面の新規作成または変更を必要とする機能の追加である場合.&lt;br /&gt;
&lt;br /&gt;
===新規 PHP 画面の作成===&lt;br /&gt;
次に、 &#039;&#039;&#039;modulebuilder/myobject_page.php&#039;&#039;&#039;  ディレクトリに例として提示されているスケルトンテンプレートを使用して、テーブルのデータを表示/編集するPHPページを作成する必要がある (コマンドラインからのスクリプト開発については、 [[Script development]] を参照).&lt;br /&gt;
&lt;br /&gt;
新しいユーザー画面を作成するには、&#039;&#039;&#039;htdocs&#039;&#039;&#039; のサブディレクトリを作成し（まだ作成されていない場合）、作成するページを保存するために、モジュール（例えば、&#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;
main.inc.phpファイルへの相対パスが正しくなるようにファイルを編集する. &lt;br /&gt;
&amp;lt;syntaxhighlight 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 calculated 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
ご覧のように、main.inc.php（または master.inc.php）のロードは何回か試行される。目標は、大抵のケースで成功すること。最小は2行: master/main.inc.phpをdolibarrルートディレクトリにロードしようとする行と、モジュールが &amp;quot;custom &amp;quot;ディレクトリにデプロイされるケースをサポートするためにファイルをロードしようとする行。しかし、より多くの状況に対応するため、より多くを持つことができる。提供された例は、ほぼすべての状況/セットアップで main/master.inc.php ファイルをロードできるはず。&lt;br /&gt;
&lt;br /&gt;
注意： モジュール・ディレクトリ・ツリーに対するファイルの深さによっては、さらに&amp;quot;../&amp;quot;を追加する。&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;
*モジュール専用クラスやライブラリをインクルードするには、（include_onceを直接使わず）Dolibarr関数を使う：&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*Dolibarrで提供されているクラスをインクルードするには、以下の構文を使う:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add some fields into existing forms===&lt;br /&gt;
You may want to provide a module that adds more fields into forms (input and view) of some elements. &lt;br /&gt;
&lt;br /&gt;
A heavy solution (but not so bad) may be to replace all pages used to create element (this means to disable the &amp;quot;New element&amp;quot; menu entry and adding yours, and disable tab that shows element to replace with a tab that is your own full page (copied/pasted from original) to do same than original page but modified to add your fields and stored added data into your own table). Go to menu [[#Define your entries in the menu (optional)]] and [[#The tab management (optional)]] if this solution suits you (this solution is more powerful since you can change everything you want into the page). &lt;br /&gt;
&lt;br /&gt;
We will describe here another solution, that works only to &amp;quot;add fields&amp;quot; at end of existing fields, using the element &amp;quot;category&amp;quot; as an example but you can convert this tutorial for invoice, proposal ...&lt;br /&gt;
&lt;br /&gt;
*First thing is to add a table, owned by your module, to store the value of new fields. This table will have only one column called &amp;quot;rowid&amp;quot; (will contain the same value than field rowid of element table) + one column for each new field you want to add. Then create a class with CRUD (Create/Read/Update/Delete) methods for this new table. For this two tasks, go back to previous chapter [[#Create your SQL tables and the PHP DAO class]].&lt;br /&gt;
*Next step is to add a hook into your module to add the new fields into the form. See chapter [[Hooks_system#Implement_the_Hook]] for generic documentation to use hooks.&lt;br /&gt;
&lt;br /&gt;
If you follow this tutorial, to be able to add fields into category forms, you must do:&lt;br /&gt;
{{ToComplete}}&lt;br /&gt;
&lt;br /&gt;
===Add/replace part of fields supported by hooks===&lt;br /&gt;
See chapter [[Hooks_system#Implement_the_Hook]] to know how to use Dolibarr existing hooks to add/replace code at Dolibarr hooks place.&lt;br /&gt;
&lt;br /&gt;
===Database access===&lt;br /&gt;
If you need to edit some data in the database inside your own table, use the PHP class generated before.&lt;br /&gt;
&lt;br /&gt;
If you to make access to tables with no dedicated PHP class available, this is always possible (for example if you want to get a list of records with a particular join or filter). In this case, this is a code samples to follow:&lt;br /&gt;
&lt;br /&gt;
To make an insert, update or delete:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To read:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Define style of your pages===&lt;br /&gt;
To have the look of your own pages to match the Dolibarr theme, it is necessary to use the Dolibarr CSS styles.&lt;br /&gt;
&lt;br /&gt;
You can use for example:&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;
===Use the Dolibarr date picker===&lt;br /&gt;
If you want to use the Dolibarr date selector (with its calendar popup) into your pages, use the following line:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
The string mykey will identify the date selector in the form. You must use different values if you use several date selectors in same page.&lt;br /&gt;
The string myform is the name of the FORM in which the selector is included (value found in the form name=&amp;quot;myform&amp;quot; in HTML page).&lt;br /&gt;
This means a date selector must be included necessarily into an html FORM.&lt;br /&gt;
&lt;br /&gt;
To get value after the POST of your form, the command is:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$mydate = dol_mktime(12, 0 , 0, $GETPOST(&#039;mykeymonth&#039;, &#039;int&#039;), GETPOST(&#039;mykeyday&#039;, &#039;int&#039;), GETPOST(&#039;mykeyyear&#039;, &#039;int&#039;));&lt;br /&gt;
print strftime(&#039;%A %d %B %Y&#039;, $mydate);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Overwrite template file (tpl)===&lt;br /&gt;
If you want to overwrite tpl file on your module, you need to declare it on the module_parts :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
&#039;tpl&#039; =&amp;gt; 1,&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Then you can put any tpl file on &#039;&#039;&#039;mymodule/core/tpl&#039;&#039;&#039;&lt;br /&gt;
as soon as the module is activate, the tpl will be overwrited&lt;br /&gt;
&lt;br /&gt;
==自前の準備ページを追加 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs parameters, which are to be provided by the user, for proper setting up of the module.&lt;br /&gt;
&lt;br /&gt;
===Create your page to edit parameters===&lt;br /&gt;
If your module needs several parameters to be setup, you must create a page to edit options (these options will be saved in the [[Table llx_const|table &#039;&#039;&#039;llx_const&#039;&#039;&#039;]]).&lt;br /&gt;
Create a page named &#039;&#039;&#039;mymodule_setuppage.php&#039;&#039;&#039; that shows a form for possible options to update them into the above-mentioned table.&lt;br /&gt;
It is necessary to take an example from a page of the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; that will show you the way to read/save your parameters.&lt;br /&gt;
Put this PHP page into the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; of your module (e.g. mymodule/admin/mymodule_setuppage.php).&lt;br /&gt;
&lt;br /&gt;
===Modify the descriptor file of your module===&lt;br /&gt;
Then, within the descriptor file of your module, modify the variable &#039;&#039;&#039;config_page_url&#039;&#039;&#039; to set the name of this PHP page.&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;admin/&#039;&#039;&#039;, then the path is not required, e.g. like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;mymodule/admin/&#039;&#039;&#039;, then like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test your page===&lt;br /&gt;
Go into page &#039;&#039;&#039;Home-&amp;gt;Setup-&amp;gt;Modules&#039;&#039;&#039;, you should see a picture at the end of the line of your module to reach your setup page. Click on it, you should be able to view/edit parameters from your page.&lt;br /&gt;
&lt;br /&gt;
==メニューに自前項目を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If you have created PHP pages, it is necessary that those pages can be reached from menu entries in Dolibarr menu.&lt;br /&gt;
&lt;br /&gt;
===Define your menu entries===&lt;br /&gt;
For this, you must define into the module descriptor, the array this-&amp;gt;menu that declares 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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To show the menu or not depending on a permission, modify property &#039;&#039;&#039;perms&#039;&#039;&#039; in the array. See chapter on permissions later to see how to add permissions.&lt;br /&gt;
&lt;br /&gt;
===Test your menu entries===&lt;br /&gt;
Disable and re-enable your module under the 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;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;rights_class = &#039;mymodule&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight 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][2] = &#039;r&#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;/syntaxhighlight&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][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; Translation key should be &amp;quot;Permission10001=My permission Label&amp;quot;).&lt;br /&gt;
Into $this-&amp;gt;rights[$r][2], types of the permission. There are three type of permission, &#039;r&#039; for read, list or expert permission, &#039;w&#039; for write or update permission and &#039;d&#039; for delete permission.&lt;br /&gt;
Into $this-&amp;gt;rights[$r][3], put 1 if this permission must be granted automatically by default to any newly created user.&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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==自前の box を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs to provide one or several new boxes to show on home page.&lt;br /&gt;
&lt;br /&gt;
===Define your box===&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;syntaxhighlight 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;/syntaxhighlight&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 activate. Activate the box and go on the home page to see if the box is showing correctly.&lt;br /&gt;
&lt;br /&gt;
==自前のエキスポートを定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module provides new predefined database export profiles (for its own tables or for already existing tables of another module).&lt;br /&gt;
&lt;br /&gt;
===Define export===&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 a 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;
==自前の CSS スタイルを定義 (任意)==&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 several CSS files 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 files only if you need absolutely to add not already existing styles.&lt;br /&gt;
&lt;br /&gt;
Once your style sheets are ready, declare them 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 an array of relative URLs to your CSS files.&lt;br /&gt;
For example&lt;br /&gt;
&amp;lt;syntaxhighlight 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;,&#039;/mymodule/css/myother.css&#039;));&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 the 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 declares your style sheet.&lt;br /&gt;
&lt;br /&gt;
==自前の Javascript 関数を追加 (任意)==&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;syntaxhighlight 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;/syntaxhighlight&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;
==Dolibarr フックポジションの内部に、自前コードを挿入 (任意)==&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 the 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 are not covered by existing rules.&lt;br /&gt;
&lt;br /&gt;
See page [[Create numbering module]].&lt;br /&gt;
&lt;br /&gt;
==自前の文書テンプレートを追加 (任意)==&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;
==自前のスキンを追加 (任意)==&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;
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 marketplace.&lt;br /&gt;
But you can use it to have a package easy to distribute on your own 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 a 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
perl makepack-dolibarrmodule.pl&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
tar -xvf mymodule.zip&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 marketplace website: {{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 built correctly, the file will be validated later.&lt;br /&gt;
**If quality is enough and license permits it, the code might be added inside main Dolibarr sources (except if you disagree for that).&lt;br /&gt;
&lt;br /&gt;
=DoliStore での外部モジュール 有効化/活性化 条件=&lt;br /&gt;
&lt;br /&gt;
See [[Module_Dolistore_Validation_Rules|Validation Rules]]&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=Module_Web_Services_API_REST_(developer)_JA&amp;diff=57164</id>
		<title>Module Web Services API REST (developer) JA</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=Module_Web_Services_API_REST_(developer)_JA&amp;diff=57164"/>
		<updated>2023-07-24T10:17:22Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: /* Installation */&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_Web_Services_API_REST_(développeur)]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{TemplateDocDevEn}}&lt;br /&gt;
{{TemplateModEN}}&lt;br /&gt;
[[Category:List of Modules]]&lt;br /&gt;
{{BasculeDevUserEn|&lt;br /&gt;
name=Web services|&lt;br /&gt;
num=2610|&lt;br /&gt;
devdoc=This page|&lt;br /&gt;
userdoc=Not applicable|}}&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サーバが提供するウェブサービスを利用可能にできる. そこから、Dolibarrが提供する別のウェブサービスに REST 呼出しを実行することもできる.&lt;br /&gt;
&lt;br /&gt;
=インストール=&lt;br /&gt;
&lt;br /&gt;
インストールするには, モジュールページを開いて &amp;quot;API REST&amp;quot; モジュールを有効化する. &lt;br /&gt;
&lt;br /&gt;
一旦モジュール webservices REST が有効化されると, Dolibarr も REST web services サーバとなる. なので、自前の REST リクエストが可能：相対  URL&lt;br /&gt;
&#039;&#039;&#039;/api/index.php/xxx&#039;&#039;&#039; ここで xxx は呼び出す API の名称.&lt;br /&gt;
&lt;br /&gt;
自前でインストールした API 一覧は エクスプローラを通じて検索可能. エクスプローラへのリンクをクリックして API エクスプローラ を開く.&lt;br /&gt;
&lt;br /&gt;
==Apache 設定==&lt;br /&gt;
設定は不要. 自前の Dolibarr が Apache で動作中なら, REST API も動作するはず. API は自前アプリと同じ仮想サーバにて動作する.&lt;br /&gt;
&lt;br /&gt;
==Nginx setup==&lt;br /&gt;
Like Apache, if your Dolibarr is working inside a NGinx virtual host, you should have nothing to do to have your API working. APIs will be served by the same virtual web server than your application.&lt;br /&gt;
&lt;br /&gt;
However, NGinx default setup on a lot of distribution is often a gaz engine and you may experience troubles. If you experience such troubles, you can try to edit your NGinx config file to match the following example. This is a simple localhost setup with a working REST API handling (tested with 9.0.1 on parabola gnu/linux).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;nginx&amp;quot;&amp;gt;&lt;br /&gt;
worker_processes  1;&lt;br /&gt;
error_log  /var/log/nginx/error.log;&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections  1024;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    include       mime.types;&lt;br /&gt;
    default_type  application/octet-stream;&lt;br /&gt;
&lt;br /&gt;
    #log_format  main  &#039;$remote_addr - $remote_user [$time_local] &amp;quot;$request&amp;quot; &#039;&lt;br /&gt;
    #                  &#039;$status $body_bytes_sent &amp;quot;$http_referer&amp;quot; &#039;&lt;br /&gt;
    #                  &#039;&amp;quot;$http_user_agent&amp;quot; &amp;quot;$http_x_forwarded_for&amp;quot;&#039;;&lt;br /&gt;
&lt;br /&gt;
    #access_log  logs/access.log  main;&lt;br /&gt;
&lt;br /&gt;
    sendfile        on;&lt;br /&gt;
    #tcp_nopush     on;&lt;br /&gt;
&lt;br /&gt;
    #keepalive_timeout  0;&lt;br /&gt;
    keepalive_timeout  65;&lt;br /&gt;
&lt;br /&gt;
    #gzip  on;&lt;br /&gt;
&lt;br /&gt;
    server {&lt;br /&gt;
    	listen		80;&lt;br /&gt;
        server_name     dolibarr.localhost; # adjust to your domain&lt;br /&gt;
&lt;br /&gt;
        root    /usr/share/webapps/dolibarr/htdocs; # adjust to your path &lt;br /&gt;
        index   index.php;&lt;br /&gt;
&lt;br /&gt;
        # from https://github.com/Dolibarr/dolibarr/issues/6163#issuecomment-391265538&lt;br /&gt;
        location ~ [^/]\.php(/|$) {&lt;br /&gt;
            fastcgi_split_path_info ^(.+?\.php)(/.*)$;&lt;br /&gt;
            if (!-f $document_root$fastcgi_script_name) {&lt;br /&gt;
                return 404;&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            # Mitigate https://httpoxy.org/ vulnerabilities&lt;br /&gt;
            fastcgi_param HTTP_PROXY &amp;quot;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
            root           /usr/share/webapps/dolibarr/htdocs;&lt;br /&gt;
            fastcgi_pass   unix:/run/php-fpm/php-fpm.sock;&lt;br /&gt;
            fastcgi_index  index.php;&lt;br /&gt;
            include        fastcgi_params;&lt;br /&gt;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;&lt;br /&gt;
            # Dolibarr Rest API path support&lt;br /&gt;
            fastcgi_param  PATH_INFO       $fastcgi_path_info;&lt;br /&gt;
            fastcgi_param  PATH_TRANSLATED $document_root$fastcgi_script_name;&lt;br /&gt;
        }&lt;br /&gt;
     }		&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=List of provided services=&lt;br /&gt;
Only few services are available. You can see full list of Dolibarr Web services provided, by calling the explorer here at address:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;http://yourdolibarrurl/api/index.php/explorer&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
For example, you can try the explorer on the demo instance at:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;https://demo.dolibarr.org/api/index.php/explorer&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On the top right corner, paste the &amp;lt;token&amp;gt; of the user you want to use to call the API and click the &amp;quot;explore&amp;quot; button. Note: The token of each user can be defined on the user record page. &lt;br /&gt;
If you prefer, you can first make a first call to the &#039;&#039;&#039;login&#039;&#039;&#039; API to get the API token key. Then enter API key to get list of all other available API services.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After clicking on &amp;quot;Explore&amp;quot;, you should see all the actions available with this token. If you don&#039;t have a lot of actions, it&#039;s probably because the according modules are not activated. If you want to see the invoices, you have to activate the invoice module in the configuration of Dolibarr. Same for products, third parties and so on.&lt;br /&gt;
&lt;br /&gt;
On this exploration page of the API, you can do quite a lot of tests. Reading datas from Dolibarr and writing, modifying and deleting as well. Warning: Data are really modified in your database.&lt;br /&gt;
&lt;br /&gt;
You can then test directly from the explorer tool any API. This is the recommended solution to test any Dolibarr API since any API and parameters is documented here. As a result of any test, you will get the answer but also example on how to call the API from command line using &#039;&#039;&#039;curl&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=Use=&lt;br /&gt;
&lt;br /&gt;
To use the REST API,  you have to call an url such as this one : &amp;lt;nowiki&amp;gt;http://&amp;lt;my_server&amp;gt;/api/index.php/&amp;lt;action&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
with one of the 4 following methods : GET, POST, PUT, DELETE, replacing &amp;lt;action&amp;gt; by the action you want to use. Ex : &amp;lt;nowiki&amp;gt;http://&amp;lt;my_server&amp;gt;/api/index.php/invoices&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before using any API, you must first get a custom API-key. You have to create a new user and generate or set its &amp;quot;Key for API&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
[[File:Dolibarr user for api.png|400px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will have to use this API key in any of your client program that need to call a Dolibarr API.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Client code example==&lt;br /&gt;
&lt;br /&gt;
===PHP===&lt;br /&gt;
There&#039;s different ways to do so. Here&#039;s a piece of code but you can also use libraries such as phphttpclient.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
// Example of function to call a REST API&lt;br /&gt;
function callAPI($method, $apikey, $url, $data = false)&lt;br /&gt;
{&lt;br /&gt;
    $curl = curl_init();&lt;br /&gt;
    $httpheader = [&#039;DOLAPIKEY: &#039;.$apikey];&lt;br /&gt;
&lt;br /&gt;
    switch ($method)&lt;br /&gt;
    {&lt;br /&gt;
        case &amp;quot;POST&amp;quot;:&lt;br /&gt;
            curl_setopt($curl, CURLOPT_POST, 1);&lt;br /&gt;
            $httpheader[] = &amp;quot;Content-Type:application/json&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
            if ($data)&lt;br /&gt;
                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);&lt;br /&gt;
&lt;br /&gt;
            break;&lt;br /&gt;
        case &amp;quot;PUT&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
	    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, &#039;PUT&#039;);&lt;br /&gt;
            $httpheader[] = &amp;quot;Content-Type:application/json&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
            if ($data)&lt;br /&gt;
                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);&lt;br /&gt;
&lt;br /&gt;
            break;&lt;br /&gt;
        default:&lt;br /&gt;
            if ($data)&lt;br /&gt;
                $url = sprintf(&amp;quot;%s?%s&amp;quot;, $url, http_build_query($data));&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Optional Authentication:&lt;br /&gt;
    //    curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);&lt;br /&gt;
    //    curl_setopt($curl, CURLOPT_USERPWD, &amp;quot;username:password&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    curl_setopt($curl, CURLOPT_URL, $url);&lt;br /&gt;
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);&lt;br /&gt;
    curl_setopt($curl, CURLOPT_HTTPHEADER, $httpheader);&lt;br /&gt;
&lt;br /&gt;
    $result = curl_exec($curl);&lt;br /&gt;
&lt;br /&gt;
    curl_close($curl);&lt;br /&gt;
&lt;br /&gt;
    return $result;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is just a working example. There&#039;s no error control and security was not in mind but you can use this code, modify it to suit your needs&amp;lt;br /&amp;gt;&lt;br /&gt;
The fonction has 4 parameters :&lt;br /&gt;
&lt;br /&gt;
*$method : string, &amp;quot;GET&amp;quot;, &amp;quot;POST&amp;quot;, &amp;quot;PUT&amp;quot;, &amp;quot;DELETE&amp;quot;&lt;br /&gt;
*$apikey : string, &amp;quot;your &amp;lt;token&amp;gt; generated earlier&amp;quot;&lt;br /&gt;
*$url : string, url to call. Ex : &amp;quot;&amp;lt;nowiki&amp;gt;http://&amp;lt;my_server&amp;gt;/api/index.php/invoices&amp;lt;/nowiki&amp;gt;&amp;quot;&lt;br /&gt;
*$data : string, datas in json format. This parameter is not mandatory.&lt;br /&gt;
&lt;br /&gt;
===Javascript Ajax===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
$.ajax({&lt;br /&gt;
  type: &#039;GET&#039;,&lt;br /&gt;
  async: true,&lt;br /&gt;
  contentType: &amp;quot;application/json; charset=utf-8&amp;quot;,&lt;br /&gt;
  data: { &#039;lang&#039;: &#039;en_US&#039; },&lt;br /&gt;
  dataType: &amp;quot;json&amp;quot;,&lt;br /&gt;
  cache: false,&lt;br /&gt;
  jsonp: false,&lt;br /&gt;
  headers: {&lt;br /&gt;
    &#039;DOLAPIKEY&#039;: &#039;abcdef123456&#039;&lt;br /&gt;
  }, &lt;br /&gt;
  url: &#039;https://myserver/api/index.php/theapi&#039;,&lt;br /&gt;
  success: function(rep) {&lt;br /&gt;
    console.log(&amp;quot;API call success&amp;quot;);&lt;br /&gt;
    console.log(rep);&lt;br /&gt;
  },&lt;br /&gt;
  error: function(rep) {&lt;br /&gt;
    console.log(&amp;quot;API call error&amp;quot;);&lt;br /&gt;
    console.log(rep);&lt;br /&gt;
  }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Accepted parameters==&lt;br /&gt;
This is documented somewhat in the REST Explorer. Check that first. Second try and see what response you get. Third look at the source code for the given API.&lt;br /&gt;
&lt;br /&gt;
===sqlfilters===&lt;br /&gt;
They are passed on to the database after a check.&lt;br /&gt;
These work on the product endpoint:&lt;br /&gt;
&lt;br /&gt;
*(t.fk_product_type: = :&#039;0&#039;) and (t.tosell: = :&#039;1&#039;) and (t.label: ilike :&#039;%string&#039;)&lt;br /&gt;
&lt;br /&gt;
===Date===&lt;br /&gt;
The ISO date format is accepted: %Y-%m-%d e.g. 2020-07-14. yymmdd is not accepted.&lt;br /&gt;
&lt;br /&gt;
=Examples with PHP=&lt;br /&gt;
&lt;br /&gt;
This is more examples, for different uses cases:&lt;br /&gt;
&lt;br /&gt;
In every examples, we have:&lt;br /&gt;
&lt;br /&gt;
*$apiKey = &amp;quot;&amp;lt;my token&amp;gt;&amp;quot;;&lt;br /&gt;
*$apiUrl = &amp;quot;&amp;lt;nowiki&amp;gt;http://&amp;lt;my_server&amp;gt;/api/index.php/&amp;lt;/nowiki&amp;gt;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
// Retrieve products list&lt;br /&gt;
	$listProduits = [];&lt;br /&gt;
	$produitParam = [&amp;quot;limit&amp;quot; =&amp;gt; 10000, &amp;quot;sortfield&amp;quot; =&amp;gt; &amp;quot;rowid&amp;quot;];&lt;br /&gt;
	$listProduitsResult = CallAPI(&amp;quot;GET&amp;quot;, $apiKey, $apiUrl.&amp;quot;products&amp;quot;, $produitParam);&lt;br /&gt;
	$listProduitsResult = json_decode($listProduitsResult, true);&lt;br /&gt;
&lt;br /&gt;
	if (isset($listProduitsResult[&amp;quot;error&amp;quot;]) &amp;amp;&amp;amp; $listProduitsResult[&amp;quot;error&amp;quot;][&amp;quot;code&amp;quot;] &amp;gt;= &amp;quot;300&amp;quot;) {&lt;br /&gt;
	} else {&lt;br /&gt;
		foreach ($listProduitsResult as $produit) {&lt;br /&gt;
			$listProduits[intval($produit[&amp;quot;id&amp;quot;])] = html_entity_decode($produit[&amp;quot;ref&amp;quot;], ENT_QUOTES);&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Comments :&lt;br /&gt;
&lt;br /&gt;
*I retrieve the 10&#039;000 first products sorted on their ID in the base&lt;br /&gt;
*html_entity_decode is necessary as single quotes are encoded&lt;br /&gt;
*It&#039;s easy to use the same method (replacing products with dictionnarycountries) to retrieve the list of countries and their ID&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
// Create a product&lt;br /&gt;
	$ref = &amp;quot;my_product_ref_X203ZZ&amp;quot;;&lt;br /&gt;
	$newProduct = [&lt;br /&gt;
		&amp;quot;ref&amp;quot;	=&amp;gt; $ref,&lt;br /&gt;
		&amp;quot;label&amp;quot;	=&amp;gt; $ref&lt;br /&gt;
	];&lt;br /&gt;
	$newProductResult = CallAPI(&amp;quot;POST&amp;quot;, $apiKey, $apiUrl.&amp;quot;products&amp;quot;, json_encode($newProduct));&lt;br /&gt;
	$newProductResult = json_decode($newProductResult, true);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Comments :&lt;br /&gt;
&lt;br /&gt;
*before creating a product, it could be wise to check if it exists. Using my first example, you&#039;ll have  :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
// my ref&lt;br /&gt;
	$ref = &amp;quot;my_product_ref_X203ZZ&amp;quot;;&lt;br /&gt;
// does it exist in my array&lt;br /&gt;
	$produitKey = array_search($ref, $listProduits);&lt;br /&gt;
	if ($produitKey) {&lt;br /&gt;
// yes&lt;br /&gt;
		$fk_product = $produitKey;&lt;br /&gt;
	} else {&lt;br /&gt;
// no&lt;br /&gt;
// Create the product&lt;br /&gt;
		$newProduct = [&lt;br /&gt;
			&amp;quot;ref&amp;quot;	=&amp;gt; $ref,&lt;br /&gt;
			&amp;quot;label&amp;quot;	=&amp;gt; $ref&lt;br /&gt;
		];&lt;br /&gt;
		$newProductResult = CallAPI(&amp;quot;POST&amp;quot;, $apiKey, $apiUrl.&amp;quot;products&amp;quot;, json_encode($newProduct));&lt;br /&gt;
		$newProductResult = json_decode($newProductResult, true);&lt;br /&gt;
		if (isset($newProductResult[&amp;quot;error&amp;quot;]) &amp;amp;&amp;amp; $newProductResult[&amp;quot;error&amp;quot;][&amp;quot;code&amp;quot;] &amp;gt;= &amp;quot;300&amp;quot;) {&lt;br /&gt;
// there&#039;s been an error&lt;br /&gt;
			echo &amp;quot;&amp;lt;pre&amp;gt;ERROR&amp;quot;, var_dump($newProductResult), &amp;quot;&amp;lt;/pre&amp;gt;&amp;quot;;&lt;br /&gt;
			exit;&lt;br /&gt;
		} else {&lt;br /&gt;
// everything good&lt;br /&gt;
			$fk_product = $newProductResult;&lt;br /&gt;
			$listProduits[$fk_product] = $ref;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Comments :&lt;br /&gt;
&lt;br /&gt;
*I check if the ref of my product exist in the array created in the first example.&lt;br /&gt;
*If it exists, I use it&#039;s key in the array as ID&lt;br /&gt;
*If it doesn&#039;t exist, I create the product, then I add it to my array for next time then I use the ID created&lt;br /&gt;
*I choose this method to do less API calls when I have to import 500 orders. I just need to retrieve the products list once at the beginning instead of searching Dolibarr each time.&lt;br /&gt;
&lt;br /&gt;
Warning: The example below is not working properly. Creating an order and lines in one go is not supported. Instead you have to create an order first and with the returned order id add the lines using the /orders/{id}/lines endpoint. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
// create an order with 2 products&lt;br /&gt;
&lt;br /&gt;
// The array where there will be all the products lines of my order.&lt;br /&gt;
	$newCommandeLine = [];&lt;br /&gt;
&lt;br /&gt;
// product 1&lt;br /&gt;
	$ref1 = &amp;quot;my_product_ref_X203ZZ&amp;quot;;&lt;br /&gt;
	$prix1 = 10;&lt;br /&gt;
	$qtt1  = 100;&lt;br /&gt;
	$tva1 = 20;&lt;br /&gt;
	$fk_product1&lt;br /&gt;
// product 2&lt;br /&gt;
	$ref2 = &amp;quot;my_product_ref_B707FD&amp;quot;;&lt;br /&gt;
	$prix2 = 13;&lt;br /&gt;
	$qtt2  = 37;&lt;br /&gt;
	$tva2 = 20;&lt;br /&gt;
&lt;br /&gt;
	$newCommandeLine[] = [&lt;br /&gt;
		&amp;quot;desc&amp;quot;		=&amp;gt; $ref1,&lt;br /&gt;
		&amp;quot;subprice&amp;quot;	=&amp;gt; $prix1,&lt;br /&gt;
		&amp;quot;qty&amp;quot;		=&amp;gt; $qtt1,&lt;br /&gt;
		&amp;quot;tva_tx&amp;quot;	=&amp;gt; floatval($tva1),&lt;br /&gt;
		&amp;quot;fk_product&amp;quot;=&amp;gt; $fk_product1&lt;br /&gt;
	];&lt;br /&gt;
&lt;br /&gt;
	$newCommandeLine[] = [&lt;br /&gt;
		&amp;quot;desc&amp;quot;		=&amp;gt; $ref2,&lt;br /&gt;
		&amp;quot;subprice&amp;quot;	=&amp;gt; $prix2,&lt;br /&gt;
		&amp;quot;qty&amp;quot;		=&amp;gt; $qtt2,&lt;br /&gt;
		&amp;quot;tva_tx&amp;quot;	=&amp;gt; floatval($tva2),&lt;br /&gt;
		&amp;quot;fk_product&amp;quot;=&amp;gt; $fk_product2&lt;br /&gt;
	];&lt;br /&gt;
&lt;br /&gt;
	if (count($newCommandeLine) &amp;gt; 0) {&lt;br /&gt;
		$newCommande = [&lt;br /&gt;
			&amp;quot;socid&amp;quot;			=&amp;gt; $clientDoliId,&lt;br /&gt;
			&amp;quot;type&amp;quot; 			=&amp;gt; &amp;quot;0&amp;quot;,&lt;br /&gt;
			&amp;quot;lines&amp;quot;			=&amp;gt; $newCommandeLine,&lt;br /&gt;
			&amp;quot;note_private&amp;quot;	=&amp;gt; &amp;quot;order created automatically with API&amp;quot;,&lt;br /&gt;
		];&lt;br /&gt;
		$newCommandeResult = CallAPI(&amp;quot;POST&amp;quot;, $apiKey, $apiUrl.&amp;quot;orders&amp;quot;, json_encode($newCommande));&lt;br /&gt;
		$newCommandeResult = json_decode($newCommandeResult, true);&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Comments :&lt;br /&gt;
&lt;br /&gt;
*$clientDoliId is the ID of the customer in the Dolibarr database. Either you know it or you can search for it before&lt;br /&gt;
*type =&amp;gt; 0, This is a customer order (while 1 = supplier order)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
// Validate an order &lt;br /&gt;
	$newCommandeValider = [&lt;br /&gt;
		&amp;quot;idwarehouse&amp;quot;	=&amp;gt; &amp;quot;0&amp;quot;,&lt;br /&gt;
		&amp;quot;notrigger&amp;quot;		=&amp;gt; &amp;quot;0&amp;quot;&lt;br /&gt;
	];&lt;br /&gt;
	$newCommandeValiderResult = CallAPI(&amp;quot;POST&amp;quot;, $apiKey, $apiUrl.&amp;quot;orders/&amp;quot;.$newCommandeResult.&amp;quot;/validate&amp;quot;, json_encode($newCommandeValider));&lt;br /&gt;
	$newCommandeValiderResult = json_decode($newCommandeValiderResult, true);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Comments :&lt;br /&gt;
&lt;br /&gt;
*in this example, on the penultimate line, we can see : $apiUrl.&amp;quot;orders/&amp;quot;.$newCommandeResult.&amp;quot;/validate&amp;quot;.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$newCommandeResult is the ID of the order created in the previous example&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
// search in the database if a customer exist&lt;br /&gt;
	$customer_name = &amp;quot;Acme Inc&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
	$clientSearch = json_decode(CallAPI(&amp;quot;GET&amp;quot;, $apiKey, $apiUrl.&amp;quot;thirdparties&amp;quot;, array(&lt;br /&gt;
		&amp;quot;sortfield&amp;quot; =&amp;gt; &amp;quot;t.rowid&amp;quot;, &lt;br /&gt;
		&amp;quot;sortorder&amp;quot; =&amp;gt; &amp;quot;ASC&amp;quot;, &lt;br /&gt;
		&amp;quot;limit&amp;quot; =&amp;gt; &amp;quot;1&amp;quot;, &lt;br /&gt;
		&amp;quot;mode&amp;quot; =&amp;gt; &amp;quot;1&amp;quot;,&lt;br /&gt;
		&amp;quot;sqlfilters&amp;quot; =&amp;gt; &amp;quot;(t.nom:=:&#039;&amp;quot;.$customer_name.&amp;quot;&#039;)&amp;quot;&lt;br /&gt;
		)&lt;br /&gt;
	), true);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Comments :&lt;br /&gt;
&lt;br /&gt;
*limit =&amp;gt; 1 only 1 customer&lt;br /&gt;
*mode =&amp;gt; 1 we are looking for a customer, not a supplier (they are thirdparties too but with a different status)&lt;br /&gt;
*sqlfilters a bit special but there are more examples on the explorer page&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
// customer doesn&#039;t exist. Let&#039;s create it and get it&#039;s ID&lt;br /&gt;
	$newClient = [&lt;br /&gt;
		&amp;quot;name&amp;quot; 			=&amp;gt; &amp;quot;customer company name&amp;quot;,&lt;br /&gt;
		&amp;quot;email&amp;quot;			=&amp;gt; &amp;quot;customer company email&amp;quot;,&lt;br /&gt;
		&amp;quot;client&amp;quot; 		=&amp;gt; &amp;quot;1&amp;quot;,&lt;br /&gt;
		&amp;quot;code_client&amp;quot;	=&amp;gt; &amp;quot;-1&amp;quot;&lt;br /&gt;
	];&lt;br /&gt;
	$newClientResult = CallAPI(&amp;quot;POST&amp;quot;, $apiKey, $apiUrl.&amp;quot;thirdparties&amp;quot;, json_encode($newClient));&lt;br /&gt;
	$newClientResult = json_decode($newClientResult, true);&lt;br /&gt;
	$clientDoliId = $newClientResult;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Comments :&lt;br /&gt;
&lt;br /&gt;
*client =&amp;gt; 1 He is a customer (not a supplier)&lt;br /&gt;
*code_client =&amp;gt; -1 so the customer code will be generated automatically.&lt;br /&gt;
*we get the customer ID in $clientDoliId&lt;br /&gt;
&lt;br /&gt;
=Examples with Python=&lt;br /&gt;
See https://pypi.org/project/dolipy/ and https://pypi.org/project/dolibarr/&lt;br /&gt;
&lt;br /&gt;
First you can install the python-module with &amp;quot;pip install dolibarr&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
 from dolibarr import Dolibarr&lt;br /&gt;
&lt;br /&gt;
 api_url = &#039;&amp;lt;nowiki&amp;gt;http://your-url/dolibarr/htdocs/api/index.php/&#039;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 api_key = &#039;custom_API-Key&#039;&lt;br /&gt;
&lt;br /&gt;
 # Connection to dolibarr&lt;br /&gt;
 dolibarr_inst = Dolibarr(api_url, api_key)&lt;br /&gt;
&lt;br /&gt;
 # create Product&lt;br /&gt;
 params = {&#039;ref&#039;: &#039;Product_Reference&#039;, &#039;status&#039;: &#039;1&#039;, &#039;barcode_type&#039;: &#039;6&#039;, &#039;note_public&#039;: None,          &lt;br /&gt;
&lt;br /&gt;
           &#039;note_private&#039;: &amp;lt;nowiki&amp;gt;&#039;&#039;&amp;lt;/nowiki&amp;gt;, &#039;specimen&#039;: 0, &#039;label&#039;: &#039;Product_Label&#039;,&lt;br /&gt;
&lt;br /&gt;
           &#039;description&#039;: &amp;lt;nowiki&amp;gt;&#039;&#039;&amp;lt;/nowiki&amp;gt;, &#039;type&#039;: &#039;0&#039;, &#039;price&#039;: &amp;lt;nowiki&amp;gt;&#039;&#039;&amp;lt;/nowiki&amp;gt;, &#039;price_ttc&#039;: &#039;15.6000000&#039;, &#039;price_base_type&#039;: &#039;TTC&#039;,  # excl. tax = HT, incl. tax = TTC&lt;br /&gt;
&lt;br /&gt;
           &#039;tva_tx&#039;: &#039;19.0000&#039;, &#039;seuil_stock_alerte&#039;: &#039;0&#039;, &#039;desiredstock&#039;: &#039;0&#039;, &#039;status_buy&#039;: &#039;1&#039;, &#039;barcode&#039;: &#039;barcode&#039;}&lt;br /&gt;
&lt;br /&gt;
 ret_val = dolibarr_inst.call_create_api(&#039;products&#039;, params)&lt;br /&gt;
 print(ret_val)&lt;br /&gt;
&lt;br /&gt;
 # get product list&lt;br /&gt;
 product_dict = dolibarr_inst.call_list_api(&#039;products&#039;)&lt;br /&gt;
 print(product_dict)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Develop your own service / API=&lt;br /&gt;
Adding a new REST service is as easy than adding a file called &#039;&#039;&#039;api_mymoduleobject.class.php&#039;&#039;&#039; into the directory &#039;&#039;&#039;htdocs/mymodule/class&#039;&#039;&#039;.&lt;br /&gt;
You can take an example into &#039;&#039;&#039;htdocs/commande/class/api_orders.class.php&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Note that if you use the &#039;&#039;&#039;modulebuilder&#039;&#039;&#039; tool, this file may be generated for you.&lt;br /&gt;
&lt;br /&gt;
The framework detects automatically the API files and it should be visible into the explorer.&lt;br /&gt;
&lt;br /&gt;
Method and parameters are detected according to introspection done into PHP class of the object (&#039;&#039;&#039;htdocs/mymodule/class/object.class.php&#039;&#039;&#039;) using the &#039;&#039;&#039;annotations&#039;&#039;&#039; found into the class.&lt;br /&gt;
For a documentation about annotation: https://github.com/Luracast/Restler/blob/master/ANNOTATIONS.md&lt;br /&gt;
&lt;br /&gt;
These are just the basics.&lt;br /&gt;
&lt;br /&gt;
To find all existing API files in Dolibarr, you can search all files htdocs/&amp;lt;directory&amp;gt;/class/api_xxx_class.php&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=Module_Web_Services_API_REST_(developer)_JA&amp;diff=57163</id>
		<title>Module Web Services API REST (developer) JA</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=Module_Web_Services_API_REST_(developer)_JA&amp;diff=57163"/>
		<updated>2023-07-24T05:51:33Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: /* Function */&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_Web_Services_API_REST_(développeur)]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{TemplateDocDevEn}}&lt;br /&gt;
{{TemplateModEN}}&lt;br /&gt;
[[Category:List of Modules]]&lt;br /&gt;
{{BasculeDevUserEn|&lt;br /&gt;
name=Web services|&lt;br /&gt;
num=2610|&lt;br /&gt;
devdoc=This page|&lt;br /&gt;
userdoc=Not applicable|}}&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サーバが提供するウェブサービスを利用可能にできる. そこから、Dolibarrが提供する別のウェブサービスに REST 呼出しを実行することもできる.&lt;br /&gt;
&lt;br /&gt;
=Installation=&lt;br /&gt;
&lt;br /&gt;
To install, open the modules page and activate de &amp;quot;API REST&amp;quot; module. &lt;br /&gt;
&lt;br /&gt;
Once module webservices REST is activated, Dolibarr become also a server of REST web services. So you can send your own REST request to relative URL&lt;br /&gt;
&#039;&#039;&#039;/api/index.php/xxx&#039;&#039;&#039; where xxx is name of the API to call.&lt;br /&gt;
&lt;br /&gt;
A list of APIs on your installation can be found via the explorer. Click on link to explorer to open the API explorer.&lt;br /&gt;
&lt;br /&gt;
==Apache setup==&lt;br /&gt;
There is nothing to do. If your Dolibarr is working with Apache, the REST API should also work. APIs will be served by the same virtual web server than your application.&lt;br /&gt;
&lt;br /&gt;
==Nginx setup==&lt;br /&gt;
Like Apache, if your Dolibarr is working inside a NGinx virtual host, you should have nothing to do to have your API working. APIs will be served by the same virtual web server than your application.&lt;br /&gt;
&lt;br /&gt;
However, NGinx default setup on a lot of distribution is often a gaz engine and you may experience troubles. If you experience such troubles, you can try to edit your NGinx config file to match the following example. This is a simple localhost setup with a working REST API handling (tested with 9.0.1 on parabola gnu/linux).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;nginx&amp;quot;&amp;gt;&lt;br /&gt;
worker_processes  1;&lt;br /&gt;
error_log  /var/log/nginx/error.log;&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections  1024;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    include       mime.types;&lt;br /&gt;
    default_type  application/octet-stream;&lt;br /&gt;
&lt;br /&gt;
    #log_format  main  &#039;$remote_addr - $remote_user [$time_local] &amp;quot;$request&amp;quot; &#039;&lt;br /&gt;
    #                  &#039;$status $body_bytes_sent &amp;quot;$http_referer&amp;quot; &#039;&lt;br /&gt;
    #                  &#039;&amp;quot;$http_user_agent&amp;quot; &amp;quot;$http_x_forwarded_for&amp;quot;&#039;;&lt;br /&gt;
&lt;br /&gt;
    #access_log  logs/access.log  main;&lt;br /&gt;
&lt;br /&gt;
    sendfile        on;&lt;br /&gt;
    #tcp_nopush     on;&lt;br /&gt;
&lt;br /&gt;
    #keepalive_timeout  0;&lt;br /&gt;
    keepalive_timeout  65;&lt;br /&gt;
&lt;br /&gt;
    #gzip  on;&lt;br /&gt;
&lt;br /&gt;
    server {&lt;br /&gt;
    	listen		80;&lt;br /&gt;
        server_name     dolibarr.localhost; # adjust to your domain&lt;br /&gt;
&lt;br /&gt;
        root    /usr/share/webapps/dolibarr/htdocs; # adjust to your path &lt;br /&gt;
        index   index.php;&lt;br /&gt;
&lt;br /&gt;
        # from https://github.com/Dolibarr/dolibarr/issues/6163#issuecomment-391265538&lt;br /&gt;
        location ~ [^/]\.php(/|$) {&lt;br /&gt;
            fastcgi_split_path_info ^(.+?\.php)(/.*)$;&lt;br /&gt;
            if (!-f $document_root$fastcgi_script_name) {&lt;br /&gt;
                return 404;&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            # Mitigate https://httpoxy.org/ vulnerabilities&lt;br /&gt;
            fastcgi_param HTTP_PROXY &amp;quot;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
            root           /usr/share/webapps/dolibarr/htdocs;&lt;br /&gt;
            fastcgi_pass   unix:/run/php-fpm/php-fpm.sock;&lt;br /&gt;
            fastcgi_index  index.php;&lt;br /&gt;
            include        fastcgi_params;&lt;br /&gt;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;&lt;br /&gt;
            # Dolibarr Rest API path support&lt;br /&gt;
            fastcgi_param  PATH_INFO       $fastcgi_path_info;&lt;br /&gt;
            fastcgi_param  PATH_TRANSLATED $document_root$fastcgi_script_name;&lt;br /&gt;
        }&lt;br /&gt;
     }		&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=List of provided services=&lt;br /&gt;
Only few services are available. You can see full list of Dolibarr Web services provided, by calling the explorer here at address:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;http://yourdolibarrurl/api/index.php/explorer&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
For example, you can try the explorer on the demo instance at:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;https://demo.dolibarr.org/api/index.php/explorer&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On the top right corner, paste the &amp;lt;token&amp;gt; of the user you want to use to call the API and click the &amp;quot;explore&amp;quot; button. Note: The token of each user can be defined on the user record page. &lt;br /&gt;
If you prefer, you can first make a first call to the &#039;&#039;&#039;login&#039;&#039;&#039; API to get the API token key. Then enter API key to get list of all other available API services.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After clicking on &amp;quot;Explore&amp;quot;, you should see all the actions available with this token. If you don&#039;t have a lot of actions, it&#039;s probably because the according modules are not activated. If you want to see the invoices, you have to activate the invoice module in the configuration of Dolibarr. Same for products, third parties and so on.&lt;br /&gt;
&lt;br /&gt;
On this exploration page of the API, you can do quite a lot of tests. Reading datas from Dolibarr and writing, modifying and deleting as well. Warning: Data are really modified in your database.&lt;br /&gt;
&lt;br /&gt;
You can then test directly from the explorer tool any API. This is the recommended solution to test any Dolibarr API since any API and parameters is documented here. As a result of any test, you will get the answer but also example on how to call the API from command line using &#039;&#039;&#039;curl&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=Use=&lt;br /&gt;
&lt;br /&gt;
To use the REST API,  you have to call an url such as this one : &amp;lt;nowiki&amp;gt;http://&amp;lt;my_server&amp;gt;/api/index.php/&amp;lt;action&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
with one of the 4 following methods : GET, POST, PUT, DELETE, replacing &amp;lt;action&amp;gt; by the action you want to use. Ex : &amp;lt;nowiki&amp;gt;http://&amp;lt;my_server&amp;gt;/api/index.php/invoices&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before using any API, you must first get a custom API-key. You have to create a new user and generate or set its &amp;quot;Key for API&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
[[File:Dolibarr user for api.png|400px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will have to use this API key in any of your client program that need to call a Dolibarr API.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Client code example==&lt;br /&gt;
&lt;br /&gt;
===PHP===&lt;br /&gt;
There&#039;s different ways to do so. Here&#039;s a piece of code but you can also use libraries such as phphttpclient.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
// Example of function to call a REST API&lt;br /&gt;
function callAPI($method, $apikey, $url, $data = false)&lt;br /&gt;
{&lt;br /&gt;
    $curl = curl_init();&lt;br /&gt;
    $httpheader = [&#039;DOLAPIKEY: &#039;.$apikey];&lt;br /&gt;
&lt;br /&gt;
    switch ($method)&lt;br /&gt;
    {&lt;br /&gt;
        case &amp;quot;POST&amp;quot;:&lt;br /&gt;
            curl_setopt($curl, CURLOPT_POST, 1);&lt;br /&gt;
            $httpheader[] = &amp;quot;Content-Type:application/json&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
            if ($data)&lt;br /&gt;
                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);&lt;br /&gt;
&lt;br /&gt;
            break;&lt;br /&gt;
        case &amp;quot;PUT&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
	    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, &#039;PUT&#039;);&lt;br /&gt;
            $httpheader[] = &amp;quot;Content-Type:application/json&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
            if ($data)&lt;br /&gt;
                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);&lt;br /&gt;
&lt;br /&gt;
            break;&lt;br /&gt;
        default:&lt;br /&gt;
            if ($data)&lt;br /&gt;
                $url = sprintf(&amp;quot;%s?%s&amp;quot;, $url, http_build_query($data));&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Optional Authentication:&lt;br /&gt;
    //    curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);&lt;br /&gt;
    //    curl_setopt($curl, CURLOPT_USERPWD, &amp;quot;username:password&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    curl_setopt($curl, CURLOPT_URL, $url);&lt;br /&gt;
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);&lt;br /&gt;
    curl_setopt($curl, CURLOPT_HTTPHEADER, $httpheader);&lt;br /&gt;
&lt;br /&gt;
    $result = curl_exec($curl);&lt;br /&gt;
&lt;br /&gt;
    curl_close($curl);&lt;br /&gt;
&lt;br /&gt;
    return $result;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is just a working example. There&#039;s no error control and security was not in mind but you can use this code, modify it to suit your needs&amp;lt;br /&amp;gt;&lt;br /&gt;
The fonction has 4 parameters :&lt;br /&gt;
&lt;br /&gt;
*$method : string, &amp;quot;GET&amp;quot;, &amp;quot;POST&amp;quot;, &amp;quot;PUT&amp;quot;, &amp;quot;DELETE&amp;quot;&lt;br /&gt;
*$apikey : string, &amp;quot;your &amp;lt;token&amp;gt; generated earlier&amp;quot;&lt;br /&gt;
*$url : string, url to call. Ex : &amp;quot;&amp;lt;nowiki&amp;gt;http://&amp;lt;my_server&amp;gt;/api/index.php/invoices&amp;lt;/nowiki&amp;gt;&amp;quot;&lt;br /&gt;
*$data : string, datas in json format. This parameter is not mandatory.&lt;br /&gt;
&lt;br /&gt;
===Javascript Ajax===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
$.ajax({&lt;br /&gt;
  type: &#039;GET&#039;,&lt;br /&gt;
  async: true,&lt;br /&gt;
  contentType: &amp;quot;application/json; charset=utf-8&amp;quot;,&lt;br /&gt;
  data: { &#039;lang&#039;: &#039;en_US&#039; },&lt;br /&gt;
  dataType: &amp;quot;json&amp;quot;,&lt;br /&gt;
  cache: false,&lt;br /&gt;
  jsonp: false,&lt;br /&gt;
  headers: {&lt;br /&gt;
    &#039;DOLAPIKEY&#039;: &#039;abcdef123456&#039;&lt;br /&gt;
  }, &lt;br /&gt;
  url: &#039;https://myserver/api/index.php/theapi&#039;,&lt;br /&gt;
  success: function(rep) {&lt;br /&gt;
    console.log(&amp;quot;API call success&amp;quot;);&lt;br /&gt;
    console.log(rep);&lt;br /&gt;
  },&lt;br /&gt;
  error: function(rep) {&lt;br /&gt;
    console.log(&amp;quot;API call error&amp;quot;);&lt;br /&gt;
    console.log(rep);&lt;br /&gt;
  }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Accepted parameters==&lt;br /&gt;
This is documented somewhat in the REST Explorer. Check that first. Second try and see what response you get. Third look at the source code for the given API.&lt;br /&gt;
&lt;br /&gt;
===sqlfilters===&lt;br /&gt;
They are passed on to the database after a check.&lt;br /&gt;
These work on the product endpoint:&lt;br /&gt;
&lt;br /&gt;
*(t.fk_product_type: = :&#039;0&#039;) and (t.tosell: = :&#039;1&#039;) and (t.label: ilike :&#039;%string&#039;)&lt;br /&gt;
&lt;br /&gt;
===Date===&lt;br /&gt;
The ISO date format is accepted: %Y-%m-%d e.g. 2020-07-14. yymmdd is not accepted.&lt;br /&gt;
&lt;br /&gt;
=Examples with PHP=&lt;br /&gt;
&lt;br /&gt;
This is more examples, for different uses cases:&lt;br /&gt;
&lt;br /&gt;
In every examples, we have:&lt;br /&gt;
&lt;br /&gt;
*$apiKey = &amp;quot;&amp;lt;my token&amp;gt;&amp;quot;;&lt;br /&gt;
*$apiUrl = &amp;quot;&amp;lt;nowiki&amp;gt;http://&amp;lt;my_server&amp;gt;/api/index.php/&amp;lt;/nowiki&amp;gt;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
// Retrieve products list&lt;br /&gt;
	$listProduits = [];&lt;br /&gt;
	$produitParam = [&amp;quot;limit&amp;quot; =&amp;gt; 10000, &amp;quot;sortfield&amp;quot; =&amp;gt; &amp;quot;rowid&amp;quot;];&lt;br /&gt;
	$listProduitsResult = CallAPI(&amp;quot;GET&amp;quot;, $apiKey, $apiUrl.&amp;quot;products&amp;quot;, $produitParam);&lt;br /&gt;
	$listProduitsResult = json_decode($listProduitsResult, true);&lt;br /&gt;
&lt;br /&gt;
	if (isset($listProduitsResult[&amp;quot;error&amp;quot;]) &amp;amp;&amp;amp; $listProduitsResult[&amp;quot;error&amp;quot;][&amp;quot;code&amp;quot;] &amp;gt;= &amp;quot;300&amp;quot;) {&lt;br /&gt;
	} else {&lt;br /&gt;
		foreach ($listProduitsResult as $produit) {&lt;br /&gt;
			$listProduits[intval($produit[&amp;quot;id&amp;quot;])] = html_entity_decode($produit[&amp;quot;ref&amp;quot;], ENT_QUOTES);&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Comments :&lt;br /&gt;
&lt;br /&gt;
*I retrieve the 10&#039;000 first products sorted on their ID in the base&lt;br /&gt;
*html_entity_decode is necessary as single quotes are encoded&lt;br /&gt;
*It&#039;s easy to use the same method (replacing products with dictionnarycountries) to retrieve the list of countries and their ID&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
// Create a product&lt;br /&gt;
	$ref = &amp;quot;my_product_ref_X203ZZ&amp;quot;;&lt;br /&gt;
	$newProduct = [&lt;br /&gt;
		&amp;quot;ref&amp;quot;	=&amp;gt; $ref,&lt;br /&gt;
		&amp;quot;label&amp;quot;	=&amp;gt; $ref&lt;br /&gt;
	];&lt;br /&gt;
	$newProductResult = CallAPI(&amp;quot;POST&amp;quot;, $apiKey, $apiUrl.&amp;quot;products&amp;quot;, json_encode($newProduct));&lt;br /&gt;
	$newProductResult = json_decode($newProductResult, true);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Comments :&lt;br /&gt;
&lt;br /&gt;
*before creating a product, it could be wise to check if it exists. Using my first example, you&#039;ll have  :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
// my ref&lt;br /&gt;
	$ref = &amp;quot;my_product_ref_X203ZZ&amp;quot;;&lt;br /&gt;
// does it exist in my array&lt;br /&gt;
	$produitKey = array_search($ref, $listProduits);&lt;br /&gt;
	if ($produitKey) {&lt;br /&gt;
// yes&lt;br /&gt;
		$fk_product = $produitKey;&lt;br /&gt;
	} else {&lt;br /&gt;
// no&lt;br /&gt;
// Create the product&lt;br /&gt;
		$newProduct = [&lt;br /&gt;
			&amp;quot;ref&amp;quot;	=&amp;gt; $ref,&lt;br /&gt;
			&amp;quot;label&amp;quot;	=&amp;gt; $ref&lt;br /&gt;
		];&lt;br /&gt;
		$newProductResult = CallAPI(&amp;quot;POST&amp;quot;, $apiKey, $apiUrl.&amp;quot;products&amp;quot;, json_encode($newProduct));&lt;br /&gt;
		$newProductResult = json_decode($newProductResult, true);&lt;br /&gt;
		if (isset($newProductResult[&amp;quot;error&amp;quot;]) &amp;amp;&amp;amp; $newProductResult[&amp;quot;error&amp;quot;][&amp;quot;code&amp;quot;] &amp;gt;= &amp;quot;300&amp;quot;) {&lt;br /&gt;
// there&#039;s been an error&lt;br /&gt;
			echo &amp;quot;&amp;lt;pre&amp;gt;ERROR&amp;quot;, var_dump($newProductResult), &amp;quot;&amp;lt;/pre&amp;gt;&amp;quot;;&lt;br /&gt;
			exit;&lt;br /&gt;
		} else {&lt;br /&gt;
// everything good&lt;br /&gt;
			$fk_product = $newProductResult;&lt;br /&gt;
			$listProduits[$fk_product] = $ref;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Comments :&lt;br /&gt;
&lt;br /&gt;
*I check if the ref of my product exist in the array created in the first example.&lt;br /&gt;
*If it exists, I use it&#039;s key in the array as ID&lt;br /&gt;
*If it doesn&#039;t exist, I create the product, then I add it to my array for next time then I use the ID created&lt;br /&gt;
*I choose this method to do less API calls when I have to import 500 orders. I just need to retrieve the products list once at the beginning instead of searching Dolibarr each time.&lt;br /&gt;
&lt;br /&gt;
Warning: The example below is not working properly. Creating an order and lines in one go is not supported. Instead you have to create an order first and with the returned order id add the lines using the /orders/{id}/lines endpoint. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
// create an order with 2 products&lt;br /&gt;
&lt;br /&gt;
// The array where there will be all the products lines of my order.&lt;br /&gt;
	$newCommandeLine = [];&lt;br /&gt;
&lt;br /&gt;
// product 1&lt;br /&gt;
	$ref1 = &amp;quot;my_product_ref_X203ZZ&amp;quot;;&lt;br /&gt;
	$prix1 = 10;&lt;br /&gt;
	$qtt1  = 100;&lt;br /&gt;
	$tva1 = 20;&lt;br /&gt;
	$fk_product1&lt;br /&gt;
// product 2&lt;br /&gt;
	$ref2 = &amp;quot;my_product_ref_B707FD&amp;quot;;&lt;br /&gt;
	$prix2 = 13;&lt;br /&gt;
	$qtt2  = 37;&lt;br /&gt;
	$tva2 = 20;&lt;br /&gt;
&lt;br /&gt;
	$newCommandeLine[] = [&lt;br /&gt;
		&amp;quot;desc&amp;quot;		=&amp;gt; $ref1,&lt;br /&gt;
		&amp;quot;subprice&amp;quot;	=&amp;gt; $prix1,&lt;br /&gt;
		&amp;quot;qty&amp;quot;		=&amp;gt; $qtt1,&lt;br /&gt;
		&amp;quot;tva_tx&amp;quot;	=&amp;gt; floatval($tva1),&lt;br /&gt;
		&amp;quot;fk_product&amp;quot;=&amp;gt; $fk_product1&lt;br /&gt;
	];&lt;br /&gt;
&lt;br /&gt;
	$newCommandeLine[] = [&lt;br /&gt;
		&amp;quot;desc&amp;quot;		=&amp;gt; $ref2,&lt;br /&gt;
		&amp;quot;subprice&amp;quot;	=&amp;gt; $prix2,&lt;br /&gt;
		&amp;quot;qty&amp;quot;		=&amp;gt; $qtt2,&lt;br /&gt;
		&amp;quot;tva_tx&amp;quot;	=&amp;gt; floatval($tva2),&lt;br /&gt;
		&amp;quot;fk_product&amp;quot;=&amp;gt; $fk_product2&lt;br /&gt;
	];&lt;br /&gt;
&lt;br /&gt;
	if (count($newCommandeLine) &amp;gt; 0) {&lt;br /&gt;
		$newCommande = [&lt;br /&gt;
			&amp;quot;socid&amp;quot;			=&amp;gt; $clientDoliId,&lt;br /&gt;
			&amp;quot;type&amp;quot; 			=&amp;gt; &amp;quot;0&amp;quot;,&lt;br /&gt;
			&amp;quot;lines&amp;quot;			=&amp;gt; $newCommandeLine,&lt;br /&gt;
			&amp;quot;note_private&amp;quot;	=&amp;gt; &amp;quot;order created automatically with API&amp;quot;,&lt;br /&gt;
		];&lt;br /&gt;
		$newCommandeResult = CallAPI(&amp;quot;POST&amp;quot;, $apiKey, $apiUrl.&amp;quot;orders&amp;quot;, json_encode($newCommande));&lt;br /&gt;
		$newCommandeResult = json_decode($newCommandeResult, true);&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Comments :&lt;br /&gt;
&lt;br /&gt;
*$clientDoliId is the ID of the customer in the Dolibarr database. Either you know it or you can search for it before&lt;br /&gt;
*type =&amp;gt; 0, This is a customer order (while 1 = supplier order)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
// Validate an order &lt;br /&gt;
	$newCommandeValider = [&lt;br /&gt;
		&amp;quot;idwarehouse&amp;quot;	=&amp;gt; &amp;quot;0&amp;quot;,&lt;br /&gt;
		&amp;quot;notrigger&amp;quot;		=&amp;gt; &amp;quot;0&amp;quot;&lt;br /&gt;
	];&lt;br /&gt;
	$newCommandeValiderResult = CallAPI(&amp;quot;POST&amp;quot;, $apiKey, $apiUrl.&amp;quot;orders/&amp;quot;.$newCommandeResult.&amp;quot;/validate&amp;quot;, json_encode($newCommandeValider));&lt;br /&gt;
	$newCommandeValiderResult = json_decode($newCommandeValiderResult, true);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Comments :&lt;br /&gt;
&lt;br /&gt;
*in this example, on the penultimate line, we can see : $apiUrl.&amp;quot;orders/&amp;quot;.$newCommandeResult.&amp;quot;/validate&amp;quot;.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$newCommandeResult is the ID of the order created in the previous example&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
// search in the database if a customer exist&lt;br /&gt;
	$customer_name = &amp;quot;Acme Inc&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
	$clientSearch = json_decode(CallAPI(&amp;quot;GET&amp;quot;, $apiKey, $apiUrl.&amp;quot;thirdparties&amp;quot;, array(&lt;br /&gt;
		&amp;quot;sortfield&amp;quot; =&amp;gt; &amp;quot;t.rowid&amp;quot;, &lt;br /&gt;
		&amp;quot;sortorder&amp;quot; =&amp;gt; &amp;quot;ASC&amp;quot;, &lt;br /&gt;
		&amp;quot;limit&amp;quot; =&amp;gt; &amp;quot;1&amp;quot;, &lt;br /&gt;
		&amp;quot;mode&amp;quot; =&amp;gt; &amp;quot;1&amp;quot;,&lt;br /&gt;
		&amp;quot;sqlfilters&amp;quot; =&amp;gt; &amp;quot;(t.nom:=:&#039;&amp;quot;.$customer_name.&amp;quot;&#039;)&amp;quot;&lt;br /&gt;
		)&lt;br /&gt;
	), true);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Comments :&lt;br /&gt;
&lt;br /&gt;
*limit =&amp;gt; 1 only 1 customer&lt;br /&gt;
*mode =&amp;gt; 1 we are looking for a customer, not a supplier (they are thirdparties too but with a different status)&lt;br /&gt;
*sqlfilters a bit special but there are more examples on the explorer page&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
// customer doesn&#039;t exist. Let&#039;s create it and get it&#039;s ID&lt;br /&gt;
	$newClient = [&lt;br /&gt;
		&amp;quot;name&amp;quot; 			=&amp;gt; &amp;quot;customer company name&amp;quot;,&lt;br /&gt;
		&amp;quot;email&amp;quot;			=&amp;gt; &amp;quot;customer company email&amp;quot;,&lt;br /&gt;
		&amp;quot;client&amp;quot; 		=&amp;gt; &amp;quot;1&amp;quot;,&lt;br /&gt;
		&amp;quot;code_client&amp;quot;	=&amp;gt; &amp;quot;-1&amp;quot;&lt;br /&gt;
	];&lt;br /&gt;
	$newClientResult = CallAPI(&amp;quot;POST&amp;quot;, $apiKey, $apiUrl.&amp;quot;thirdparties&amp;quot;, json_encode($newClient));&lt;br /&gt;
	$newClientResult = json_decode($newClientResult, true);&lt;br /&gt;
	$clientDoliId = $newClientResult;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Comments :&lt;br /&gt;
&lt;br /&gt;
*client =&amp;gt; 1 He is a customer (not a supplier)&lt;br /&gt;
*code_client =&amp;gt; -1 so the customer code will be generated automatically.&lt;br /&gt;
*we get the customer ID in $clientDoliId&lt;br /&gt;
&lt;br /&gt;
=Examples with Python=&lt;br /&gt;
See https://pypi.org/project/dolipy/ and https://pypi.org/project/dolibarr/&lt;br /&gt;
&lt;br /&gt;
First you can install the python-module with &amp;quot;pip install dolibarr&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
 from dolibarr import Dolibarr&lt;br /&gt;
&lt;br /&gt;
 api_url = &#039;&amp;lt;nowiki&amp;gt;http://your-url/dolibarr/htdocs/api/index.php/&#039;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 api_key = &#039;custom_API-Key&#039;&lt;br /&gt;
&lt;br /&gt;
 # Connection to dolibarr&lt;br /&gt;
 dolibarr_inst = Dolibarr(api_url, api_key)&lt;br /&gt;
&lt;br /&gt;
 # create Product&lt;br /&gt;
 params = {&#039;ref&#039;: &#039;Product_Reference&#039;, &#039;status&#039;: &#039;1&#039;, &#039;barcode_type&#039;: &#039;6&#039;, &#039;note_public&#039;: None,          &lt;br /&gt;
&lt;br /&gt;
           &#039;note_private&#039;: &amp;lt;nowiki&amp;gt;&#039;&#039;&amp;lt;/nowiki&amp;gt;, &#039;specimen&#039;: 0, &#039;label&#039;: &#039;Product_Label&#039;,&lt;br /&gt;
&lt;br /&gt;
           &#039;description&#039;: &amp;lt;nowiki&amp;gt;&#039;&#039;&amp;lt;/nowiki&amp;gt;, &#039;type&#039;: &#039;0&#039;, &#039;price&#039;: &amp;lt;nowiki&amp;gt;&#039;&#039;&amp;lt;/nowiki&amp;gt;, &#039;price_ttc&#039;: &#039;15.6000000&#039;, &#039;price_base_type&#039;: &#039;TTC&#039;,  # excl. tax = HT, incl. tax = TTC&lt;br /&gt;
&lt;br /&gt;
           &#039;tva_tx&#039;: &#039;19.0000&#039;, &#039;seuil_stock_alerte&#039;: &#039;0&#039;, &#039;desiredstock&#039;: &#039;0&#039;, &#039;status_buy&#039;: &#039;1&#039;, &#039;barcode&#039;: &#039;barcode&#039;}&lt;br /&gt;
&lt;br /&gt;
 ret_val = dolibarr_inst.call_create_api(&#039;products&#039;, params)&lt;br /&gt;
 print(ret_val)&lt;br /&gt;
&lt;br /&gt;
 # get product list&lt;br /&gt;
 product_dict = dolibarr_inst.call_list_api(&#039;products&#039;)&lt;br /&gt;
 print(product_dict)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Develop your own service / API=&lt;br /&gt;
Adding a new REST service is as easy than adding a file called &#039;&#039;&#039;api_mymoduleobject.class.php&#039;&#039;&#039; into the directory &#039;&#039;&#039;htdocs/mymodule/class&#039;&#039;&#039;.&lt;br /&gt;
You can take an example into &#039;&#039;&#039;htdocs/commande/class/api_orders.class.php&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Note that if you use the &#039;&#039;&#039;modulebuilder&#039;&#039;&#039; tool, this file may be generated for you.&lt;br /&gt;
&lt;br /&gt;
The framework detects automatically the API files and it should be visible into the explorer.&lt;br /&gt;
&lt;br /&gt;
Method and parameters are detected according to introspection done into PHP class of the object (&#039;&#039;&#039;htdocs/mymodule/class/object.class.php&#039;&#039;&#039;) using the &#039;&#039;&#039;annotations&#039;&#039;&#039; found into the class.&lt;br /&gt;
For a documentation about annotation: https://github.com/Luracast/Restler/blob/master/ANNOTATIONS.md&lt;br /&gt;
&lt;br /&gt;
These are just the basics.&lt;br /&gt;
&lt;br /&gt;
To find all existing API files in Dolibarr, you can search all files htdocs/&amp;lt;directory&amp;gt;/class/api_xxx_class.php&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=Module_Web_Services_API_REST_(developer)_JA&amp;diff=57161</id>
		<title>Module Web Services API REST (developer) JA</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=Module_Web_Services_API_REST_(developer)_JA&amp;diff=57161"/>
		<updated>2023-07-24T05:18:50Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: Copied from EN version.&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_Web_Services_API_REST_(développeur)]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{TemplateDocDevEn}}&lt;br /&gt;
{{TemplateModEN}}&lt;br /&gt;
[[Category:List of Modules]]&lt;br /&gt;
{{BasculeDevUserEn|&lt;br /&gt;
name=Web services|&lt;br /&gt;
num=2610|&lt;br /&gt;
devdoc=This page|&lt;br /&gt;
userdoc=Not applicable|}}&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;
=Function=&lt;br /&gt;
When enabling this module, you enable usage of web services provided by Dolibarr server. You can then make REST call of different web services provided by Dolibarr.&lt;br /&gt;
&lt;br /&gt;
=Installation=&lt;br /&gt;
&lt;br /&gt;
To install, open the modules page and activate de &amp;quot;API REST&amp;quot; module. &lt;br /&gt;
&lt;br /&gt;
Once module webservices REST is activated, Dolibarr become also a server of REST web services. So you can send your own REST request to relative URL&lt;br /&gt;
&#039;&#039;&#039;/api/index.php/xxx&#039;&#039;&#039; where xxx is name of the API to call.&lt;br /&gt;
&lt;br /&gt;
A list of APIs on your installation can be found via the explorer. Click on link to explorer to open the API explorer.&lt;br /&gt;
&lt;br /&gt;
==Apache setup==&lt;br /&gt;
There is nothing to do. If your Dolibarr is working with Apache, the REST API should also work. APIs will be served by the same virtual web server than your application.&lt;br /&gt;
&lt;br /&gt;
==Nginx setup==&lt;br /&gt;
Like Apache, if your Dolibarr is working inside a NGinx virtual host, you should have nothing to do to have your API working. APIs will be served by the same virtual web server than your application.&lt;br /&gt;
&lt;br /&gt;
However, NGinx default setup on a lot of distribution is often a gaz engine and you may experience troubles. If you experience such troubles, you can try to edit your NGinx config file to match the following example. This is a simple localhost setup with a working REST API handling (tested with 9.0.1 on parabola gnu/linux).&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;nginx&amp;quot;&amp;gt;&lt;br /&gt;
worker_processes  1;&lt;br /&gt;
error_log  /var/log/nginx/error.log;&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections  1024;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    include       mime.types;&lt;br /&gt;
    default_type  application/octet-stream;&lt;br /&gt;
&lt;br /&gt;
    #log_format  main  &#039;$remote_addr - $remote_user [$time_local] &amp;quot;$request&amp;quot; &#039;&lt;br /&gt;
    #                  &#039;$status $body_bytes_sent &amp;quot;$http_referer&amp;quot; &#039;&lt;br /&gt;
    #                  &#039;&amp;quot;$http_user_agent&amp;quot; &amp;quot;$http_x_forwarded_for&amp;quot;&#039;;&lt;br /&gt;
&lt;br /&gt;
    #access_log  logs/access.log  main;&lt;br /&gt;
&lt;br /&gt;
    sendfile        on;&lt;br /&gt;
    #tcp_nopush     on;&lt;br /&gt;
&lt;br /&gt;
    #keepalive_timeout  0;&lt;br /&gt;
    keepalive_timeout  65;&lt;br /&gt;
&lt;br /&gt;
    #gzip  on;&lt;br /&gt;
&lt;br /&gt;
    server {&lt;br /&gt;
    	listen		80;&lt;br /&gt;
        server_name     dolibarr.localhost; # adjust to your domain&lt;br /&gt;
&lt;br /&gt;
        root    /usr/share/webapps/dolibarr/htdocs; # adjust to your path &lt;br /&gt;
        index   index.php;&lt;br /&gt;
&lt;br /&gt;
        # from https://github.com/Dolibarr/dolibarr/issues/6163#issuecomment-391265538&lt;br /&gt;
        location ~ [^/]\.php(/|$) {&lt;br /&gt;
            fastcgi_split_path_info ^(.+?\.php)(/.*)$;&lt;br /&gt;
            if (!-f $document_root$fastcgi_script_name) {&lt;br /&gt;
                return 404;&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            # Mitigate https://httpoxy.org/ vulnerabilities&lt;br /&gt;
            fastcgi_param HTTP_PROXY &amp;quot;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
            root           /usr/share/webapps/dolibarr/htdocs;&lt;br /&gt;
            fastcgi_pass   unix:/run/php-fpm/php-fpm.sock;&lt;br /&gt;
            fastcgi_index  index.php;&lt;br /&gt;
            include        fastcgi_params;&lt;br /&gt;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;&lt;br /&gt;
            # Dolibarr Rest API path support&lt;br /&gt;
            fastcgi_param  PATH_INFO       $fastcgi_path_info;&lt;br /&gt;
            fastcgi_param  PATH_TRANSLATED $document_root$fastcgi_script_name;&lt;br /&gt;
        }&lt;br /&gt;
     }		&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=List of provided services=&lt;br /&gt;
Only few services are available. You can see full list of Dolibarr Web services provided, by calling the explorer here at address:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;http://yourdolibarrurl/api/index.php/explorer&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
For example, you can try the explorer on the demo instance at:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;https://demo.dolibarr.org/api/index.php/explorer&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
On the top right corner, paste the &amp;lt;token&amp;gt; of the user you want to use to call the API and click the &amp;quot;explore&amp;quot; button. Note: The token of each user can be defined on the user record page. &lt;br /&gt;
If you prefer, you can first make a first call to the &#039;&#039;&#039;login&#039;&#039;&#039; API to get the API token key. Then enter API key to get list of all other available API services.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After clicking on &amp;quot;Explore&amp;quot;, you should see all the actions available with this token. If you don&#039;t have a lot of actions, it&#039;s probably because the according modules are not activated. If you want to see the invoices, you have to activate the invoice module in the configuration of Dolibarr. Same for products, third parties and so on.&lt;br /&gt;
&lt;br /&gt;
On this exploration page of the API, you can do quite a lot of tests. Reading datas from Dolibarr and writing, modifying and deleting as well. Warning: Data are really modified in your database.&lt;br /&gt;
&lt;br /&gt;
You can then test directly from the explorer tool any API. This is the recommended solution to test any Dolibarr API since any API and parameters is documented here. As a result of any test, you will get the answer but also example on how to call the API from command line using &#039;&#039;&#039;curl&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=Use=&lt;br /&gt;
&lt;br /&gt;
To use the REST API,  you have to call an url such as this one : &amp;lt;nowiki&amp;gt;http://&amp;lt;my_server&amp;gt;/api/index.php/&amp;lt;action&amp;gt;&amp;lt;/nowiki&amp;gt;&amp;lt;br /&amp;gt;&lt;br /&gt;
with one of the 4 following methods : GET, POST, PUT, DELETE, replacing &amp;lt;action&amp;gt; by the action you want to use. Ex : &amp;lt;nowiki&amp;gt;http://&amp;lt;my_server&amp;gt;/api/index.php/invoices&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Before using any API, you must first get a custom API-key. You have to create a new user and generate or set its &amp;quot;Key for API&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
[[File:Dolibarr user for api.png|400px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You will have to use this API key in any of your client program that need to call a Dolibarr API.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Client code example==&lt;br /&gt;
&lt;br /&gt;
===PHP===&lt;br /&gt;
There&#039;s different ways to do so. Here&#039;s a piece of code but you can also use libraries such as phphttpclient.com&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
// Example of function to call a REST API&lt;br /&gt;
function callAPI($method, $apikey, $url, $data = false)&lt;br /&gt;
{&lt;br /&gt;
    $curl = curl_init();&lt;br /&gt;
    $httpheader = [&#039;DOLAPIKEY: &#039;.$apikey];&lt;br /&gt;
&lt;br /&gt;
    switch ($method)&lt;br /&gt;
    {&lt;br /&gt;
        case &amp;quot;POST&amp;quot;:&lt;br /&gt;
            curl_setopt($curl, CURLOPT_POST, 1);&lt;br /&gt;
            $httpheader[] = &amp;quot;Content-Type:application/json&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
            if ($data)&lt;br /&gt;
                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);&lt;br /&gt;
&lt;br /&gt;
            break;&lt;br /&gt;
        case &amp;quot;PUT&amp;quot;:&lt;br /&gt;
&lt;br /&gt;
	    curl_setopt($curl, CURLOPT_CUSTOMREQUEST, &#039;PUT&#039;);&lt;br /&gt;
            $httpheader[] = &amp;quot;Content-Type:application/json&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
            if ($data)&lt;br /&gt;
                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);&lt;br /&gt;
&lt;br /&gt;
            break;&lt;br /&gt;
        default:&lt;br /&gt;
            if ($data)&lt;br /&gt;
                $url = sprintf(&amp;quot;%s?%s&amp;quot;, $url, http_build_query($data));&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    // Optional Authentication:&lt;br /&gt;
    //    curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);&lt;br /&gt;
    //    curl_setopt($curl, CURLOPT_USERPWD, &amp;quot;username:password&amp;quot;);&lt;br /&gt;
&lt;br /&gt;
    curl_setopt($curl, CURLOPT_URL, $url);&lt;br /&gt;
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);&lt;br /&gt;
    curl_setopt($curl, CURLOPT_HTTPHEADER, $httpheader);&lt;br /&gt;
&lt;br /&gt;
    $result = curl_exec($curl);&lt;br /&gt;
&lt;br /&gt;
    curl_close($curl);&lt;br /&gt;
&lt;br /&gt;
    return $result;&lt;br /&gt;
}&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is just a working example. There&#039;s no error control and security was not in mind but you can use this code, modify it to suit your needs&amp;lt;br /&amp;gt;&lt;br /&gt;
The fonction has 4 parameters :&lt;br /&gt;
&lt;br /&gt;
*$method : string, &amp;quot;GET&amp;quot;, &amp;quot;POST&amp;quot;, &amp;quot;PUT&amp;quot;, &amp;quot;DELETE&amp;quot;&lt;br /&gt;
*$apikey : string, &amp;quot;your &amp;lt;token&amp;gt; generated earlier&amp;quot;&lt;br /&gt;
*$url : string, url to call. Ex : &amp;quot;&amp;lt;nowiki&amp;gt;http://&amp;lt;my_server&amp;gt;/api/index.php/invoices&amp;lt;/nowiki&amp;gt;&amp;quot;&lt;br /&gt;
*$data : string, datas in json format. This parameter is not mandatory.&lt;br /&gt;
&lt;br /&gt;
===Javascript Ajax===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;javascript&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;script&amp;gt;&lt;br /&gt;
$.ajax({&lt;br /&gt;
  type: &#039;GET&#039;,&lt;br /&gt;
  async: true,&lt;br /&gt;
  contentType: &amp;quot;application/json; charset=utf-8&amp;quot;,&lt;br /&gt;
  data: { &#039;lang&#039;: &#039;en_US&#039; },&lt;br /&gt;
  dataType: &amp;quot;json&amp;quot;,&lt;br /&gt;
  cache: false,&lt;br /&gt;
  jsonp: false,&lt;br /&gt;
  headers: {&lt;br /&gt;
    &#039;DOLAPIKEY&#039;: &#039;abcdef123456&#039;&lt;br /&gt;
  }, &lt;br /&gt;
  url: &#039;https://myserver/api/index.php/theapi&#039;,&lt;br /&gt;
  success: function(rep) {&lt;br /&gt;
    console.log(&amp;quot;API call success&amp;quot;);&lt;br /&gt;
    console.log(rep);&lt;br /&gt;
  },&lt;br /&gt;
  error: function(rep) {&lt;br /&gt;
    console.log(&amp;quot;API call error&amp;quot;);&lt;br /&gt;
    console.log(rep);&lt;br /&gt;
  }&lt;br /&gt;
});&lt;br /&gt;
&amp;lt;/script&amp;gt;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Accepted parameters==&lt;br /&gt;
This is documented somewhat in the REST Explorer. Check that first. Second try and see what response you get. Third look at the source code for the given API.&lt;br /&gt;
&lt;br /&gt;
===sqlfilters===&lt;br /&gt;
They are passed on to the database after a check.&lt;br /&gt;
These work on the product endpoint:&lt;br /&gt;
&lt;br /&gt;
*(t.fk_product_type: = :&#039;0&#039;) and (t.tosell: = :&#039;1&#039;) and (t.label: ilike :&#039;%string&#039;)&lt;br /&gt;
&lt;br /&gt;
===Date===&lt;br /&gt;
The ISO date format is accepted: %Y-%m-%d e.g. 2020-07-14. yymmdd is not accepted.&lt;br /&gt;
&lt;br /&gt;
=Examples with PHP=&lt;br /&gt;
&lt;br /&gt;
This is more examples, for different uses cases:&lt;br /&gt;
&lt;br /&gt;
In every examples, we have:&lt;br /&gt;
&lt;br /&gt;
*$apiKey = &amp;quot;&amp;lt;my token&amp;gt;&amp;quot;;&lt;br /&gt;
*$apiUrl = &amp;quot;&amp;lt;nowiki&amp;gt;http://&amp;lt;my_server&amp;gt;/api/index.php/&amp;lt;/nowiki&amp;gt;&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
// Retrieve products list&lt;br /&gt;
	$listProduits = [];&lt;br /&gt;
	$produitParam = [&amp;quot;limit&amp;quot; =&amp;gt; 10000, &amp;quot;sortfield&amp;quot; =&amp;gt; &amp;quot;rowid&amp;quot;];&lt;br /&gt;
	$listProduitsResult = CallAPI(&amp;quot;GET&amp;quot;, $apiKey, $apiUrl.&amp;quot;products&amp;quot;, $produitParam);&lt;br /&gt;
	$listProduitsResult = json_decode($listProduitsResult, true);&lt;br /&gt;
&lt;br /&gt;
	if (isset($listProduitsResult[&amp;quot;error&amp;quot;]) &amp;amp;&amp;amp; $listProduitsResult[&amp;quot;error&amp;quot;][&amp;quot;code&amp;quot;] &amp;gt;= &amp;quot;300&amp;quot;) {&lt;br /&gt;
	} else {&lt;br /&gt;
		foreach ($listProduitsResult as $produit) {&lt;br /&gt;
			$listProduits[intval($produit[&amp;quot;id&amp;quot;])] = html_entity_decode($produit[&amp;quot;ref&amp;quot;], ENT_QUOTES);&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Comments :&lt;br /&gt;
&lt;br /&gt;
*I retrieve the 10&#039;000 first products sorted on their ID in the base&lt;br /&gt;
*html_entity_decode is necessary as single quotes are encoded&lt;br /&gt;
*It&#039;s easy to use the same method (replacing products with dictionnarycountries) to retrieve the list of countries and their ID&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
// Create a product&lt;br /&gt;
	$ref = &amp;quot;my_product_ref_X203ZZ&amp;quot;;&lt;br /&gt;
	$newProduct = [&lt;br /&gt;
		&amp;quot;ref&amp;quot;	=&amp;gt; $ref,&lt;br /&gt;
		&amp;quot;label&amp;quot;	=&amp;gt; $ref&lt;br /&gt;
	];&lt;br /&gt;
	$newProductResult = CallAPI(&amp;quot;POST&amp;quot;, $apiKey, $apiUrl.&amp;quot;products&amp;quot;, json_encode($newProduct));&lt;br /&gt;
	$newProductResult = json_decode($newProductResult, true);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Comments :&lt;br /&gt;
&lt;br /&gt;
*before creating a product, it could be wise to check if it exists. Using my first example, you&#039;ll have  :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
// my ref&lt;br /&gt;
	$ref = &amp;quot;my_product_ref_X203ZZ&amp;quot;;&lt;br /&gt;
// does it exist in my array&lt;br /&gt;
	$produitKey = array_search($ref, $listProduits);&lt;br /&gt;
	if ($produitKey) {&lt;br /&gt;
// yes&lt;br /&gt;
		$fk_product = $produitKey;&lt;br /&gt;
	} else {&lt;br /&gt;
// no&lt;br /&gt;
// Create the product&lt;br /&gt;
		$newProduct = [&lt;br /&gt;
			&amp;quot;ref&amp;quot;	=&amp;gt; $ref,&lt;br /&gt;
			&amp;quot;label&amp;quot;	=&amp;gt; $ref&lt;br /&gt;
		];&lt;br /&gt;
		$newProductResult = CallAPI(&amp;quot;POST&amp;quot;, $apiKey, $apiUrl.&amp;quot;products&amp;quot;, json_encode($newProduct));&lt;br /&gt;
		$newProductResult = json_decode($newProductResult, true);&lt;br /&gt;
		if (isset($newProductResult[&amp;quot;error&amp;quot;]) &amp;amp;&amp;amp; $newProductResult[&amp;quot;error&amp;quot;][&amp;quot;code&amp;quot;] &amp;gt;= &amp;quot;300&amp;quot;) {&lt;br /&gt;
// there&#039;s been an error&lt;br /&gt;
			echo &amp;quot;&amp;lt;pre&amp;gt;ERROR&amp;quot;, var_dump($newProductResult), &amp;quot;&amp;lt;/pre&amp;gt;&amp;quot;;&lt;br /&gt;
			exit;&lt;br /&gt;
		} else {&lt;br /&gt;
// everything good&lt;br /&gt;
			$fk_product = $newProductResult;&lt;br /&gt;
			$listProduits[$fk_product] = $ref;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Comments :&lt;br /&gt;
&lt;br /&gt;
*I check if the ref of my product exist in the array created in the first example.&lt;br /&gt;
*If it exists, I use it&#039;s key in the array as ID&lt;br /&gt;
*If it doesn&#039;t exist, I create the product, then I add it to my array for next time then I use the ID created&lt;br /&gt;
*I choose this method to do less API calls when I have to import 500 orders. I just need to retrieve the products list once at the beginning instead of searching Dolibarr each time.&lt;br /&gt;
&lt;br /&gt;
Warning: The example below is not working properly. Creating an order and lines in one go is not supported. Instead you have to create an order first and with the returned order id add the lines using the /orders/{id}/lines endpoint. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
// create an order with 2 products&lt;br /&gt;
&lt;br /&gt;
// The array where there will be all the products lines of my order.&lt;br /&gt;
	$newCommandeLine = [];&lt;br /&gt;
&lt;br /&gt;
// product 1&lt;br /&gt;
	$ref1 = &amp;quot;my_product_ref_X203ZZ&amp;quot;;&lt;br /&gt;
	$prix1 = 10;&lt;br /&gt;
	$qtt1  = 100;&lt;br /&gt;
	$tva1 = 20;&lt;br /&gt;
	$fk_product1&lt;br /&gt;
// product 2&lt;br /&gt;
	$ref2 = &amp;quot;my_product_ref_B707FD&amp;quot;;&lt;br /&gt;
	$prix2 = 13;&lt;br /&gt;
	$qtt2  = 37;&lt;br /&gt;
	$tva2 = 20;&lt;br /&gt;
&lt;br /&gt;
	$newCommandeLine[] = [&lt;br /&gt;
		&amp;quot;desc&amp;quot;		=&amp;gt; $ref1,&lt;br /&gt;
		&amp;quot;subprice&amp;quot;	=&amp;gt; $prix1,&lt;br /&gt;
		&amp;quot;qty&amp;quot;		=&amp;gt; $qtt1,&lt;br /&gt;
		&amp;quot;tva_tx&amp;quot;	=&amp;gt; floatval($tva1),&lt;br /&gt;
		&amp;quot;fk_product&amp;quot;=&amp;gt; $fk_product1&lt;br /&gt;
	];&lt;br /&gt;
&lt;br /&gt;
	$newCommandeLine[] = [&lt;br /&gt;
		&amp;quot;desc&amp;quot;		=&amp;gt; $ref2,&lt;br /&gt;
		&amp;quot;subprice&amp;quot;	=&amp;gt; $prix2,&lt;br /&gt;
		&amp;quot;qty&amp;quot;		=&amp;gt; $qtt2,&lt;br /&gt;
		&amp;quot;tva_tx&amp;quot;	=&amp;gt; floatval($tva2),&lt;br /&gt;
		&amp;quot;fk_product&amp;quot;=&amp;gt; $fk_product2&lt;br /&gt;
	];&lt;br /&gt;
&lt;br /&gt;
	if (count($newCommandeLine) &amp;gt; 0) {&lt;br /&gt;
		$newCommande = [&lt;br /&gt;
			&amp;quot;socid&amp;quot;			=&amp;gt; $clientDoliId,&lt;br /&gt;
			&amp;quot;type&amp;quot; 			=&amp;gt; &amp;quot;0&amp;quot;,&lt;br /&gt;
			&amp;quot;lines&amp;quot;			=&amp;gt; $newCommandeLine,&lt;br /&gt;
			&amp;quot;note_private&amp;quot;	=&amp;gt; &amp;quot;order created automatically with API&amp;quot;,&lt;br /&gt;
		];&lt;br /&gt;
		$newCommandeResult = CallAPI(&amp;quot;POST&amp;quot;, $apiKey, $apiUrl.&amp;quot;orders&amp;quot;, json_encode($newCommande));&lt;br /&gt;
		$newCommandeResult = json_decode($newCommandeResult, true);&lt;br /&gt;
	}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Comments :&lt;br /&gt;
&lt;br /&gt;
*$clientDoliId is the ID of the customer in the Dolibarr database. Either you know it or you can search for it before&lt;br /&gt;
*type =&amp;gt; 0, This is a customer order (while 1 = supplier order)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
// Validate an order &lt;br /&gt;
	$newCommandeValider = [&lt;br /&gt;
		&amp;quot;idwarehouse&amp;quot;	=&amp;gt; &amp;quot;0&amp;quot;,&lt;br /&gt;
		&amp;quot;notrigger&amp;quot;		=&amp;gt; &amp;quot;0&amp;quot;&lt;br /&gt;
	];&lt;br /&gt;
	$newCommandeValiderResult = CallAPI(&amp;quot;POST&amp;quot;, $apiKey, $apiUrl.&amp;quot;orders/&amp;quot;.$newCommandeResult.&amp;quot;/validate&amp;quot;, json_encode($newCommandeValider));&lt;br /&gt;
	$newCommandeValiderResult = json_decode($newCommandeValiderResult, true);&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Comments :&lt;br /&gt;
&lt;br /&gt;
*in this example, on the penultimate line, we can see : $apiUrl.&amp;quot;orders/&amp;quot;.$newCommandeResult.&amp;quot;/validate&amp;quot;.&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
$newCommandeResult is the ID of the order created in the previous example&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
// search in the database if a customer exist&lt;br /&gt;
	$customer_name = &amp;quot;Acme Inc&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
	$clientSearch = json_decode(CallAPI(&amp;quot;GET&amp;quot;, $apiKey, $apiUrl.&amp;quot;thirdparties&amp;quot;, array(&lt;br /&gt;
		&amp;quot;sortfield&amp;quot; =&amp;gt; &amp;quot;t.rowid&amp;quot;, &lt;br /&gt;
		&amp;quot;sortorder&amp;quot; =&amp;gt; &amp;quot;ASC&amp;quot;, &lt;br /&gt;
		&amp;quot;limit&amp;quot; =&amp;gt; &amp;quot;1&amp;quot;, &lt;br /&gt;
		&amp;quot;mode&amp;quot; =&amp;gt; &amp;quot;1&amp;quot;,&lt;br /&gt;
		&amp;quot;sqlfilters&amp;quot; =&amp;gt; &amp;quot;(t.nom:=:&#039;&amp;quot;.$customer_name.&amp;quot;&#039;)&amp;quot;&lt;br /&gt;
		)&lt;br /&gt;
	), true);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Comments :&lt;br /&gt;
&lt;br /&gt;
*limit =&amp;gt; 1 only 1 customer&lt;br /&gt;
*mode =&amp;gt; 1 we are looking for a customer, not a supplier (they are thirdparties too but with a different status)&lt;br /&gt;
*sqlfilters a bit special but there are more examples on the explorer page&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
// customer doesn&#039;t exist. Let&#039;s create it and get it&#039;s ID&lt;br /&gt;
	$newClient = [&lt;br /&gt;
		&amp;quot;name&amp;quot; 			=&amp;gt; &amp;quot;customer company name&amp;quot;,&lt;br /&gt;
		&amp;quot;email&amp;quot;			=&amp;gt; &amp;quot;customer company email&amp;quot;,&lt;br /&gt;
		&amp;quot;client&amp;quot; 		=&amp;gt; &amp;quot;1&amp;quot;,&lt;br /&gt;
		&amp;quot;code_client&amp;quot;	=&amp;gt; &amp;quot;-1&amp;quot;&lt;br /&gt;
	];&lt;br /&gt;
	$newClientResult = CallAPI(&amp;quot;POST&amp;quot;, $apiKey, $apiUrl.&amp;quot;thirdparties&amp;quot;, json_encode($newClient));&lt;br /&gt;
	$newClientResult = json_decode($newClientResult, true);&lt;br /&gt;
	$clientDoliId = $newClientResult;&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Comments :&lt;br /&gt;
&lt;br /&gt;
*client =&amp;gt; 1 He is a customer (not a supplier)&lt;br /&gt;
*code_client =&amp;gt; -1 so the customer code will be generated automatically.&lt;br /&gt;
*we get the customer ID in $clientDoliId&lt;br /&gt;
&lt;br /&gt;
=Examples with Python=&lt;br /&gt;
See https://pypi.org/project/dolipy/ and https://pypi.org/project/dolibarr/&lt;br /&gt;
&lt;br /&gt;
First you can install the python-module with &amp;quot;pip install dolibarr&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxHighlight lang=python&amp;gt;&lt;br /&gt;
 from dolibarr import Dolibarr&lt;br /&gt;
&lt;br /&gt;
 api_url = &#039;&amp;lt;nowiki&amp;gt;http://your-url/dolibarr/htdocs/api/index.php/&#039;&amp;lt;/nowiki&amp;gt;&lt;br /&gt;
 api_key = &#039;custom_API-Key&#039;&lt;br /&gt;
&lt;br /&gt;
 # Connection to dolibarr&lt;br /&gt;
 dolibarr_inst = Dolibarr(api_url, api_key)&lt;br /&gt;
&lt;br /&gt;
 # create Product&lt;br /&gt;
 params = {&#039;ref&#039;: &#039;Product_Reference&#039;, &#039;status&#039;: &#039;1&#039;, &#039;barcode_type&#039;: &#039;6&#039;, &#039;note_public&#039;: None,          &lt;br /&gt;
&lt;br /&gt;
           &#039;note_private&#039;: &amp;lt;nowiki&amp;gt;&#039;&#039;&amp;lt;/nowiki&amp;gt;, &#039;specimen&#039;: 0, &#039;label&#039;: &#039;Product_Label&#039;,&lt;br /&gt;
&lt;br /&gt;
           &#039;description&#039;: &amp;lt;nowiki&amp;gt;&#039;&#039;&amp;lt;/nowiki&amp;gt;, &#039;type&#039;: &#039;0&#039;, &#039;price&#039;: &amp;lt;nowiki&amp;gt;&#039;&#039;&amp;lt;/nowiki&amp;gt;, &#039;price_ttc&#039;: &#039;15.6000000&#039;, &#039;price_base_type&#039;: &#039;TTC&#039;,  # excl. tax = HT, incl. tax = TTC&lt;br /&gt;
&lt;br /&gt;
           &#039;tva_tx&#039;: &#039;19.0000&#039;, &#039;seuil_stock_alerte&#039;: &#039;0&#039;, &#039;desiredstock&#039;: &#039;0&#039;, &#039;status_buy&#039;: &#039;1&#039;, &#039;barcode&#039;: &#039;barcode&#039;}&lt;br /&gt;
&lt;br /&gt;
 ret_val = dolibarr_inst.call_create_api(&#039;products&#039;, params)&lt;br /&gt;
 print(ret_val)&lt;br /&gt;
&lt;br /&gt;
 # get product list&lt;br /&gt;
 product_dict = dolibarr_inst.call_list_api(&#039;products&#039;)&lt;br /&gt;
 print(product_dict)&lt;br /&gt;
&amp;lt;/syntaxHighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Develop your own service / API=&lt;br /&gt;
Adding a new REST service is as easy than adding a file called &#039;&#039;&#039;api_mymoduleobject.class.php&#039;&#039;&#039; into the directory &#039;&#039;&#039;htdocs/mymodule/class&#039;&#039;&#039;.&lt;br /&gt;
You can take an example into &#039;&#039;&#039;htdocs/commande/class/api_orders.class.php&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Note that if you use the &#039;&#039;&#039;modulebuilder&#039;&#039;&#039; tool, this file may be generated for you.&lt;br /&gt;
&lt;br /&gt;
The framework detects automatically the API files and it should be visible into the explorer.&lt;br /&gt;
&lt;br /&gt;
Method and parameters are detected according to introspection done into PHP class of the object (&#039;&#039;&#039;htdocs/mymodule/class/object.class.php&#039;&#039;&#039;) using the &#039;&#039;&#039;annotations&#039;&#039;&#039; found into the class.&lt;br /&gt;
For a documentation about annotation: https://github.com/Luracast/Restler/blob/master/ANNOTATIONS.md&lt;br /&gt;
&lt;br /&gt;
These are just the basics.&lt;br /&gt;
&lt;br /&gt;
To find all existing API files in Dolibarr, you can search all files htdocs/&amp;lt;directory&amp;gt;/class/api_xxx_class.php&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=JA_Developer_documentation&amp;diff=57160</id>
		<title>JA Developer documentation</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=JA_Developer_documentation&amp;diff=57160"/>
		<updated>2023-07-22T13:30:10Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: /* 大量 エクスポート/インポート (Mass exports/imports) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:開発者手引き}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;seo metak=&amp;quot;developer, development, documentation, guide, doc, tutorial, usage, help, api, coding, standard, rules&amp;quot; /&amp;gt;&lt;br /&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 : Developer_documentation --&amp;gt;&lt;br /&gt;
[[fr:Documentation_Développeur]]&lt;br /&gt;
[[es:Documentación_Desarrolladores]]&lt;br /&gt;
[[de:Entwickler_Dokumentation]]&lt;br /&gt;
[[zh:开发文档]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This page is main index of documents relating to developer documentation. For user documentation [[User documentation|see here]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=開発組織とツール=&lt;br /&gt;
This chapter contains global information that must be read before starting any development on Dolibarr.&lt;br /&gt;
&lt;br /&gt;
#[[Dolibarr Project|Organization of project]]&lt;br /&gt;
#[[To known before to start|To be known before starting to develop]]&lt;br /&gt;
#[[Environment and development tools]]&lt;br /&gt;
#[[Dependencies and external libraries]]&lt;br /&gt;
#[[FAQ_Get,update_project_sources|Get or update sources of a development version]]&lt;br /&gt;
&lt;br /&gt;
=コーディング規約とベストプラクティス=&lt;br /&gt;
&lt;br /&gt;
#[[Prerequisite|Prerequisites]]&lt;br /&gt;
#[[Language and development rules|Language and development rules (PHP, SQL, HTML)]]&lt;br /&gt;
#[[:Category:Table SQL|List of tables]]&lt;br /&gt;
#Tree structure of files and classes are available in the [http://doxygen.dolibarr.org/ doxygen generated documentation]&lt;br /&gt;
&lt;br /&gt;
=モジュールリスト=&lt;br /&gt;
標準ビジネスモデルの技術文書は、それぞれのモジュール開発者の文書ページ (documentation pages) にある.  関心に応じて適切なページを選ぶとよい:&lt;br /&gt;
&lt;br /&gt;
*[[:Category:List of Modules (developer)‎|List of standard modules]]&lt;br /&gt;
*[[:Category:Complementary modules|List of complementary modules]]&lt;br /&gt;
&lt;br /&gt;
=GUI 向けの新 モジュール/アドオン を作るには=&lt;br /&gt;
この項では、Dolibarr のユーザインタフェースを変更する新規モジュールの開発方法を述べる. 該当するのは、スクリーン、テーマ、データ、保有するCSSスタイルシート 、ソースコード、またはそれらのすべて.&lt;br /&gt;
&lt;br /&gt;
スクリプト開発はこの項には含まれない (これは次章で述べる).&lt;br /&gt;
&lt;br /&gt;
自分のモジュールを開発するには、[[モジュール 開発|モジュール開発]] チュートリアルを確認すること.&lt;br /&gt;
&lt;br /&gt;
=バッチまたはコマンドラインスクリプトを作るには=&lt;br /&gt;
この章では、Dolibarr でタスクを実行するためのコマンドラインスクリプト開発方法について説明する (read, update data...).&lt;br /&gt;
&lt;br /&gt;
グラフィカルユーザーインターフェイス（GUI）への変更作成は、本章には含まれない。これについては、前章を参照.&lt;br /&gt;
&lt;br /&gt;
cronスクリプトや外部ソースからデータを取り込むためのコマンドライン インポートツールなど、スクリプトを開発するには、スクリプト開発 ([[Script development]]) ページをご覧ください.&lt;br /&gt;
&lt;br /&gt;
=Dolibarr の技術的要素 (Technical components)=&lt;br /&gt;
==ツリー構造 (Tree structure)==&lt;br /&gt;
現バージョンのファイルのパス階層は、 [http://doxygen.dolibarr.org/ doxygen generated documentation] (&amp;quot;javadoc&amp;quot; 文書に類似) から把握できる.&lt;br /&gt;
&lt;br /&gt;
新規モジュールによる新規ファイルの追加で使用するパスは、新規モジュール開発の文書 ([[Module development|Module development 参照]]) で定義される.&lt;br /&gt;
&lt;br /&gt;
==ストレージ準備 (Setup storage)==&lt;br /&gt;
Dolibarr 設定パラメータは3か所存在する.&lt;br /&gt;
&lt;br /&gt;
*Dolibarr 技術的設定パラメータ (認証モード, データベースログインとファイル向けストレージ領域) が定義される設定ファイルは1つだけ: &amp;lt;code&amp;gt;/conf/conf.php&amp;lt;/code&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
:さらに詳細は [[Configuration file]] を参照.&lt;br /&gt;
&lt;br /&gt;
*グローバル特質パラメータは [[Table llx_const]] に保存.&lt;br /&gt;
&lt;br /&gt;
:さらに詳細は [[Constants]] ページを参照.&lt;br /&gt;
&lt;br /&gt;
*ユーザに対する特質パラメータは [[Table llx_user_param]] に保存.&lt;br /&gt;
&lt;br /&gt;
==ビジネスオブジェクト (Business objects)==&lt;br /&gt;
参照 [[ビジネス オブジェクト|ビジネスオブジェクト]] &lt;br /&gt;
&lt;br /&gt;
==メニューシステム (Menu system)==&lt;br /&gt;
参照 [[Menus system]] &lt;br /&gt;
&lt;br /&gt;
==タブシステム (Tabs system)==&lt;br /&gt;
参照 [[Tabs system]] &lt;br /&gt;
&lt;br /&gt;
==スキンシステム (Skins system)==&lt;br /&gt;
参照 [[Skins]] &lt;br /&gt;
&lt;br /&gt;
==ウィジェットシステム (Widget system)==&lt;br /&gt;
参照 [[Widget system]]&lt;br /&gt;
&lt;br /&gt;
==認証システム (Authentication system)==&lt;br /&gt;
参照 [[Authentication]] &lt;br /&gt;
&lt;br /&gt;
==許可システム (Permission system)==&lt;br /&gt;
参照 [[Permissions En|Permissions]] &lt;br /&gt;
&lt;br /&gt;
==翻訳システム (Translation system)==&lt;br /&gt;
参照 [[Translation system]] &lt;br /&gt;
&lt;br /&gt;
==エラー管理 (Error management)==&lt;br /&gt;
参照 [[Error reporting|Error reporting]] &lt;br /&gt;
&lt;br /&gt;
==キャンバスシステム (Canvas system)==&lt;br /&gt;
Canvasは、レコード（商品、取引先、連絡先など）を作成、更新、閲覧するための画面を置き換える開発者向けの機能. 例えば、取引先の新規作成に使用する入力フォームやその編集フォームを置き換えたり、閲覧テンプレートを置き換えたりすることがでる.&lt;br /&gt;
 &lt;br /&gt;
参照 [[Canvas development]] &lt;br /&gt;
&lt;br /&gt;
==トリガーシステム (Triggers system)==&lt;br /&gt;
トリガーは、Dolibarrの &amp;quot;ビジネスイベント&amp;quot; （請求書の作成、ユーザーの削除、取引先の更新など） に付随して、パーソナライズされたコードを実行するための開発機能で、ビジネスイベントに対してのみ有効. 他のコンテキストでコードをパーソナライズするには、代わりにフックシステム (&#039;&#039;&#039;Hooks system) の章を参照&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
トリガーの使用に関して、参照 [[Interfaces Dolibarr toward foreign systems|this page]].&lt;br /&gt;
&lt;br /&gt;
==フックシステム (Hooks system)==&lt;br /&gt;
参照 [[Hooks system]] &lt;br /&gt;
&lt;br /&gt;
==変数置換システム (Variable substitution system)==&lt;br /&gt;
参照 [[Variable substitution system]] &lt;br /&gt;
&lt;br /&gt;
==ウェブサービス (Web services)==&lt;br /&gt;
Dolibarr はいくつかのサービスを提供するように設定可能.&lt;br /&gt;
&lt;br /&gt;
参照 [[Module Web Services API REST (developer)]] &lt;br /&gt;
&lt;br /&gt;
注: [[Module Web Services API SOAP (developer)]]  は非推奨.&lt;br /&gt;
&lt;br /&gt;
==ファイル/書類 ストレージ管理 (Files/Documents storage management)==&lt;br /&gt;
参照 [[Generated documents]] &lt;br /&gt;
&lt;br /&gt;
==番号付けモジュール (Numbering modules)==&lt;br /&gt;
For アプリケーションで作成された各エンティティに対して、Dolibarrは参照を割り当てる．どのような用途にも参照を適応できるように、Dolibarrはモジュールを使って参照生成ルールを定義する．いくつかの標準モジュールが提供されてる．あるモジュールは汎用的で、ナンバリングマスクの定義に使用される(x文字の番号、接頭辞の有無、日付の有無、など)。しかし、提供されているモジュールがニーズを満たさない場合もある．この場合、カスタム番号モジュールを開発する必要がある．&lt;br /&gt;
&lt;br /&gt;
詳しくは,  [[Create numeration module|Create numbering module]] を参照.&lt;br /&gt;
==文書テンプレートと文書生成 (Document templates and documents generation)==&lt;br /&gt;
&lt;br /&gt;
テンプレートからの文書生成に関して、 [[Create a PDF document template]] や [[Create an ODT document template]] に更なる説明がある.&lt;br /&gt;
&lt;br /&gt;
==エクストラフィールド (Extrafields)==&lt;br /&gt;
参照 [[Extrafields]]&lt;br /&gt;
&lt;br /&gt;
==オンライン決済システム (Online payment system)==&lt;br /&gt;
参照 [[Online payment system]]&lt;br /&gt;
&lt;br /&gt;
==他内部機能 (Other internal function)==&lt;br /&gt;
自前コードで利用できる多くの内部ライブラリがある．functions.lib.php、functions2.lib.php、admin.lib.phpに多くの汎用関数が見つかる． htdocs/core/lib/*.lib ファイルにある関数はどれでも使用可．&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Dolibarrのバージョン番号に基づく要件を指定するには&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
例えば、Dolibarrバージョンの3.5以上を前提条件にするには、 admin.lib.php にある versioncompare と versiondolibarrarray を使用する：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
if (versioncompare(versiondolibarrarray(), array(3,5,0)) &amp;gt; 0)&lt;br /&gt;
{&lt;br /&gt;
 ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=大量 エクスポート/インポート (Mass exports/imports)=&lt;br /&gt;
&lt;br /&gt;
*[[Mass imports]]&lt;br /&gt;
*[[Module Exports En|Mass exports]]&lt;br /&gt;
&lt;br /&gt;
=他のアプリとのインタフェースやリンク (Interfaces and links with other applications)=&lt;br /&gt;
&lt;br /&gt;
*[https://wiki.dolibarr.org/Interfaces_Dolibarr_toward_foreign_systems Interfaces Dolibarr toward foreign systems] or Dolibarr toward Dolibarr (Dolibarr Triggers or Hooks)&lt;br /&gt;
*[https://wiki.dolibarr.org/Interfaces_from_foreign_systems_toward_Dolibarr Interfaces from foreign systems toward Dolibarr]&lt;br /&gt;
&lt;br /&gt;
Integrate Dolibarr to automation platforms:&lt;br /&gt;
&lt;br /&gt;
*[https://wiki.dolibarr.org/Integration_of_Dolibarr_to_the_Zapier_automation_platform Integration of Dolibarr to the Zapier automation platform]&lt;br /&gt;
*[https://wiki.dolibarr.org/Integration_of_Dolibarr_to_the_n8n_automation_platform Integration of Dolibarr to the n8n automation platform]&lt;br /&gt;
*[https://wiki.dolibarr.org/Integration_of_Dolibarr_to_the_Make_automation_platform Integration of Dolibarr to the Make automation platform]&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
すべての FAQs は FAQ インデックスページ [[:Category:FAQ EN|FAQ EN]] から利用可能&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=JA_Developer_documentation&amp;diff=57159</id>
		<title>JA Developer documentation</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=JA_Developer_documentation&amp;diff=57159"/>
		<updated>2023-07-22T13:25:57Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: /* 他のアプリとのインタフェースやリンク (Interfaces and links with other applications) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:開発者手引き}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;seo metak=&amp;quot;developer, development, documentation, guide, doc, tutorial, usage, help, api, coding, standard, rules&amp;quot; /&amp;gt;&lt;br /&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 : Developer_documentation --&amp;gt;&lt;br /&gt;
[[fr:Documentation_Développeur]]&lt;br /&gt;
[[es:Documentación_Desarrolladores]]&lt;br /&gt;
[[de:Entwickler_Dokumentation]]&lt;br /&gt;
[[zh:开发文档]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This page is main index of documents relating to developer documentation. For user documentation [[User documentation|see here]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=開発組織とツール=&lt;br /&gt;
This chapter contains global information that must be read before starting any development on Dolibarr.&lt;br /&gt;
&lt;br /&gt;
#[[Dolibarr Project|Organization of project]]&lt;br /&gt;
#[[To known before to start|To be known before starting to develop]]&lt;br /&gt;
#[[Environment and development tools]]&lt;br /&gt;
#[[Dependencies and external libraries]]&lt;br /&gt;
#[[FAQ_Get,update_project_sources|Get or update sources of a development version]]&lt;br /&gt;
&lt;br /&gt;
=コーディング規約とベストプラクティス=&lt;br /&gt;
&lt;br /&gt;
#[[Prerequisite|Prerequisites]]&lt;br /&gt;
#[[Language and development rules|Language and development rules (PHP, SQL, HTML)]]&lt;br /&gt;
#[[:Category:Table SQL|List of tables]]&lt;br /&gt;
#Tree structure of files and classes are available in the [http://doxygen.dolibarr.org/ doxygen generated documentation]&lt;br /&gt;
&lt;br /&gt;
=モジュールリスト=&lt;br /&gt;
標準ビジネスモデルの技術文書は、それぞれのモジュール開発者の文書ページ (documentation pages) にある.  関心に応じて適切なページを選ぶとよい:&lt;br /&gt;
&lt;br /&gt;
*[[:Category:List of Modules (developer)‎|List of standard modules]]&lt;br /&gt;
*[[:Category:Complementary modules|List of complementary modules]]&lt;br /&gt;
&lt;br /&gt;
=GUI 向けの新 モジュール/アドオン を作るには=&lt;br /&gt;
この項では、Dolibarr のユーザインタフェースを変更する新規モジュールの開発方法を述べる. 該当するのは、スクリーン、テーマ、データ、保有するCSSスタイルシート 、ソースコード、またはそれらのすべて.&lt;br /&gt;
&lt;br /&gt;
スクリプト開発はこの項には含まれない (これは次章で述べる).&lt;br /&gt;
&lt;br /&gt;
自分のモジュールを開発するには、[[モジュール 開発|モジュール開発]] チュートリアルを確認すること.&lt;br /&gt;
&lt;br /&gt;
=バッチまたはコマンドラインスクリプトを作るには=&lt;br /&gt;
この章では、Dolibarr でタスクを実行するためのコマンドラインスクリプト開発方法について説明する (read, update data...).&lt;br /&gt;
&lt;br /&gt;
グラフィカルユーザーインターフェイス（GUI）への変更作成は、本章には含まれない。これについては、前章を参照.&lt;br /&gt;
&lt;br /&gt;
cronスクリプトや外部ソースからデータを取り込むためのコマンドライン インポートツールなど、スクリプトを開発するには、スクリプト開発 ([[Script development]]) ページをご覧ください.&lt;br /&gt;
&lt;br /&gt;
=Dolibarr の技術的要素 (Technical components)=&lt;br /&gt;
==ツリー構造 (Tree structure)==&lt;br /&gt;
現バージョンのファイルのパス階層は、 [http://doxygen.dolibarr.org/ doxygen generated documentation] (&amp;quot;javadoc&amp;quot; 文書に類似) から把握できる.&lt;br /&gt;
&lt;br /&gt;
新規モジュールによる新規ファイルの追加で使用するパスは、新規モジュール開発の文書 ([[Module development|Module development 参照]]) で定義される.&lt;br /&gt;
&lt;br /&gt;
==ストレージ準備 (Setup storage)==&lt;br /&gt;
Dolibarr 設定パラメータは3か所存在する.&lt;br /&gt;
&lt;br /&gt;
*Dolibarr 技術的設定パラメータ (認証モード, データベースログインとファイル向けストレージ領域) が定義される設定ファイルは1つだけ: &amp;lt;code&amp;gt;/conf/conf.php&amp;lt;/code&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
:さらに詳細は [[Configuration file]] を参照.&lt;br /&gt;
&lt;br /&gt;
*グローバル特質パラメータは [[Table llx_const]] に保存.&lt;br /&gt;
&lt;br /&gt;
:さらに詳細は [[Constants]] ページを参照.&lt;br /&gt;
&lt;br /&gt;
*ユーザに対する特質パラメータは [[Table llx_user_param]] に保存.&lt;br /&gt;
&lt;br /&gt;
==ビジネスオブジェクト (Business objects)==&lt;br /&gt;
参照 [[ビジネス オブジェクト|ビジネスオブジェクト]] &lt;br /&gt;
&lt;br /&gt;
==メニューシステム (Menu system)==&lt;br /&gt;
参照 [[Menus system]] &lt;br /&gt;
&lt;br /&gt;
==タブシステム (Tabs system)==&lt;br /&gt;
参照 [[Tabs system]] &lt;br /&gt;
&lt;br /&gt;
==スキンシステム (Skins system)==&lt;br /&gt;
参照 [[Skins]] &lt;br /&gt;
&lt;br /&gt;
==ウィジェットシステム (Widget system)==&lt;br /&gt;
参照 [[Widget system]]&lt;br /&gt;
&lt;br /&gt;
==認証システム (Authentication system)==&lt;br /&gt;
参照 [[Authentication]] &lt;br /&gt;
&lt;br /&gt;
==許可システム (Permission system)==&lt;br /&gt;
参照 [[Permissions En|Permissions]] &lt;br /&gt;
&lt;br /&gt;
==翻訳システム (Translation system)==&lt;br /&gt;
参照 [[Translation system]] &lt;br /&gt;
&lt;br /&gt;
==エラー管理 (Error management)==&lt;br /&gt;
参照 [[Error reporting|Error reporting]] &lt;br /&gt;
&lt;br /&gt;
==キャンバスシステム (Canvas system)==&lt;br /&gt;
Canvasは、レコード（商品、取引先、連絡先など）を作成、更新、閲覧するための画面を置き換える開発者向けの機能. 例えば、取引先の新規作成に使用する入力フォームやその編集フォームを置き換えたり、閲覧テンプレートを置き換えたりすることがでる.&lt;br /&gt;
 &lt;br /&gt;
参照 [[Canvas development]] &lt;br /&gt;
&lt;br /&gt;
==トリガーシステム (Triggers system)==&lt;br /&gt;
トリガーは、Dolibarrの &amp;quot;ビジネスイベント&amp;quot; （請求書の作成、ユーザーの削除、取引先の更新など） に付随して、パーソナライズされたコードを実行するための開発機能で、ビジネスイベントに対してのみ有効. 他のコンテキストでコードをパーソナライズするには、代わりにフックシステム (&#039;&#039;&#039;Hooks system) の章を参照&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
トリガーの使用に関して、参照 [[Interfaces Dolibarr toward foreign systems|this page]].&lt;br /&gt;
&lt;br /&gt;
==フックシステム (Hooks system)==&lt;br /&gt;
参照 [[Hooks system]] &lt;br /&gt;
&lt;br /&gt;
==変数置換システム (Variable substitution system)==&lt;br /&gt;
参照 [[Variable substitution system]] &lt;br /&gt;
&lt;br /&gt;
==ウェブサービス (Web services)==&lt;br /&gt;
Dolibarr はいくつかのサービスを提供するように設定可能.&lt;br /&gt;
&lt;br /&gt;
参照 [[Module Web Services API REST (developer)]] &lt;br /&gt;
&lt;br /&gt;
注: [[Module Web Services API SOAP (developer)]]  は非推奨.&lt;br /&gt;
&lt;br /&gt;
==ファイル/書類 ストレージ管理 (Files/Documents storage management)==&lt;br /&gt;
参照 [[Generated documents]] &lt;br /&gt;
&lt;br /&gt;
==番号付けモジュール (Numbering modules)==&lt;br /&gt;
For アプリケーションで作成された各エンティティに対して、Dolibarrは参照を割り当てる．どのような用途にも参照を適応できるように、Dolibarrはモジュールを使って参照生成ルールを定義する．いくつかの標準モジュールが提供されてる．あるモジュールは汎用的で、ナンバリングマスクの定義に使用される(x文字の番号、接頭辞の有無、日付の有無、など)。しかし、提供されているモジュールがニーズを満たさない場合もある．この場合、カスタム番号モジュールを開発する必要がある．&lt;br /&gt;
&lt;br /&gt;
詳しくは,  [[Create numeration module|Create numbering module]] を参照.&lt;br /&gt;
==文書テンプレートと文書生成 (Document templates and documents generation)==&lt;br /&gt;
&lt;br /&gt;
テンプレートからの文書生成に関して、 [[Create a PDF document template]] や [[Create an ODT document template]] に更なる説明がある.&lt;br /&gt;
&lt;br /&gt;
==エクストラフィールド (Extrafields)==&lt;br /&gt;
参照 [[Extrafields]]&lt;br /&gt;
&lt;br /&gt;
==オンライン決済システム (Online payment system)==&lt;br /&gt;
参照 [[Online payment system]]&lt;br /&gt;
&lt;br /&gt;
==他内部機能 (Other internal function)==&lt;br /&gt;
自前コードで利用できる多くの内部ライブラリがある．functions.lib.php、functions2.lib.php、admin.lib.phpに多くの汎用関数が見つかる． htdocs/core/lib/*.lib ファイルにある関数はどれでも使用可．&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Dolibarrのバージョン番号に基づく要件を指定するには&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
例えば、Dolibarrバージョンの3.5以上を前提条件にするには、 admin.lib.php にある versioncompare と versiondolibarrarray を使用する：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
if (versioncompare(versiondolibarrarray(), array(3,5,0)) &amp;gt; 0)&lt;br /&gt;
{&lt;br /&gt;
 ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=大量 エクスポート/インポート (Mass exports/imports)=&lt;br /&gt;
&lt;br /&gt;
#[[Mass imports]]&lt;br /&gt;
#[[Module Exports En|Mass exports]]&lt;br /&gt;
&lt;br /&gt;
=他のアプリとのインタフェースやリンク (Interfaces and links with other applications)=&lt;br /&gt;
&lt;br /&gt;
*[https://wiki.dolibarr.org/Interfaces_Dolibarr_toward_foreign_systems Interfaces Dolibarr toward foreign systems] or Dolibarr toward Dolibarr (Dolibarr Triggers or Hooks)&lt;br /&gt;
*[https://wiki.dolibarr.org/Interfaces_from_foreign_systems_toward_Dolibarr Interfaces from foreign systems toward Dolibarr]&lt;br /&gt;
&lt;br /&gt;
Integrate Dolibarr to automation platforms:&lt;br /&gt;
&lt;br /&gt;
*[https://wiki.dolibarr.org/Integration_of_Dolibarr_to_the_Zapier_automation_platform Integration of Dolibarr to the Zapier automation platform]&lt;br /&gt;
*[https://wiki.dolibarr.org/Integration_of_Dolibarr_to_the_n8n_automation_platform Integration of Dolibarr to the n8n automation platform]&lt;br /&gt;
*[https://wiki.dolibarr.org/Integration_of_Dolibarr_to_the_Make_automation_platform Integration of Dolibarr to the Make automation platform]&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
すべての FAQs は FAQ インデックスページ [[:Category:FAQ EN|FAQ EN]] から利用可能&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=JA_Developer_documentation&amp;diff=56891</id>
		<title>JA Developer documentation</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=JA_Developer_documentation&amp;diff=56891"/>
		<updated>2023-06-24T07:18:56Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: /* 番号付けモジュール (Numbering modules) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:開発者手引き}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;seo metak=&amp;quot;developer, development, documentation, guide, doc, tutorial, usage, help, api, coding, standard, rules&amp;quot; /&amp;gt;&lt;br /&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 : Developer_documentation --&amp;gt;&lt;br /&gt;
[[fr:Documentation_Développeur]]&lt;br /&gt;
[[es:Documentación_Desarrolladores]]&lt;br /&gt;
[[de:Entwickler_Dokumentation]]&lt;br /&gt;
[[zh:开发文档]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This page is main index of documents relating to developer documentation. For user documentation [[User documentation|see here]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=開発組織とツール=&lt;br /&gt;
This chapter contains global information that must be read before starting any development on Dolibarr.&lt;br /&gt;
&lt;br /&gt;
#[[Dolibarr Project|Organization of project]]&lt;br /&gt;
#[[To known before to start|To be known before starting to develop]]&lt;br /&gt;
#[[Environment and development tools]]&lt;br /&gt;
#[[Dependencies and external libraries]]&lt;br /&gt;
#[[FAQ_Get,update_project_sources|Get or update sources of a development version]]&lt;br /&gt;
&lt;br /&gt;
=コーディング規約とベストプラクティス=&lt;br /&gt;
&lt;br /&gt;
#[[Prerequisite|Prerequisites]]&lt;br /&gt;
#[[Language and development rules|Language and development rules (PHP, SQL, HTML)]]&lt;br /&gt;
#[[:Category:Table SQL|List of tables]]&lt;br /&gt;
#Tree structure of files and classes are available in the [http://doxygen.dolibarr.org/ doxygen generated documentation]&lt;br /&gt;
&lt;br /&gt;
=モジュールリスト=&lt;br /&gt;
標準ビジネスモデルの技術文書は、それぞれのモジュール開発者の文書ページ (documentation pages) にある.  関心に応じて適切なページを選ぶとよい:&lt;br /&gt;
&lt;br /&gt;
*[[:Category:List of Modules (developer)‎|List of standard modules]]&lt;br /&gt;
*[[:Category:Complementary modules|List of complementary modules]]&lt;br /&gt;
&lt;br /&gt;
=GUI 向けの新 モジュール/アドオン を作るには=&lt;br /&gt;
この項では、Dolibarr のユーザインタフェースを変更する新規モジュールの開発方法を述べる. 該当するのは、スクリーン、テーマ、データ、保有するCSSスタイルシート 、ソースコード、またはそれらのすべて.&lt;br /&gt;
&lt;br /&gt;
スクリプト開発はこの項には含まれない (これは次章で述べる).&lt;br /&gt;
&lt;br /&gt;
自分のモジュールを開発するには、[[モジュール 開発|モジュール開発]] チュートリアルを確認すること.&lt;br /&gt;
&lt;br /&gt;
=バッチまたはコマンドラインスクリプトを作るには=&lt;br /&gt;
この章では、Dolibarr でタスクを実行するためのコマンドラインスクリプト開発方法について説明する (read, update data...).&lt;br /&gt;
&lt;br /&gt;
グラフィカルユーザーインターフェイス（GUI）への変更作成は、本章には含まれない。これについては、前章を参照.&lt;br /&gt;
&lt;br /&gt;
cronスクリプトや外部ソースからデータを取り込むためのコマンドライン インポートツールなど、スクリプトを開発するには、スクリプト開発 ([[Script development]]) ページをご覧ください.&lt;br /&gt;
&lt;br /&gt;
=Dolibarr の技術的要素 (Technical components)=&lt;br /&gt;
==ツリー構造 (Tree structure)==&lt;br /&gt;
現バージョンのファイルのパス階層は、 [http://doxygen.dolibarr.org/ doxygen generated documentation] (&amp;quot;javadoc&amp;quot; 文書に類似) から把握できる.&lt;br /&gt;
&lt;br /&gt;
新規モジュールによる新規ファイルの追加で使用するパスは、新規モジュール開発の文書 ([[Module development|Module development 参照]]) で定義される.&lt;br /&gt;
&lt;br /&gt;
==ストレージ準備 (Setup storage)==&lt;br /&gt;
Dolibarr 設定パラメータは3か所存在する.&lt;br /&gt;
&lt;br /&gt;
*Dolibarr 技術的設定パラメータ (認証モード, データベースログインとファイル向けストレージ領域) が定義される設定ファイルは1つだけ: &amp;lt;code&amp;gt;/conf/conf.php&amp;lt;/code&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
:さらに詳細は [[Configuration file]] を参照.&lt;br /&gt;
&lt;br /&gt;
*グローバル特質パラメータは [[Table llx_const]] に保存.&lt;br /&gt;
&lt;br /&gt;
:さらに詳細は [[Constants]] ページを参照.&lt;br /&gt;
&lt;br /&gt;
*ユーザに対する特質パラメータは [[Table llx_user_param]] に保存.&lt;br /&gt;
&lt;br /&gt;
==ビジネスオブジェクト (Business objects)==&lt;br /&gt;
参照 [[ビジネス オブジェクト|ビジネスオブジェクト]] &lt;br /&gt;
&lt;br /&gt;
==メニューシステム (Menu system)==&lt;br /&gt;
参照 [[Menus system]] &lt;br /&gt;
&lt;br /&gt;
==タブシステム (Tabs system)==&lt;br /&gt;
参照 [[Tabs system]] &lt;br /&gt;
&lt;br /&gt;
==スキンシステム (Skins system)==&lt;br /&gt;
参照 [[Skins]] &lt;br /&gt;
&lt;br /&gt;
==ウィジェットシステム (Widget system)==&lt;br /&gt;
参照 [[Widget system]]&lt;br /&gt;
&lt;br /&gt;
==認証システム (Authentication system)==&lt;br /&gt;
参照 [[Authentication]] &lt;br /&gt;
&lt;br /&gt;
==許可システム (Permission system)==&lt;br /&gt;
参照 [[Permissions En|Permissions]] &lt;br /&gt;
&lt;br /&gt;
==翻訳システム (Translation system)==&lt;br /&gt;
参照 [[Translation system]] &lt;br /&gt;
&lt;br /&gt;
==エラー管理 (Error management)==&lt;br /&gt;
参照 [[Error reporting|Error reporting]] &lt;br /&gt;
&lt;br /&gt;
==キャンバスシステム (Canvas system)==&lt;br /&gt;
Canvasは、レコード（商品、取引先、連絡先など）を作成、更新、閲覧するための画面を置き換える開発者向けの機能. 例えば、取引先の新規作成に使用する入力フォームやその編集フォームを置き換えたり、閲覧テンプレートを置き換えたりすることがでる.&lt;br /&gt;
 &lt;br /&gt;
参照 [[Canvas development]] &lt;br /&gt;
&lt;br /&gt;
==トリガーシステム (Triggers system)==&lt;br /&gt;
トリガーは、Dolibarrの &amp;quot;ビジネスイベント&amp;quot; （請求書の作成、ユーザーの削除、取引先の更新など） に付随して、パーソナライズされたコードを実行するための開発機能で、ビジネスイベントに対してのみ有効. 他のコンテキストでコードをパーソナライズするには、代わりにフックシステム (&#039;&#039;&#039;Hooks system) の章を参照&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
トリガーの使用に関して、参照 [[Interfaces Dolibarr toward foreign systems|this page]].&lt;br /&gt;
&lt;br /&gt;
==フックシステム (Hooks system)==&lt;br /&gt;
参照 [[Hooks system]] &lt;br /&gt;
&lt;br /&gt;
==変数置換システム (Variable substitution system)==&lt;br /&gt;
参照 [[Variable substitution system]] &lt;br /&gt;
&lt;br /&gt;
==ウェブサービス (Web services)==&lt;br /&gt;
Dolibarr はいくつかのサービスを提供するように設定可能.&lt;br /&gt;
&lt;br /&gt;
参照 [[Module Web Services API REST (developer)]] &lt;br /&gt;
&lt;br /&gt;
注: [[Module Web Services API SOAP (developer)]]  は非推奨.&lt;br /&gt;
&lt;br /&gt;
==ファイル/書類 ストレージ管理 (Files/Documents storage management)==&lt;br /&gt;
参照 [[Generated documents]] &lt;br /&gt;
&lt;br /&gt;
==番号付けモジュール (Numbering modules)==&lt;br /&gt;
For アプリケーションで作成された各エンティティに対して、Dolibarrは参照を割り当てる．どのような用途にも参照を適応できるように、Dolibarrはモジュールを使って参照生成ルールを定義する．いくつかの標準モジュールが提供されてる．あるモジュールは汎用的で、ナンバリングマスクの定義に使用される(x文字の番号、接頭辞の有無、日付の有無、など)。しかし、提供されているモジュールがニーズを満たさない場合もある．この場合、カスタム番号モジュールを開発する必要がある．&lt;br /&gt;
&lt;br /&gt;
詳しくは,  [[Create numeration module|Create numbering module]] を参照.&lt;br /&gt;
==文書テンプレートと文書生成 (Document templates and documents generation)==&lt;br /&gt;
&lt;br /&gt;
テンプレートからの文書生成に関して、 [[Create a PDF document template]] や [[Create an ODT document template]] に更なる説明がある.&lt;br /&gt;
&lt;br /&gt;
==エクストラフィールド (Extrafields)==&lt;br /&gt;
参照 [[Extrafields]]&lt;br /&gt;
&lt;br /&gt;
==オンライン決済システム (Online payment system)==&lt;br /&gt;
参照 [[Online payment system]]&lt;br /&gt;
&lt;br /&gt;
==他内部機能 (Other internal function)==&lt;br /&gt;
自前コードで利用できる多くの内部ライブラリがある．functions.lib.php、functions2.lib.php、admin.lib.phpに多くの汎用関数が見つかる． htdocs/core/lib/*.lib ファイルにある関数はどれでも使用可．&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Dolibarrのバージョン番号に基づく要件を指定するには&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
例えば、Dolibarrバージョンの3.5以上を前提条件にするには、 admin.lib.php にある versioncompare と versiondolibarrarray を使用する：&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
if (versioncompare(versiondolibarrarray(), array(3,5,0)) &amp;gt; 0)&lt;br /&gt;
{&lt;br /&gt;
 ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=大量 エクスポート/インポート (Mass exports/imports)=&lt;br /&gt;
&lt;br /&gt;
#[[Mass imports]]&lt;br /&gt;
#[[Module Exports En|Mass exports]]&lt;br /&gt;
&lt;br /&gt;
=他のアプリとのインタフェースやリンク (Interfaces and links with other applications)=&lt;br /&gt;
&lt;br /&gt;
#[[Interfaces Dolibarr toward foreign systems]] or Dolibarr toward Dolibarr (Dolibarr Triggers or Hooks)&lt;br /&gt;
#[[Interfaces from foreign systems toward Dolibarr]]&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
すべての FAQs は FAQ インデックスページ [[:Category:FAQ EN|FAQ EN]] から利用可能&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56890</id>
		<title>モジュール 開発</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56890"/>
		<updated>2023-06-24T06:55:04Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: /* タブ管理 (任意) */&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:Développement_module]]&lt;br /&gt;
[[es:Desarrollo_de_un_módulo]]&lt;br /&gt;
[[de:Modul_Entwicklung]]&lt;br /&gt;
[[zh:模块开发]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Core]]&lt;br /&gt;
{{TemplateDocDevEn}}&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;
etc...&lt;br /&gt;
&lt;br /&gt;
以下の章では、これらすべてを手作業で簡単に行う方法を示す.&lt;br /&gt;
&lt;br /&gt;
=モジュールビルダ によるモジュールの生成=&lt;br /&gt;
Dolibarr 9.0 から、モジュールビルダにより、自前モジュールのメインページ作成が可能. 起動方法は:&lt;br /&gt;
&lt;br /&gt;
*モジュールリストにて、&amp;quot;モジュールビルダ(Module Builder)&amp;quot;を有効化する,&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_2.png|400px]]&lt;br /&gt;
&lt;br /&gt;
*その後 &amp;quot;バグ(bug)&amp;quot; 画像をクリック、場所は画面右上.&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_3.png|400px]]&lt;br /&gt;
&lt;br /&gt;
=テンプレート外部モジュールの例=&lt;br /&gt;
外部モジュールの開発を開始するのによいお手本は、ここで見つかるだろう : [https://github.com/Dolibarr/dolibarr/tree/develop/htdocs/modulebuilder/template GitHub Dolibarr Module Modèle]&lt;br /&gt;
&lt;br /&gt;
=自前モジュールを作る=&lt;br /&gt;
==自前モジュールに関するモジュール記述(Module descriptor)を作る (必須)==&lt;br /&gt;
&#039;&#039;&#039;必須となる時期&#039;&#039;&#039;: アドオンを開発すると早急に必要、たとえゴールが何であれ (例外はスキンの追加).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Dolibarr 9.0 から, モジュールビルダ (ModuleBuilder) モジュールを使用すべきだ、モジュール記述を生成するための標準モデルとして使える&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===自前のモジュール記述 (module descriptor) を作成する===&lt;br /&gt;
最初のステップは、モジュールに対するファイル記述 (file descriptor) を作成すること. (訳者注： 以下の内容は&#039;&#039;&#039;モジュールビルダを使うことで自動設定&#039;&#039;&#039;される) &lt;br /&gt;
&lt;br /&gt;
*ディレクトリ作成： &#039;&#039;&#039;/htdocs/custom/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; (外部モジュール向け) または &#039;&#039;&#039;/htdocs/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; ここはDolibarr の公式コアモジュール (official core module) とする場合. 次にファイル modMyModule.class.php をディレクトリ &#039;&#039;&#039;htdocs/modulebuilder/template&#039;&#039;&#039; からコピーして上記のディレクトリに作成. ファイルの名称を modMyModule.class.php から 自前モジュールの目的に合致した名称に変更. ファイル名は、先頭に &#039;mod&#039; があり、最後が .class.php で終わる (例えば、ファイル名を &#039;新名&#039; にするなら, &#039;mod新名.class.php&#039; となる).&lt;br /&gt;
&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;
*番号を変更: $this-&amp;gt;numero = 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;
Dolibarrを起動し、&#039;&#039;&#039;設定-&amp;gt;モジュール (Setup-&amp;gt;module&#039;&#039;&#039;?) ページを表示.&lt;br /&gt;
モジュール記述でプロパティバージョン (property version) を設定すると、自前の新規モジュールを載せた新規行とそれを有効化するかどうかの選択が表示されるはず. プロパティバージョンを &amp;quot;develop&amp;quot; または &amp;quot;experimental&amp;quot; に設定した場合、自前モジュールを見るには、まず &#039;&#039;&#039;設定-&amp;gt;その他 (Setup-Others)&#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;
これは、新しいモジュールを構築する際に、ファイルをどう整理するかを示している (ZIPファイルもこのルールに合わせる必要あり).&lt;br /&gt;
注：2行目だけが必須.&lt;br /&gt;
&lt;br /&gt;
{{TemplateModuleTreeSimpleJA}}&lt;br /&gt;
&lt;br /&gt;
==自前 SQL テーブル と PHP DAO クラス (任意)==&lt;br /&gt;
&#039;&#039;&#039;使用場面&#039;&#039;&#039;: 自前モジュールがそれ自身のデータを管理する必要がある場合&lt;br /&gt;
&lt;br /&gt;
===自前の .sql ファイルを作成===&lt;br /&gt;
自前モジュールが、Dolibarr標準版では利用できない独自データを管理する設計である場合、そのデータを格納するためのSQLテーブルを定義する必要がある.&lt;br /&gt;
&lt;br /&gt;
自前モジュールでテーブルを作成したり、データを読込むためのスクリプトは、自前モジュールのsqlサブディレクトリ (&amp;quot;&#039;&#039;&#039;mymodule/sql&#039;&#039;&#039;&amp;quot;) に保存される。(ModuleBuilder では、オブジェクト タブから新しいオブジェクトを作成するとき、このディレクトリとすべての sql ファイルが自動作成される）.&lt;br /&gt;
&lt;br /&gt;
次に、記述ファイルでの、&#039;&#039;&#039;init&#039;&#039;&#039; 関数にて、次の行&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;$this-&amp;gt;_load_tables(&#039;/mymodule/sql/&#039;);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
が、コメントでないことを確認する.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;従うべきルール:&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*テーブルごとに &#039;&#039;&#039;llx_matable.sql&#039;&#039;&#039; ファイルを１つ、&#039;&#039;&#039;llx_matable.key.sql&#039;&#039;&#039; ファイルを可能なら１つ、作成するという原則に基づき、テーブル作成コマンドのファイルを追加する（例として、 &#039;&#039;&#039;install/mysql/tables&#039;&#039;&#039; にあるファイルを参照）.&lt;br /&gt;
*SQLフィールドの推奨される型と名前は、このページに定義されてる [[Language_and_development_rules#Table_and_fields_structures]].&lt;br /&gt;
*データ管理のため、 &#039;&#039;&#039;/mymodule/sql/&#039;&#039;&#039;  ディレクトリ内に  &#039;&#039;&#039;data.sql&#039;&#039;&#039;  というファイルを作成し、データの追加/編集/削除を行う SQL コマンドを記述すること.&lt;br /&gt;
*文字列にダブルクォートを使わない（例： &amp;quot;chaine&amp;quot; でなく &#039;chaine&#039;） ダブルクォートは PostGreSQL では特定の意味を持つ&lt;br /&gt;
&lt;br /&gt;
例としてファイル data.sql の中身は&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ファイルは、mysql データベースで動作可能であること. 備考: 他データベースのファイルはメンテナンスされない. 他データベースのドライバによって、その場で読込まれ変換さる.&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;
DAO PHPファイルは、オブジェクトを作成した後にモジュールビルダによって生成されているはず.&lt;br /&gt;
&lt;br /&gt;
だとしても、既存オブジェクトをコピーして手動作成することもできる、しかし、モジュールビルダの使用を強く勧める。実例がここにあるはず &#039;&#039;&#039;htdocs/modulebuilder/templates/class/myobject.class.php&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
このクラスでは、テーブル行の挿入、取得（選択）、更新、削除を実行するためのCRUD（作成/読込/更新/削除）メソッドがすでに実行可能となっている。正しいモジュール名、テーブルを使用するようにファイルを編集し、このファイルをモジュールのクラスサブディレクトリに配置する。モジュールビルダを使用すると、マウスを数回クリックするだけで、この作業を実行できる.&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;
そのためには、先に作成したモジュールのファイル記述に行って、$this-&amp;gt;tabs 配列を編集する:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
テーブルには文字列のリストが含まれ、各文字列は新しいタブを表す．文字列の形式は &amp;quot;: &amp;quot; で区切られた5つの部分からなる．&lt;br /&gt;
&lt;br /&gt;
*Part 1: タブを表示するエレメントタイプ（オブジェクトタイプ）で、以下の値:&lt;br /&gt;
{{TemplateModuleTabsJA}}&lt;br /&gt;
&lt;br /&gt;
*Part 2: タブのコードで、タブの追加（+で始まる）または削除（-で始まる）を識別する．&lt;br /&gt;
*Part 3: タブのタイトル．タイトルが読みずらいなら、コードにして言語ファイルで翻訳するとよい．&lt;br /&gt;
*Part 4: ファイル名 &amp;quot;*.lang&amp;quot; は、コード翻訳と表示する言語の対応を含む．この名前の後に@mymoduleが続く場合、 Dolibarrはモジュール内の翻訳ファイル &amp;quot;*.lang &amp;quot;を検索するので、htdocs/mymodule/langs/code_CODE/mylangfile.langとなり、そうでない場合はhtdocs/langs/code_CODE/mylangfile.langとなる．&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;
既存タブの名前 &#039;tabname&#039; を取得するには、ファイル &#039;core/lib/module.lib.php&#039; の関数 &#039;product_prepare_head&#039; で使用されている名前で、セクション &#039;$head[$h][2]&#039; に対応するものをチェックする必要がある．&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. Include files you need into your file&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each object type, there are two files to include with line&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;require_once($url_fichier) ;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is example of files to include (DOL_DOCUMENT_ROOT is often dolibarr/htdocs/) :&lt;br /&gt;
&lt;br /&gt;
*Object thirdparty (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;
*Object product (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;
*Object invoice (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. Create and load the object to show into your tab&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create an instance of an object of the correct class and load object from the database by using the fetch method of an object in providing to this method the id you get from URL (ie : /mytab.php?id=1).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Get a list of all tabs to show for your object type&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function XXX_prepare_head($obj), where XXX is name of object. This will return an array with all definition of tab entries to show. The parameter to put into this method is the instance of an object you want tabs.&lt;br /&gt;
&lt;br /&gt;
The resulting array has the following structure&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$head = product_prepare_head($product, $user) ; // parameter $user is present for some function anly&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4. show tabs into your page&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function dol_fiche_head() to show all tabs defined into array $head returned by XX_prepare_head().&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&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;
使用場面: モジュールの目的が、画面の新規作成または変更を必要とする機能の追加である場合.&lt;br /&gt;
&lt;br /&gt;
===新規 PHP 画面の作成===&lt;br /&gt;
次に、 &#039;&#039;&#039;modulebuilder/myobject_page.php&#039;&#039;&#039;  ディレクトリに例として提示されているスケルトンテンプレートを使用して、テーブルのデータを表示/編集するPHPページを作成する必要がある (コマンドラインからのスクリプト開発については、 [[Script development]] を参照).&lt;br /&gt;
&lt;br /&gt;
新しいユーザー画面を作成するには、&#039;&#039;&#039;htdocs&#039;&#039;&#039; のサブディレクトリを作成し（まだ作成されていない場合）、作成するページを保存するために、モジュール（例えば、&#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;
main.inc.phpファイルへの相対パスが正しくなるようにファイルを編集する. &lt;br /&gt;
&amp;lt;syntaxhighlight 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 calculated 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
As you can see, there are several tries to load the main.inc.php (or master.inc.php). The goal is to succeed in the most cases as possible. The minimum is 2 lines: one to try to load the master/main.inc.php into the dolibarr root directory and another one to try to load the file to support the case when the module is deployed into the &amp;quot;custom&amp;quot; directory. But you can have more to deal more situation. The provided example should be able to load the file main/master.inc.php in nearly all situation/setups.&lt;br /&gt;
&lt;br /&gt;
Note that you may add more &amp;quot;../&amp;quot; depending on the depth of the file relative to your module directory tree.&lt;br /&gt;
&lt;br /&gt;
It&#039;s in the main.inc.php file that is loaded technical environment variables and permissions. The following variables are objects positioned in this file:&lt;br /&gt;
&lt;br /&gt;
*$user    Object that contains the characteristics of the user + his permissions.&lt;br /&gt;
*$conf    Object that contains Dolibarr configuration.&lt;br /&gt;
*$db      Object that contains an opened connection handler to the database.&lt;br /&gt;
*$langs   Object that contains the user&#039;s language.&lt;br /&gt;
&lt;br /&gt;
Then enter your code to display the page.&lt;br /&gt;
&lt;br /&gt;
*To include a class or library dedicated to the module is done using a Dolibarr function (and not using directly include_once):&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*To include classes provided with Dolibarr, use the following syntax:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add some fields into existing forms===&lt;br /&gt;
You may want to provide a module that adds more fields into forms (input and view) of some elements. &lt;br /&gt;
&lt;br /&gt;
A heavy solution (but not so bad) may be to replace all pages used to create element (this means to disable the &amp;quot;New element&amp;quot; menu entry and adding yours, and disable tab that shows element to replace with a tab that is your own full page (copied/pasted from original) to do same than original page but modified to add your fields and stored added data into your own table). Go to menu [[#Define your entries in the menu (optional)]] and [[#The tab management (optional)]] if this solution suits you (this solution is more powerful since you can change everything you want into the page). &lt;br /&gt;
&lt;br /&gt;
We will describe here another solution, that works only to &amp;quot;add fields&amp;quot; at end of existing fields, using the element &amp;quot;category&amp;quot; as an example but you can convert this tutorial for invoice, proposal ...&lt;br /&gt;
&lt;br /&gt;
*First thing is to add a table, owned by your module, to store the value of new fields. This table will have only one column called &amp;quot;rowid&amp;quot; (will contain the same value than field rowid of element table) + one column for each new field you want to add. Then create a class with CRUD (Create/Read/Update/Delete) methods for this new table. For this two tasks, go back to previous chapter [[#Create your SQL tables and the PHP DAO class]].&lt;br /&gt;
*Next step is to add a hook into your module to add the new fields into the form. See chapter [[Hooks_system#Implement_the_Hook]] for generic documentation to use hooks.&lt;br /&gt;
&lt;br /&gt;
If you follow this tutorial, to be able to add fields into category forms, you must do:&lt;br /&gt;
{{ToComplete}}&lt;br /&gt;
&lt;br /&gt;
===Add/replace part of fields supported by hooks===&lt;br /&gt;
See chapter [[Hooks_system#Implement_the_Hook]] to know how to use Dolibarr existing hooks to add/replace code at Dolibarr hooks place.&lt;br /&gt;
&lt;br /&gt;
===Database access===&lt;br /&gt;
If you need to edit some data in the database inside your own table, use the PHP class generated before.&lt;br /&gt;
&lt;br /&gt;
If you to make access to tables with no dedicated PHP class available, this is always possible (for example if you want to get a list of records with a particular join or filter). In this case, this is a code samples to follow:&lt;br /&gt;
&lt;br /&gt;
To make an insert, update or delete:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To read:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Define style of your pages===&lt;br /&gt;
To have the look of your own pages to match the Dolibarr theme, it is necessary to use the Dolibarr CSS styles.&lt;br /&gt;
&lt;br /&gt;
You can use for example:&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;
===Use the Dolibarr date picker===&lt;br /&gt;
If you want to use the Dolibarr date selector (with its calendar popup) into your pages, use the following line:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
The string mykey will identify the date selector in the form. You must use different values if you use several date selectors in same page.&lt;br /&gt;
The string myform is the name of the FORM in which the selector is included (value found in the form name=&amp;quot;myform&amp;quot; in HTML page).&lt;br /&gt;
This means a date selector must be included necessarily into an html FORM.&lt;br /&gt;
&lt;br /&gt;
To get value after the POST of your form, the command is:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$mydate = dol_mktime(12, 0 , 0, $GETPOST(&#039;mykeymonth&#039;, &#039;int&#039;), GETPOST(&#039;mykeyday&#039;, &#039;int&#039;), GETPOST(&#039;mykeyyear&#039;, &#039;int&#039;));&lt;br /&gt;
print strftime(&#039;%A %d %B %Y&#039;, $mydate);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Overwrite template file (tpl)===&lt;br /&gt;
If you want to overwrite tpl file on your module, you need to declare it on the module_parts :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
&#039;tpl&#039; =&amp;gt; 1,&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Then you can put any tpl file on &#039;&#039;&#039;mymodule/core/tpl&#039;&#039;&#039;&lt;br /&gt;
as soon as the module is activate, the tpl will be overwrited&lt;br /&gt;
&lt;br /&gt;
==自前の準備ページを追加 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs parameters, which are to be provided by the user, for proper setting up of the module.&lt;br /&gt;
&lt;br /&gt;
===Create your page to edit parameters===&lt;br /&gt;
If your module needs several parameters to be setup, you must create a page to edit options (these options will be saved in the [[Table llx_const|table &#039;&#039;&#039;llx_const&#039;&#039;&#039;]]).&lt;br /&gt;
Create a page named &#039;&#039;&#039;mymodule_setuppage.php&#039;&#039;&#039; that shows a form for possible options to update them into the above-mentioned table.&lt;br /&gt;
It is necessary to take an example from a page of the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; that will show you the way to read/save your parameters.&lt;br /&gt;
Put this PHP page into the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; of your module (e.g. mymodule/admin/mymodule_setuppage.php).&lt;br /&gt;
&lt;br /&gt;
===Modify the descriptor file of your module===&lt;br /&gt;
Then, within the descriptor file of your module, modify the variable &#039;&#039;&#039;config_page_url&#039;&#039;&#039; to set the name of this PHP page.&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;admin/&#039;&#039;&#039;, then the path is not required, e.g. like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;mymodule/admin/&#039;&#039;&#039;, then like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test your page===&lt;br /&gt;
Go into page &#039;&#039;&#039;Home-&amp;gt;Setup-&amp;gt;Modules&#039;&#039;&#039;, you should see a picture at the end of the line of your module to reach your setup page. Click on it, you should be able to view/edit parameters from your page.&lt;br /&gt;
&lt;br /&gt;
==メニューに自前項目を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If you have created PHP pages, it is necessary that those pages can be reached from menu entries in Dolibarr menu.&lt;br /&gt;
&lt;br /&gt;
===Define your menu entries===&lt;br /&gt;
For this, you must define into the module descriptor, the array this-&amp;gt;menu that declares 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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To show the menu or not depending on a permission, modify property &#039;&#039;&#039;perms&#039;&#039;&#039; in the array. See chapter on permissions later to see how to add permissions.&lt;br /&gt;
&lt;br /&gt;
===Test your menu entries===&lt;br /&gt;
Disable and re-enable your module under the 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;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;rights_class = &#039;mymodule&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight 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][2] = &#039;r&#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;/syntaxhighlight&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][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; Translation key should be &amp;quot;Permission10001=My permission Label&amp;quot;).&lt;br /&gt;
Into $this-&amp;gt;rights[$r][2], types of the permission. There are three type of permission, &#039;r&#039; for read, list or expert permission, &#039;w&#039; for write or update permission and &#039;d&#039; for delete permission.&lt;br /&gt;
Into $this-&amp;gt;rights[$r][3], put 1 if this permission must be granted automatically by default to any newly created user.&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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==自前の box を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs to provide one or several new boxes to show on home page.&lt;br /&gt;
&lt;br /&gt;
===Define your box===&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;syntaxhighlight 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;/syntaxhighlight&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 activate. Activate the box and go on the home page to see if the box is showing correctly.&lt;br /&gt;
&lt;br /&gt;
==自前のエキスポートを定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module provides new predefined database export profiles (for its own tables or for already existing tables of another module).&lt;br /&gt;
&lt;br /&gt;
===Define export===&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 a 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;
==自前の CSS スタイルを定義 (任意)==&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 several CSS files 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 files only if you need absolutely to add not already existing styles.&lt;br /&gt;
&lt;br /&gt;
Once your style sheets are ready, declare them 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 an array of relative URLs to your CSS files.&lt;br /&gt;
For example&lt;br /&gt;
&amp;lt;syntaxhighlight 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;,&#039;/mymodule/css/myother.css&#039;));&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 the 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 declares your style sheet.&lt;br /&gt;
&lt;br /&gt;
==自前の Javascript 関数を追加 (任意)==&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;syntaxhighlight 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;/syntaxhighlight&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;
==Dolibarr フックポジションの内部に、自前コードを挿入 (任意)==&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 the 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 are not covered by existing rules.&lt;br /&gt;
&lt;br /&gt;
See page [[Create numbering module]].&lt;br /&gt;
&lt;br /&gt;
==自前の文書テンプレートを追加 (任意)==&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;
==自前のスキンを追加 (任意)==&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;
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 marketplace.&lt;br /&gt;
But you can use it to have a package easy to distribute on your own 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 a 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
perl makepack-dolibarrmodule.pl&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
tar -xvf mymodule.zip&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 marketplace website: {{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 built correctly, the file will be validated later.&lt;br /&gt;
**If quality is enough and license permits it, the code might be added inside main Dolibarr sources (except if you disagree for that).&lt;br /&gt;
&lt;br /&gt;
=DoliStore での外部モジュール 有効化/活性化 条件=&lt;br /&gt;
&lt;br /&gt;
See [[Module_Dolistore_Validation_Rules|Validation Rules]]&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56885</id>
		<title>モジュール 開発</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56885"/>
		<updated>2023-06-24T06:54:22Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: /* オブジェクトシートに自前のタブを追加・削除できる */&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:Développement_module]]&lt;br /&gt;
[[es:Desarrollo_de_un_módulo]]&lt;br /&gt;
[[de:Modul_Entwicklung]]&lt;br /&gt;
[[zh:模块开发]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Core]]&lt;br /&gt;
{{TemplateDocDevEn}}&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;
etc...&lt;br /&gt;
&lt;br /&gt;
以下の章では、これらすべてを手作業で簡単に行う方法を示す.&lt;br /&gt;
&lt;br /&gt;
=モジュールビルダ によるモジュールの生成=&lt;br /&gt;
Dolibarr 9.0 から、モジュールビルダにより、自前モジュールのメインページ作成が可能. 起動方法は:&lt;br /&gt;
&lt;br /&gt;
*モジュールリストにて、&amp;quot;モジュールビルダ(Module Builder)&amp;quot;を有効化する,&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_2.png|400px]]&lt;br /&gt;
&lt;br /&gt;
*その後 &amp;quot;バグ(bug)&amp;quot; 画像をクリック、場所は画面右上.&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_3.png|400px]]&lt;br /&gt;
&lt;br /&gt;
=テンプレート外部モジュールの例=&lt;br /&gt;
外部モジュールの開発を開始するのによいお手本は、ここで見つかるだろう : [https://github.com/Dolibarr/dolibarr/tree/develop/htdocs/modulebuilder/template GitHub Dolibarr Module Modèle]&lt;br /&gt;
&lt;br /&gt;
=自前モジュールを作る=&lt;br /&gt;
==自前モジュールに関するモジュール記述(Module descriptor)を作る (必須)==&lt;br /&gt;
&#039;&#039;&#039;必須となる時期&#039;&#039;&#039;: アドオンを開発すると早急に必要、たとえゴールが何であれ (例外はスキンの追加).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Dolibarr 9.0 から, モジュールビルダ (ModuleBuilder) モジュールを使用すべきだ、モジュール記述を生成するための標準モデルとして使える&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===自前のモジュール記述 (module descriptor) を作成する===&lt;br /&gt;
最初のステップは、モジュールに対するファイル記述 (file descriptor) を作成すること. (訳者注： 以下の内容は&#039;&#039;&#039;モジュールビルダを使うことで自動設定&#039;&#039;&#039;される) &lt;br /&gt;
&lt;br /&gt;
*ディレクトリ作成： &#039;&#039;&#039;/htdocs/custom/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; (外部モジュール向け) または &#039;&#039;&#039;/htdocs/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; ここはDolibarr の公式コアモジュール (official core module) とする場合. 次にファイル modMyModule.class.php をディレクトリ &#039;&#039;&#039;htdocs/modulebuilder/template&#039;&#039;&#039; からコピーして上記のディレクトリに作成. ファイルの名称を modMyModule.class.php から 自前モジュールの目的に合致した名称に変更. ファイル名は、先頭に &#039;mod&#039; があり、最後が .class.php で終わる (例えば、ファイル名を &#039;新名&#039; にするなら, &#039;mod新名.class.php&#039; となる).&lt;br /&gt;
&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;
*番号を変更: $this-&amp;gt;numero = 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;
Dolibarrを起動し、&#039;&#039;&#039;設定-&amp;gt;モジュール (Setup-&amp;gt;module&#039;&#039;&#039;?) ページを表示.&lt;br /&gt;
モジュール記述でプロパティバージョン (property version) を設定すると、自前の新規モジュールを載せた新規行とそれを有効化するかどうかの選択が表示されるはず. プロパティバージョンを &amp;quot;develop&amp;quot; または &amp;quot;experimental&amp;quot; に設定した場合、自前モジュールを見るには、まず &#039;&#039;&#039;設定-&amp;gt;その他 (Setup-Others)&#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;
これは、新しいモジュールを構築する際に、ファイルをどう整理するかを示している (ZIPファイルもこのルールに合わせる必要あり).&lt;br /&gt;
注：2行目だけが必須.&lt;br /&gt;
&lt;br /&gt;
{{TemplateModuleTreeSimpleJA}}&lt;br /&gt;
&lt;br /&gt;
==自前 SQL テーブル と PHP DAO クラス (任意)==&lt;br /&gt;
&#039;&#039;&#039;使用場面&#039;&#039;&#039;: 自前モジュールがそれ自身のデータを管理する必要がある場合&lt;br /&gt;
&lt;br /&gt;
===自前の .sql ファイルを作成===&lt;br /&gt;
自前モジュールが、Dolibarr標準版では利用できない独自データを管理する設計である場合、そのデータを格納するためのSQLテーブルを定義する必要がある.&lt;br /&gt;
&lt;br /&gt;
自前モジュールでテーブルを作成したり、データを読込むためのスクリプトは、自前モジュールのsqlサブディレクトリ (&amp;quot;&#039;&#039;&#039;mymodule/sql&#039;&#039;&#039;&amp;quot;) に保存される。(ModuleBuilder では、オブジェクト タブから新しいオブジェクトを作成するとき、このディレクトリとすべての sql ファイルが自動作成される）.&lt;br /&gt;
&lt;br /&gt;
次に、記述ファイルでの、&#039;&#039;&#039;init&#039;&#039;&#039; 関数にて、次の行&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;$this-&amp;gt;_load_tables(&#039;/mymodule/sql/&#039;);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
が、コメントでないことを確認する.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;従うべきルール:&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*テーブルごとに &#039;&#039;&#039;llx_matable.sql&#039;&#039;&#039; ファイルを１つ、&#039;&#039;&#039;llx_matable.key.sql&#039;&#039;&#039; ファイルを可能なら１つ、作成するという原則に基づき、テーブル作成コマンドのファイルを追加する（例として、 &#039;&#039;&#039;install/mysql/tables&#039;&#039;&#039; にあるファイルを参照）.&lt;br /&gt;
*SQLフィールドの推奨される型と名前は、このページに定義されてる [[Language_and_development_rules#Table_and_fields_structures]].&lt;br /&gt;
*データ管理のため、 &#039;&#039;&#039;/mymodule/sql/&#039;&#039;&#039;  ディレクトリ内に  &#039;&#039;&#039;data.sql&#039;&#039;&#039;  というファイルを作成し、データの追加/編集/削除を行う SQL コマンドを記述すること.&lt;br /&gt;
*文字列にダブルクォートを使わない（例： &amp;quot;chaine&amp;quot; でなく &#039;chaine&#039;） ダブルクォートは PostGreSQL では特定の意味を持つ&lt;br /&gt;
&lt;br /&gt;
例としてファイル data.sql の中身は&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ファイルは、mysql データベースで動作可能であること. 備考: 他データベースのファイルはメンテナンスされない. 他データベースのドライバによって、その場で読込まれ変換さる.&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;
DAO PHPファイルは、オブジェクトを作成した後にモジュールビルダによって生成されているはず.&lt;br /&gt;
&lt;br /&gt;
だとしても、既存オブジェクトをコピーして手動作成することもできる、しかし、モジュールビルダの使用を強く勧める。実例がここにあるはず &#039;&#039;&#039;htdocs/modulebuilder/templates/class/myobject.class.php&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
このクラスでは、テーブル行の挿入、取得（選択）、更新、削除を実行するためのCRUD（作成/読込/更新/削除）メソッドがすでに実行可能となっている。正しいモジュール名、テーブルを使用するようにファイルを編集し、このファイルをモジュールのクラスサブディレクトリに配置する。モジュールビルダを使用すると、マウスを数回クリックするだけで、この作業を実行できる.&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;
そのためには、先に作成したモジュールのファイル記述に行って、$this-&amp;gt;tabs 配列を編集する:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
テーブルには文字列のリストが含まれ、各文字列は新しいタブを表す．文字列の形式は &amp;quot;: &amp;quot; で区切られた5つの部分で構成される．&lt;br /&gt;
&lt;br /&gt;
*Part 1: タブを表示するエレメントタイプ（オブジェクトタイプ）で、以下の値:&lt;br /&gt;
{{TemplateModuleTabsJA}}&lt;br /&gt;
&lt;br /&gt;
*Part 2: タブのコードで、タブの追加（+で始まる）または削除（-で始まる）を識別する．&lt;br /&gt;
*Part 3: タブのタイトル．タイトルが読みずらいなら、コードにして言語ファイルで翻訳するとよい．&lt;br /&gt;
*Part 4: ファイル名 &amp;quot;*.lang&amp;quot; は、コード翻訳と表示する言語の対応を含む．この名前の後に@mymoduleが続く場合、 Dolibarrはモジュール内の翻訳ファイル &amp;quot;*.lang &amp;quot;を検索するので、htdocs/mymodule/langs/code_CODE/mylangfile.langとなり、そうでない場合はhtdocs/langs/code_CODE/mylangfile.langとなる．&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;
既存タブの名前 &#039;tabname&#039; を取得するには、ファイル &#039;core/lib/module.lib.php&#039; の関数 &#039;product_prepare_head&#039; で使用されている名前で、セクション &#039;$head[$h][2]&#039; に対応するものをチェックする必要がある．&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. Include files you need into your file&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each object type, there are two files to include with line&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;require_once($url_fichier) ;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is example of files to include (DOL_DOCUMENT_ROOT is often dolibarr/htdocs/) :&lt;br /&gt;
&lt;br /&gt;
*Object thirdparty (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;
*Object product (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;
*Object invoice (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. Create and load the object to show into your tab&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create an instance of an object of the correct class and load object from the database by using the fetch method of an object in providing to this method the id you get from URL (ie : /mytab.php?id=1).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Get a list of all tabs to show for your object type&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function XXX_prepare_head($obj), where XXX is name of object. This will return an array with all definition of tab entries to show. The parameter to put into this method is the instance of an object you want tabs.&lt;br /&gt;
&lt;br /&gt;
The resulting array has the following structure&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$head = product_prepare_head($product, $user) ; // parameter $user is present for some function anly&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4. show tabs into your page&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function dol_fiche_head() to show all tabs defined into array $head returned by XX_prepare_head().&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&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;
使用場面: モジュールの目的が、画面の新規作成または変更を必要とする機能の追加である場合.&lt;br /&gt;
&lt;br /&gt;
===新規 PHP 画面の作成===&lt;br /&gt;
次に、 &#039;&#039;&#039;modulebuilder/myobject_page.php&#039;&#039;&#039;  ディレクトリに例として提示されているスケルトンテンプレートを使用して、テーブルのデータを表示/編集するPHPページを作成する必要がある (コマンドラインからのスクリプト開発については、 [[Script development]] を参照).&lt;br /&gt;
&lt;br /&gt;
新しいユーザー画面を作成するには、&#039;&#039;&#039;htdocs&#039;&#039;&#039; のサブディレクトリを作成し（まだ作成されていない場合）、作成するページを保存するために、モジュール（例えば、&#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;
main.inc.phpファイルへの相対パスが正しくなるようにファイルを編集する. &lt;br /&gt;
&amp;lt;syntaxhighlight 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 calculated 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
As you can see, there are several tries to load the main.inc.php (or master.inc.php). The goal is to succeed in the most cases as possible. The minimum is 2 lines: one to try to load the master/main.inc.php into the dolibarr root directory and another one to try to load the file to support the case when the module is deployed into the &amp;quot;custom&amp;quot; directory. But you can have more to deal more situation. The provided example should be able to load the file main/master.inc.php in nearly all situation/setups.&lt;br /&gt;
&lt;br /&gt;
Note that you may add more &amp;quot;../&amp;quot; depending on the depth of the file relative to your module directory tree.&lt;br /&gt;
&lt;br /&gt;
It&#039;s in the main.inc.php file that is loaded technical environment variables and permissions. The following variables are objects positioned in this file:&lt;br /&gt;
&lt;br /&gt;
*$user    Object that contains the characteristics of the user + his permissions.&lt;br /&gt;
*$conf    Object that contains Dolibarr configuration.&lt;br /&gt;
*$db      Object that contains an opened connection handler to the database.&lt;br /&gt;
*$langs   Object that contains the user&#039;s language.&lt;br /&gt;
&lt;br /&gt;
Then enter your code to display the page.&lt;br /&gt;
&lt;br /&gt;
*To include a class or library dedicated to the module is done using a Dolibarr function (and not using directly include_once):&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*To include classes provided with Dolibarr, use the following syntax:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add some fields into existing forms===&lt;br /&gt;
You may want to provide a module that adds more fields into forms (input and view) of some elements. &lt;br /&gt;
&lt;br /&gt;
A heavy solution (but not so bad) may be to replace all pages used to create element (this means to disable the &amp;quot;New element&amp;quot; menu entry and adding yours, and disable tab that shows element to replace with a tab that is your own full page (copied/pasted from original) to do same than original page but modified to add your fields and stored added data into your own table). Go to menu [[#Define your entries in the menu (optional)]] and [[#The tab management (optional)]] if this solution suits you (this solution is more powerful since you can change everything you want into the page). &lt;br /&gt;
&lt;br /&gt;
We will describe here another solution, that works only to &amp;quot;add fields&amp;quot; at end of existing fields, using the element &amp;quot;category&amp;quot; as an example but you can convert this tutorial for invoice, proposal ...&lt;br /&gt;
&lt;br /&gt;
*First thing is to add a table, owned by your module, to store the value of new fields. This table will have only one column called &amp;quot;rowid&amp;quot; (will contain the same value than field rowid of element table) + one column for each new field you want to add. Then create a class with CRUD (Create/Read/Update/Delete) methods for this new table. For this two tasks, go back to previous chapter [[#Create your SQL tables and the PHP DAO class]].&lt;br /&gt;
*Next step is to add a hook into your module to add the new fields into the form. See chapter [[Hooks_system#Implement_the_Hook]] for generic documentation to use hooks.&lt;br /&gt;
&lt;br /&gt;
If you follow this tutorial, to be able to add fields into category forms, you must do:&lt;br /&gt;
{{ToComplete}}&lt;br /&gt;
&lt;br /&gt;
===Add/replace part of fields supported by hooks===&lt;br /&gt;
See chapter [[Hooks_system#Implement_the_Hook]] to know how to use Dolibarr existing hooks to add/replace code at Dolibarr hooks place.&lt;br /&gt;
&lt;br /&gt;
===Database access===&lt;br /&gt;
If you need to edit some data in the database inside your own table, use the PHP class generated before.&lt;br /&gt;
&lt;br /&gt;
If you to make access to tables with no dedicated PHP class available, this is always possible (for example if you want to get a list of records with a particular join or filter). In this case, this is a code samples to follow:&lt;br /&gt;
&lt;br /&gt;
To make an insert, update or delete:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To read:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Define style of your pages===&lt;br /&gt;
To have the look of your own pages to match the Dolibarr theme, it is necessary to use the Dolibarr CSS styles.&lt;br /&gt;
&lt;br /&gt;
You can use for example:&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;
===Use the Dolibarr date picker===&lt;br /&gt;
If you want to use the Dolibarr date selector (with its calendar popup) into your pages, use the following line:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
The string mykey will identify the date selector in the form. You must use different values if you use several date selectors in same page.&lt;br /&gt;
The string myform is the name of the FORM in which the selector is included (value found in the form name=&amp;quot;myform&amp;quot; in HTML page).&lt;br /&gt;
This means a date selector must be included necessarily into an html FORM.&lt;br /&gt;
&lt;br /&gt;
To get value after the POST of your form, the command is:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$mydate = dol_mktime(12, 0 , 0, $GETPOST(&#039;mykeymonth&#039;, &#039;int&#039;), GETPOST(&#039;mykeyday&#039;, &#039;int&#039;), GETPOST(&#039;mykeyyear&#039;, &#039;int&#039;));&lt;br /&gt;
print strftime(&#039;%A %d %B %Y&#039;, $mydate);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Overwrite template file (tpl)===&lt;br /&gt;
If you want to overwrite tpl file on your module, you need to declare it on the module_parts :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
&#039;tpl&#039; =&amp;gt; 1,&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Then you can put any tpl file on &#039;&#039;&#039;mymodule/core/tpl&#039;&#039;&#039;&lt;br /&gt;
as soon as the module is activate, the tpl will be overwrited&lt;br /&gt;
&lt;br /&gt;
==自前の準備ページを追加 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs parameters, which are to be provided by the user, for proper setting up of the module.&lt;br /&gt;
&lt;br /&gt;
===Create your page to edit parameters===&lt;br /&gt;
If your module needs several parameters to be setup, you must create a page to edit options (these options will be saved in the [[Table llx_const|table &#039;&#039;&#039;llx_const&#039;&#039;&#039;]]).&lt;br /&gt;
Create a page named &#039;&#039;&#039;mymodule_setuppage.php&#039;&#039;&#039; that shows a form for possible options to update them into the above-mentioned table.&lt;br /&gt;
It is necessary to take an example from a page of the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; that will show you the way to read/save your parameters.&lt;br /&gt;
Put this PHP page into the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; of your module (e.g. mymodule/admin/mymodule_setuppage.php).&lt;br /&gt;
&lt;br /&gt;
===Modify the descriptor file of your module===&lt;br /&gt;
Then, within the descriptor file of your module, modify the variable &#039;&#039;&#039;config_page_url&#039;&#039;&#039; to set the name of this PHP page.&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;admin/&#039;&#039;&#039;, then the path is not required, e.g. like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;mymodule/admin/&#039;&#039;&#039;, then like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test your page===&lt;br /&gt;
Go into page &#039;&#039;&#039;Home-&amp;gt;Setup-&amp;gt;Modules&#039;&#039;&#039;, you should see a picture at the end of the line of your module to reach your setup page. Click on it, you should be able to view/edit parameters from your page.&lt;br /&gt;
&lt;br /&gt;
==メニューに自前項目を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If you have created PHP pages, it is necessary that those pages can be reached from menu entries in Dolibarr menu.&lt;br /&gt;
&lt;br /&gt;
===Define your menu entries===&lt;br /&gt;
For this, you must define into the module descriptor, the array this-&amp;gt;menu that declares 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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To show the menu or not depending on a permission, modify property &#039;&#039;&#039;perms&#039;&#039;&#039; in the array. See chapter on permissions later to see how to add permissions.&lt;br /&gt;
&lt;br /&gt;
===Test your menu entries===&lt;br /&gt;
Disable and re-enable your module under the 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;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;rights_class = &#039;mymodule&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight 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][2] = &#039;r&#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;/syntaxhighlight&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][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; Translation key should be &amp;quot;Permission10001=My permission Label&amp;quot;).&lt;br /&gt;
Into $this-&amp;gt;rights[$r][2], types of the permission. There are three type of permission, &#039;r&#039; for read, list or expert permission, &#039;w&#039; for write or update permission and &#039;d&#039; for delete permission.&lt;br /&gt;
Into $this-&amp;gt;rights[$r][3], put 1 if this permission must be granted automatically by default to any newly created user.&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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==自前の box を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs to provide one or several new boxes to show on home page.&lt;br /&gt;
&lt;br /&gt;
===Define your box===&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;syntaxhighlight 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;/syntaxhighlight&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 activate. Activate the box and go on the home page to see if the box is showing correctly.&lt;br /&gt;
&lt;br /&gt;
==自前のエキスポートを定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module provides new predefined database export profiles (for its own tables or for already existing tables of another module).&lt;br /&gt;
&lt;br /&gt;
===Define export===&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 a 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;
==自前の CSS スタイルを定義 (任意)==&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 several CSS files 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 files only if you need absolutely to add not already existing styles.&lt;br /&gt;
&lt;br /&gt;
Once your style sheets are ready, declare them 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 an array of relative URLs to your CSS files.&lt;br /&gt;
For example&lt;br /&gt;
&amp;lt;syntaxhighlight 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;,&#039;/mymodule/css/myother.css&#039;));&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 the 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 declares your style sheet.&lt;br /&gt;
&lt;br /&gt;
==自前の Javascript 関数を追加 (任意)==&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;syntaxhighlight 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;/syntaxhighlight&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;
==Dolibarr フックポジションの内部に、自前コードを挿入 (任意)==&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 the 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 are not covered by existing rules.&lt;br /&gt;
&lt;br /&gt;
See page [[Create numbering module]].&lt;br /&gt;
&lt;br /&gt;
==自前の文書テンプレートを追加 (任意)==&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;
==自前のスキンを追加 (任意)==&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;
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 marketplace.&lt;br /&gt;
But you can use it to have a package easy to distribute on your own 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 a 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
perl makepack-dolibarrmodule.pl&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
tar -xvf mymodule.zip&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 marketplace website: {{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 built correctly, the file will be validated later.&lt;br /&gt;
**If quality is enough and license permits it, the code might be added inside main Dolibarr sources (except if you disagree for that).&lt;br /&gt;
&lt;br /&gt;
=DoliStore での外部モジュール 有効化/活性化 条件=&lt;br /&gt;
&lt;br /&gt;
See [[Module_Dolistore_Validation_Rules|Validation Rules]]&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56557</id>
		<title>モジュール 開発</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56557"/>
		<updated>2023-05-17T06:06:25Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: /* PHP 画面の作成や更新 (任意) */&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:Développement_module]]&lt;br /&gt;
[[es:Desarrollo_de_un_módulo]]&lt;br /&gt;
[[de:Modul_Entwicklung]]&lt;br /&gt;
[[zh:模块开发]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Core]]&lt;br /&gt;
{{TemplateDocDevEn}}&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;
etc...&lt;br /&gt;
&lt;br /&gt;
以下の章では、これらすべてを手作業で簡単に行う方法を示す.&lt;br /&gt;
&lt;br /&gt;
=モジュールビルダ によるモジュールの生成=&lt;br /&gt;
Dolibarr 9.0 から、モジュールビルダにより、自前モジュールのメインページ作成が可能. 起動方法は:&lt;br /&gt;
&lt;br /&gt;
*モジュールリストにて、&amp;quot;モジュールビルダ(Module Builder)&amp;quot;を有効化する,&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_2.png|400px]]&lt;br /&gt;
&lt;br /&gt;
*その後 &amp;quot;バグ(bug)&amp;quot; 画像をクリック、場所は画面右上.&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_3.png|400px]]&lt;br /&gt;
&lt;br /&gt;
=テンプレート外部モジュールの例=&lt;br /&gt;
外部モジュールの開発を開始するのによいお手本は、ここで見つかるだろう : [https://github.com/Dolibarr/dolibarr/tree/develop/htdocs/modulebuilder/template GitHub Dolibarr Module Modèle]&lt;br /&gt;
&lt;br /&gt;
=自前モジュールを作る=&lt;br /&gt;
==自前モジュールに関するモジュール記述(Module descriptor)を作る (必須)==&lt;br /&gt;
&#039;&#039;&#039;必須となる時期&#039;&#039;&#039;: アドオンを開発すると早急に必要、たとえゴールが何であれ (例外はスキンの追加).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Dolibarr 9.0 から, モジュールビルダ (ModuleBuilder) モジュールを使用すべきだ、モジュール記述を生成するための標準モデルとして使える&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===自前のモジュール記述 (module descriptor) を作成する===&lt;br /&gt;
最初のステップは、モジュールに対するファイル記述 (file descriptor) を作成すること. (訳者注： 以下の内容は&#039;&#039;&#039;モジュールビルダを使うことで自動設定&#039;&#039;&#039;される) &lt;br /&gt;
&lt;br /&gt;
*ディレクトリ作成： &#039;&#039;&#039;/htdocs/custom/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; (外部モジュール向け) または &#039;&#039;&#039;/htdocs/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; ここはDolibarr の公式コアモジュール (official core module) とする場合. 次にファイル modMyModule.class.php をディレクトリ &#039;&#039;&#039;htdocs/modulebuilder/template&#039;&#039;&#039; からコピーして上記のディレクトリに作成. ファイルの名称を modMyModule.class.php から 自前モジュールの目的に合致した名称に変更. ファイル名は、先頭に &#039;mod&#039; があり、最後が .class.php で終わる (例えば、ファイル名を &#039;新名&#039; にするなら, &#039;mod新名.class.php&#039; となる).&lt;br /&gt;
&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;
*番号を変更: $this-&amp;gt;numero = 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;
Dolibarrを起動し、&#039;&#039;&#039;設定-&amp;gt;モジュール (Setup-&amp;gt;module&#039;&#039;&#039;?) ページを表示.&lt;br /&gt;
モジュール記述でプロパティバージョン (property version) を設定すると、自前の新規モジュールを載せた新規行とそれを有効化するかどうかの選択が表示されるはず. プロパティバージョンを &amp;quot;develop&amp;quot; または &amp;quot;experimental&amp;quot; に設定した場合、自前モジュールを見るには、まず &#039;&#039;&#039;設定-&amp;gt;その他 (Setup-Others)&#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;
これは、新しいモジュールを構築する際に、ファイルをどう整理するかを示している (ZIPファイルもこのルールに合わせる必要あり).&lt;br /&gt;
注：2行目だけが必須.&lt;br /&gt;
&lt;br /&gt;
{{TemplateModuleTreeSimpleJA}}&lt;br /&gt;
&lt;br /&gt;
==自前 SQL テーブル と PHP DAO クラス (任意)==&lt;br /&gt;
&#039;&#039;&#039;使用場面&#039;&#039;&#039;: 自前モジュールがそれ自身のデータを管理する必要がある場合&lt;br /&gt;
&lt;br /&gt;
===自前の .sql ファイルを作成===&lt;br /&gt;
自前モジュールが、Dolibarr標準版では利用できない独自データを管理する設計である場合、そのデータを格納するためのSQLテーブルを定義する必要がある.&lt;br /&gt;
&lt;br /&gt;
自前モジュールでテーブルを作成したり、データを読込むためのスクリプトは、自前モジュールのsqlサブディレクトリ (&amp;quot;&#039;&#039;&#039;mymodule/sql&#039;&#039;&#039;&amp;quot;) に保存される。(ModuleBuilder では、オブジェクト タブから新しいオブジェクトを作成するとき、このディレクトリとすべての sql ファイルが自動作成される）.&lt;br /&gt;
&lt;br /&gt;
次に、記述ファイルでの、&#039;&#039;&#039;init&#039;&#039;&#039; 関数にて、次の行&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;$this-&amp;gt;_load_tables(&#039;/mymodule/sql/&#039;);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
が、コメントでないことを確認する.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;従うべきルール:&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*テーブルごとに &#039;&#039;&#039;llx_matable.sql&#039;&#039;&#039; ファイルを１つ、&#039;&#039;&#039;llx_matable.key.sql&#039;&#039;&#039; ファイルを可能なら１つ、作成するという原則に基づき、テーブル作成コマンドのファイルを追加する（例として、 &#039;&#039;&#039;install/mysql/tables&#039;&#039;&#039; にあるファイルを参照）.&lt;br /&gt;
*SQLフィールドの推奨される型と名前は、このページに定義されてる [[Language_and_development_rules#Table_and_fields_structures]].&lt;br /&gt;
*データ管理のため、 &#039;&#039;&#039;/mymodule/sql/&#039;&#039;&#039;  ディレクトリ内に  &#039;&#039;&#039;data.sql&#039;&#039;&#039;  というファイルを作成し、データの追加/編集/削除を行う SQL コマンドを記述すること.&lt;br /&gt;
*文字列にダブルクォートを使わない（例： &amp;quot;chaine&amp;quot; でなく &#039;chaine&#039;） ダブルクォートは PostGreSQL では特定の意味を持つ&lt;br /&gt;
&lt;br /&gt;
例としてファイル data.sql の中身は&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ファイルは、mysql データベースで動作可能であること. 備考: 他データベースのファイルはメンテナンスされない. 他データベースのドライバによって、その場で読込まれ変換さる.&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;
DAO PHPファイルは、オブジェクトを作成した後にモジュールビルダによって生成されているはず.&lt;br /&gt;
&lt;br /&gt;
だとしても、既存オブジェクトをコピーして手動作成することもできる、しかし、モジュールビルダの使用を強く勧める。実例がここにあるはず &#039;&#039;&#039;htdocs/modulebuilder/templates/class/myobject.class.php&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
このクラスでは、テーブル行の挿入、取得（選択）、更新、削除を実行するためのCRUD（作成/読込/更新/削除）メソッドがすでに実行可能となっている。正しいモジュール名、テーブルを使用するようにファイルを編集し、このファイルをモジュールのクラスサブディレクトリに配置する。モジュールビルダを使用すると、マウスを数回クリックするだけで、この作業を実行できる.&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;
そのためには、先に作成したモジュールのファイル記述に行って、$this-&amp;gt;tabs 配列を編集する:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The table should contain a list of strings, each string representing a new tab. &lt;br /&gt;
The format of the string consisting of 5 parts separated by &amp;quot;:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*Part 1: The element type (object type) where the tab should appear is a value from the following:&lt;br /&gt;
{{TemplateModuleTabsJA}}&lt;br /&gt;
&lt;br /&gt;
*Part 2: A code to identify tab to add (start with +) or to remove (start with -)&lt;br /&gt;
*Part 3: The title of the tab. This can be a hard read or better code translation in a file lang.&lt;br /&gt;
*Part 4: The name of the file &amp;quot;*.lang&amp;quot; which contains correspondence between the code translation and language to display. If this name is followed with @mymodule, Dolibarr will search translation file &amp;quot;*.lang&amp;quot; within the module, so htdocs/mymodule/langs/code_CODE/mylangfile.lang, otherwise Dolibarr will look for file htdocs/langs/code_CODE/mylangfile.lang&lt;br /&gt;
*Part 5: A condition to test if tab must be visible. Put 1 to be always visible.&lt;br /&gt;
*Part 6: The URL of the page to display when you click on the tab. The __ID__ string will be replaced automatically by the Id of the element concerned.&lt;br /&gt;
&lt;br /&gt;
To feed the contents of the tab with data from the database, see the next chapter.&lt;br /&gt;
&lt;br /&gt;
In order to get the names  &#039;tabname&#039; of existing tabs, you have to check the names used in the function &#039;product_prepare_head&#039; of the file  &#039;core/lib/module.lib.php&#039; corresponding to section &#039;$head[$h][2]&#039;.&lt;br /&gt;
&lt;br /&gt;
===Show tabs navigation into your own pages===&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: To show all standard tabs of an object (product, tiers, etc.) on your page.&lt;br /&gt;
&lt;br /&gt;
You must follow these steps :&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1. Include files you need into your file&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each object type, there are two files to include with line&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;require_once($url_fichier) ;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is example of files to include (DOL_DOCUMENT_ROOT is often dolibarr/htdocs/) :&lt;br /&gt;
&lt;br /&gt;
*Object thirdparty (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;
*Object product (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;
*Object invoice (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. Create and load the object to show into your tab&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create an instance of an object of the correct class and load object from the database by using the fetch method of an object in providing to this method the id you get from URL (ie : /mytab.php?id=1).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Get a list of all tabs to show for your object type&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function XXX_prepare_head($obj), where XXX is name of object. This will return an array with all definition of tab entries to show. The parameter to put into this method is the instance of an object you want tabs.&lt;br /&gt;
&lt;br /&gt;
The resulting array has the following structure&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$head = product_prepare_head($product, $user) ; // parameter $user is present for some function anly&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4. show tabs into your page&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function dol_fiche_head() to show all tabs defined into array $head returned by XX_prepare_head().&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&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;
使用場面: モジュールの目的が、画面の新規作成または変更を必要とする機能の追加である場合.&lt;br /&gt;
&lt;br /&gt;
===新規 PHP 画面の作成===&lt;br /&gt;
次に、 &#039;&#039;&#039;modulebuilder/myobject_page.php&#039;&#039;&#039;  ディレクトリに例として提示されているスケルトンテンプレートを使用して、テーブルのデータを表示/編集するPHPページを作成する必要がある (コマンドラインからのスクリプト開発については、 [[Script development]] を参照).&lt;br /&gt;
&lt;br /&gt;
新しいユーザー画面を作成するには、&#039;&#039;&#039;htdocs&#039;&#039;&#039; のサブディレクトリを作成し（まだ作成されていない場合）、作成するページを保存するために、モジュール（例えば、&#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;
main.inc.phpファイルへの相対パスが正しくなるようにファイルを編集する. &lt;br /&gt;
&amp;lt;syntaxhighlight 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 calculated 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
As you can see, there are several tries to load the main.inc.php (or master.inc.php). The goal is to succeed in the most cases as possible. The minimum is 2 lines: one to try to load the master/main.inc.php into the dolibarr root directory and another one to try to load the file to support the case when the module is deployed into the &amp;quot;custom&amp;quot; directory. But you can have more to deal more situation. The provided example should be able to load the file main/master.inc.php in nearly all situation/setups.&lt;br /&gt;
&lt;br /&gt;
Note that you may add more &amp;quot;../&amp;quot; depending on the depth of the file relative to your module directory tree.&lt;br /&gt;
&lt;br /&gt;
It&#039;s in the main.inc.php file that is loaded technical environment variables and permissions. The following variables are objects positioned in this file:&lt;br /&gt;
&lt;br /&gt;
*$user    Object that contains the characteristics of the user + his permissions.&lt;br /&gt;
*$conf    Object that contains Dolibarr configuration.&lt;br /&gt;
*$db      Object that contains an opened connection handler to the database.&lt;br /&gt;
*$langs   Object that contains the user&#039;s language.&lt;br /&gt;
&lt;br /&gt;
Then enter your code to display the page.&lt;br /&gt;
&lt;br /&gt;
*To include a class or library dedicated to the module is done using a Dolibarr function (and not using directly include_once):&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*To include classes provided with Dolibarr, use the following syntax:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add some fields into existing forms===&lt;br /&gt;
You may want to provide a module that adds more fields into forms (input and view) of some elements. &lt;br /&gt;
&lt;br /&gt;
A heavy solution (but not so bad) may be to replace all pages used to create element (this means to disable the &amp;quot;New element&amp;quot; menu entry and adding yours, and disable tab that shows element to replace with a tab that is your own full page (copied/pasted from original) to do same than original page but modified to add your fields and stored added data into your own table). Go to menu [[#Define your entries in the menu (optional)]] and [[#The tab management (optional)]] if this solution suits you (this solution is more powerful since you can change everything you want into the page). &lt;br /&gt;
&lt;br /&gt;
We will describe here another solution, that works only to &amp;quot;add fields&amp;quot; at end of existing fields, using the element &amp;quot;category&amp;quot; as an example but you can convert this tutorial for invoice, proposal ...&lt;br /&gt;
&lt;br /&gt;
*First thing is to add a table, owned by your module, to store the value of new fields. This table will have only one column called &amp;quot;rowid&amp;quot; (will contain the same value than field rowid of element table) + one column for each new field you want to add. Then create a class with CRUD (Create/Read/Update/Delete) methods for this new table. For this two tasks, go back to previous chapter [[#Create your SQL tables and the PHP DAO class]].&lt;br /&gt;
*Next step is to add a hook into your module to add the new fields into the form. See chapter [[Hooks_system#Implement_the_Hook]] for generic documentation to use hooks.&lt;br /&gt;
&lt;br /&gt;
If you follow this tutorial, to be able to add fields into category forms, you must do:&lt;br /&gt;
{{ToComplete}}&lt;br /&gt;
&lt;br /&gt;
===Add/replace part of fields supported by hooks===&lt;br /&gt;
See chapter [[Hooks_system#Implement_the_Hook]] to know how to use Dolibarr existing hooks to add/replace code at Dolibarr hooks place.&lt;br /&gt;
&lt;br /&gt;
===Database access===&lt;br /&gt;
If you need to edit some data in the database inside your own table, use the PHP class generated before.&lt;br /&gt;
&lt;br /&gt;
If you to make access to tables with no dedicated PHP class available, this is always possible (for example if you want to get a list of records with a particular join or filter). In this case, this is a code samples to follow:&lt;br /&gt;
&lt;br /&gt;
To make an insert, update or delete:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To read:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Define style of your pages===&lt;br /&gt;
To have the look of your own pages to match the Dolibarr theme, it is necessary to use the Dolibarr CSS styles.&lt;br /&gt;
&lt;br /&gt;
You can use for example:&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;
===Use the Dolibarr date picker===&lt;br /&gt;
If you want to use the Dolibarr date selector (with its calendar popup) into your pages, use the following line:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
The string mykey will identify the date selector in the form. You must use different values if you use several date selectors in same page.&lt;br /&gt;
The string myform is the name of the FORM in which the selector is included (value found in the form name=&amp;quot;myform&amp;quot; in HTML page).&lt;br /&gt;
This means a date selector must be included necessarily into an html FORM.&lt;br /&gt;
&lt;br /&gt;
To get value after the POST of your form, the command is:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$mydate = dol_mktime(12, 0 , 0, $GETPOST(&#039;mykeymonth&#039;, &#039;int&#039;), GETPOST(&#039;mykeyday&#039;, &#039;int&#039;), GETPOST(&#039;mykeyyear&#039;, &#039;int&#039;));&lt;br /&gt;
print strftime(&#039;%A %d %B %Y&#039;, $mydate);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Overwrite template file (tpl)===&lt;br /&gt;
If you want to overwrite tpl file on your module, you need to declare it on the module_parts :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
&#039;tpl&#039; =&amp;gt; 1,&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Then you can put any tpl file on &#039;&#039;&#039;mymodule/core/tpl&#039;&#039;&#039;&lt;br /&gt;
as soon as the module is activate, the tpl will be overwrited&lt;br /&gt;
&lt;br /&gt;
==自前の準備ページを追加 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs parameters, which are to be provided by the user, for proper setting up of the module.&lt;br /&gt;
&lt;br /&gt;
===Create your page to edit parameters===&lt;br /&gt;
If your module needs several parameters to be setup, you must create a page to edit options (these options will be saved in the [[Table llx_const|table &#039;&#039;&#039;llx_const&#039;&#039;&#039;]]).&lt;br /&gt;
Create a page named &#039;&#039;&#039;mymodule_setuppage.php&#039;&#039;&#039; that shows a form for possible options to update them into the above-mentioned table.&lt;br /&gt;
It is necessary to take an example from a page of the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; that will show you the way to read/save your parameters.&lt;br /&gt;
Put this PHP page into the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; of your module (e.g. mymodule/admin/mymodule_setuppage.php).&lt;br /&gt;
&lt;br /&gt;
===Modify the descriptor file of your module===&lt;br /&gt;
Then, within the descriptor file of your module, modify the variable &#039;&#039;&#039;config_page_url&#039;&#039;&#039; to set the name of this PHP page.&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;admin/&#039;&#039;&#039;, then the path is not required, e.g. like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;mymodule/admin/&#039;&#039;&#039;, then like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test your page===&lt;br /&gt;
Go into page &#039;&#039;&#039;Home-&amp;gt;Setup-&amp;gt;Modules&#039;&#039;&#039;, you should see a picture at the end of the line of your module to reach your setup page. Click on it, you should be able to view/edit parameters from your page.&lt;br /&gt;
&lt;br /&gt;
==メニューに自前項目を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If you have created PHP pages, it is necessary that those pages can be reached from menu entries in Dolibarr menu.&lt;br /&gt;
&lt;br /&gt;
===Define your menu entries===&lt;br /&gt;
For this, you must define into the module descriptor, the array this-&amp;gt;menu that declares 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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To show the menu or not depending on a permission, modify property &#039;&#039;&#039;perms&#039;&#039;&#039; in the array. See chapter on permissions later to see how to add permissions.&lt;br /&gt;
&lt;br /&gt;
===Test your menu entries===&lt;br /&gt;
Disable and re-enable your module under the 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;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;rights_class = &#039;mymodule&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight 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][2] = &#039;r&#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;/syntaxhighlight&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][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; Translation key should be &amp;quot;Permission10001=My permission Label&amp;quot;).&lt;br /&gt;
Into $this-&amp;gt;rights[$r][2], types of the permission. There are three type of permission, &#039;r&#039; for read, list or expert permission, &#039;w&#039; for write or update permission and &#039;d&#039; for delete permission.&lt;br /&gt;
Into $this-&amp;gt;rights[$r][3], put 1 if this permission must be granted automatically by default to any newly created user.&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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==自前の box を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs to provide one or several new boxes to show on home page.&lt;br /&gt;
&lt;br /&gt;
===Define your box===&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;syntaxhighlight 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;/syntaxhighlight&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 activate. Activate the box and go on the home page to see if the box is showing correctly.&lt;br /&gt;
&lt;br /&gt;
==自前のエキスポートを定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module provides new predefined database export profiles (for its own tables or for already existing tables of another module).&lt;br /&gt;
&lt;br /&gt;
===Define export===&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 a 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;
==自前の CSS スタイルを定義 (任意)==&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 several CSS files 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 files only if you need absolutely to add not already existing styles.&lt;br /&gt;
&lt;br /&gt;
Once your style sheets are ready, declare them 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 an array of relative URLs to your CSS files.&lt;br /&gt;
For example&lt;br /&gt;
&amp;lt;syntaxhighlight 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;,&#039;/mymodule/css/myother.css&#039;));&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 the 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 declares your style sheet.&lt;br /&gt;
&lt;br /&gt;
==自前の Javascript 関数を追加 (任意)==&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;syntaxhighlight 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;/syntaxhighlight&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;
==Dolibarr フックポジションの内部に、自前コードを挿入 (任意)==&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 the 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 are not covered by existing rules.&lt;br /&gt;
&lt;br /&gt;
See page [[Create numbering module]].&lt;br /&gt;
&lt;br /&gt;
==自前の文書テンプレートを追加 (任意)==&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;
==自前のスキンを追加 (任意)==&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;
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 marketplace.&lt;br /&gt;
But you can use it to have a package easy to distribute on your own 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 a 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
perl makepack-dolibarrmodule.pl&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
tar -xvf mymodule.zip&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 marketplace website: {{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 built correctly, the file will be validated later.&lt;br /&gt;
**If quality is enough and license permits it, the code might be added inside main Dolibarr sources (except if you disagree for that).&lt;br /&gt;
&lt;br /&gt;
=DoliStore での外部モジュール 有効化/活性化 条件=&lt;br /&gt;
&lt;br /&gt;
See [[Module_Dolistore_Validation_Rules|Validation Rules]]&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56556</id>
		<title>モジュール 開発</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56556"/>
		<updated>2023-05-17T03:39:18Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: /* PHP 画面の作成や更新 (任意) */&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:Développement_module]]&lt;br /&gt;
[[es:Desarrollo_de_un_módulo]]&lt;br /&gt;
[[de:Modul_Entwicklung]]&lt;br /&gt;
[[zh:模块开发]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Core]]&lt;br /&gt;
{{TemplateDocDevEn}}&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;
etc...&lt;br /&gt;
&lt;br /&gt;
以下の章では、これらすべてを手作業で簡単に行う方法を示す.&lt;br /&gt;
&lt;br /&gt;
=モジュールビルダ によるモジュールの生成=&lt;br /&gt;
Dolibarr 9.0 から、モジュールビルダにより、自前モジュールのメインページ作成が可能. 起動方法は:&lt;br /&gt;
&lt;br /&gt;
*モジュールリストにて、&amp;quot;モジュールビルダ(Module Builder)&amp;quot;を有効化する,&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_2.png|400px]]&lt;br /&gt;
&lt;br /&gt;
*その後 &amp;quot;バグ(bug)&amp;quot; 画像をクリック、場所は画面右上.&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_3.png|400px]]&lt;br /&gt;
&lt;br /&gt;
=テンプレート外部モジュールの例=&lt;br /&gt;
外部モジュールの開発を開始するのによいお手本は、ここで見つかるだろう : [https://github.com/Dolibarr/dolibarr/tree/develop/htdocs/modulebuilder/template GitHub Dolibarr Module Modèle]&lt;br /&gt;
&lt;br /&gt;
=自前モジュールを作る=&lt;br /&gt;
==自前モジュールに関するモジュール記述(Module descriptor)を作る (必須)==&lt;br /&gt;
&#039;&#039;&#039;必須となる時期&#039;&#039;&#039;: アドオンを開発すると早急に必要、たとえゴールが何であれ (例外はスキンの追加).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Dolibarr 9.0 から, モジュールビルダ (ModuleBuilder) モジュールを使用すべきだ、モジュール記述を生成するための標準モデルとして使える&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===自前のモジュール記述 (module descriptor) を作成する===&lt;br /&gt;
最初のステップは、モジュールに対するファイル記述 (file descriptor) を作成すること. (訳者注： 以下の内容は&#039;&#039;&#039;モジュールビルダを使うことで自動設定&#039;&#039;&#039;される) &lt;br /&gt;
&lt;br /&gt;
*ディレクトリ作成： &#039;&#039;&#039;/htdocs/custom/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; (外部モジュール向け) または &#039;&#039;&#039;/htdocs/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; ここはDolibarr の公式コアモジュール (official core module) とする場合. 次にファイル modMyModule.class.php をディレクトリ &#039;&#039;&#039;htdocs/modulebuilder/template&#039;&#039;&#039; からコピーして上記のディレクトリに作成. ファイルの名称を modMyModule.class.php から 自前モジュールの目的に合致した名称に変更. ファイル名は、先頭に &#039;mod&#039; があり、最後が .class.php で終わる (例えば、ファイル名を &#039;新名&#039; にするなら, &#039;mod新名.class.php&#039; となる).&lt;br /&gt;
&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;
*番号を変更: $this-&amp;gt;numero = 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;
Dolibarrを起動し、&#039;&#039;&#039;設定-&amp;gt;モジュール (Setup-&amp;gt;module&#039;&#039;&#039;?) ページを表示.&lt;br /&gt;
モジュール記述でプロパティバージョン (property version) を設定すると、自前の新規モジュールを載せた新規行とそれを有効化するかどうかの選択が表示されるはず. プロパティバージョンを &amp;quot;develop&amp;quot; または &amp;quot;experimental&amp;quot; に設定した場合、自前モジュールを見るには、まず &#039;&#039;&#039;設定-&amp;gt;その他 (Setup-Others)&#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;
これは、新しいモジュールを構築する際に、ファイルをどう整理するかを示している (ZIPファイルもこのルールに合わせる必要あり).&lt;br /&gt;
注：2行目だけが必須.&lt;br /&gt;
&lt;br /&gt;
{{TemplateModuleTreeSimpleJA}}&lt;br /&gt;
&lt;br /&gt;
==自前 SQL テーブル と PHP DAO クラス (任意)==&lt;br /&gt;
&#039;&#039;&#039;使用場面&#039;&#039;&#039;: 自前モジュールがそれ自身のデータを管理する必要がある場合&lt;br /&gt;
&lt;br /&gt;
===自前の .sql ファイルを作成===&lt;br /&gt;
自前モジュールが、Dolibarr標準版では利用できない独自データを管理する設計である場合、そのデータを格納するためのSQLテーブルを定義する必要がある.&lt;br /&gt;
&lt;br /&gt;
自前モジュールでテーブルを作成したり、データを読込むためのスクリプトは、自前モジュールのsqlサブディレクトリ (&amp;quot;&#039;&#039;&#039;mymodule/sql&#039;&#039;&#039;&amp;quot;) に保存される。(ModuleBuilder では、オブジェクト タブから新しいオブジェクトを作成するとき、このディレクトリとすべての sql ファイルが自動作成される）.&lt;br /&gt;
&lt;br /&gt;
次に、記述ファイルでの、&#039;&#039;&#039;init&#039;&#039;&#039; 関数にて、次の行&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;$this-&amp;gt;_load_tables(&#039;/mymodule/sql/&#039;);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
が、コメントでないことを確認する.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;従うべきルール:&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*テーブルごとに &#039;&#039;&#039;llx_matable.sql&#039;&#039;&#039; ファイルを１つ、&#039;&#039;&#039;llx_matable.key.sql&#039;&#039;&#039; ファイルを可能なら１つ、作成するという原則に基づき、テーブル作成コマンドのファイルを追加する（例として、 &#039;&#039;&#039;install/mysql/tables&#039;&#039;&#039; にあるファイルを参照）.&lt;br /&gt;
*SQLフィールドの推奨される型と名前は、このページに定義されてる [[Language_and_development_rules#Table_and_fields_structures]].&lt;br /&gt;
*データ管理のため、 &#039;&#039;&#039;/mymodule/sql/&#039;&#039;&#039;  ディレクトリ内に  &#039;&#039;&#039;data.sql&#039;&#039;&#039;  というファイルを作成し、データの追加/編集/削除を行う SQL コマンドを記述すること.&lt;br /&gt;
*文字列にダブルクォートを使わない（例： &amp;quot;chaine&amp;quot; でなく &#039;chaine&#039;） ダブルクォートは PostGreSQL では特定の意味を持つ&lt;br /&gt;
&lt;br /&gt;
例としてファイル data.sql の中身は&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ファイルは、mysql データベースで動作可能であること. 備考: 他データベースのファイルはメンテナンスされない. 他データベースのドライバによって、その場で読込まれ変換さる.&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;
DAO PHPファイルは、オブジェクトを作成した後にモジュールビルダによって生成されているはず.&lt;br /&gt;
&lt;br /&gt;
だとしても、既存オブジェクトをコピーして手動作成することもできる、しかし、モジュールビルダの使用を強く勧める。実例がここにあるはず &#039;&#039;&#039;htdocs/modulebuilder/templates/class/myobject.class.php&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
このクラスでは、テーブル行の挿入、取得（選択）、更新、削除を実行するためのCRUD（作成/読込/更新/削除）メソッドがすでに実行可能となっている。正しいモジュール名、テーブルを使用するようにファイルを編集し、このファイルをモジュールのクラスサブディレクトリに配置する。モジュールビルダを使用すると、マウスを数回クリックするだけで、この作業を実行できる.&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;
そのためには、先に作成したモジュールのファイル記述に行って、$this-&amp;gt;tabs 配列を編集する:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The table should contain a list of strings, each string representing a new tab. &lt;br /&gt;
The format of the string consisting of 5 parts separated by &amp;quot;:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*Part 1: The element type (object type) where the tab should appear is a value from the following:&lt;br /&gt;
{{TemplateModuleTabsJA}}&lt;br /&gt;
&lt;br /&gt;
*Part 2: A code to identify tab to add (start with +) or to remove (start with -)&lt;br /&gt;
*Part 3: The title of the tab. This can be a hard read or better code translation in a file lang.&lt;br /&gt;
*Part 4: The name of the file &amp;quot;*.lang&amp;quot; which contains correspondence between the code translation and language to display. If this name is followed with @mymodule, Dolibarr will search translation file &amp;quot;*.lang&amp;quot; within the module, so htdocs/mymodule/langs/code_CODE/mylangfile.lang, otherwise Dolibarr will look for file htdocs/langs/code_CODE/mylangfile.lang&lt;br /&gt;
*Part 5: A condition to test if tab must be visible. Put 1 to be always visible.&lt;br /&gt;
*Part 6: The URL of the page to display when you click on the tab. The __ID__ string will be replaced automatically by the Id of the element concerned.&lt;br /&gt;
&lt;br /&gt;
To feed the contents of the tab with data from the database, see the next chapter.&lt;br /&gt;
&lt;br /&gt;
In order to get the names  &#039;tabname&#039; of existing tabs, you have to check the names used in the function &#039;product_prepare_head&#039; of the file  &#039;core/lib/module.lib.php&#039; corresponding to section &#039;$head[$h][2]&#039;.&lt;br /&gt;
&lt;br /&gt;
===Show tabs navigation into your own pages===&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: To show all standard tabs of an object (product, tiers, etc.) on your page.&lt;br /&gt;
&lt;br /&gt;
You must follow these steps :&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1. Include files you need into your file&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each object type, there are two files to include with line&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;require_once($url_fichier) ;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is example of files to include (DOL_DOCUMENT_ROOT is often dolibarr/htdocs/) :&lt;br /&gt;
&lt;br /&gt;
*Object thirdparty (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;
*Object product (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;
*Object invoice (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. Create and load the object to show into your tab&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create an instance of an object of the correct class and load object from the database by using the fetch method of an object in providing to this method the id you get from URL (ie : /mytab.php?id=1).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Get a list of all tabs to show for your object type&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function XXX_prepare_head($obj), where XXX is name of object. This will return an array with all definition of tab entries to show. The parameter to put into this method is the instance of an object you want tabs.&lt;br /&gt;
&lt;br /&gt;
The resulting array has the following structure&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$head = product_prepare_head($product, $user) ; // parameter $user is present for some function anly&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4. show tabs into your page&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function dol_fiche_head() to show all tabs defined into array $head returned by XX_prepare_head().&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&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;
使用場面: モジュールの目的が、画面の新規作成または変更を必要とする機能の追加である場合.&lt;br /&gt;
&lt;br /&gt;
===新規 PHP 画面の作成===&lt;br /&gt;
次に、 &#039;&#039;&#039;modulebuilder/myobject_page.php&#039;&#039;&#039;  ディレクトリに例として提示されているスケルトンテンプレートを使用して、テーブルのデータを表示/編集するPHPページを作成する必要がある (コマンドラインからのスクリプト開発については、 [[Script development]] を参照).&lt;br /&gt;
&lt;br /&gt;
To create a new user screen, create a subdirectory of &#039;&#039;&#039;htdocs&#039;&#039;&#039; (if not already done) for your module (in &#039;&#039;&#039;htdocs/mymodule&#039;&#039;&#039; for example) to store the pages you will create.&lt;br /&gt;
&lt;br /&gt;
Copy, into that directory, the file &#039;&#039;&#039;myobject_page.phpp&#039;&#039;&#039; that will serve as a starting point for your page file.&lt;br /&gt;
Edit the file to have a correct relative path to the main.inc.php file. &lt;br /&gt;
&amp;lt;syntaxhighlight 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 calculated 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
As you can see, there are several tries to load the main.inc.php (or master.inc.php). The goal is to succeed in the most cases as possible. The minimum is 2 lines: one to try to load the master/main.inc.php into the dolibarr root directory and another one to try to load the file to support the case when the module is deployed into the &amp;quot;custom&amp;quot; directory. But you can have more to deal more situation. The provided example should be able to load the file main/master.inc.php in nearly all situation/setups.&lt;br /&gt;
&lt;br /&gt;
Note that you may add more &amp;quot;../&amp;quot; depending on the depth of the file relative to your module directory tree.&lt;br /&gt;
&lt;br /&gt;
It&#039;s in the main.inc.php file that is loaded technical environment variables and permissions. The following variables are objects positioned in this file:&lt;br /&gt;
&lt;br /&gt;
*$user    Object that contains the characteristics of the user + his permissions.&lt;br /&gt;
*$conf    Object that contains Dolibarr configuration.&lt;br /&gt;
*$db      Object that contains an opened connection handler to the database.&lt;br /&gt;
*$langs   Object that contains the user&#039;s language.&lt;br /&gt;
&lt;br /&gt;
Then enter your code to display the page.&lt;br /&gt;
&lt;br /&gt;
*To include a class or library dedicated to the module is done using a Dolibarr function (and not using directly include_once):&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*To include classes provided with Dolibarr, use the following syntax:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add some fields into existing forms===&lt;br /&gt;
You may want to provide a module that adds more fields into forms (input and view) of some elements. &lt;br /&gt;
&lt;br /&gt;
A heavy solution (but not so bad) may be to replace all pages used to create element (this means to disable the &amp;quot;New element&amp;quot; menu entry and adding yours, and disable tab that shows element to replace with a tab that is your own full page (copied/pasted from original) to do same than original page but modified to add your fields and stored added data into your own table). Go to menu [[#Define your entries in the menu (optional)]] and [[#The tab management (optional)]] if this solution suits you (this solution is more powerful since you can change everything you want into the page). &lt;br /&gt;
&lt;br /&gt;
We will describe here another solution, that works only to &amp;quot;add fields&amp;quot; at end of existing fields, using the element &amp;quot;category&amp;quot; as an example but you can convert this tutorial for invoice, proposal ...&lt;br /&gt;
&lt;br /&gt;
*First thing is to add a table, owned by your module, to store the value of new fields. This table will have only one column called &amp;quot;rowid&amp;quot; (will contain the same value than field rowid of element table) + one column for each new field you want to add. Then create a class with CRUD (Create/Read/Update/Delete) methods for this new table. For this two tasks, go back to previous chapter [[#Create your SQL tables and the PHP DAO class]].&lt;br /&gt;
*Next step is to add a hook into your module to add the new fields into the form. See chapter [[Hooks_system#Implement_the_Hook]] for generic documentation to use hooks.&lt;br /&gt;
&lt;br /&gt;
If you follow this tutorial, to be able to add fields into category forms, you must do:&lt;br /&gt;
{{ToComplete}}&lt;br /&gt;
&lt;br /&gt;
===Add/replace part of fields supported by hooks===&lt;br /&gt;
See chapter [[Hooks_system#Implement_the_Hook]] to know how to use Dolibarr existing hooks to add/replace code at Dolibarr hooks place.&lt;br /&gt;
&lt;br /&gt;
===Database access===&lt;br /&gt;
If you need to edit some data in the database inside your own table, use the PHP class generated before.&lt;br /&gt;
&lt;br /&gt;
If you to make access to tables with no dedicated PHP class available, this is always possible (for example if you want to get a list of records with a particular join or filter). In this case, this is a code samples to follow:&lt;br /&gt;
&lt;br /&gt;
To make an insert, update or delete:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To read:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Define style of your pages===&lt;br /&gt;
To have the look of your own pages to match the Dolibarr theme, it is necessary to use the Dolibarr CSS styles.&lt;br /&gt;
&lt;br /&gt;
You can use for example:&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;
===Use the Dolibarr date picker===&lt;br /&gt;
If you want to use the Dolibarr date selector (with its calendar popup) into your pages, use the following line:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
The string mykey will identify the date selector in the form. You must use different values if you use several date selectors in same page.&lt;br /&gt;
The string myform is the name of the FORM in which the selector is included (value found in the form name=&amp;quot;myform&amp;quot; in HTML page).&lt;br /&gt;
This means a date selector must be included necessarily into an html FORM.&lt;br /&gt;
&lt;br /&gt;
To get value after the POST of your form, the command is:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$mydate = dol_mktime(12, 0 , 0, $GETPOST(&#039;mykeymonth&#039;, &#039;int&#039;), GETPOST(&#039;mykeyday&#039;, &#039;int&#039;), GETPOST(&#039;mykeyyear&#039;, &#039;int&#039;));&lt;br /&gt;
print strftime(&#039;%A %d %B %Y&#039;, $mydate);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Overwrite template file (tpl)===&lt;br /&gt;
If you want to overwrite tpl file on your module, you need to declare it on the module_parts :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
&#039;tpl&#039; =&amp;gt; 1,&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Then you can put any tpl file on &#039;&#039;&#039;mymodule/core/tpl&#039;&#039;&#039;&lt;br /&gt;
as soon as the module is activate, the tpl will be overwrited&lt;br /&gt;
&lt;br /&gt;
==自前の準備ページを追加 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs parameters, which are to be provided by the user, for proper setting up of the module.&lt;br /&gt;
&lt;br /&gt;
===Create your page to edit parameters===&lt;br /&gt;
If your module needs several parameters to be setup, you must create a page to edit options (these options will be saved in the [[Table llx_const|table &#039;&#039;&#039;llx_const&#039;&#039;&#039;]]).&lt;br /&gt;
Create a page named &#039;&#039;&#039;mymodule_setuppage.php&#039;&#039;&#039; that shows a form for possible options to update them into the above-mentioned table.&lt;br /&gt;
It is necessary to take an example from a page of the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; that will show you the way to read/save your parameters.&lt;br /&gt;
Put this PHP page into the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; of your module (e.g. mymodule/admin/mymodule_setuppage.php).&lt;br /&gt;
&lt;br /&gt;
===Modify the descriptor file of your module===&lt;br /&gt;
Then, within the descriptor file of your module, modify the variable &#039;&#039;&#039;config_page_url&#039;&#039;&#039; to set the name of this PHP page.&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;admin/&#039;&#039;&#039;, then the path is not required, e.g. like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;mymodule/admin/&#039;&#039;&#039;, then like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test your page===&lt;br /&gt;
Go into page &#039;&#039;&#039;Home-&amp;gt;Setup-&amp;gt;Modules&#039;&#039;&#039;, you should see a picture at the end of the line of your module to reach your setup page. Click on it, you should be able to view/edit parameters from your page.&lt;br /&gt;
&lt;br /&gt;
==メニューに自前項目を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If you have created PHP pages, it is necessary that those pages can be reached from menu entries in Dolibarr menu.&lt;br /&gt;
&lt;br /&gt;
===Define your menu entries===&lt;br /&gt;
For this, you must define into the module descriptor, the array this-&amp;gt;menu that declares 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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To show the menu or not depending on a permission, modify property &#039;&#039;&#039;perms&#039;&#039;&#039; in the array. See chapter on permissions later to see how to add permissions.&lt;br /&gt;
&lt;br /&gt;
===Test your menu entries===&lt;br /&gt;
Disable and re-enable your module under the 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;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;rights_class = &#039;mymodule&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight 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][2] = &#039;r&#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;/syntaxhighlight&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][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; Translation key should be &amp;quot;Permission10001=My permission Label&amp;quot;).&lt;br /&gt;
Into $this-&amp;gt;rights[$r][2], types of the permission. There are three type of permission, &#039;r&#039; for read, list or expert permission, &#039;w&#039; for write or update permission and &#039;d&#039; for delete permission.&lt;br /&gt;
Into $this-&amp;gt;rights[$r][3], put 1 if this permission must be granted automatically by default to any newly created user.&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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==自前の box を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs to provide one or several new boxes to show on home page.&lt;br /&gt;
&lt;br /&gt;
===Define your box===&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;syntaxhighlight 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;/syntaxhighlight&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 activate. Activate the box and go on the home page to see if the box is showing correctly.&lt;br /&gt;
&lt;br /&gt;
==自前のエキスポートを定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module provides new predefined database export profiles (for its own tables or for already existing tables of another module).&lt;br /&gt;
&lt;br /&gt;
===Define export===&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 a 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;
==自前の CSS スタイルを定義 (任意)==&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 several CSS files 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 files only if you need absolutely to add not already existing styles.&lt;br /&gt;
&lt;br /&gt;
Once your style sheets are ready, declare them 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 an array of relative URLs to your CSS files.&lt;br /&gt;
For example&lt;br /&gt;
&amp;lt;syntaxhighlight 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;,&#039;/mymodule/css/myother.css&#039;));&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 the 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 declares your style sheet.&lt;br /&gt;
&lt;br /&gt;
==自前の Javascript 関数を追加 (任意)==&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;syntaxhighlight 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;/syntaxhighlight&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;
==Dolibarr フックポジションの内部に、自前コードを挿入 (任意)==&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 the 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 are not covered by existing rules.&lt;br /&gt;
&lt;br /&gt;
See page [[Create numbering module]].&lt;br /&gt;
&lt;br /&gt;
==自前の文書テンプレートを追加 (任意)==&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;
==自前のスキンを追加 (任意)==&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;
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 marketplace.&lt;br /&gt;
But you can use it to have a package easy to distribute on your own 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 a 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
perl makepack-dolibarrmodule.pl&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
tar -xvf mymodule.zip&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 marketplace website: {{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 built correctly, the file will be validated later.&lt;br /&gt;
**If quality is enough and license permits it, the code might be added inside main Dolibarr sources (except if you disagree for that).&lt;br /&gt;
&lt;br /&gt;
=DoliStore での外部モジュール 有効化/活性化 条件=&lt;br /&gt;
&lt;br /&gt;
See [[Module_Dolistore_Validation_Rules|Validation Rules]]&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56555</id>
		<title>モジュール 開発</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56555"/>
		<updated>2023-05-17T03:31:30Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: /* オブジェクトシートに自前のタブを追加・削除できる */&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:Développement_module]]&lt;br /&gt;
[[es:Desarrollo_de_un_módulo]]&lt;br /&gt;
[[de:Modul_Entwicklung]]&lt;br /&gt;
[[zh:模块开发]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Core]]&lt;br /&gt;
{{TemplateDocDevEn}}&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;
etc...&lt;br /&gt;
&lt;br /&gt;
以下の章では、これらすべてを手作業で簡単に行う方法を示す.&lt;br /&gt;
&lt;br /&gt;
=モジュールビルダ によるモジュールの生成=&lt;br /&gt;
Dolibarr 9.0 から、モジュールビルダにより、自前モジュールのメインページ作成が可能. 起動方法は:&lt;br /&gt;
&lt;br /&gt;
*モジュールリストにて、&amp;quot;モジュールビルダ(Module Builder)&amp;quot;を有効化する,&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_2.png|400px]]&lt;br /&gt;
&lt;br /&gt;
*その後 &amp;quot;バグ(bug)&amp;quot; 画像をクリック、場所は画面右上.&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_3.png|400px]]&lt;br /&gt;
&lt;br /&gt;
=テンプレート外部モジュールの例=&lt;br /&gt;
外部モジュールの開発を開始するのによいお手本は、ここで見つかるだろう : [https://github.com/Dolibarr/dolibarr/tree/develop/htdocs/modulebuilder/template GitHub Dolibarr Module Modèle]&lt;br /&gt;
&lt;br /&gt;
=自前モジュールを作る=&lt;br /&gt;
==自前モジュールに関するモジュール記述(Module descriptor)を作る (必須)==&lt;br /&gt;
&#039;&#039;&#039;必須となる時期&#039;&#039;&#039;: アドオンを開発すると早急に必要、たとえゴールが何であれ (例外はスキンの追加).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Dolibarr 9.0 から, モジュールビルダ (ModuleBuilder) モジュールを使用すべきだ、モジュール記述を生成するための標準モデルとして使える&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===自前のモジュール記述 (module descriptor) を作成する===&lt;br /&gt;
最初のステップは、モジュールに対するファイル記述 (file descriptor) を作成すること. (訳者注： 以下の内容は&#039;&#039;&#039;モジュールビルダを使うことで自動設定&#039;&#039;&#039;される) &lt;br /&gt;
&lt;br /&gt;
*ディレクトリ作成： &#039;&#039;&#039;/htdocs/custom/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; (外部モジュール向け) または &#039;&#039;&#039;/htdocs/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; ここはDolibarr の公式コアモジュール (official core module) とする場合. 次にファイル modMyModule.class.php をディレクトリ &#039;&#039;&#039;htdocs/modulebuilder/template&#039;&#039;&#039; からコピーして上記のディレクトリに作成. ファイルの名称を modMyModule.class.php から 自前モジュールの目的に合致した名称に変更. ファイル名は、先頭に &#039;mod&#039; があり、最後が .class.php で終わる (例えば、ファイル名を &#039;新名&#039; にするなら, &#039;mod新名.class.php&#039; となる).&lt;br /&gt;
&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;
*番号を変更: $this-&amp;gt;numero = 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;
Dolibarrを起動し、&#039;&#039;&#039;設定-&amp;gt;モジュール (Setup-&amp;gt;module&#039;&#039;&#039;?) ページを表示.&lt;br /&gt;
モジュール記述でプロパティバージョン (property version) を設定すると、自前の新規モジュールを載せた新規行とそれを有効化するかどうかの選択が表示されるはず. プロパティバージョンを &amp;quot;develop&amp;quot; または &amp;quot;experimental&amp;quot; に設定した場合、自前モジュールを見るには、まず &#039;&#039;&#039;設定-&amp;gt;その他 (Setup-Others)&#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;
これは、新しいモジュールを構築する際に、ファイルをどう整理するかを示している (ZIPファイルもこのルールに合わせる必要あり).&lt;br /&gt;
注：2行目だけが必須.&lt;br /&gt;
&lt;br /&gt;
{{TemplateModuleTreeSimpleJA}}&lt;br /&gt;
&lt;br /&gt;
==自前 SQL テーブル と PHP DAO クラス (任意)==&lt;br /&gt;
&#039;&#039;&#039;使用場面&#039;&#039;&#039;: 自前モジュールがそれ自身のデータを管理する必要がある場合&lt;br /&gt;
&lt;br /&gt;
===自前の .sql ファイルを作成===&lt;br /&gt;
自前モジュールが、Dolibarr標準版では利用できない独自データを管理する設計である場合、そのデータを格納するためのSQLテーブルを定義する必要がある.&lt;br /&gt;
&lt;br /&gt;
自前モジュールでテーブルを作成したり、データを読込むためのスクリプトは、自前モジュールのsqlサブディレクトリ (&amp;quot;&#039;&#039;&#039;mymodule/sql&#039;&#039;&#039;&amp;quot;) に保存される。(ModuleBuilder では、オブジェクト タブから新しいオブジェクトを作成するとき、このディレクトリとすべての sql ファイルが自動作成される）.&lt;br /&gt;
&lt;br /&gt;
次に、記述ファイルでの、&#039;&#039;&#039;init&#039;&#039;&#039; 関数にて、次の行&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;$this-&amp;gt;_load_tables(&#039;/mymodule/sql/&#039;);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
が、コメントでないことを確認する.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;従うべきルール:&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*テーブルごとに &#039;&#039;&#039;llx_matable.sql&#039;&#039;&#039; ファイルを１つ、&#039;&#039;&#039;llx_matable.key.sql&#039;&#039;&#039; ファイルを可能なら１つ、作成するという原則に基づき、テーブル作成コマンドのファイルを追加する（例として、 &#039;&#039;&#039;install/mysql/tables&#039;&#039;&#039; にあるファイルを参照）.&lt;br /&gt;
*SQLフィールドの推奨される型と名前は、このページに定義されてる [[Language_and_development_rules#Table_and_fields_structures]].&lt;br /&gt;
*データ管理のため、 &#039;&#039;&#039;/mymodule/sql/&#039;&#039;&#039;  ディレクトリ内に  &#039;&#039;&#039;data.sql&#039;&#039;&#039;  というファイルを作成し、データの追加/編集/削除を行う SQL コマンドを記述すること.&lt;br /&gt;
*文字列にダブルクォートを使わない（例： &amp;quot;chaine&amp;quot; でなく &#039;chaine&#039;） ダブルクォートは PostGreSQL では特定の意味を持つ&lt;br /&gt;
&lt;br /&gt;
例としてファイル data.sql の中身は&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ファイルは、mysql データベースで動作可能であること. 備考: 他データベースのファイルはメンテナンスされない. 他データベースのドライバによって、その場で読込まれ変換さる.&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;
DAO PHPファイルは、オブジェクトを作成した後にモジュールビルダによって生成されているはず.&lt;br /&gt;
&lt;br /&gt;
だとしても、既存オブジェクトをコピーして手動作成することもできる、しかし、モジュールビルダの使用を強く勧める。実例がここにあるはず &#039;&#039;&#039;htdocs/modulebuilder/templates/class/myobject.class.php&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
このクラスでは、テーブル行の挿入、取得（選択）、更新、削除を実行するためのCRUD（作成/読込/更新/削除）メソッドがすでに実行可能となっている。正しいモジュール名、テーブルを使用するようにファイルを編集し、このファイルをモジュールのクラスサブディレクトリに配置する。モジュールビルダを使用すると、マウスを数回クリックするだけで、この作業を実行できる.&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;
そのためには、先に作成したモジュールのファイル記述に行って、$this-&amp;gt;tabs 配列を編集する:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The table should contain a list of strings, each string representing a new tab. &lt;br /&gt;
The format of the string consisting of 5 parts separated by &amp;quot;:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*Part 1: The element type (object type) where the tab should appear is a value from the following:&lt;br /&gt;
{{TemplateModuleTabsJA}}&lt;br /&gt;
&lt;br /&gt;
*Part 2: A code to identify tab to add (start with +) or to remove (start with -)&lt;br /&gt;
*Part 3: The title of the tab. This can be a hard read or better code translation in a file lang.&lt;br /&gt;
*Part 4: The name of the file &amp;quot;*.lang&amp;quot; which contains correspondence between the code translation and language to display. If this name is followed with @mymodule, Dolibarr will search translation file &amp;quot;*.lang&amp;quot; within the module, so htdocs/mymodule/langs/code_CODE/mylangfile.lang, otherwise Dolibarr will look for file htdocs/langs/code_CODE/mylangfile.lang&lt;br /&gt;
*Part 5: A condition to test if tab must be visible. Put 1 to be always visible.&lt;br /&gt;
*Part 6: The URL of the page to display when you click on the tab. The __ID__ string will be replaced automatically by the Id of the element concerned.&lt;br /&gt;
&lt;br /&gt;
To feed the contents of the tab with data from the database, see the next chapter.&lt;br /&gt;
&lt;br /&gt;
In order to get the names  &#039;tabname&#039; of existing tabs, you have to check the names used in the function &#039;product_prepare_head&#039; of the file  &#039;core/lib/module.lib.php&#039; corresponding to section &#039;$head[$h][2]&#039;.&lt;br /&gt;
&lt;br /&gt;
===Show tabs navigation into your own pages===&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: To show all standard tabs of an object (product, tiers, etc.) on your page.&lt;br /&gt;
&lt;br /&gt;
You must follow these steps :&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1. Include files you need into your file&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each object type, there are two files to include with line&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;require_once($url_fichier) ;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is example of files to include (DOL_DOCUMENT_ROOT is often dolibarr/htdocs/) :&lt;br /&gt;
&lt;br /&gt;
*Object thirdparty (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;
*Object product (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;
*Object invoice (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. Create and load the object to show into your tab&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create an instance of an object of the correct class and load object from the database by using the fetch method of an object in providing to this method the id you get from URL (ie : /mytab.php?id=1).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Get a list of all tabs to show for your object type&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function XXX_prepare_head($obj), where XXX is name of object. This will return an array with all definition of tab entries to show. The parameter to put into this method is the instance of an object you want tabs.&lt;br /&gt;
&lt;br /&gt;
The resulting array has the following structure&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$head = product_prepare_head($product, $user) ; // parameter $user is present for some function anly&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4. show tabs into your page&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function dol_fiche_head() to show all tabs defined into array $head returned by XX_prepare_head().&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&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;When&#039;&#039;&#039;: If the purpose of your module is to add features that require new or modified screens.&lt;br /&gt;
&lt;br /&gt;
===Create a new PHP screen===&lt;br /&gt;
You must then create your PHP pages that will show/edit data from tables using the skeleton templates provided as an example in the directory &#039;&#039;&#039;modulebuilder/myobject_page.php&#039;&#039;&#039; (For the development of a script from the command line, see [[Script development]]).&lt;br /&gt;
&lt;br /&gt;
To create a new user screen, create a subdirectory of &#039;&#039;&#039;htdocs&#039;&#039;&#039; (if not already done) for your module (in &#039;&#039;&#039;htdocs/mymodule&#039;&#039;&#039; for example) to store the pages you will create.&lt;br /&gt;
&lt;br /&gt;
Copy, into that directory, the file &#039;&#039;&#039;myobject_page.phpp&#039;&#039;&#039; that will serve as a starting point for your page file.&lt;br /&gt;
Edit the file to have a correct relative path to the main.inc.php file. &lt;br /&gt;
&amp;lt;syntaxhighlight 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 calculated 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
As you can see, there are several tries to load the main.inc.php (or master.inc.php). The goal is to succeed in the most cases as possible. The minimum is 2 lines: one to try to load the master/main.inc.php into the dolibarr root directory and another one to try to load the file to support the case when the module is deployed into the &amp;quot;custom&amp;quot; directory. But you can have more to deal more situation. The provided example should be able to load the file main/master.inc.php in nearly all situation/setups.&lt;br /&gt;
&lt;br /&gt;
Note that you may add more &amp;quot;../&amp;quot; depending on the depth of the file relative to your module directory tree.&lt;br /&gt;
&lt;br /&gt;
It&#039;s in the main.inc.php file that is loaded technical environment variables and permissions. The following variables are objects positioned in this file:&lt;br /&gt;
&lt;br /&gt;
*$user    Object that contains the characteristics of the user + his permissions.&lt;br /&gt;
*$conf    Object that contains Dolibarr configuration.&lt;br /&gt;
*$db      Object that contains an opened connection handler to the database.&lt;br /&gt;
*$langs   Object that contains the user&#039;s language.&lt;br /&gt;
&lt;br /&gt;
Then enter your code to display the page.&lt;br /&gt;
&lt;br /&gt;
*To include a class or library dedicated to the module is done using a Dolibarr function (and not using directly include_once):&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*To include classes provided with Dolibarr, use the following syntax:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add some fields into existing forms===&lt;br /&gt;
You may want to provide a module that adds more fields into forms (input and view) of some elements. &lt;br /&gt;
&lt;br /&gt;
A heavy solution (but not so bad) may be to replace all pages used to create element (this means to disable the &amp;quot;New element&amp;quot; menu entry and adding yours, and disable tab that shows element to replace with a tab that is your own full page (copied/pasted from original) to do same than original page but modified to add your fields and stored added data into your own table). Go to menu [[#Define your entries in the menu (optional)]] and [[#The tab management (optional)]] if this solution suits you (this solution is more powerful since you can change everything you want into the page). &lt;br /&gt;
&lt;br /&gt;
We will describe here another solution, that works only to &amp;quot;add fields&amp;quot; at end of existing fields, using the element &amp;quot;category&amp;quot; as an example but you can convert this tutorial for invoice, proposal ...&lt;br /&gt;
&lt;br /&gt;
*First thing is to add a table, owned by your module, to store the value of new fields. This table will have only one column called &amp;quot;rowid&amp;quot; (will contain the same value than field rowid of element table) + one column for each new field you want to add. Then create a class with CRUD (Create/Read/Update/Delete) methods for this new table. For this two tasks, go back to previous chapter [[#Create your SQL tables and the PHP DAO class]].&lt;br /&gt;
*Next step is to add a hook into your module to add the new fields into the form. See chapter [[Hooks_system#Implement_the_Hook]] for generic documentation to use hooks.&lt;br /&gt;
&lt;br /&gt;
If you follow this tutorial, to be able to add fields into category forms, you must do:&lt;br /&gt;
{{ToComplete}}&lt;br /&gt;
&lt;br /&gt;
===Add/replace part of fields supported by hooks===&lt;br /&gt;
See chapter [[Hooks_system#Implement_the_Hook]] to know how to use Dolibarr existing hooks to add/replace code at Dolibarr hooks place.&lt;br /&gt;
&lt;br /&gt;
===Database access===&lt;br /&gt;
If you need to edit some data in the database inside your own table, use the PHP class generated before.&lt;br /&gt;
&lt;br /&gt;
If you to make access to tables with no dedicated PHP class available, this is always possible (for example if you want to get a list of records with a particular join or filter). In this case, this is a code samples to follow:&lt;br /&gt;
&lt;br /&gt;
To make an insert, update or delete:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To read:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Define style of your pages===&lt;br /&gt;
To have the look of your own pages to match the Dolibarr theme, it is necessary to use the Dolibarr CSS styles.&lt;br /&gt;
&lt;br /&gt;
You can use for example:&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;
===Use the Dolibarr date picker===&lt;br /&gt;
If you want to use the Dolibarr date selector (with its calendar popup) into your pages, use the following line:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
The string mykey will identify the date selector in the form. You must use different values if you use several date selectors in same page.&lt;br /&gt;
The string myform is the name of the FORM in which the selector is included (value found in the form name=&amp;quot;myform&amp;quot; in HTML page).&lt;br /&gt;
This means a date selector must be included necessarily into an html FORM.&lt;br /&gt;
&lt;br /&gt;
To get value after the POST of your form, the command is:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$mydate = dol_mktime(12, 0 , 0, $GETPOST(&#039;mykeymonth&#039;, &#039;int&#039;), GETPOST(&#039;mykeyday&#039;, &#039;int&#039;), GETPOST(&#039;mykeyyear&#039;, &#039;int&#039;));&lt;br /&gt;
print strftime(&#039;%A %d %B %Y&#039;, $mydate);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Overwrite template file (tpl)===&lt;br /&gt;
If you want to overwrite tpl file on your module, you need to declare it on the module_parts :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
&#039;tpl&#039; =&amp;gt; 1,&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Then you can put any tpl file on &#039;&#039;&#039;mymodule/core/tpl&#039;&#039;&#039;&lt;br /&gt;
as soon as the module is activate, the tpl will be overwrited&lt;br /&gt;
&lt;br /&gt;
==自前の準備ページを追加 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs parameters, which are to be provided by the user, for proper setting up of the module.&lt;br /&gt;
&lt;br /&gt;
===Create your page to edit parameters===&lt;br /&gt;
If your module needs several parameters to be setup, you must create a page to edit options (these options will be saved in the [[Table llx_const|table &#039;&#039;&#039;llx_const&#039;&#039;&#039;]]).&lt;br /&gt;
Create a page named &#039;&#039;&#039;mymodule_setuppage.php&#039;&#039;&#039; that shows a form for possible options to update them into the above-mentioned table.&lt;br /&gt;
It is necessary to take an example from a page of the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; that will show you the way to read/save your parameters.&lt;br /&gt;
Put this PHP page into the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; of your module (e.g. mymodule/admin/mymodule_setuppage.php).&lt;br /&gt;
&lt;br /&gt;
===Modify the descriptor file of your module===&lt;br /&gt;
Then, within the descriptor file of your module, modify the variable &#039;&#039;&#039;config_page_url&#039;&#039;&#039; to set the name of this PHP page.&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;admin/&#039;&#039;&#039;, then the path is not required, e.g. like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;mymodule/admin/&#039;&#039;&#039;, then like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test your page===&lt;br /&gt;
Go into page &#039;&#039;&#039;Home-&amp;gt;Setup-&amp;gt;Modules&#039;&#039;&#039;, you should see a picture at the end of the line of your module to reach your setup page. Click on it, you should be able to view/edit parameters from your page.&lt;br /&gt;
&lt;br /&gt;
==メニューに自前項目を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If you have created PHP pages, it is necessary that those pages can be reached from menu entries in Dolibarr menu.&lt;br /&gt;
&lt;br /&gt;
===Define your menu entries===&lt;br /&gt;
For this, you must define into the module descriptor, the array this-&amp;gt;menu that declares 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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To show the menu or not depending on a permission, modify property &#039;&#039;&#039;perms&#039;&#039;&#039; in the array. See chapter on permissions later to see how to add permissions.&lt;br /&gt;
&lt;br /&gt;
===Test your menu entries===&lt;br /&gt;
Disable and re-enable your module under the 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;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;rights_class = &#039;mymodule&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight 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][2] = &#039;r&#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;/syntaxhighlight&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][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; Translation key should be &amp;quot;Permission10001=My permission Label&amp;quot;).&lt;br /&gt;
Into $this-&amp;gt;rights[$r][2], types of the permission. There are three type of permission, &#039;r&#039; for read, list or expert permission, &#039;w&#039; for write or update permission and &#039;d&#039; for delete permission.&lt;br /&gt;
Into $this-&amp;gt;rights[$r][3], put 1 if this permission must be granted automatically by default to any newly created user.&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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==自前の box を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs to provide one or several new boxes to show on home page.&lt;br /&gt;
&lt;br /&gt;
===Define your box===&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;syntaxhighlight 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;/syntaxhighlight&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 activate. Activate the box and go on the home page to see if the box is showing correctly.&lt;br /&gt;
&lt;br /&gt;
==自前のエキスポートを定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module provides new predefined database export profiles (for its own tables or for already existing tables of another module).&lt;br /&gt;
&lt;br /&gt;
===Define export===&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 a 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;
==自前の CSS スタイルを定義 (任意)==&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 several CSS files 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 files only if you need absolutely to add not already existing styles.&lt;br /&gt;
&lt;br /&gt;
Once your style sheets are ready, declare them 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 an array of relative URLs to your CSS files.&lt;br /&gt;
For example&lt;br /&gt;
&amp;lt;syntaxhighlight 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;,&#039;/mymodule/css/myother.css&#039;));&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 the 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 declares your style sheet.&lt;br /&gt;
&lt;br /&gt;
==自前の Javascript 関数を追加 (任意)==&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;syntaxhighlight 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;/syntaxhighlight&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;
==Dolibarr フックポジションの内部に、自前コードを挿入 (任意)==&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 the 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 are not covered by existing rules.&lt;br /&gt;
&lt;br /&gt;
See page [[Create numbering module]].&lt;br /&gt;
&lt;br /&gt;
==自前の文書テンプレートを追加 (任意)==&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;
==自前のスキンを追加 (任意)==&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;
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 marketplace.&lt;br /&gt;
But you can use it to have a package easy to distribute on your own 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 a 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
perl makepack-dolibarrmodule.pl&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
tar -xvf mymodule.zip&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 marketplace website: {{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 built correctly, the file will be validated later.&lt;br /&gt;
**If quality is enough and license permits it, the code might be added inside main Dolibarr sources (except if you disagree for that).&lt;br /&gt;
&lt;br /&gt;
=DoliStore での外部モジュール 有効化/活性化 条件=&lt;br /&gt;
&lt;br /&gt;
See [[Module_Dolistore_Validation_Rules|Validation Rules]]&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=Template:TemplateModuleTabsJA&amp;diff=56554</id>
		<title>Template:TemplateModuleTabsJA</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=Template:TemplateModuleTabsJA&amp;diff=56554"/>
		<updated>2023-05-17T03:30:24Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: 初期翻訳： Enから複製&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;** &#039;thirdparty&#039; 取引先ビューでタブ追加&lt;br /&gt;
** &#039;intervention&#039; 出張ビューでタブ追加&lt;br /&gt;
** &#039;supplier_order&#039; 仕入注文ビューでタブ追加&lt;br /&gt;
** &#039;supplier_invoice&#039; 仕入請求ビューでタブ追加&lt;br /&gt;
** &#039;invoice&#039; 顧客請求ビューでタブ追加&lt;br /&gt;
** &#039;order&#039; 顧客注文ビューでタブ追加&lt;br /&gt;
** &#039;product&#039; 製品ビューでタブ追加&lt;br /&gt;
** &#039;stock&#039; 在庫ビューでタブ追加&lt;br /&gt;
** &#039;propal&#039; 提案ビューでタブ追加&lt;br /&gt;
** &#039;member&#039; 財団メンバービューでタブ追加&lt;br /&gt;
** &#039;contract&#039; 契約ビューでタブ追加&lt;br /&gt;
** &#039;user&#039; ユーザビューでタブ追加&lt;br /&gt;
** &#039;group&#039; グループビューでタブ追加&lt;br /&gt;
** &#039;contact&#039; 連絡先ビューでタブ追加&lt;br /&gt;
** &#039;payment&#039; 支払ビューでタブ追加 (since 3.6.0)&lt;br /&gt;
** &#039;payment_supplier&#039; 仕入支払ビューでタブ追加 (since 3.6.0)&lt;br /&gt;
** &#039;categories_x&#039; 種別ビューでタブ追加 (&#039;x&#039; を種別タイプ (0=product, 1=supplier, 2=customer, 3=member) に変更)&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56553</id>
		<title>モジュール 開発</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56553"/>
		<updated>2023-05-17T03:12:14Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: /* Add or remove your own tabs on object sheets */&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:Développement_module]]&lt;br /&gt;
[[es:Desarrollo_de_un_módulo]]&lt;br /&gt;
[[de:Modul_Entwicklung]]&lt;br /&gt;
[[zh:模块开发]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Core]]&lt;br /&gt;
{{TemplateDocDevEn}}&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;
etc...&lt;br /&gt;
&lt;br /&gt;
以下の章では、これらすべてを手作業で簡単に行う方法を示す.&lt;br /&gt;
&lt;br /&gt;
=モジュールビルダ によるモジュールの生成=&lt;br /&gt;
Dolibarr 9.0 から、モジュールビルダにより、自前モジュールのメインページ作成が可能. 起動方法は:&lt;br /&gt;
&lt;br /&gt;
*モジュールリストにて、&amp;quot;モジュールビルダ(Module Builder)&amp;quot;を有効化する,&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_2.png|400px]]&lt;br /&gt;
&lt;br /&gt;
*その後 &amp;quot;バグ(bug)&amp;quot; 画像をクリック、場所は画面右上.&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_3.png|400px]]&lt;br /&gt;
&lt;br /&gt;
=テンプレート外部モジュールの例=&lt;br /&gt;
外部モジュールの開発を開始するのによいお手本は、ここで見つかるだろう : [https://github.com/Dolibarr/dolibarr/tree/develop/htdocs/modulebuilder/template GitHub Dolibarr Module Modèle]&lt;br /&gt;
&lt;br /&gt;
=自前モジュールを作る=&lt;br /&gt;
==自前モジュールに関するモジュール記述(Module descriptor)を作る (必須)==&lt;br /&gt;
&#039;&#039;&#039;必須となる時期&#039;&#039;&#039;: アドオンを開発すると早急に必要、たとえゴールが何であれ (例外はスキンの追加).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Dolibarr 9.0 から, モジュールビルダ (ModuleBuilder) モジュールを使用すべきだ、モジュール記述を生成するための標準モデルとして使える&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===自前のモジュール記述 (module descriptor) を作成する===&lt;br /&gt;
最初のステップは、モジュールに対するファイル記述 (file descriptor) を作成すること. (訳者注： 以下の内容は&#039;&#039;&#039;モジュールビルダを使うことで自動設定&#039;&#039;&#039;される) &lt;br /&gt;
&lt;br /&gt;
*ディレクトリ作成： &#039;&#039;&#039;/htdocs/custom/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; (外部モジュール向け) または &#039;&#039;&#039;/htdocs/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; ここはDolibarr の公式コアモジュール (official core module) とする場合. 次にファイル modMyModule.class.php をディレクトリ &#039;&#039;&#039;htdocs/modulebuilder/template&#039;&#039;&#039; からコピーして上記のディレクトリに作成. ファイルの名称を modMyModule.class.php から 自前モジュールの目的に合致した名称に変更. ファイル名は、先頭に &#039;mod&#039; があり、最後が .class.php で終わる (例えば、ファイル名を &#039;新名&#039; にするなら, &#039;mod新名.class.php&#039; となる).&lt;br /&gt;
&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;
*番号を変更: $this-&amp;gt;numero = 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;
Dolibarrを起動し、&#039;&#039;&#039;設定-&amp;gt;モジュール (Setup-&amp;gt;module&#039;&#039;&#039;?) ページを表示.&lt;br /&gt;
モジュール記述でプロパティバージョン (property version) を設定すると、自前の新規モジュールを載せた新規行とそれを有効化するかどうかの選択が表示されるはず. プロパティバージョンを &amp;quot;develop&amp;quot; または &amp;quot;experimental&amp;quot; に設定した場合、自前モジュールを見るには、まず &#039;&#039;&#039;設定-&amp;gt;その他 (Setup-Others)&#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;
これは、新しいモジュールを構築する際に、ファイルをどう整理するかを示している (ZIPファイルもこのルールに合わせる必要あり).&lt;br /&gt;
注：2行目だけが必須.&lt;br /&gt;
&lt;br /&gt;
{{TemplateModuleTreeSimpleJA}}&lt;br /&gt;
&lt;br /&gt;
==自前 SQL テーブル と PHP DAO クラス (任意)==&lt;br /&gt;
&#039;&#039;&#039;使用場面&#039;&#039;&#039;: 自前モジュールがそれ自身のデータを管理する必要がある場合&lt;br /&gt;
&lt;br /&gt;
===自前の .sql ファイルを作成===&lt;br /&gt;
自前モジュールが、Dolibarr標準版では利用できない独自データを管理する設計である場合、そのデータを格納するためのSQLテーブルを定義する必要がある.&lt;br /&gt;
&lt;br /&gt;
自前モジュールでテーブルを作成したり、データを読込むためのスクリプトは、自前モジュールのsqlサブディレクトリ (&amp;quot;&#039;&#039;&#039;mymodule/sql&#039;&#039;&#039;&amp;quot;) に保存される。(ModuleBuilder では、オブジェクト タブから新しいオブジェクトを作成するとき、このディレクトリとすべての sql ファイルが自動作成される）.&lt;br /&gt;
&lt;br /&gt;
次に、記述ファイルでの、&#039;&#039;&#039;init&#039;&#039;&#039; 関数にて、次の行&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;$this-&amp;gt;_load_tables(&#039;/mymodule/sql/&#039;);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
が、コメントでないことを確認する.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;従うべきルール:&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*テーブルごとに &#039;&#039;&#039;llx_matable.sql&#039;&#039;&#039; ファイルを１つ、&#039;&#039;&#039;llx_matable.key.sql&#039;&#039;&#039; ファイルを可能なら１つ、作成するという原則に基づき、テーブル作成コマンドのファイルを追加する（例として、 &#039;&#039;&#039;install/mysql/tables&#039;&#039;&#039; にあるファイルを参照）.&lt;br /&gt;
*SQLフィールドの推奨される型と名前は、このページに定義されてる [[Language_and_development_rules#Table_and_fields_structures]].&lt;br /&gt;
*データ管理のため、 &#039;&#039;&#039;/mymodule/sql/&#039;&#039;&#039;  ディレクトリ内に  &#039;&#039;&#039;data.sql&#039;&#039;&#039;  というファイルを作成し、データの追加/編集/削除を行う SQL コマンドを記述すること.&lt;br /&gt;
*文字列にダブルクォートを使わない（例： &amp;quot;chaine&amp;quot; でなく &#039;chaine&#039;） ダブルクォートは PostGreSQL では特定の意味を持つ&lt;br /&gt;
&lt;br /&gt;
例としてファイル data.sql の中身は&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ファイルは、mysql データベースで動作可能であること. 備考: 他データベースのファイルはメンテナンスされない. 他データベースのドライバによって、その場で読込まれ変換さる.&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;
DAO PHPファイルは、オブジェクトを作成した後にモジュールビルダによって生成されているはず.&lt;br /&gt;
&lt;br /&gt;
だとしても、既存オブジェクトをコピーして手動作成することもできる、しかし、モジュールビルダの使用を強く勧める。実例がここにあるはず &#039;&#039;&#039;htdocs/modulebuilder/templates/class/myobject.class.php&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
このクラスでは、テーブル行の挿入、取得（選択）、更新、削除を実行するためのCRUD（作成/読込/更新/削除）メソッドがすでに実行可能となっている。正しいモジュール名、テーブルを使用するようにファイルを編集し、このファイルをモジュールのクラスサブディレクトリに配置する。モジュールビルダを使用すると、マウスを数回クリックするだけで、この作業を実行できる.&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;
そのためには、先に作成したモジュールのファイル記述に行って、$this-&amp;gt;tabs 配列を編集する:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The table should contain a list of strings, each string representing a new tab. &lt;br /&gt;
The format of the string consisting of 5 parts separated by &amp;quot;:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*Part 1: The element type (object type) where the tab should appear is a value from the following:&lt;br /&gt;
{{TemplateModuleTabs}}&lt;br /&gt;
&lt;br /&gt;
*Part 2: A code to identify tab to add (start with +) or to remove (start with -)&lt;br /&gt;
*Part 3: The title of the tab. This can be a hard read or better code translation in a file lang.&lt;br /&gt;
*Part 4: The name of the file &amp;quot;*.lang&amp;quot; which contains correspondence between the code translation and language to display. If this name is followed with @mymodule, Dolibarr will search translation file &amp;quot;*.lang&amp;quot; within the module, so htdocs/mymodule/langs/code_CODE/mylangfile.lang, otherwise Dolibarr will look for file htdocs/langs/code_CODE/mylangfile.lang&lt;br /&gt;
*Part 5: A condition to test if tab must be visible. Put 1 to be always visible.&lt;br /&gt;
*Part 6: The URL of the page to display when you click on the tab. The __ID__ string will be replaced automatically by the Id of the element concerned.&lt;br /&gt;
&lt;br /&gt;
To feed the contents of the tab with data from the database, see the next chapter.&lt;br /&gt;
&lt;br /&gt;
In order to get the names  &#039;tabname&#039; of existing tabs, you have to check the names used in the function &#039;product_prepare_head&#039; of the file  &#039;core/lib/module.lib.php&#039; corresponding to section &#039;$head[$h][2]&#039;.&lt;br /&gt;
&lt;br /&gt;
===Show tabs navigation into your own pages===&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: To show all standard tabs of an object (product, tiers, etc.) on your page.&lt;br /&gt;
&lt;br /&gt;
You must follow these steps :&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1. Include files you need into your file&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each object type, there are two files to include with line&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;require_once($url_fichier) ;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is example of files to include (DOL_DOCUMENT_ROOT is often dolibarr/htdocs/) :&lt;br /&gt;
&lt;br /&gt;
*Object thirdparty (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;
*Object product (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;
*Object invoice (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. Create and load the object to show into your tab&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create an instance of an object of the correct class and load object from the database by using the fetch method of an object in providing to this method the id you get from URL (ie : /mytab.php?id=1).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Get a list of all tabs to show for your object type&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function XXX_prepare_head($obj), where XXX is name of object. This will return an array with all definition of tab entries to show. The parameter to put into this method is the instance of an object you want tabs.&lt;br /&gt;
&lt;br /&gt;
The resulting array has the following structure&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$head = product_prepare_head($product, $user) ; // parameter $user is present for some function anly&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4. show tabs into your page&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function dol_fiche_head() to show all tabs defined into array $head returned by XX_prepare_head().&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&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;When&#039;&#039;&#039;: If the purpose of your module is to add features that require new or modified screens.&lt;br /&gt;
&lt;br /&gt;
===Create a new PHP screen===&lt;br /&gt;
You must then create your PHP pages that will show/edit data from tables using the skeleton templates provided as an example in the directory &#039;&#039;&#039;modulebuilder/myobject_page.php&#039;&#039;&#039; (For the development of a script from the command line, see [[Script development]]).&lt;br /&gt;
&lt;br /&gt;
To create a new user screen, create a subdirectory of &#039;&#039;&#039;htdocs&#039;&#039;&#039; (if not already done) for your module (in &#039;&#039;&#039;htdocs/mymodule&#039;&#039;&#039; for example) to store the pages you will create.&lt;br /&gt;
&lt;br /&gt;
Copy, into that directory, the file &#039;&#039;&#039;myobject_page.phpp&#039;&#039;&#039; that will serve as a starting point for your page file.&lt;br /&gt;
Edit the file to have a correct relative path to the main.inc.php file. &lt;br /&gt;
&amp;lt;syntaxhighlight 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 calculated 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
As you can see, there are several tries to load the main.inc.php (or master.inc.php). The goal is to succeed in the most cases as possible. The minimum is 2 lines: one to try to load the master/main.inc.php into the dolibarr root directory and another one to try to load the file to support the case when the module is deployed into the &amp;quot;custom&amp;quot; directory. But you can have more to deal more situation. The provided example should be able to load the file main/master.inc.php in nearly all situation/setups.&lt;br /&gt;
&lt;br /&gt;
Note that you may add more &amp;quot;../&amp;quot; depending on the depth of the file relative to your module directory tree.&lt;br /&gt;
&lt;br /&gt;
It&#039;s in the main.inc.php file that is loaded technical environment variables and permissions. The following variables are objects positioned in this file:&lt;br /&gt;
&lt;br /&gt;
*$user    Object that contains the characteristics of the user + his permissions.&lt;br /&gt;
*$conf    Object that contains Dolibarr configuration.&lt;br /&gt;
*$db      Object that contains an opened connection handler to the database.&lt;br /&gt;
*$langs   Object that contains the user&#039;s language.&lt;br /&gt;
&lt;br /&gt;
Then enter your code to display the page.&lt;br /&gt;
&lt;br /&gt;
*To include a class or library dedicated to the module is done using a Dolibarr function (and not using directly include_once):&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*To include classes provided with Dolibarr, use the following syntax:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add some fields into existing forms===&lt;br /&gt;
You may want to provide a module that adds more fields into forms (input and view) of some elements. &lt;br /&gt;
&lt;br /&gt;
A heavy solution (but not so bad) may be to replace all pages used to create element (this means to disable the &amp;quot;New element&amp;quot; menu entry and adding yours, and disable tab that shows element to replace with a tab that is your own full page (copied/pasted from original) to do same than original page but modified to add your fields and stored added data into your own table). Go to menu [[#Define your entries in the menu (optional)]] and [[#The tab management (optional)]] if this solution suits you (this solution is more powerful since you can change everything you want into the page). &lt;br /&gt;
&lt;br /&gt;
We will describe here another solution, that works only to &amp;quot;add fields&amp;quot; at end of existing fields, using the element &amp;quot;category&amp;quot; as an example but you can convert this tutorial for invoice, proposal ...&lt;br /&gt;
&lt;br /&gt;
*First thing is to add a table, owned by your module, to store the value of new fields. This table will have only one column called &amp;quot;rowid&amp;quot; (will contain the same value than field rowid of element table) + one column for each new field you want to add. Then create a class with CRUD (Create/Read/Update/Delete) methods for this new table. For this two tasks, go back to previous chapter [[#Create your SQL tables and the PHP DAO class]].&lt;br /&gt;
*Next step is to add a hook into your module to add the new fields into the form. See chapter [[Hooks_system#Implement_the_Hook]] for generic documentation to use hooks.&lt;br /&gt;
&lt;br /&gt;
If you follow this tutorial, to be able to add fields into category forms, you must do:&lt;br /&gt;
{{ToComplete}}&lt;br /&gt;
&lt;br /&gt;
===Add/replace part of fields supported by hooks===&lt;br /&gt;
See chapter [[Hooks_system#Implement_the_Hook]] to know how to use Dolibarr existing hooks to add/replace code at Dolibarr hooks place.&lt;br /&gt;
&lt;br /&gt;
===Database access===&lt;br /&gt;
If you need to edit some data in the database inside your own table, use the PHP class generated before.&lt;br /&gt;
&lt;br /&gt;
If you to make access to tables with no dedicated PHP class available, this is always possible (for example if you want to get a list of records with a particular join or filter). In this case, this is a code samples to follow:&lt;br /&gt;
&lt;br /&gt;
To make an insert, update or delete:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To read:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Define style of your pages===&lt;br /&gt;
To have the look of your own pages to match the Dolibarr theme, it is necessary to use the Dolibarr CSS styles.&lt;br /&gt;
&lt;br /&gt;
You can use for example:&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;
===Use the Dolibarr date picker===&lt;br /&gt;
If you want to use the Dolibarr date selector (with its calendar popup) into your pages, use the following line:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
The string mykey will identify the date selector in the form. You must use different values if you use several date selectors in same page.&lt;br /&gt;
The string myform is the name of the FORM in which the selector is included (value found in the form name=&amp;quot;myform&amp;quot; in HTML page).&lt;br /&gt;
This means a date selector must be included necessarily into an html FORM.&lt;br /&gt;
&lt;br /&gt;
To get value after the POST of your form, the command is:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$mydate = dol_mktime(12, 0 , 0, $GETPOST(&#039;mykeymonth&#039;, &#039;int&#039;), GETPOST(&#039;mykeyday&#039;, &#039;int&#039;), GETPOST(&#039;mykeyyear&#039;, &#039;int&#039;));&lt;br /&gt;
print strftime(&#039;%A %d %B %Y&#039;, $mydate);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Overwrite template file (tpl)===&lt;br /&gt;
If you want to overwrite tpl file on your module, you need to declare it on the module_parts :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
&#039;tpl&#039; =&amp;gt; 1,&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Then you can put any tpl file on &#039;&#039;&#039;mymodule/core/tpl&#039;&#039;&#039;&lt;br /&gt;
as soon as the module is activate, the tpl will be overwrited&lt;br /&gt;
&lt;br /&gt;
==自前の準備ページを追加 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs parameters, which are to be provided by the user, for proper setting up of the module.&lt;br /&gt;
&lt;br /&gt;
===Create your page to edit parameters===&lt;br /&gt;
If your module needs several parameters to be setup, you must create a page to edit options (these options will be saved in the [[Table llx_const|table &#039;&#039;&#039;llx_const&#039;&#039;&#039;]]).&lt;br /&gt;
Create a page named &#039;&#039;&#039;mymodule_setuppage.php&#039;&#039;&#039; that shows a form for possible options to update them into the above-mentioned table.&lt;br /&gt;
It is necessary to take an example from a page of the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; that will show you the way to read/save your parameters.&lt;br /&gt;
Put this PHP page into the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; of your module (e.g. mymodule/admin/mymodule_setuppage.php).&lt;br /&gt;
&lt;br /&gt;
===Modify the descriptor file of your module===&lt;br /&gt;
Then, within the descriptor file of your module, modify the variable &#039;&#039;&#039;config_page_url&#039;&#039;&#039; to set the name of this PHP page.&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;admin/&#039;&#039;&#039;, then the path is not required, e.g. like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;mymodule/admin/&#039;&#039;&#039;, then like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test your page===&lt;br /&gt;
Go into page &#039;&#039;&#039;Home-&amp;gt;Setup-&amp;gt;Modules&#039;&#039;&#039;, you should see a picture at the end of the line of your module to reach your setup page. Click on it, you should be able to view/edit parameters from your page.&lt;br /&gt;
&lt;br /&gt;
==メニューに自前項目を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If you have created PHP pages, it is necessary that those pages can be reached from menu entries in Dolibarr menu.&lt;br /&gt;
&lt;br /&gt;
===Define your menu entries===&lt;br /&gt;
For this, you must define into the module descriptor, the array this-&amp;gt;menu that declares 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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To show the menu or not depending on a permission, modify property &#039;&#039;&#039;perms&#039;&#039;&#039; in the array. See chapter on permissions later to see how to add permissions.&lt;br /&gt;
&lt;br /&gt;
===Test your menu entries===&lt;br /&gt;
Disable and re-enable your module under the 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;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;rights_class = &#039;mymodule&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight 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][2] = &#039;r&#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;/syntaxhighlight&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][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; Translation key should be &amp;quot;Permission10001=My permission Label&amp;quot;).&lt;br /&gt;
Into $this-&amp;gt;rights[$r][2], types of the permission. There are three type of permission, &#039;r&#039; for read, list or expert permission, &#039;w&#039; for write or update permission and &#039;d&#039; for delete permission.&lt;br /&gt;
Into $this-&amp;gt;rights[$r][3], put 1 if this permission must be granted automatically by default to any newly created user.&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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==自前の box を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs to provide one or several new boxes to show on home page.&lt;br /&gt;
&lt;br /&gt;
===Define your box===&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;syntaxhighlight 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;/syntaxhighlight&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 activate. Activate the box and go on the home page to see if the box is showing correctly.&lt;br /&gt;
&lt;br /&gt;
==自前のエキスポートを定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module provides new predefined database export profiles (for its own tables or for already existing tables of another module).&lt;br /&gt;
&lt;br /&gt;
===Define export===&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 a 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;
==自前の CSS スタイルを定義 (任意)==&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 several CSS files 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 files only if you need absolutely to add not already existing styles.&lt;br /&gt;
&lt;br /&gt;
Once your style sheets are ready, declare them 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 an array of relative URLs to your CSS files.&lt;br /&gt;
For example&lt;br /&gt;
&amp;lt;syntaxhighlight 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;,&#039;/mymodule/css/myother.css&#039;));&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 the 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 declares your style sheet.&lt;br /&gt;
&lt;br /&gt;
==自前の Javascript 関数を追加 (任意)==&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;syntaxhighlight 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;/syntaxhighlight&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;
==Dolibarr フックポジションの内部に、自前コードを挿入 (任意)==&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 the 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 are not covered by existing rules.&lt;br /&gt;
&lt;br /&gt;
See page [[Create numbering module]].&lt;br /&gt;
&lt;br /&gt;
==自前の文書テンプレートを追加 (任意)==&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;
==自前のスキンを追加 (任意)==&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;
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 marketplace.&lt;br /&gt;
But you can use it to have a package easy to distribute on your own 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 a 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
perl makepack-dolibarrmodule.pl&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
tar -xvf mymodule.zip&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 marketplace website: {{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 built correctly, the file will be validated later.&lt;br /&gt;
**If quality is enough and license permits it, the code might be added inside main Dolibarr sources (except if you disagree for that).&lt;br /&gt;
&lt;br /&gt;
=DoliStore での外部モジュール 有効化/活性化 条件=&lt;br /&gt;
&lt;br /&gt;
See [[Module_Dolistore_Validation_Rules|Validation Rules]]&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56543</id>
		<title>モジュール 開発</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56543"/>
		<updated>2023-05-15T10:18:52Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: /* Test your .sql files */&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:Développement_module]]&lt;br /&gt;
[[es:Desarrollo_de_un_módulo]]&lt;br /&gt;
[[de:Modul_Entwicklung]]&lt;br /&gt;
[[zh:模块开发]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Core]]&lt;br /&gt;
{{TemplateDocDevEn}}&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;
etc...&lt;br /&gt;
&lt;br /&gt;
以下の章では、これらすべてを手作業で簡単に行う方法を示す.&lt;br /&gt;
&lt;br /&gt;
=モジュールビルダ によるモジュールの生成=&lt;br /&gt;
Dolibarr 9.0 から、モジュールビルダにより、自前モジュールのメインページ作成が可能. 起動方法は:&lt;br /&gt;
&lt;br /&gt;
*モジュールリストにて、&amp;quot;モジュールビルダ(Module Builder)&amp;quot;を有効化する,&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_2.png|400px]]&lt;br /&gt;
&lt;br /&gt;
*その後 &amp;quot;バグ(bug)&amp;quot; 画像をクリック、場所は画面右上.&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_3.png|400px]]&lt;br /&gt;
&lt;br /&gt;
=テンプレート外部モジュールの例=&lt;br /&gt;
外部モジュールの開発を開始するのによいお手本は、ここで見つかるだろう : [https://github.com/Dolibarr/dolibarr/tree/develop/htdocs/modulebuilder/template GitHub Dolibarr Module Modèle]&lt;br /&gt;
&lt;br /&gt;
=自前モジュールを作る=&lt;br /&gt;
==自前モジュールに関するモジュール記述(Module descriptor)を作る (必須)==&lt;br /&gt;
&#039;&#039;&#039;必須となる時期&#039;&#039;&#039;: アドオンを開発すると早急に必要、たとえゴールが何であれ (例外はスキンの追加).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Dolibarr 9.0 から, モジュールビルダ (ModuleBuilder) モジュールを使用すべきだ、モジュール記述を生成するための標準モデルとして使える&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===自前のモジュール記述 (module descriptor) を作成する===&lt;br /&gt;
最初のステップは、モジュールに対するファイル記述 (file descriptor) を作成すること. (訳者注： 以下の内容は&#039;&#039;&#039;モジュールビルダを使うことで自動設定&#039;&#039;&#039;される) &lt;br /&gt;
&lt;br /&gt;
*ディレクトリ作成： &#039;&#039;&#039;/htdocs/custom/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; (外部モジュール向け) または &#039;&#039;&#039;/htdocs/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; ここはDolibarr の公式コアモジュール (official core module) とする場合. 次にファイル modMyModule.class.php をディレクトリ &#039;&#039;&#039;htdocs/modulebuilder/template&#039;&#039;&#039; からコピーして上記のディレクトリに作成. ファイルの名称を modMyModule.class.php から 自前モジュールの目的に合致した名称に変更. ファイル名は、先頭に &#039;mod&#039; があり、最後が .class.php で終わる (例えば、ファイル名を &#039;新名&#039; にするなら, &#039;mod新名.class.php&#039; となる).&lt;br /&gt;
&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;
*番号を変更: $this-&amp;gt;numero = 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;
Dolibarrを起動し、&#039;&#039;&#039;設定-&amp;gt;モジュール (Setup-&amp;gt;module&#039;&#039;&#039;?) ページを表示.&lt;br /&gt;
モジュール記述でプロパティバージョン (property version) を設定すると、自前の新規モジュールを載せた新規行とそれを有効化するかどうかの選択が表示されるはず. プロパティバージョンを &amp;quot;develop&amp;quot; または &amp;quot;experimental&amp;quot; に設定した場合、自前モジュールを見るには、まず &#039;&#039;&#039;設定-&amp;gt;その他 (Setup-Others)&#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;
これは、新しいモジュールを構築する際に、ファイルをどう整理するかを示している (ZIPファイルもこのルールに合わせる必要あり).&lt;br /&gt;
注：2行目だけが必須.&lt;br /&gt;
&lt;br /&gt;
{{TemplateModuleTreeSimpleJA}}&lt;br /&gt;
&lt;br /&gt;
==自前 SQL テーブル と PHP DAO クラス (任意)==&lt;br /&gt;
&#039;&#039;&#039;使用場面&#039;&#039;&#039;: 自前モジュールがそれ自身のデータを管理する必要がある場合&lt;br /&gt;
&lt;br /&gt;
===自前の .sql ファイルを作成===&lt;br /&gt;
自前モジュールが、Dolibarr標準版では利用できない独自データを管理する設計である場合、そのデータを格納するためのSQLテーブルを定義する必要がある.&lt;br /&gt;
&lt;br /&gt;
自前モジュールでテーブルを作成したり、データを読込むためのスクリプトは、自前モジュールのsqlサブディレクトリ (&amp;quot;&#039;&#039;&#039;mymodule/sql&#039;&#039;&#039;&amp;quot;) に保存される。(ModuleBuilder では、オブジェクト タブから新しいオブジェクトを作成するとき、このディレクトリとすべての sql ファイルが自動作成される）.&lt;br /&gt;
&lt;br /&gt;
次に、記述ファイルでの、&#039;&#039;&#039;init&#039;&#039;&#039; 関数にて、次の行&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;$this-&amp;gt;_load_tables(&#039;/mymodule/sql/&#039;);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
が、コメントでないことを確認する.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;従うべきルール:&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*テーブルごとに &#039;&#039;&#039;llx_matable.sql&#039;&#039;&#039; ファイルを１つ、&#039;&#039;&#039;llx_matable.key.sql&#039;&#039;&#039; ファイルを可能なら１つ、作成するという原則に基づき、テーブル作成コマンドのファイルを追加する（例として、 &#039;&#039;&#039;install/mysql/tables&#039;&#039;&#039; にあるファイルを参照）.&lt;br /&gt;
*SQLフィールドの推奨される型と名前は、このページに定義されてる [[Language_and_development_rules#Table_and_fields_structures]].&lt;br /&gt;
*データ管理のため、 &#039;&#039;&#039;/mymodule/sql/&#039;&#039;&#039;  ディレクトリ内に  &#039;&#039;&#039;data.sql&#039;&#039;&#039;  というファイルを作成し、データの追加/編集/削除を行う SQL コマンドを記述すること.&lt;br /&gt;
*文字列にダブルクォートを使わない（例： &amp;quot;chaine&amp;quot; でなく &#039;chaine&#039;） ダブルクォートは PostGreSQL では特定の意味を持つ&lt;br /&gt;
&lt;br /&gt;
例としてファイル data.sql の中身は&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ファイルは、mysql データベースで動作可能であること. 備考: 他データベースのファイルはメンテナンスされない. 他データベースのドライバによって、その場で読込まれ変換さる.&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;
DAO PHPファイルは、オブジェクトを作成した後にモジュールビルダによって生成されているはず.&lt;br /&gt;
&lt;br /&gt;
だとしても、既存オブジェクトをコピーして手動作成することもできる、しかし、モジュールビルダの使用を強く勧める。実例がここにあるはず &#039;&#039;&#039;htdocs/modulebuilder/templates/class/myobject.class.php&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
このクラスでは、テーブル行の挿入、取得（選択）、更新、削除を実行するためのCRUD（作成/読込/更新/削除）メソッドがすでに実行可能となっている。正しいモジュール名、テーブルを使用するようにファイルを編集し、このファイルをモジュールのクラスサブディレクトリに配置する。モジュールビルダを使用すると、マウスを数回クリックするだけで、この作業を実行できる.&lt;br /&gt;
&lt;br /&gt;
==タブ管理 (任意)==&lt;br /&gt;
&lt;br /&gt;
===Add or remove your own tabs on object sheets===&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: To add a tab on an object (invoices, orders, proposals, member ...)&lt;br /&gt;
&lt;br /&gt;
To do this go into the file descriptor of module previously created and edit the $this-&amp;gt;tabs array:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The table should contain a list of strings, each string representing a new tab. &lt;br /&gt;
The format of the string consisting of 5 parts separated by &amp;quot;:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*Part 1: The element type (object type) where the tab should appear is a value from the following:&lt;br /&gt;
{{TemplateModuleTabs}}&lt;br /&gt;
&lt;br /&gt;
*Part 2: A code to identify tab to add (start with +) or to remove (start with -)&lt;br /&gt;
*Part 3: The title of the tab. This can be a hard read or better code translation in a file lang.&lt;br /&gt;
*Part 4: The name of the file &amp;quot;*.lang&amp;quot; which contains correspondence between the code translation and language to display. If this name is followed with @mymodule, Dolibarr will search translation file &amp;quot;*.lang&amp;quot; within the module, so htdocs/mymodule/langs/code_CODE/mylangfile.lang, otherwise Dolibarr will look for file htdocs/langs/code_CODE/mylangfile.lang&lt;br /&gt;
*Part 5: A condition to test if tab must be visible. Put 1 to be always visible.&lt;br /&gt;
*Part 6: The URL of the page to display when you click on the tab. The __ID__ string will be replaced automatically by the Id of the element concerned.&lt;br /&gt;
&lt;br /&gt;
To feed the contents of the tab with data from the database, see the next chapter.&lt;br /&gt;
&lt;br /&gt;
In order to get the names  &#039;tabname&#039; of existing tabs, you have to check the names used in the function &#039;product_prepare_head&#039; of the file  &#039;core/lib/module.lib.php&#039; corresponding to section &#039;$head[$h][2]&#039;.&lt;br /&gt;
&lt;br /&gt;
===Show tabs navigation into your own pages===&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: To show all standard tabs of an object (product, tiers, etc.) on your page.&lt;br /&gt;
&lt;br /&gt;
You must follow these steps :&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1. Include files you need into your file&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each object type, there are two files to include with line&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;require_once($url_fichier) ;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is example of files to include (DOL_DOCUMENT_ROOT is often dolibarr/htdocs/) :&lt;br /&gt;
&lt;br /&gt;
*Object thirdparty (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;
*Object product (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;
*Object invoice (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. Create and load the object to show into your tab&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create an instance of an object of the correct class and load object from the database by using the fetch method of an object in providing to this method the id you get from URL (ie : /mytab.php?id=1).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Get a list of all tabs to show for your object type&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function XXX_prepare_head($obj), where XXX is name of object. This will return an array with all definition of tab entries to show. The parameter to put into this method is the instance of an object you want tabs.&lt;br /&gt;
&lt;br /&gt;
The resulting array has the following structure&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$head = product_prepare_head($product, $user) ; // parameter $user is present for some function anly&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4. show tabs into your page&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function dol_fiche_head() to show all tabs defined into array $head returned by XX_prepare_head().&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&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;When&#039;&#039;&#039;: If the purpose of your module is to add features that require new or modified screens.&lt;br /&gt;
&lt;br /&gt;
===Create a new PHP screen===&lt;br /&gt;
You must then create your PHP pages that will show/edit data from tables using the skeleton templates provided as an example in the directory &#039;&#039;&#039;modulebuilder/myobject_page.php&#039;&#039;&#039; (For the development of a script from the command line, see [[Script development]]).&lt;br /&gt;
&lt;br /&gt;
To create a new user screen, create a subdirectory of &#039;&#039;&#039;htdocs&#039;&#039;&#039; (if not already done) for your module (in &#039;&#039;&#039;htdocs/mymodule&#039;&#039;&#039; for example) to store the pages you will create.&lt;br /&gt;
&lt;br /&gt;
Copy, into that directory, the file &#039;&#039;&#039;myobject_page.phpp&#039;&#039;&#039; that will serve as a starting point for your page file.&lt;br /&gt;
Edit the file to have a correct relative path to the main.inc.php file. &lt;br /&gt;
&amp;lt;syntaxhighlight 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 calculated 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
As you can see, there are several tries to load the main.inc.php (or master.inc.php). The goal is to succeed in the most cases as possible. The minimum is 2 lines: one to try to load the master/main.inc.php into the dolibarr root directory and another one to try to load the file to support the case when the module is deployed into the &amp;quot;custom&amp;quot; directory. But you can have more to deal more situation. The provided example should be able to load the file main/master.inc.php in nearly all situation/setups.&lt;br /&gt;
&lt;br /&gt;
Note that you may add more &amp;quot;../&amp;quot; depending on the depth of the file relative to your module directory tree.&lt;br /&gt;
&lt;br /&gt;
It&#039;s in the main.inc.php file that is loaded technical environment variables and permissions. The following variables are objects positioned in this file:&lt;br /&gt;
&lt;br /&gt;
*$user    Object that contains the characteristics of the user + his permissions.&lt;br /&gt;
*$conf    Object that contains Dolibarr configuration.&lt;br /&gt;
*$db      Object that contains an opened connection handler to the database.&lt;br /&gt;
*$langs   Object that contains the user&#039;s language.&lt;br /&gt;
&lt;br /&gt;
Then enter your code to display the page.&lt;br /&gt;
&lt;br /&gt;
*To include a class or library dedicated to the module is done using a Dolibarr function (and not using directly include_once):&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*To include classes provided with Dolibarr, use the following syntax:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add some fields into existing forms===&lt;br /&gt;
You may want to provide a module that adds more fields into forms (input and view) of some elements. &lt;br /&gt;
&lt;br /&gt;
A heavy solution (but not so bad) may be to replace all pages used to create element (this means to disable the &amp;quot;New element&amp;quot; menu entry and adding yours, and disable tab that shows element to replace with a tab that is your own full page (copied/pasted from original) to do same than original page but modified to add your fields and stored added data into your own table). Go to menu [[#Define your entries in the menu (optional)]] and [[#The tab management (optional)]] if this solution suits you (this solution is more powerful since you can change everything you want into the page). &lt;br /&gt;
&lt;br /&gt;
We will describe here another solution, that works only to &amp;quot;add fields&amp;quot; at end of existing fields, using the element &amp;quot;category&amp;quot; as an example but you can convert this tutorial for invoice, proposal ...&lt;br /&gt;
&lt;br /&gt;
*First thing is to add a table, owned by your module, to store the value of new fields. This table will have only one column called &amp;quot;rowid&amp;quot; (will contain the same value than field rowid of element table) + one column for each new field you want to add. Then create a class with CRUD (Create/Read/Update/Delete) methods for this new table. For this two tasks, go back to previous chapter [[#Create your SQL tables and the PHP DAO class]].&lt;br /&gt;
*Next step is to add a hook into your module to add the new fields into the form. See chapter [[Hooks_system#Implement_the_Hook]] for generic documentation to use hooks.&lt;br /&gt;
&lt;br /&gt;
If you follow this tutorial, to be able to add fields into category forms, you must do:&lt;br /&gt;
{{ToComplete}}&lt;br /&gt;
&lt;br /&gt;
===Add/replace part of fields supported by hooks===&lt;br /&gt;
See chapter [[Hooks_system#Implement_the_Hook]] to know how to use Dolibarr existing hooks to add/replace code at Dolibarr hooks place.&lt;br /&gt;
&lt;br /&gt;
===Database access===&lt;br /&gt;
If you need to edit some data in the database inside your own table, use the PHP class generated before.&lt;br /&gt;
&lt;br /&gt;
If you to make access to tables with no dedicated PHP class available, this is always possible (for example if you want to get a list of records with a particular join or filter). In this case, this is a code samples to follow:&lt;br /&gt;
&lt;br /&gt;
To make an insert, update or delete:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To read:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Define style of your pages===&lt;br /&gt;
To have the look of your own pages to match the Dolibarr theme, it is necessary to use the Dolibarr CSS styles.&lt;br /&gt;
&lt;br /&gt;
You can use for example:&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;
===Use the Dolibarr date picker===&lt;br /&gt;
If you want to use the Dolibarr date selector (with its calendar popup) into your pages, use the following line:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
The string mykey will identify the date selector in the form. You must use different values if you use several date selectors in same page.&lt;br /&gt;
The string myform is the name of the FORM in which the selector is included (value found in the form name=&amp;quot;myform&amp;quot; in HTML page).&lt;br /&gt;
This means a date selector must be included necessarily into an html FORM.&lt;br /&gt;
&lt;br /&gt;
To get value after the POST of your form, the command is:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$mydate = dol_mktime(12, 0 , 0, $GETPOST(&#039;mykeymonth&#039;, &#039;int&#039;), GETPOST(&#039;mykeyday&#039;, &#039;int&#039;), GETPOST(&#039;mykeyyear&#039;, &#039;int&#039;));&lt;br /&gt;
print strftime(&#039;%A %d %B %Y&#039;, $mydate);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Overwrite template file (tpl)===&lt;br /&gt;
If you want to overwrite tpl file on your module, you need to declare it on the module_parts :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
&#039;tpl&#039; =&amp;gt; 1,&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Then you can put any tpl file on &#039;&#039;&#039;mymodule/core/tpl&#039;&#039;&#039;&lt;br /&gt;
as soon as the module is activate, the tpl will be overwrited&lt;br /&gt;
&lt;br /&gt;
==自前の準備ページを追加 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs parameters, which are to be provided by the user, for proper setting up of the module.&lt;br /&gt;
&lt;br /&gt;
===Create your page to edit parameters===&lt;br /&gt;
If your module needs several parameters to be setup, you must create a page to edit options (these options will be saved in the [[Table llx_const|table &#039;&#039;&#039;llx_const&#039;&#039;&#039;]]).&lt;br /&gt;
Create a page named &#039;&#039;&#039;mymodule_setuppage.php&#039;&#039;&#039; that shows a form for possible options to update them into the above-mentioned table.&lt;br /&gt;
It is necessary to take an example from a page of the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; that will show you the way to read/save your parameters.&lt;br /&gt;
Put this PHP page into the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; of your module (e.g. mymodule/admin/mymodule_setuppage.php).&lt;br /&gt;
&lt;br /&gt;
===Modify the descriptor file of your module===&lt;br /&gt;
Then, within the descriptor file of your module, modify the variable &#039;&#039;&#039;config_page_url&#039;&#039;&#039; to set the name of this PHP page.&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;admin/&#039;&#039;&#039;, then the path is not required, e.g. like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;mymodule/admin/&#039;&#039;&#039;, then like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test your page===&lt;br /&gt;
Go into page &#039;&#039;&#039;Home-&amp;gt;Setup-&amp;gt;Modules&#039;&#039;&#039;, you should see a picture at the end of the line of your module to reach your setup page. Click on it, you should be able to view/edit parameters from your page.&lt;br /&gt;
&lt;br /&gt;
==メニューに自前項目を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If you have created PHP pages, it is necessary that those pages can be reached from menu entries in Dolibarr menu.&lt;br /&gt;
&lt;br /&gt;
===Define your menu entries===&lt;br /&gt;
For this, you must define into the module descriptor, the array this-&amp;gt;menu that declares 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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To show the menu or not depending on a permission, modify property &#039;&#039;&#039;perms&#039;&#039;&#039; in the array. See chapter on permissions later to see how to add permissions.&lt;br /&gt;
&lt;br /&gt;
===Test your menu entries===&lt;br /&gt;
Disable and re-enable your module under the 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;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;rights_class = &#039;mymodule&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight 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][2] = &#039;r&#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;/syntaxhighlight&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][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; Translation key should be &amp;quot;Permission10001=My permission Label&amp;quot;).&lt;br /&gt;
Into $this-&amp;gt;rights[$r][2], types of the permission. There are three type of permission, &#039;r&#039; for read, list or expert permission, &#039;w&#039; for write or update permission and &#039;d&#039; for delete permission.&lt;br /&gt;
Into $this-&amp;gt;rights[$r][3], put 1 if this permission must be granted automatically by default to any newly created user.&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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==自前の box を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs to provide one or several new boxes to show on home page.&lt;br /&gt;
&lt;br /&gt;
===Define your box===&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;syntaxhighlight 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;/syntaxhighlight&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 activate. Activate the box and go on the home page to see if the box is showing correctly.&lt;br /&gt;
&lt;br /&gt;
==自前のエキスポートを定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module provides new predefined database export profiles (for its own tables or for already existing tables of another module).&lt;br /&gt;
&lt;br /&gt;
===Define export===&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 a 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;
==自前の CSS スタイルを定義 (任意)==&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 several CSS files 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 files only if you need absolutely to add not already existing styles.&lt;br /&gt;
&lt;br /&gt;
Once your style sheets are ready, declare them 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 an array of relative URLs to your CSS files.&lt;br /&gt;
For example&lt;br /&gt;
&amp;lt;syntaxhighlight 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;,&#039;/mymodule/css/myother.css&#039;));&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 the 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 declares your style sheet.&lt;br /&gt;
&lt;br /&gt;
==自前の Javascript 関数を追加 (任意)==&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;syntaxhighlight 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;/syntaxhighlight&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;
==Dolibarr フックポジションの内部に、自前コードを挿入 (任意)==&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 the 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 are not covered by existing rules.&lt;br /&gt;
&lt;br /&gt;
See page [[Create numbering module]].&lt;br /&gt;
&lt;br /&gt;
==自前の文書テンプレートを追加 (任意)==&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;
==自前のスキンを追加 (任意)==&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;
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 marketplace.&lt;br /&gt;
But you can use it to have a package easy to distribute on your own 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 a 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
perl makepack-dolibarrmodule.pl&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
tar -xvf mymodule.zip&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 marketplace website: {{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 built correctly, the file will be validated later.&lt;br /&gt;
**If quality is enough and license permits it, the code might be added inside main Dolibarr sources (except if you disagree for that).&lt;br /&gt;
&lt;br /&gt;
=DoliStore での外部モジュール 有効化/活性化 条件=&lt;br /&gt;
&lt;br /&gt;
See [[Module_Dolistore_Validation_Rules|Validation Rules]]&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56475</id>
		<title>モジュール 開発</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56475"/>
		<updated>2023-05-10T04:39:23Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: /* 自前の .sql ファイルを作成 */&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:Développement_module]]&lt;br /&gt;
[[es:Desarrollo_de_un_módulo]]&lt;br /&gt;
[[de:Modul_Entwicklung]]&lt;br /&gt;
[[zh:模块开发]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Core]]&lt;br /&gt;
{{TemplateDocDevEn}}&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;
etc...&lt;br /&gt;
&lt;br /&gt;
以下の章では、これらすべてを手作業で簡単に行う方法を示す.&lt;br /&gt;
&lt;br /&gt;
=モジュールビルダ によるモジュールの生成=&lt;br /&gt;
Dolibarr 9.0 から、モジュールビルダにより、自前モジュールのメインページ作成が可能. 起動方法は:&lt;br /&gt;
&lt;br /&gt;
*モジュールリストにて、&amp;quot;モジュールビルダ(Module Builder)&amp;quot;を有効化する,&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_2.png|400px]]&lt;br /&gt;
&lt;br /&gt;
*その後 &amp;quot;バグ(bug)&amp;quot; 画像をクリック、場所は画面右上.&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_3.png|400px]]&lt;br /&gt;
&lt;br /&gt;
=テンプレート外部モジュールの例=&lt;br /&gt;
外部モジュールの開発を開始するのによいお手本は、ここで見つかるだろう : [https://github.com/Dolibarr/dolibarr/tree/develop/htdocs/modulebuilder/template GitHub Dolibarr Module Modèle]&lt;br /&gt;
&lt;br /&gt;
=自前モジュールを作る=&lt;br /&gt;
==自前モジュールに関するモジュール記述(Module descriptor)を作る (必須)==&lt;br /&gt;
&#039;&#039;&#039;必須となる時期&#039;&#039;&#039;: アドオンを開発すると早急に必要、たとえゴールが何であれ (例外はスキンの追加).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Dolibarr 9.0 から, モジュールビルダ (ModuleBuilder) モジュールを使用すべきだ、モジュール記述を生成するための標準モデルとして使える&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===自前のモジュール記述 (module descriptor) を作成する===&lt;br /&gt;
最初のステップは、モジュールに対するファイル記述 (file descriptor) を作成すること. (訳者注： 以下の内容は&#039;&#039;&#039;モジュールビルダを使うことで自動設定&#039;&#039;&#039;される) &lt;br /&gt;
&lt;br /&gt;
*ディレクトリ作成： &#039;&#039;&#039;/htdocs/custom/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; (外部モジュール向け) または &#039;&#039;&#039;/htdocs/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; ここはDolibarr の公式コアモジュール (official core module) とする場合. 次にファイル modMyModule.class.php をディレクトリ &#039;&#039;&#039;htdocs/modulebuilder/template&#039;&#039;&#039; からコピーして上記のディレクトリに作成. ファイルの名称を modMyModule.class.php から 自前モジュールの目的に合致した名称に変更. ファイル名は、先頭に &#039;mod&#039; があり、最後が .class.php で終わる (例えば、ファイル名を &#039;新名&#039; にするなら, &#039;mod新名.class.php&#039; となる).&lt;br /&gt;
&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;
*番号を変更: $this-&amp;gt;numero = 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;
Dolibarrを起動し、&#039;&#039;&#039;設定-&amp;gt;モジュール (Setup-&amp;gt;module&#039;&#039;&#039;?) ページを表示.&lt;br /&gt;
モジュール記述でプロパティバージョン (property version) を設定すると、自前の新規モジュールを載せた新規行とそれを有効化するかどうかの選択が表示されるはず. プロパティバージョンを &amp;quot;develop&amp;quot; または &amp;quot;experimental&amp;quot; に設定した場合、自前モジュールを見るには、まず &#039;&#039;&#039;設定-&amp;gt;その他 (Setup-Others)&#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;
これは、新しいモジュールを構築する際に、ファイルをどう整理するかを示している (ZIPファイルもこのルールに合わせる必要あり).&lt;br /&gt;
注：2行目だけが必須.&lt;br /&gt;
&lt;br /&gt;
{{TemplateModuleTreeSimpleJA}}&lt;br /&gt;
&lt;br /&gt;
==自前 SQL テーブル と PHP DAO クラス (任意)==&lt;br /&gt;
&#039;&#039;&#039;使用場面&#039;&#039;&#039;: 自前モジュールがそれ自身のデータを管理する必要がある場合&lt;br /&gt;
&lt;br /&gt;
===自前の .sql ファイルを作成===&lt;br /&gt;
自前モジュールが、Dolibarr標準版では利用できない独自データを管理する設計である場合、そのデータを格納するためのSQLテーブルを定義する必要がある.&lt;br /&gt;
&lt;br /&gt;
自前モジュールでテーブルを作成したり、データを読込むためのスクリプトは、自前モジュールのsqlサブディレクトリ (&amp;quot;&#039;&#039;&#039;mymodule/sql&#039;&#039;&#039;&amp;quot;) に保存される。(ModuleBuilder では、オブジェクト タブから新しいオブジェクトを作成するとき、このディレクトリとすべての sql ファイルが自動作成される）.&lt;br /&gt;
&lt;br /&gt;
次に、記述ファイルでの、&#039;&#039;&#039;init&#039;&#039;&#039; 関数にて、次の行&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;$this-&amp;gt;_load_tables(&#039;/mymodule/sql/&#039;);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
が、コメントでないことを確認する.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;従うべきルール:&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*テーブルごとに &#039;&#039;&#039;llx_matable.sql&#039;&#039;&#039; ファイルを１つ、&#039;&#039;&#039;llx_matable.key.sql&#039;&#039;&#039; ファイルを可能なら１つ、作成するという原則に基づき、テーブル作成コマンドのファイルを追加する（例として、 &#039;&#039;&#039;install/mysql/tables&#039;&#039;&#039; にあるファイルを参照）.&lt;br /&gt;
*SQLフィールドの推奨される型と名前は、このページに定義されてる [[Language_and_development_rules#Table_and_fields_structures]].&lt;br /&gt;
*データ管理のため、 &#039;&#039;&#039;/mymodule/sql/&#039;&#039;&#039;  ディレクトリ内に  &#039;&#039;&#039;data.sql&#039;&#039;&#039;  というファイルを作成し、データの追加/編集/削除を行う SQL コマンドを記述すること.&lt;br /&gt;
*文字列にダブルクォートを使わない（例： &amp;quot;chaine&amp;quot; でなく &#039;chaine&#039;） ダブルクォートは PostGreSQL では特定の意味を持つ&lt;br /&gt;
&lt;br /&gt;
例としてファイル data.sql の中身は&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
ファイルは、mysql データベースで動作可能であること. 備考: 他データベースのファイルはメンテナンスされない. 他データベースのドライバによって、その場で読込まれ変換さる.&lt;br /&gt;
&lt;br /&gt;
===Test your .sql files===&lt;br /&gt;
&lt;br /&gt;
Once the files ready, you can return to the page to enable Dolibarr modules and disable the module, drop those tables in the database (if they already exists) and reactivate the module. The tables should be recreated by the activation of the module. If this is not the case, check your scripts by passing them by hand, or check the Dolibarr logs.&lt;br /&gt;
&lt;br /&gt;
===Generate the PHP DAO class===&lt;br /&gt;
The DAO PHP files should have been generated by ModuleBuilder after creating an object.&lt;br /&gt;
&lt;br /&gt;
You can however create them manually by copying existing object however using ModuleBuilder is highly recommended. You should find examples into &#039;&#039;&#039;htdocs/modulebuilder/templates/class/myobject.class.php&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this class, there are already operational CRUD (Create/Read/Update/Delete) methods to perform an insert, a fetch (select), an update, a delete of a table row. Edit the file to use the correct module name, tables and place this file in the class subdirectory of the module. The Module Builder allows you to do this with just a few mouse clicks.&lt;br /&gt;
&lt;br /&gt;
==タブ管理 (任意)==&lt;br /&gt;
&lt;br /&gt;
===Add or remove your own tabs on object sheets===&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: To add a tab on an object (invoices, orders, proposals, member ...)&lt;br /&gt;
&lt;br /&gt;
To do this go into the file descriptor of module previously created and edit the $this-&amp;gt;tabs array:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The table should contain a list of strings, each string representing a new tab. &lt;br /&gt;
The format of the string consisting of 5 parts separated by &amp;quot;:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*Part 1: The element type (object type) where the tab should appear is a value from the following:&lt;br /&gt;
{{TemplateModuleTabs}}&lt;br /&gt;
&lt;br /&gt;
*Part 2: A code to identify tab to add (start with +) or to remove (start with -)&lt;br /&gt;
*Part 3: The title of the tab. This can be a hard read or better code translation in a file lang.&lt;br /&gt;
*Part 4: The name of the file &amp;quot;*.lang&amp;quot; which contains correspondence between the code translation and language to display. If this name is followed with @mymodule, Dolibarr will search translation file &amp;quot;*.lang&amp;quot; within the module, so htdocs/mymodule/langs/code_CODE/mylangfile.lang, otherwise Dolibarr will look for file htdocs/langs/code_CODE/mylangfile.lang&lt;br /&gt;
*Part 5: A condition to test if tab must be visible. Put 1 to be always visible.&lt;br /&gt;
*Part 6: The URL of the page to display when you click on the tab. The __ID__ string will be replaced automatically by the Id of the element concerned.&lt;br /&gt;
&lt;br /&gt;
To feed the contents of the tab with data from the database, see the next chapter.&lt;br /&gt;
&lt;br /&gt;
In order to get the names  &#039;tabname&#039; of existing tabs, you have to check the names used in the function &#039;product_prepare_head&#039; of the file  &#039;core/lib/module.lib.php&#039; corresponding to section &#039;$head[$h][2]&#039;.&lt;br /&gt;
&lt;br /&gt;
===Show tabs navigation into your own pages===&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: To show all standard tabs of an object (product, tiers, etc.) on your page.&lt;br /&gt;
&lt;br /&gt;
You must follow these steps :&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1. Include files you need into your file&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each object type, there are two files to include with line&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;require_once($url_fichier) ;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is example of files to include (DOL_DOCUMENT_ROOT is often dolibarr/htdocs/) :&lt;br /&gt;
&lt;br /&gt;
*Object thirdparty (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;
*Object product (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;
*Object invoice (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. Create and load the object to show into your tab&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create an instance of an object of the correct class and load object from the database by using the fetch method of an object in providing to this method the id you get from URL (ie : /mytab.php?id=1).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Get a list of all tabs to show for your object type&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function XXX_prepare_head($obj), where XXX is name of object. This will return an array with all definition of tab entries to show. The parameter to put into this method is the instance of an object you want tabs.&lt;br /&gt;
&lt;br /&gt;
The resulting array has the following structure&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$head = product_prepare_head($product, $user) ; // parameter $user is present for some function anly&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4. show tabs into your page&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function dol_fiche_head() to show all tabs defined into array $head returned by XX_prepare_head().&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&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;When&#039;&#039;&#039;: If the purpose of your module is to add features that require new or modified screens.&lt;br /&gt;
&lt;br /&gt;
===Create a new PHP screen===&lt;br /&gt;
You must then create your PHP pages that will show/edit data from tables using the skeleton templates provided as an example in the directory &#039;&#039;&#039;modulebuilder/myobject_page.php&#039;&#039;&#039; (For the development of a script from the command line, see [[Script development]]).&lt;br /&gt;
&lt;br /&gt;
To create a new user screen, create a subdirectory of &#039;&#039;&#039;htdocs&#039;&#039;&#039; (if not already done) for your module (in &#039;&#039;&#039;htdocs/mymodule&#039;&#039;&#039; for example) to store the pages you will create.&lt;br /&gt;
&lt;br /&gt;
Copy, into that directory, the file &#039;&#039;&#039;myobject_page.phpp&#039;&#039;&#039; that will serve as a starting point for your page file.&lt;br /&gt;
Edit the file to have a correct relative path to the main.inc.php file. &lt;br /&gt;
&amp;lt;syntaxhighlight 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 calculated 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
As you can see, there are several tries to load the main.inc.php (or master.inc.php). The goal is to succeed in the most cases as possible. The minimum is 2 lines: one to try to load the master/main.inc.php into the dolibarr root directory and another one to try to load the file to support the case when the module is deployed into the &amp;quot;custom&amp;quot; directory. But you can have more to deal more situation. The provided example should be able to load the file main/master.inc.php in nearly all situation/setups.&lt;br /&gt;
&lt;br /&gt;
Note that you may add more &amp;quot;../&amp;quot; depending on the depth of the file relative to your module directory tree.&lt;br /&gt;
&lt;br /&gt;
It&#039;s in the main.inc.php file that is loaded technical environment variables and permissions. The following variables are objects positioned in this file:&lt;br /&gt;
&lt;br /&gt;
*$user    Object that contains the characteristics of the user + his permissions.&lt;br /&gt;
*$conf    Object that contains Dolibarr configuration.&lt;br /&gt;
*$db      Object that contains an opened connection handler to the database.&lt;br /&gt;
*$langs   Object that contains the user&#039;s language.&lt;br /&gt;
&lt;br /&gt;
Then enter your code to display the page.&lt;br /&gt;
&lt;br /&gt;
*To include a class or library dedicated to the module is done using a Dolibarr function (and not using directly include_once):&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*To include classes provided with Dolibarr, use the following syntax:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add some fields into existing forms===&lt;br /&gt;
You may want to provide a module that adds more fields into forms (input and view) of some elements. &lt;br /&gt;
&lt;br /&gt;
A heavy solution (but not so bad) may be to replace all pages used to create element (this means to disable the &amp;quot;New element&amp;quot; menu entry and adding yours, and disable tab that shows element to replace with a tab that is your own full page (copied/pasted from original) to do same than original page but modified to add your fields and stored added data into your own table). Go to menu [[#Define your entries in the menu (optional)]] and [[#The tab management (optional)]] if this solution suits you (this solution is more powerful since you can change everything you want into the page). &lt;br /&gt;
&lt;br /&gt;
We will describe here another solution, that works only to &amp;quot;add fields&amp;quot; at end of existing fields, using the element &amp;quot;category&amp;quot; as an example but you can convert this tutorial for invoice, proposal ...&lt;br /&gt;
&lt;br /&gt;
*First thing is to add a table, owned by your module, to store the value of new fields. This table will have only one column called &amp;quot;rowid&amp;quot; (will contain the same value than field rowid of element table) + one column for each new field you want to add. Then create a class with CRUD (Create/Read/Update/Delete) methods for this new table. For this two tasks, go back to previous chapter [[#Create your SQL tables and the PHP DAO class]].&lt;br /&gt;
*Next step is to add a hook into your module to add the new fields into the form. See chapter [[Hooks_system#Implement_the_Hook]] for generic documentation to use hooks.&lt;br /&gt;
&lt;br /&gt;
If you follow this tutorial, to be able to add fields into category forms, you must do:&lt;br /&gt;
{{ToComplete}}&lt;br /&gt;
&lt;br /&gt;
===Add/replace part of fields supported by hooks===&lt;br /&gt;
See chapter [[Hooks_system#Implement_the_Hook]] to know how to use Dolibarr existing hooks to add/replace code at Dolibarr hooks place.&lt;br /&gt;
&lt;br /&gt;
===Database access===&lt;br /&gt;
If you need to edit some data in the database inside your own table, use the PHP class generated before.&lt;br /&gt;
&lt;br /&gt;
If you to make access to tables with no dedicated PHP class available, this is always possible (for example if you want to get a list of records with a particular join or filter). In this case, this is a code samples to follow:&lt;br /&gt;
&lt;br /&gt;
To make an insert, update or delete:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To read:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Define style of your pages===&lt;br /&gt;
To have the look of your own pages to match the Dolibarr theme, it is necessary to use the Dolibarr CSS styles.&lt;br /&gt;
&lt;br /&gt;
You can use for example:&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;
===Use the Dolibarr date picker===&lt;br /&gt;
If you want to use the Dolibarr date selector (with its calendar popup) into your pages, use the following line:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
The string mykey will identify the date selector in the form. You must use different values if you use several date selectors in same page.&lt;br /&gt;
The string myform is the name of the FORM in which the selector is included (value found in the form name=&amp;quot;myform&amp;quot; in HTML page).&lt;br /&gt;
This means a date selector must be included necessarily into an html FORM.&lt;br /&gt;
&lt;br /&gt;
To get value after the POST of your form, the command is:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$mydate = dol_mktime(12, 0 , 0, $GETPOST(&#039;mykeymonth&#039;, &#039;int&#039;), GETPOST(&#039;mykeyday&#039;, &#039;int&#039;), GETPOST(&#039;mykeyyear&#039;, &#039;int&#039;));&lt;br /&gt;
print strftime(&#039;%A %d %B %Y&#039;, $mydate);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Overwrite template file (tpl)===&lt;br /&gt;
If you want to overwrite tpl file on your module, you need to declare it on the module_parts :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
&#039;tpl&#039; =&amp;gt; 1,&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Then you can put any tpl file on &#039;&#039;&#039;mymodule/core/tpl&#039;&#039;&#039;&lt;br /&gt;
as soon as the module is activate, the tpl will be overwrited&lt;br /&gt;
&lt;br /&gt;
==自前の準備ページを追加 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs parameters, which are to be provided by the user, for proper setting up of the module.&lt;br /&gt;
&lt;br /&gt;
===Create your page to edit parameters===&lt;br /&gt;
If your module needs several parameters to be setup, you must create a page to edit options (these options will be saved in the [[Table llx_const|table &#039;&#039;&#039;llx_const&#039;&#039;&#039;]]).&lt;br /&gt;
Create a page named &#039;&#039;&#039;mymodule_setuppage.php&#039;&#039;&#039; that shows a form for possible options to update them into the above-mentioned table.&lt;br /&gt;
It is necessary to take an example from a page of the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; that will show you the way to read/save your parameters.&lt;br /&gt;
Put this PHP page into the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; of your module (e.g. mymodule/admin/mymodule_setuppage.php).&lt;br /&gt;
&lt;br /&gt;
===Modify the descriptor file of your module===&lt;br /&gt;
Then, within the descriptor file of your module, modify the variable &#039;&#039;&#039;config_page_url&#039;&#039;&#039; to set the name of this PHP page.&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;admin/&#039;&#039;&#039;, then the path is not required, e.g. like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;mymodule/admin/&#039;&#039;&#039;, then like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test your page===&lt;br /&gt;
Go into page &#039;&#039;&#039;Home-&amp;gt;Setup-&amp;gt;Modules&#039;&#039;&#039;, you should see a picture at the end of the line of your module to reach your setup page. Click on it, you should be able to view/edit parameters from your page.&lt;br /&gt;
&lt;br /&gt;
==メニューに自前項目を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If you have created PHP pages, it is necessary that those pages can be reached from menu entries in Dolibarr menu.&lt;br /&gt;
&lt;br /&gt;
===Define your menu entries===&lt;br /&gt;
For this, you must define into the module descriptor, the array this-&amp;gt;menu that declares 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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To show the menu or not depending on a permission, modify property &#039;&#039;&#039;perms&#039;&#039;&#039; in the array. See chapter on permissions later to see how to add permissions.&lt;br /&gt;
&lt;br /&gt;
===Test your menu entries===&lt;br /&gt;
Disable and re-enable your module under the 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;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;rights_class = &#039;mymodule&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight 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][2] = &#039;r&#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;/syntaxhighlight&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][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; Translation key should be &amp;quot;Permission10001=My permission Label&amp;quot;).&lt;br /&gt;
Into $this-&amp;gt;rights[$r][2], types of the permission. There are three type of permission, &#039;r&#039; for read, list or expert permission, &#039;w&#039; for write or update permission and &#039;d&#039; for delete permission.&lt;br /&gt;
Into $this-&amp;gt;rights[$r][3], put 1 if this permission must be granted automatically by default to any newly created user.&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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==自前の box を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs to provide one or several new boxes to show on home page.&lt;br /&gt;
&lt;br /&gt;
===Define your box===&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;syntaxhighlight 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;/syntaxhighlight&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 activate. Activate the box and go on the home page to see if the box is showing correctly.&lt;br /&gt;
&lt;br /&gt;
==自前のエキスポートを定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module provides new predefined database export profiles (for its own tables or for already existing tables of another module).&lt;br /&gt;
&lt;br /&gt;
===Define export===&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 a 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;
==自前の CSS スタイルを定義 (任意)==&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 several CSS files 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 files only if you need absolutely to add not already existing styles.&lt;br /&gt;
&lt;br /&gt;
Once your style sheets are ready, declare them 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 an array of relative URLs to your CSS files.&lt;br /&gt;
For example&lt;br /&gt;
&amp;lt;syntaxhighlight 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;,&#039;/mymodule/css/myother.css&#039;));&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 the 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 declares your style sheet.&lt;br /&gt;
&lt;br /&gt;
==自前の Javascript 関数を追加 (任意)==&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;syntaxhighlight 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;/syntaxhighlight&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;
==Dolibarr フックポジションの内部に、自前コードを挿入 (任意)==&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 the 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 are not covered by existing rules.&lt;br /&gt;
&lt;br /&gt;
See page [[Create numbering module]].&lt;br /&gt;
&lt;br /&gt;
==自前の文書テンプレートを追加 (任意)==&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;
==自前のスキンを追加 (任意)==&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;
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 marketplace.&lt;br /&gt;
But you can use it to have a package easy to distribute on your own 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 a 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
perl makepack-dolibarrmodule.pl&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
tar -xvf mymodule.zip&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 marketplace website: {{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 built correctly, the file will be validated later.&lt;br /&gt;
**If quality is enough and license permits it, the code might be added inside main Dolibarr sources (except if you disagree for that).&lt;br /&gt;
&lt;br /&gt;
=DoliStore での外部モジュール 有効化/活性化 条件=&lt;br /&gt;
&lt;br /&gt;
See [[Module_Dolistore_Validation_Rules|Validation Rules]]&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=Template:TemplateModuleTreeSimpleJA&amp;diff=56474</id>
		<title>Template:TemplateModuleTreeSimpleJA</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=Template:TemplateModuleTreeSimpleJA&amp;diff=56474"/>
		<updated>2023-05-10T04:31:37Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* &#039;&#039;&#039;mymodule/*&#039;&#039;&#039; には php ページを配置（任意のサブディレクトリ追加も可であることに注意）注: 自前モジュールがメタパッケージ（同一 zip 内に他モジュールを埋め込むモジュールである場合、ここに metapackage.conf ファイルを置く必要がある）&lt;br /&gt;
* &#039;&#039;&#039;mymodule/build/&#039;&#039;&#039; には任意のファイルを配置でき、それはコンパイルやビルドに使用するもの&lt;br /&gt;
* &#039;&#039;&#039;mymodule/core/modules/&#039;&#039;&#039; には、モジュール記述ファイル &#039;&#039;&#039; modMyModule.class.php&#039;&#039;&#039; を配置&lt;br /&gt;
* &#039;&#039;&#039;mymodule/core/triggers&#039;&#039;&#039; には、モジュールが提供するトリガーを配置&lt;br /&gt;
* &#039;&#039;&#039;mymodule/admin/&#039;&#039;&#039; には、モジュールを設定するページを配置&lt;br /&gt;
* &#039;&#039;&#039;mymodule/class/&#039;&#039;&#039; には、モジュールが提供するPHP クラスファイルを配置&lt;br /&gt;
* &#039;&#039;&#039;mymodule/css&#039;&#039;&#039; には、モジュールが提供する CSS ファイルを配置&lt;br /&gt;
* &#039;&#039;&#039;mymodule/js&#039;&#039;&#039; には、モジュールが提供する javascirpt ファイルを配置し、新規 function を追加&lt;br /&gt;
* &#039;&#039;&#039;mymodule/docs&#039;&#039;&#039; には、文書及びライセンスファイルを配置&lt;br /&gt;
* &#039;&#039;&#039;mymodule/img&#039;&#039;&#039; には、モジュールが提供する画像ファイルを配置&lt;br /&gt;
* &#039;&#039;&#039;mymodule/langs/xx_XX&#039;&#039;&#039; には、言語 xx_XX (少なくと en_US は配置)に対応する言語ファイルを配置&lt;br /&gt;
* &#039;&#039;&#039;mymodule/lib&#039;&#039;&#039; には、モジュールが提供し使用するライブラリを配置&lt;br /&gt;
* &#039;&#039;&#039;mymodule/scripts&#039;&#039;&#039; には、コマンドラインツールやスクリプトを配置. 注: コマンドラインスクリプトの先頭行に次のもの使う #!/usr/bin/env php&lt;br /&gt;
* &#039;&#039;&#039;mymodule/sql&#039;&#039;&#039; には、モジュールが提供する SQL ファイルを配置し、新規テーブルやインデックスを追加&lt;br /&gt;
* &#039;&#039;&#039;mymodule/theme/mytheme&#039;&#039;&#039; モジュールが自前のテーマ/スキンを提供する場合&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=Template:TemplateModuleTreeSimple&amp;diff=56467</id>
		<title>Template:TemplateModuleTreeSimple</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=Template:TemplateModuleTreeSimple&amp;diff=56467"/>
		<updated>2023-05-08T13:13:02Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: add javascript location&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* &#039;&#039;&#039;mymodule/*&#039;&#039;&#039; contains php pages (note that you can also add any other subdir of your choice). Note: If your module is a metapackage (a module that will embed other modules in same zip, you must put here a file metapackage.conf)&lt;br /&gt;
* &#039;&#039;&#039;mymodule/build/&#039;&#039;&#039; can contains any file you develop for compiling or building package&lt;br /&gt;
* &#039;&#039;&#039;mymodule/core/modules/&#039;&#039;&#039; contains module descriptor file &#039;&#039;&#039; modMyModule.class.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;mymodule/core/triggers&#039;&#039;&#039; contains triggers provided by module&lt;br /&gt;
* &#039;&#039;&#039;mymodule/admin/&#039;&#039;&#039; contains pages to setup module&lt;br /&gt;
* &#039;&#039;&#039;mymodule/class/&#039;&#039;&#039; contains PHP class files provided by module&lt;br /&gt;
* &#039;&#039;&#039;mymodule/css&#039;&#039;&#039; contains CSS files provided by module&lt;br /&gt;
* &#039;&#039;&#039;mymodule/js&#039;&#039;&#039; contains javascirpt files provided by module to add new functions&lt;br /&gt;
* &#039;&#039;&#039;mymodule/docs&#039;&#039;&#039; to provide doc and licence files&lt;br /&gt;
* &#039;&#039;&#039;mymodule/img&#039;&#039;&#039; contains images files provided by module&lt;br /&gt;
* &#039;&#039;&#039;mymodule/langs/xx_XX&#039;&#039;&#039; contains language files for language xx_XX (try to put at least en_US)&lt;br /&gt;
* &#039;&#039;&#039;mymodule/lib&#039;&#039;&#039; contains libraries provided and used by module&lt;br /&gt;
* &#039;&#039;&#039;mymodule/scripts&#039;&#039;&#039; to provide command line tools or scripts. Note: Command lines script must start with line #!/usr/bin/env php&lt;br /&gt;
* &#039;&#039;&#039;mymodule/sql&#039;&#039;&#039; contains SQL file provided by module to add new tables or indexes&lt;br /&gt;
* &#039;&#039;&#039;mymodule/theme/mytheme&#039;&#039;&#039; if module provide its own theme/skin&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=Template:TemplateModuleTreeSimpleJA&amp;diff=56466</id>
		<title>Template:TemplateModuleTreeSimpleJA</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=Template:TemplateModuleTreeSimpleJA&amp;diff=56466"/>
		<updated>2023-05-08T13:12:16Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* &#039;&#039;&#039;mymodule/*&#039;&#039;&#039; にはphpページが含まれる（任意のサブディレクトリ追加も可であることに注意）注: 自前モジュールがメタパッケージ（同一 zip 内に他モジュールを埋め込むモジュールである場合、ここに metapackage.conf ファイルを置く必要がある）&lt;br /&gt;
* &#039;&#039;&#039;mymodule/build/&#039;&#039;&#039; can contains any file you develop for compiling or building package&lt;br /&gt;
* &#039;&#039;&#039;mymodule/core/modules/&#039;&#039;&#039; contains module descriptor file &#039;&#039;&#039; modMyModule.class.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;mymodule/core/triggers&#039;&#039;&#039; contains triggers provided by module&lt;br /&gt;
* &#039;&#039;&#039;mymodule/admin/&#039;&#039;&#039; contains pages to setup module&lt;br /&gt;
* &#039;&#039;&#039;mymodule/class/&#039;&#039;&#039; contains PHP class files provided by module&lt;br /&gt;
* &#039;&#039;&#039;mymodule/css&#039;&#039;&#039; contains CSS files provided by module&lt;br /&gt;
* &#039;&#039;&#039;mymodule/js&#039;&#039;&#039; contains javascirpt files provided by module to add new functions&lt;br /&gt;
* &#039;&#039;&#039;mymodule/docs&#039;&#039;&#039; to provide doc and licence files&lt;br /&gt;
* &#039;&#039;&#039;mymodule/img&#039;&#039;&#039; contains images files provided by module&lt;br /&gt;
* &#039;&#039;&#039;mymodule/langs/xx_XX&#039;&#039;&#039; contains language files for language xx_XX (try to put at least en_US)&lt;br /&gt;
* &#039;&#039;&#039;mymodule/lib&#039;&#039;&#039; contains libraries provided and used by module&lt;br /&gt;
* &#039;&#039;&#039;mymodule/scripts&#039;&#039;&#039; to provide command line tools or scripts. Note: Command lines script must start with line #!/usr/bin/env php&lt;br /&gt;
* &#039;&#039;&#039;mymodule/sql&#039;&#039;&#039; contains SQL file provided by module to add new tables or indexes&lt;br /&gt;
* &#039;&#039;&#039;mymodule/theme/mytheme&#039;&#039;&#039; if module provide its own theme/skin&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56465</id>
		<title>モジュール 開発</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56465"/>
		<updated>2023-05-08T10:37:27Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: /* 新規モジュールファイルに関するパスツリー (必須) */&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:Développement_module]]&lt;br /&gt;
[[es:Desarrollo_de_un_módulo]]&lt;br /&gt;
[[de:Modul_Entwicklung]]&lt;br /&gt;
[[zh:模块开发]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Core]]&lt;br /&gt;
{{TemplateDocDevEn}}&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;
etc...&lt;br /&gt;
&lt;br /&gt;
以下の章では、これらすべてを手作業で簡単に行う方法を示す.&lt;br /&gt;
&lt;br /&gt;
=モジュールビルダ によるモジュールの生成=&lt;br /&gt;
Dolibarr 9.0 から、モジュールビルダにより、自前モジュールのメインページ作成が可能. 起動方法は:&lt;br /&gt;
&lt;br /&gt;
*モジュールリストにて、&amp;quot;モジュールビルダ(Module Builder)&amp;quot;を有効化する,&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_2.png|400px]]&lt;br /&gt;
&lt;br /&gt;
*その後 &amp;quot;バグ(bug)&amp;quot; 画像をクリック、場所は画面右上.&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_3.png|400px]]&lt;br /&gt;
&lt;br /&gt;
=テンプレート外部モジュールの例=&lt;br /&gt;
外部モジュールの開発を開始するのによいお手本は、ここで見つかるだろう : [https://github.com/Dolibarr/dolibarr/tree/develop/htdocs/modulebuilder/template GitHub Dolibarr Module Modèle]&lt;br /&gt;
&lt;br /&gt;
=自前モジュールを作る=&lt;br /&gt;
==自前モジュールに関するモジュール記述(Module descriptor)を作る (必須)==&lt;br /&gt;
&#039;&#039;&#039;必須となる時期&#039;&#039;&#039;: アドオンを開発すると早急に必要、たとえゴールが何であれ (例外はスキンの追加).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Dolibarr 9.0 から, モジュールビルダ (ModuleBuilder) モジュールを使用すべきだ、モジュール記述を生成するための標準モデルとして使える&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===自前のモジュール記述 (module descriptor) を作成する===&lt;br /&gt;
最初のステップは、モジュールに対するファイル記述 (file descriptor) を作成すること. (訳者注： 以下の内容は&#039;&#039;&#039;モジュールビルダを使うことで自動設定&#039;&#039;&#039;される) &lt;br /&gt;
&lt;br /&gt;
*ディレクトリ作成： &#039;&#039;&#039;/htdocs/custom/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; (外部モジュール向け) または &#039;&#039;&#039;/htdocs/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; ここはDolibarr の公式コアモジュール (official core module) とする場合. 次にファイル modMyModule.class.php をディレクトリ &#039;&#039;&#039;htdocs/modulebuilder/template&#039;&#039;&#039; からコピーして上記のディレクトリに作成. ファイルの名称を modMyModule.class.php から 自前モジュールの目的に合致した名称に変更. ファイル名は、先頭に &#039;mod&#039; があり、最後が .class.php で終わる (例えば、ファイル名を &#039;新名&#039; にするなら, &#039;mod新名.class.php&#039; となる).&lt;br /&gt;
&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;
*番号を変更: $this-&amp;gt;numero = 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;
Dolibarrを起動し、&#039;&#039;&#039;設定-&amp;gt;モジュール (Setup-&amp;gt;module&#039;&#039;&#039;?) ページを表示.&lt;br /&gt;
モジュール記述でプロパティバージョン (property version) を設定すると、自前の新規モジュールを載せた新規行とそれを有効化するかどうかの選択が表示されるはず. プロパティバージョンを &amp;quot;develop&amp;quot; または &amp;quot;experimental&amp;quot; に設定した場合、自前モジュールを見るには、まず &#039;&#039;&#039;設定-&amp;gt;その他 (Setup-Others)&#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;
これは、新しいモジュールを構築する際に、ファイルをどう整理するかを示している (ZIPファイルもこのルールに合わせる必要あり).&lt;br /&gt;
注：2行目だけが必須.&lt;br /&gt;
&lt;br /&gt;
{{TemplateModuleTreeSimpleJA}}&lt;br /&gt;
&lt;br /&gt;
==自前 SQL テーブル と PHP DAO クラス (任意)==&lt;br /&gt;
&#039;&#039;&#039;使用場面&#039;&#039;&#039;: 自前モジュールがそれ自身のデータを管理する必要がある場合&lt;br /&gt;
&lt;br /&gt;
===自前の .sql ファイルを作成===&lt;br /&gt;
自前モジュールが、Dolibarr標準版では利用できない独自データを管理する設計である場合、そのデータを格納するためのSQLテーブルを定義する必要がある.&lt;br /&gt;
&lt;br /&gt;
自前モジュールでテーブルを作成したり、データを読込むためのスクリプトは、自前モジュールのsqlサブディレクトリ (&amp;quot;&#039;&#039;&#039;mymodule/sql&#039;&#039;&#039;&amp;quot;) に保存される。(ModuleBuilder では、オブジェクト タブから新しいオブジェクトを作成するとき、このディレクトリとすべての sql ファイルが自動作成される）.&lt;br /&gt;
&lt;br /&gt;
次に、記述ファイルでの、&#039;&#039;&#039;init&#039;&#039;&#039; 関数にて、次の行&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;$this-&amp;gt;_load_tables(&#039;/mymodule/sql/&#039;);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
が、コメントでないことを確認する.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;従うべきルール:&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*テーブルごとに &#039;&#039;&#039;llx_matable.sql&#039;&#039;&#039; ファイルを１つ、&#039;&#039;&#039;llx_matable.key.sql&#039;&#039;&#039; ファイルを可能なら１つ、作成するという原則に基づき、テーブル作成コマンドのファイルを追加する（例として、 &#039;&#039;&#039;install/mysql/tables&#039;&#039;&#039; にあるファイルを参照）.&lt;br /&gt;
*SQLフィールドの推奨される型と名前は、このページに定義されてる [[Language_and_development_rules#Table_and_fields_structures]].&lt;br /&gt;
*データ管理のため、 &#039;&#039;&#039;/mymodule/sql/&#039;&#039;&#039;  ディレクトリ内に  &#039;&#039;&#039;data.sql&#039;&#039;&#039;  というファイルを作成し、データの追加/編集/削除を行う SQL コマンドを記述すること.&lt;br /&gt;
*文字列にダブルクォートを使わない（例： &amp;quot;chaine&amp;quot; でなく &#039;chaine&#039;） ダブルクォートは PostGreSQL では特定の意味を持つ&lt;br /&gt;
&lt;br /&gt;
Example of content of a file data.sql&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Files must be operational for the database mysql. Rem: The files of other databases are not maintained. They will be read and converted on the fly by the driver of the other database.&lt;br /&gt;
&lt;br /&gt;
===Test your .sql files===&lt;br /&gt;
&lt;br /&gt;
Once the files ready, you can return to the page to enable Dolibarr modules and disable the module, drop those tables in the database (if they already exists) and reactivate the module. The tables should be recreated by the activation of the module. If this is not the case, check your scripts by passing them by hand, or check the Dolibarr logs.&lt;br /&gt;
&lt;br /&gt;
===Generate the PHP DAO class===&lt;br /&gt;
The DAO PHP files should have been generated by ModuleBuilder after creating an object.&lt;br /&gt;
&lt;br /&gt;
You can however create them manually by copying existing object however using ModuleBuilder is highly recommended. You should find examples into &#039;&#039;&#039;htdocs/modulebuilder/templates/class/myobject.class.php&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this class, there are already operational CRUD (Create/Read/Update/Delete) methods to perform an insert, a fetch (select), an update, a delete of a table row. Edit the file to use the correct module name, tables and place this file in the class subdirectory of the module. The Module Builder allows you to do this with just a few mouse clicks.&lt;br /&gt;
&lt;br /&gt;
==タブ管理 (任意)==&lt;br /&gt;
&lt;br /&gt;
===Add or remove your own tabs on object sheets===&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: To add a tab on an object (invoices, orders, proposals, member ...)&lt;br /&gt;
&lt;br /&gt;
To do this go into the file descriptor of module previously created and edit the $this-&amp;gt;tabs array:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The table should contain a list of strings, each string representing a new tab. &lt;br /&gt;
The format of the string consisting of 5 parts separated by &amp;quot;:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*Part 1: The element type (object type) where the tab should appear is a value from the following:&lt;br /&gt;
{{TemplateModuleTabs}}&lt;br /&gt;
&lt;br /&gt;
*Part 2: A code to identify tab to add (start with +) or to remove (start with -)&lt;br /&gt;
*Part 3: The title of the tab. This can be a hard read or better code translation in a file lang.&lt;br /&gt;
*Part 4: The name of the file &amp;quot;*.lang&amp;quot; which contains correspondence between the code translation and language to display. If this name is followed with @mymodule, Dolibarr will search translation file &amp;quot;*.lang&amp;quot; within the module, so htdocs/mymodule/langs/code_CODE/mylangfile.lang, otherwise Dolibarr will look for file htdocs/langs/code_CODE/mylangfile.lang&lt;br /&gt;
*Part 5: A condition to test if tab must be visible. Put 1 to be always visible.&lt;br /&gt;
*Part 6: The URL of the page to display when you click on the tab. The __ID__ string will be replaced automatically by the Id of the element concerned.&lt;br /&gt;
&lt;br /&gt;
To feed the contents of the tab with data from the database, see the next chapter.&lt;br /&gt;
&lt;br /&gt;
In order to get the names  &#039;tabname&#039; of existing tabs, you have to check the names used in the function &#039;product_prepare_head&#039; of the file  &#039;core/lib/module.lib.php&#039; corresponding to section &#039;$head[$h][2]&#039;.&lt;br /&gt;
&lt;br /&gt;
===Show tabs navigation into your own pages===&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: To show all standard tabs of an object (product, tiers, etc.) on your page.&lt;br /&gt;
&lt;br /&gt;
You must follow these steps :&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1. Include files you need into your file&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each object type, there are two files to include with line&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;require_once($url_fichier) ;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is example of files to include (DOL_DOCUMENT_ROOT is often dolibarr/htdocs/) :&lt;br /&gt;
&lt;br /&gt;
*Object thirdparty (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;
*Object product (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;
*Object invoice (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. Create and load the object to show into your tab&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create an instance of an object of the correct class and load object from the database by using the fetch method of an object in providing to this method the id you get from URL (ie : /mytab.php?id=1).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Get a list of all tabs to show for your object type&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function XXX_prepare_head($obj), where XXX is name of object. This will return an array with all definition of tab entries to show. The parameter to put into this method is the instance of an object you want tabs.&lt;br /&gt;
&lt;br /&gt;
The resulting array has the following structure&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$head = product_prepare_head($product, $user) ; // parameter $user is present for some function anly&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4. show tabs into your page&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function dol_fiche_head() to show all tabs defined into array $head returned by XX_prepare_head().&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&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;When&#039;&#039;&#039;: If the purpose of your module is to add features that require new or modified screens.&lt;br /&gt;
&lt;br /&gt;
===Create a new PHP screen===&lt;br /&gt;
You must then create your PHP pages that will show/edit data from tables using the skeleton templates provided as an example in the directory &#039;&#039;&#039;modulebuilder/myobject_page.php&#039;&#039;&#039; (For the development of a script from the command line, see [[Script development]]).&lt;br /&gt;
&lt;br /&gt;
To create a new user screen, create a subdirectory of &#039;&#039;&#039;htdocs&#039;&#039;&#039; (if not already done) for your module (in &#039;&#039;&#039;htdocs/mymodule&#039;&#039;&#039; for example) to store the pages you will create.&lt;br /&gt;
&lt;br /&gt;
Copy, into that directory, the file &#039;&#039;&#039;myobject_page.phpp&#039;&#039;&#039; that will serve as a starting point for your page file.&lt;br /&gt;
Edit the file to have a correct relative path to the main.inc.php file. &lt;br /&gt;
&amp;lt;syntaxhighlight 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 calculated 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
As you can see, there are several tries to load the main.inc.php (or master.inc.php). The goal is to succeed in the most cases as possible. The minimum is 2 lines: one to try to load the master/main.inc.php into the dolibarr root directory and another one to try to load the file to support the case when the module is deployed into the &amp;quot;custom&amp;quot; directory. But you can have more to deal more situation. The provided example should be able to load the file main/master.inc.php in nearly all situation/setups.&lt;br /&gt;
&lt;br /&gt;
Note that you may add more &amp;quot;../&amp;quot; depending on the depth of the file relative to your module directory tree.&lt;br /&gt;
&lt;br /&gt;
It&#039;s in the main.inc.php file that is loaded technical environment variables and permissions. The following variables are objects positioned in this file:&lt;br /&gt;
&lt;br /&gt;
*$user    Object that contains the characteristics of the user + his permissions.&lt;br /&gt;
*$conf    Object that contains Dolibarr configuration.&lt;br /&gt;
*$db      Object that contains an opened connection handler to the database.&lt;br /&gt;
*$langs   Object that contains the user&#039;s language.&lt;br /&gt;
&lt;br /&gt;
Then enter your code to display the page.&lt;br /&gt;
&lt;br /&gt;
*To include a class or library dedicated to the module is done using a Dolibarr function (and not using directly include_once):&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*To include classes provided with Dolibarr, use the following syntax:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add some fields into existing forms===&lt;br /&gt;
You may want to provide a module that adds more fields into forms (input and view) of some elements. &lt;br /&gt;
&lt;br /&gt;
A heavy solution (but not so bad) may be to replace all pages used to create element (this means to disable the &amp;quot;New element&amp;quot; menu entry and adding yours, and disable tab that shows element to replace with a tab that is your own full page (copied/pasted from original) to do same than original page but modified to add your fields and stored added data into your own table). Go to menu [[#Define your entries in the menu (optional)]] and [[#The tab management (optional)]] if this solution suits you (this solution is more powerful since you can change everything you want into the page). &lt;br /&gt;
&lt;br /&gt;
We will describe here another solution, that works only to &amp;quot;add fields&amp;quot; at end of existing fields, using the element &amp;quot;category&amp;quot; as an example but you can convert this tutorial for invoice, proposal ...&lt;br /&gt;
&lt;br /&gt;
*First thing is to add a table, owned by your module, to store the value of new fields. This table will have only one column called &amp;quot;rowid&amp;quot; (will contain the same value than field rowid of element table) + one column for each new field you want to add. Then create a class with CRUD (Create/Read/Update/Delete) methods for this new table. For this two tasks, go back to previous chapter [[#Create your SQL tables and the PHP DAO class]].&lt;br /&gt;
*Next step is to add a hook into your module to add the new fields into the form. See chapter [[Hooks_system#Implement_the_Hook]] for generic documentation to use hooks.&lt;br /&gt;
&lt;br /&gt;
If you follow this tutorial, to be able to add fields into category forms, you must do:&lt;br /&gt;
{{ToComplete}}&lt;br /&gt;
&lt;br /&gt;
===Add/replace part of fields supported by hooks===&lt;br /&gt;
See chapter [[Hooks_system#Implement_the_Hook]] to know how to use Dolibarr existing hooks to add/replace code at Dolibarr hooks place.&lt;br /&gt;
&lt;br /&gt;
===Database access===&lt;br /&gt;
If you need to edit some data in the database inside your own table, use the PHP class generated before.&lt;br /&gt;
&lt;br /&gt;
If you to make access to tables with no dedicated PHP class available, this is always possible (for example if you want to get a list of records with a particular join or filter). In this case, this is a code samples to follow:&lt;br /&gt;
&lt;br /&gt;
To make an insert, update or delete:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To read:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Define style of your pages===&lt;br /&gt;
To have the look of your own pages to match the Dolibarr theme, it is necessary to use the Dolibarr CSS styles.&lt;br /&gt;
&lt;br /&gt;
You can use for example:&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;
===Use the Dolibarr date picker===&lt;br /&gt;
If you want to use the Dolibarr date selector (with its calendar popup) into your pages, use the following line:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
The string mykey will identify the date selector in the form. You must use different values if you use several date selectors in same page.&lt;br /&gt;
The string myform is the name of the FORM in which the selector is included (value found in the form name=&amp;quot;myform&amp;quot; in HTML page).&lt;br /&gt;
This means a date selector must be included necessarily into an html FORM.&lt;br /&gt;
&lt;br /&gt;
To get value after the POST of your form, the command is:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$mydate = dol_mktime(12, 0 , 0, $GETPOST(&#039;mykeymonth&#039;, &#039;int&#039;), GETPOST(&#039;mykeyday&#039;, &#039;int&#039;), GETPOST(&#039;mykeyyear&#039;, &#039;int&#039;));&lt;br /&gt;
print strftime(&#039;%A %d %B %Y&#039;, $mydate);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Overwrite template file (tpl)===&lt;br /&gt;
If you want to overwrite tpl file on your module, you need to declare it on the module_parts :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
&#039;tpl&#039; =&amp;gt; 1,&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Then you can put any tpl file on &#039;&#039;&#039;mymodule/core/tpl&#039;&#039;&#039;&lt;br /&gt;
as soon as the module is activate, the tpl will be overwrited&lt;br /&gt;
&lt;br /&gt;
==自前の準備ページを追加 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs parameters, which are to be provided by the user, for proper setting up of the module.&lt;br /&gt;
&lt;br /&gt;
===Create your page to edit parameters===&lt;br /&gt;
If your module needs several parameters to be setup, you must create a page to edit options (these options will be saved in the [[Table llx_const|table &#039;&#039;&#039;llx_const&#039;&#039;&#039;]]).&lt;br /&gt;
Create a page named &#039;&#039;&#039;mymodule_setuppage.php&#039;&#039;&#039; that shows a form for possible options to update them into the above-mentioned table.&lt;br /&gt;
It is necessary to take an example from a page of the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; that will show you the way to read/save your parameters.&lt;br /&gt;
Put this PHP page into the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; of your module (e.g. mymodule/admin/mymodule_setuppage.php).&lt;br /&gt;
&lt;br /&gt;
===Modify the descriptor file of your module===&lt;br /&gt;
Then, within the descriptor file of your module, modify the variable &#039;&#039;&#039;config_page_url&#039;&#039;&#039; to set the name of this PHP page.&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;admin/&#039;&#039;&#039;, then the path is not required, e.g. like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;mymodule/admin/&#039;&#039;&#039;, then like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test your page===&lt;br /&gt;
Go into page &#039;&#039;&#039;Home-&amp;gt;Setup-&amp;gt;Modules&#039;&#039;&#039;, you should see a picture at the end of the line of your module to reach your setup page. Click on it, you should be able to view/edit parameters from your page.&lt;br /&gt;
&lt;br /&gt;
==メニューに自前項目を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If you have created PHP pages, it is necessary that those pages can be reached from menu entries in Dolibarr menu.&lt;br /&gt;
&lt;br /&gt;
===Define your menu entries===&lt;br /&gt;
For this, you must define into the module descriptor, the array this-&amp;gt;menu that declares 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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To show the menu or not depending on a permission, modify property &#039;&#039;&#039;perms&#039;&#039;&#039; in the array. See chapter on permissions later to see how to add permissions.&lt;br /&gt;
&lt;br /&gt;
===Test your menu entries===&lt;br /&gt;
Disable and re-enable your module under the 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;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;rights_class = &#039;mymodule&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight 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][2] = &#039;r&#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;/syntaxhighlight&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][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; Translation key should be &amp;quot;Permission10001=My permission Label&amp;quot;).&lt;br /&gt;
Into $this-&amp;gt;rights[$r][2], types of the permission. There are three type of permission, &#039;r&#039; for read, list or expert permission, &#039;w&#039; for write or update permission and &#039;d&#039; for delete permission.&lt;br /&gt;
Into $this-&amp;gt;rights[$r][3], put 1 if this permission must be granted automatically by default to any newly created user.&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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==自前の box を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs to provide one or several new boxes to show on home page.&lt;br /&gt;
&lt;br /&gt;
===Define your box===&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;syntaxhighlight 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;/syntaxhighlight&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 activate. Activate the box and go on the home page to see if the box is showing correctly.&lt;br /&gt;
&lt;br /&gt;
==自前のエキスポートを定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module provides new predefined database export profiles (for its own tables or for already existing tables of another module).&lt;br /&gt;
&lt;br /&gt;
===Define export===&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 a 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;
==自前の CSS スタイルを定義 (任意)==&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 several CSS files 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 files only if you need absolutely to add not already existing styles.&lt;br /&gt;
&lt;br /&gt;
Once your style sheets are ready, declare them 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 an array of relative URLs to your CSS files.&lt;br /&gt;
For example&lt;br /&gt;
&amp;lt;syntaxhighlight 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;,&#039;/mymodule/css/myother.css&#039;));&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 the 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 declares your style sheet.&lt;br /&gt;
&lt;br /&gt;
==自前の Javascript 関数を追加 (任意)==&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;syntaxhighlight 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;/syntaxhighlight&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;
==Dolibarr フックポジションの内部に、自前コードを挿入 (任意)==&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 the 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 are not covered by existing rules.&lt;br /&gt;
&lt;br /&gt;
See page [[Create numbering module]].&lt;br /&gt;
&lt;br /&gt;
==自前の文書テンプレートを追加 (任意)==&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;
==自前のスキンを追加 (任意)==&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;
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 marketplace.&lt;br /&gt;
But you can use it to have a package easy to distribute on your own 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 a 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
perl makepack-dolibarrmodule.pl&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
tar -xvf mymodule.zip&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 marketplace website: {{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 built correctly, the file will be validated later.&lt;br /&gt;
**If quality is enough and license permits it, the code might be added inside main Dolibarr sources (except if you disagree for that).&lt;br /&gt;
&lt;br /&gt;
=DoliStore での外部モジュール 有効化/活性化 条件=&lt;br /&gt;
&lt;br /&gt;
See [[Module_Dolistore_Validation_Rules|Validation Rules]]&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=Template:TemplateModuleTreeSimpleJA&amp;diff=56464</id>
		<title>Template:TemplateModuleTreeSimpleJA</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=Template:TemplateModuleTreeSimpleJA&amp;diff=56464"/>
		<updated>2023-05-08T10:36:49Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: 複製して初期翻訳&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;* &#039;&#039;&#039;mymodule/*&#039;&#039;&#039; にはphpページが含まれる（任意のサブディレクトリ追加も可であることに注意）注: 自前モジュールがメタパッケージ（同一 zip 内に他モジュールを埋め込むモジュールである場合、ここに metapackage.conf ファイルを置く必要がある）&lt;br /&gt;
* &#039;&#039;&#039;mymodule/build/&#039;&#039;&#039; can contains any file you develop for compiling or building package&lt;br /&gt;
* &#039;&#039;&#039;mymodule/core/modules/&#039;&#039;&#039; contains module descriptor file &#039;&#039;&#039; modMyModule.class.php&#039;&#039;&#039;&lt;br /&gt;
* &#039;&#039;&#039;mymodule/core/triggers&#039;&#039;&#039; contains triggers provided by module&lt;br /&gt;
* &#039;&#039;&#039;mymodule/admin/&#039;&#039;&#039; contains pages to setup module&lt;br /&gt;
* &#039;&#039;&#039;mymodule/class/&#039;&#039;&#039; contains PHP class files provided by module&lt;br /&gt;
* &#039;&#039;&#039;mymodule/css&#039;&#039;&#039; contains CSS files provided by module&lt;br /&gt;
* &#039;&#039;&#039;mymodule/docs&#039;&#039;&#039; to provide doc and licence files&lt;br /&gt;
* &#039;&#039;&#039;mymodule/img&#039;&#039;&#039; contains images files provided by module&lt;br /&gt;
* &#039;&#039;&#039;mymodule/langs/xx_XX&#039;&#039;&#039; contains language files for language xx_XX (try to put at least en_US)&lt;br /&gt;
* &#039;&#039;&#039;mymodule/lib&#039;&#039;&#039; contains libraries provided and used by module&lt;br /&gt;
* &#039;&#039;&#039;mymodule/scripts&#039;&#039;&#039; to provide command line tools or scripts. Note: Command lines script must start with line #!/usr/bin/env php&lt;br /&gt;
* &#039;&#039;&#039;mymodule/sql&#039;&#039;&#039; contains SQL file provided by module to add new tables or indexes&lt;br /&gt;
* &#039;&#039;&#039;mymodule/theme/mytheme&#039;&#039;&#039; if module provide its own theme/skin&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56463</id>
		<title>モジュール 開発</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56463"/>
		<updated>2023-05-08T10:18:40Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: /* 新規モジュールファイルに関するパスツリー (必須) */&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:Développement_module]]&lt;br /&gt;
[[es:Desarrollo_de_un_módulo]]&lt;br /&gt;
[[de:Modul_Entwicklung]]&lt;br /&gt;
[[zh:模块开发]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Core]]&lt;br /&gt;
{{TemplateDocDevEn}}&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;
etc...&lt;br /&gt;
&lt;br /&gt;
以下の章では、これらすべてを手作業で簡単に行う方法を示す.&lt;br /&gt;
&lt;br /&gt;
=モジュールビルダ によるモジュールの生成=&lt;br /&gt;
Dolibarr 9.0 から、モジュールビルダにより、自前モジュールのメインページ作成が可能. 起動方法は:&lt;br /&gt;
&lt;br /&gt;
*モジュールリストにて、&amp;quot;モジュールビルダ(Module Builder)&amp;quot;を有効化する,&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_2.png|400px]]&lt;br /&gt;
&lt;br /&gt;
*その後 &amp;quot;バグ(bug)&amp;quot; 画像をクリック、場所は画面右上.&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_3.png|400px]]&lt;br /&gt;
&lt;br /&gt;
=テンプレート外部モジュールの例=&lt;br /&gt;
外部モジュールの開発を開始するのによいお手本は、ここで見つかるだろう : [https://github.com/Dolibarr/dolibarr/tree/develop/htdocs/modulebuilder/template GitHub Dolibarr Module Modèle]&lt;br /&gt;
&lt;br /&gt;
=自前モジュールを作る=&lt;br /&gt;
==自前モジュールに関するモジュール記述(Module descriptor)を作る (必須)==&lt;br /&gt;
&#039;&#039;&#039;必須となる時期&#039;&#039;&#039;: アドオンを開発すると早急に必要、たとえゴールが何であれ (例外はスキンの追加).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Dolibarr 9.0 から, モジュールビルダ (ModuleBuilder) モジュールを使用すべきだ、モジュール記述を生成するための標準モデルとして使える&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===自前のモジュール記述 (module descriptor) を作成する===&lt;br /&gt;
最初のステップは、モジュールに対するファイル記述 (file descriptor) を作成すること. (訳者注： 以下の内容は&#039;&#039;&#039;モジュールビルダを使うことで自動設定&#039;&#039;&#039;される) &lt;br /&gt;
&lt;br /&gt;
*ディレクトリ作成： &#039;&#039;&#039;/htdocs/custom/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; (外部モジュール向け) または &#039;&#039;&#039;/htdocs/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; ここはDolibarr の公式コアモジュール (official core module) とする場合. 次にファイル modMyModule.class.php をディレクトリ &#039;&#039;&#039;htdocs/modulebuilder/template&#039;&#039;&#039; からコピーして上記のディレクトリに作成. ファイルの名称を modMyModule.class.php から 自前モジュールの目的に合致した名称に変更. ファイル名は、先頭に &#039;mod&#039; があり、最後が .class.php で終わる (例えば、ファイル名を &#039;新名&#039; にするなら, &#039;mod新名.class.php&#039; となる).&lt;br /&gt;
&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;
*番号を変更: $this-&amp;gt;numero = 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;
Dolibarrを起動し、&#039;&#039;&#039;設定-&amp;gt;モジュール (Setup-&amp;gt;module&#039;&#039;&#039;?) ページを表示.&lt;br /&gt;
モジュール記述でプロパティバージョン (property version) を設定すると、自前の新規モジュールを載せた新規行とそれを有効化するかどうかの選択が表示されるはず. プロパティバージョンを &amp;quot;develop&amp;quot; または &amp;quot;experimental&amp;quot; に設定した場合、自前モジュールを見るには、まず &#039;&#039;&#039;設定-&amp;gt;その他 (Setup-Others)&#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;
これは、新しいモジュールを構築する際に、ファイルをどう整理するかを示している (ZIPファイルもこのルールに合わせる必要あり).&lt;br /&gt;
注：2行目だけが必須.&lt;br /&gt;
&lt;br /&gt;
{{TemplateModuleTreeSimple}}&lt;br /&gt;
&lt;br /&gt;
==自前 SQL テーブル と PHP DAO クラス (任意)==&lt;br /&gt;
&#039;&#039;&#039;使用場面&#039;&#039;&#039;: 自前モジュールがそれ自身のデータを管理する必要がある場合&lt;br /&gt;
&lt;br /&gt;
===自前の .sql ファイルを作成===&lt;br /&gt;
自前モジュールが、Dolibarr標準版では利用できない独自データを管理する設計である場合、そのデータを格納するためのSQLテーブルを定義する必要がある.&lt;br /&gt;
&lt;br /&gt;
自前モジュールでテーブルを作成したり、データを読込むためのスクリプトは、自前モジュールのsqlサブディレクトリ (&amp;quot;&#039;&#039;&#039;mymodule/sql&#039;&#039;&#039;&amp;quot;) に保存される。(ModuleBuilder では、オブジェクト タブから新しいオブジェクトを作成するとき、このディレクトリとすべての sql ファイルが自動作成される）.&lt;br /&gt;
&lt;br /&gt;
次に、記述ファイルでの、&#039;&#039;&#039;init&#039;&#039;&#039; 関数にて、次の行&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;$this-&amp;gt;_load_tables(&#039;/mymodule/sql/&#039;);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
が、コメントでないことを確認する.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;従うべきルール:&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*テーブルごとに &#039;&#039;&#039;llx_matable.sql&#039;&#039;&#039; ファイルを１つ、&#039;&#039;&#039;llx_matable.key.sql&#039;&#039;&#039; ファイルを可能なら１つ、作成するという原則に基づき、テーブル作成コマンドのファイルを追加する（例として、 &#039;&#039;&#039;install/mysql/tables&#039;&#039;&#039; にあるファイルを参照）.&lt;br /&gt;
*SQLフィールドの推奨される型と名前は、このページに定義されてる [[Language_and_development_rules#Table_and_fields_structures]].&lt;br /&gt;
*データ管理のため、 &#039;&#039;&#039;/mymodule/sql/&#039;&#039;&#039;  ディレクトリ内に  &#039;&#039;&#039;data.sql&#039;&#039;&#039;  というファイルを作成し、データの追加/編集/削除を行う SQL コマンドを記述すること.&lt;br /&gt;
*文字列にダブルクォートを使わない（例： &amp;quot;chaine&amp;quot; でなく &#039;chaine&#039;） ダブルクォートは PostGreSQL では特定の意味を持つ&lt;br /&gt;
&lt;br /&gt;
Example of content of a file data.sql&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Files must be operational for the database mysql. Rem: The files of other databases are not maintained. They will be read and converted on the fly by the driver of the other database.&lt;br /&gt;
&lt;br /&gt;
===Test your .sql files===&lt;br /&gt;
&lt;br /&gt;
Once the files ready, you can return to the page to enable Dolibarr modules and disable the module, drop those tables in the database (if they already exists) and reactivate the module. The tables should be recreated by the activation of the module. If this is not the case, check your scripts by passing them by hand, or check the Dolibarr logs.&lt;br /&gt;
&lt;br /&gt;
===Generate the PHP DAO class===&lt;br /&gt;
The DAO PHP files should have been generated by ModuleBuilder after creating an object.&lt;br /&gt;
&lt;br /&gt;
You can however create them manually by copying existing object however using ModuleBuilder is highly recommended. You should find examples into &#039;&#039;&#039;htdocs/modulebuilder/templates/class/myobject.class.php&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this class, there are already operational CRUD (Create/Read/Update/Delete) methods to perform an insert, a fetch (select), an update, a delete of a table row. Edit the file to use the correct module name, tables and place this file in the class subdirectory of the module. The Module Builder allows you to do this with just a few mouse clicks.&lt;br /&gt;
&lt;br /&gt;
==タブ管理 (任意)==&lt;br /&gt;
&lt;br /&gt;
===Add or remove your own tabs on object sheets===&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: To add a tab on an object (invoices, orders, proposals, member ...)&lt;br /&gt;
&lt;br /&gt;
To do this go into the file descriptor of module previously created and edit the $this-&amp;gt;tabs array:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The table should contain a list of strings, each string representing a new tab. &lt;br /&gt;
The format of the string consisting of 5 parts separated by &amp;quot;:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*Part 1: The element type (object type) where the tab should appear is a value from the following:&lt;br /&gt;
{{TemplateModuleTabs}}&lt;br /&gt;
&lt;br /&gt;
*Part 2: A code to identify tab to add (start with +) or to remove (start with -)&lt;br /&gt;
*Part 3: The title of the tab. This can be a hard read or better code translation in a file lang.&lt;br /&gt;
*Part 4: The name of the file &amp;quot;*.lang&amp;quot; which contains correspondence between the code translation and language to display. If this name is followed with @mymodule, Dolibarr will search translation file &amp;quot;*.lang&amp;quot; within the module, so htdocs/mymodule/langs/code_CODE/mylangfile.lang, otherwise Dolibarr will look for file htdocs/langs/code_CODE/mylangfile.lang&lt;br /&gt;
*Part 5: A condition to test if tab must be visible. Put 1 to be always visible.&lt;br /&gt;
*Part 6: The URL of the page to display when you click on the tab. The __ID__ string will be replaced automatically by the Id of the element concerned.&lt;br /&gt;
&lt;br /&gt;
To feed the contents of the tab with data from the database, see the next chapter.&lt;br /&gt;
&lt;br /&gt;
In order to get the names  &#039;tabname&#039; of existing tabs, you have to check the names used in the function &#039;product_prepare_head&#039; of the file  &#039;core/lib/module.lib.php&#039; corresponding to section &#039;$head[$h][2]&#039;.&lt;br /&gt;
&lt;br /&gt;
===Show tabs navigation into your own pages===&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: To show all standard tabs of an object (product, tiers, etc.) on your page.&lt;br /&gt;
&lt;br /&gt;
You must follow these steps :&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1. Include files you need into your file&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each object type, there are two files to include with line&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;require_once($url_fichier) ;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is example of files to include (DOL_DOCUMENT_ROOT is often dolibarr/htdocs/) :&lt;br /&gt;
&lt;br /&gt;
*Object thirdparty (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;
*Object product (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;
*Object invoice (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. Create and load the object to show into your tab&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create an instance of an object of the correct class and load object from the database by using the fetch method of an object in providing to this method the id you get from URL (ie : /mytab.php?id=1).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Get a list of all tabs to show for your object type&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function XXX_prepare_head($obj), where XXX is name of object. This will return an array with all definition of tab entries to show. The parameter to put into this method is the instance of an object you want tabs.&lt;br /&gt;
&lt;br /&gt;
The resulting array has the following structure&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$head = product_prepare_head($product, $user) ; // parameter $user is present for some function anly&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4. show tabs into your page&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function dol_fiche_head() to show all tabs defined into array $head returned by XX_prepare_head().&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&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;When&#039;&#039;&#039;: If the purpose of your module is to add features that require new or modified screens.&lt;br /&gt;
&lt;br /&gt;
===Create a new PHP screen===&lt;br /&gt;
You must then create your PHP pages that will show/edit data from tables using the skeleton templates provided as an example in the directory &#039;&#039;&#039;modulebuilder/myobject_page.php&#039;&#039;&#039; (For the development of a script from the command line, see [[Script development]]).&lt;br /&gt;
&lt;br /&gt;
To create a new user screen, create a subdirectory of &#039;&#039;&#039;htdocs&#039;&#039;&#039; (if not already done) for your module (in &#039;&#039;&#039;htdocs/mymodule&#039;&#039;&#039; for example) to store the pages you will create.&lt;br /&gt;
&lt;br /&gt;
Copy, into that directory, the file &#039;&#039;&#039;myobject_page.phpp&#039;&#039;&#039; that will serve as a starting point for your page file.&lt;br /&gt;
Edit the file to have a correct relative path to the main.inc.php file. &lt;br /&gt;
&amp;lt;syntaxhighlight 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 calculated 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
As you can see, there are several tries to load the main.inc.php (or master.inc.php). The goal is to succeed in the most cases as possible. The minimum is 2 lines: one to try to load the master/main.inc.php into the dolibarr root directory and another one to try to load the file to support the case when the module is deployed into the &amp;quot;custom&amp;quot; directory. But you can have more to deal more situation. The provided example should be able to load the file main/master.inc.php in nearly all situation/setups.&lt;br /&gt;
&lt;br /&gt;
Note that you may add more &amp;quot;../&amp;quot; depending on the depth of the file relative to your module directory tree.&lt;br /&gt;
&lt;br /&gt;
It&#039;s in the main.inc.php file that is loaded technical environment variables and permissions. The following variables are objects positioned in this file:&lt;br /&gt;
&lt;br /&gt;
*$user    Object that contains the characteristics of the user + his permissions.&lt;br /&gt;
*$conf    Object that contains Dolibarr configuration.&lt;br /&gt;
*$db      Object that contains an opened connection handler to the database.&lt;br /&gt;
*$langs   Object that contains the user&#039;s language.&lt;br /&gt;
&lt;br /&gt;
Then enter your code to display the page.&lt;br /&gt;
&lt;br /&gt;
*To include a class or library dedicated to the module is done using a Dolibarr function (and not using directly include_once):&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*To include classes provided with Dolibarr, use the following syntax:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add some fields into existing forms===&lt;br /&gt;
You may want to provide a module that adds more fields into forms (input and view) of some elements. &lt;br /&gt;
&lt;br /&gt;
A heavy solution (but not so bad) may be to replace all pages used to create element (this means to disable the &amp;quot;New element&amp;quot; menu entry and adding yours, and disable tab that shows element to replace with a tab that is your own full page (copied/pasted from original) to do same than original page but modified to add your fields and stored added data into your own table). Go to menu [[#Define your entries in the menu (optional)]] and [[#The tab management (optional)]] if this solution suits you (this solution is more powerful since you can change everything you want into the page). &lt;br /&gt;
&lt;br /&gt;
We will describe here another solution, that works only to &amp;quot;add fields&amp;quot; at end of existing fields, using the element &amp;quot;category&amp;quot; as an example but you can convert this tutorial for invoice, proposal ...&lt;br /&gt;
&lt;br /&gt;
*First thing is to add a table, owned by your module, to store the value of new fields. This table will have only one column called &amp;quot;rowid&amp;quot; (will contain the same value than field rowid of element table) + one column for each new field you want to add. Then create a class with CRUD (Create/Read/Update/Delete) methods for this new table. For this two tasks, go back to previous chapter [[#Create your SQL tables and the PHP DAO class]].&lt;br /&gt;
*Next step is to add a hook into your module to add the new fields into the form. See chapter [[Hooks_system#Implement_the_Hook]] for generic documentation to use hooks.&lt;br /&gt;
&lt;br /&gt;
If you follow this tutorial, to be able to add fields into category forms, you must do:&lt;br /&gt;
{{ToComplete}}&lt;br /&gt;
&lt;br /&gt;
===Add/replace part of fields supported by hooks===&lt;br /&gt;
See chapter [[Hooks_system#Implement_the_Hook]] to know how to use Dolibarr existing hooks to add/replace code at Dolibarr hooks place.&lt;br /&gt;
&lt;br /&gt;
===Database access===&lt;br /&gt;
If you need to edit some data in the database inside your own table, use the PHP class generated before.&lt;br /&gt;
&lt;br /&gt;
If you to make access to tables with no dedicated PHP class available, this is always possible (for example if you want to get a list of records with a particular join or filter). In this case, this is a code samples to follow:&lt;br /&gt;
&lt;br /&gt;
To make an insert, update or delete:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To read:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Define style of your pages===&lt;br /&gt;
To have the look of your own pages to match the Dolibarr theme, it is necessary to use the Dolibarr CSS styles.&lt;br /&gt;
&lt;br /&gt;
You can use for example:&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;
===Use the Dolibarr date picker===&lt;br /&gt;
If you want to use the Dolibarr date selector (with its calendar popup) into your pages, use the following line:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
The string mykey will identify the date selector in the form. You must use different values if you use several date selectors in same page.&lt;br /&gt;
The string myform is the name of the FORM in which the selector is included (value found in the form name=&amp;quot;myform&amp;quot; in HTML page).&lt;br /&gt;
This means a date selector must be included necessarily into an html FORM.&lt;br /&gt;
&lt;br /&gt;
To get value after the POST of your form, the command is:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$mydate = dol_mktime(12, 0 , 0, $GETPOST(&#039;mykeymonth&#039;, &#039;int&#039;), GETPOST(&#039;mykeyday&#039;, &#039;int&#039;), GETPOST(&#039;mykeyyear&#039;, &#039;int&#039;));&lt;br /&gt;
print strftime(&#039;%A %d %B %Y&#039;, $mydate);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Overwrite template file (tpl)===&lt;br /&gt;
If you want to overwrite tpl file on your module, you need to declare it on the module_parts :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
&#039;tpl&#039; =&amp;gt; 1,&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Then you can put any tpl file on &#039;&#039;&#039;mymodule/core/tpl&#039;&#039;&#039;&lt;br /&gt;
as soon as the module is activate, the tpl will be overwrited&lt;br /&gt;
&lt;br /&gt;
==自前の準備ページを追加 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs parameters, which are to be provided by the user, for proper setting up of the module.&lt;br /&gt;
&lt;br /&gt;
===Create your page to edit parameters===&lt;br /&gt;
If your module needs several parameters to be setup, you must create a page to edit options (these options will be saved in the [[Table llx_const|table &#039;&#039;&#039;llx_const&#039;&#039;&#039;]]).&lt;br /&gt;
Create a page named &#039;&#039;&#039;mymodule_setuppage.php&#039;&#039;&#039; that shows a form for possible options to update them into the above-mentioned table.&lt;br /&gt;
It is necessary to take an example from a page of the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; that will show you the way to read/save your parameters.&lt;br /&gt;
Put this PHP page into the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; of your module (e.g. mymodule/admin/mymodule_setuppage.php).&lt;br /&gt;
&lt;br /&gt;
===Modify the descriptor file of your module===&lt;br /&gt;
Then, within the descriptor file of your module, modify the variable &#039;&#039;&#039;config_page_url&#039;&#039;&#039; to set the name of this PHP page.&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;admin/&#039;&#039;&#039;, then the path is not required, e.g. like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;mymodule/admin/&#039;&#039;&#039;, then like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test your page===&lt;br /&gt;
Go into page &#039;&#039;&#039;Home-&amp;gt;Setup-&amp;gt;Modules&#039;&#039;&#039;, you should see a picture at the end of the line of your module to reach your setup page. Click on it, you should be able to view/edit parameters from your page.&lt;br /&gt;
&lt;br /&gt;
==メニューに自前項目を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If you have created PHP pages, it is necessary that those pages can be reached from menu entries in Dolibarr menu.&lt;br /&gt;
&lt;br /&gt;
===Define your menu entries===&lt;br /&gt;
For this, you must define into the module descriptor, the array this-&amp;gt;menu that declares 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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To show the menu or not depending on a permission, modify property &#039;&#039;&#039;perms&#039;&#039;&#039; in the array. See chapter on permissions later to see how to add permissions.&lt;br /&gt;
&lt;br /&gt;
===Test your menu entries===&lt;br /&gt;
Disable and re-enable your module under the 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;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;rights_class = &#039;mymodule&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight 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][2] = &#039;r&#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;/syntaxhighlight&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][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; Translation key should be &amp;quot;Permission10001=My permission Label&amp;quot;).&lt;br /&gt;
Into $this-&amp;gt;rights[$r][2], types of the permission. There are three type of permission, &#039;r&#039; for read, list or expert permission, &#039;w&#039; for write or update permission and &#039;d&#039; for delete permission.&lt;br /&gt;
Into $this-&amp;gt;rights[$r][3], put 1 if this permission must be granted automatically by default to any newly created user.&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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==自前の box を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs to provide one or several new boxes to show on home page.&lt;br /&gt;
&lt;br /&gt;
===Define your box===&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;syntaxhighlight 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;/syntaxhighlight&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 activate. Activate the box and go on the home page to see if the box is showing correctly.&lt;br /&gt;
&lt;br /&gt;
==自前のエキスポートを定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module provides new predefined database export profiles (for its own tables or for already existing tables of another module).&lt;br /&gt;
&lt;br /&gt;
===Define export===&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 a 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;
==自前の CSS スタイルを定義 (任意)==&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 several CSS files 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 files only if you need absolutely to add not already existing styles.&lt;br /&gt;
&lt;br /&gt;
Once your style sheets are ready, declare them 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 an array of relative URLs to your CSS files.&lt;br /&gt;
For example&lt;br /&gt;
&amp;lt;syntaxhighlight 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;,&#039;/mymodule/css/myother.css&#039;));&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 the 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 declares your style sheet.&lt;br /&gt;
&lt;br /&gt;
==自前の Javascript 関数を追加 (任意)==&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;syntaxhighlight 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;/syntaxhighlight&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;
==Dolibarr フックポジションの内部に、自前コードを挿入 (任意)==&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 the 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 are not covered by existing rules.&lt;br /&gt;
&lt;br /&gt;
See page [[Create numbering module]].&lt;br /&gt;
&lt;br /&gt;
==自前の文書テンプレートを追加 (任意)==&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;
==自前のスキンを追加 (任意)==&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;
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 marketplace.&lt;br /&gt;
But you can use it to have a package easy to distribute on your own 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 a 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
perl makepack-dolibarrmodule.pl&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
tar -xvf mymodule.zip&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 marketplace website: {{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 built correctly, the file will be validated later.&lt;br /&gt;
**If quality is enough and license permits it, the code might be added inside main Dolibarr sources (except if you disagree for that).&lt;br /&gt;
&lt;br /&gt;
=DoliStore での外部モジュール 有効化/活性化 条件=&lt;br /&gt;
&lt;br /&gt;
See [[Module_Dolistore_Validation_Rules|Validation Rules]]&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56409</id>
		<title>モジュール 開発</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56409"/>
		<updated>2023-05-03T13:36:58Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: /* 自前のモジュール説明 (module descriptor) を作成する */ 訳者注を追加&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:Développement_module]]&lt;br /&gt;
[[es:Desarrollo_de_un_módulo]]&lt;br /&gt;
[[de:Modul_Entwicklung]]&lt;br /&gt;
[[zh:模块开发]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Core]]&lt;br /&gt;
{{TemplateDocDevEn}}&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;
etc...&lt;br /&gt;
&lt;br /&gt;
以下の章では、これらすべてを手作業で簡単に行う方法を示す.&lt;br /&gt;
&lt;br /&gt;
=モジュールビルダ によるモジュールの生成=&lt;br /&gt;
Dolibarr 9.0 から、モジュールビルダにより、自前モジュールのメインページ作成が可能. 起動方法は:&lt;br /&gt;
&lt;br /&gt;
*モジュールリストにて、&amp;quot;モジュールビルダ(Module Builder)&amp;quot;を有効化する,&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_2.png|400px]]&lt;br /&gt;
&lt;br /&gt;
*その後 &amp;quot;バグ(bug)&amp;quot; 画像をクリック、場所は画面右上.&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_3.png|400px]]&lt;br /&gt;
&lt;br /&gt;
=テンプレート外部モジュールの例=&lt;br /&gt;
外部モジュールの開発を開始するのによいお手本は、ここで見つかるだろう : [https://github.com/Dolibarr/dolibarr/tree/develop/htdocs/modulebuilder/template GitHub Dolibarr Module Modèle]&lt;br /&gt;
&lt;br /&gt;
=自前モジュールを作る=&lt;br /&gt;
==自前モジュールに関するモジュール説明(Module descriptor)を作る (必須)==&lt;br /&gt;
&#039;&#039;&#039;必須となる時期&#039;&#039;&#039;: アドオンを開発すると早急に必要、たとえゴールが何であれ (例外はスキンの追加).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Dolibarr 9.0 から, モジュールビルダ (ModuleBuilder) モジュールを使用すべきだ、モジュール説明を生成するための標準モデルとして使える&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===自前のモジュール説明 (module descriptor) を作成する===&lt;br /&gt;
最初のステップは、モジュールに対するファイル説明 (file descriptor) を作成すること. (訳者注： 以下の内容は&#039;&#039;&#039;モジュールビルダを使うことで自動設定&#039;&#039;&#039;される) &lt;br /&gt;
&lt;br /&gt;
*ディレクトリ作成： &#039;&#039;&#039;/htdocs/custom/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; (外部モジュール向け) または &#039;&#039;&#039;/htdocs/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; ここはDolibarr の公式コアモジュール (official core module) とする場合. 次にファイル modMyModule.class.php をディレクトリ &#039;&#039;&#039;htdocs/modulebuilder/template&#039;&#039;&#039; からコピーして上記のディレクトリに作成. ファイルの名称を modMyModule.class.php から 自前モジュールの目的に合致した名称に変更. ファイル名は、先頭に &#039;mod&#039; があり、最後が .class.php で終わる (例えば、ファイル名を &#039;新名&#039; にするなら, &#039;mod新名.class.php&#039; となる).&lt;br /&gt;
&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;
*番号を変更: $this-&amp;gt;numero = 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;
Dolibarrを起動し、&#039;&#039;&#039;設定-&amp;gt;モジュール (Setup-&amp;gt;module&#039;&#039;&#039;?) ページを表示.&lt;br /&gt;
モジュール説明でプロパティバージョン (property version) を設定すると、自前の新規モジュールを載せた新規行とそれを有効化するかどうかの選択が表示されるはず. プロパティバージョンを &amp;quot;develop&amp;quot; または &amp;quot;experimental&amp;quot; に設定した場合、自前モジュールを見るには、まず &#039;&#039;&#039;設定-&amp;gt;その他 (Setup-Others)&#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;
これは、新しいモジュールを構築する際に、ファイルをどう整理するかを示している (ZIPファイルもこのルールに合わせる必要あり).&lt;br /&gt;
注：2行目だけが必須.&lt;br /&gt;
&lt;br /&gt;
{{TemplateModuleTreeSimple}}&lt;br /&gt;
&lt;br /&gt;
==自前 SQL テーブル と PHP DAO クラス (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs to manage data of its own&lt;br /&gt;
&lt;br /&gt;
===Create your .sql file===&lt;br /&gt;
If your module is designed to manage data of its own, which are not available in the standard version of Dolibarr, it is necessary to define SQL tables to store the data.&lt;br /&gt;
&lt;br /&gt;
Scripts for creating tables and loading data by your own module are saved into a subdirectory sql (&#039;&#039;&#039;&amp;quot;mymodule/sql&amp;quot;&#039;&#039;&#039;) of your module. (With ModuleBuilder, the directory and all sql files will be created automatically when you will create a new Object from tab Object).&lt;br /&gt;
&lt;br /&gt;
Then check into your descriptor file, into function &#039;&#039;&#039;init&#039;&#039;&#039; that the line&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;$this-&amp;gt;_load_tables(&#039;/mymodule/sql/&#039;);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
is not commented.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Rules to follow:&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*Add the files about creating tables commands on the principle of a file &#039;&#039;&#039;llx_matable.sql&#039;&#039;&#039; per table, with a possibly file &#039;&#039;&#039;llx_matable.key.sql&#039;&#039;&#039; (see existing files in &#039;&#039;&#039;install/mysql/tables&#039;&#039;&#039; for examples).&lt;br /&gt;
*The recommended type and name for SQL fields are defined into page [[Language_and_development_rules#Table_and_fields_structures]].&lt;br /&gt;
*To manage data, you must create a file called &#039;&#039;&#039;data.sql&#039;&#039;&#039; inside directory &#039;&#039;&#039;/mymodule/sql/&#039;&#039;&#039; that contains SQL command to add/edit/delete data.&lt;br /&gt;
*Don&#039;t use the double quote for strings (eg &#039;chaine&#039; not &amp;quot;chaine&amp;quot;) because the double quote have a specific meaning in PostGreSQL&lt;br /&gt;
&lt;br /&gt;
Example of content of a file data.sql&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Files must be operational for the database mysql. Rem: The files of other databases are not maintained. They will be read and converted on the fly by the driver of the other database.&lt;br /&gt;
&lt;br /&gt;
===Test your .sql files===&lt;br /&gt;
&lt;br /&gt;
Once the files ready, you can return to the page to enable Dolibarr modules and disable the module, drop those tables in the database (if they already exists) and reactivate the module. The tables should be recreated by the activation of the module. If this is not the case, check your scripts by passing them by hand, or check the Dolibarr logs.&lt;br /&gt;
&lt;br /&gt;
===Generate the PHP DAO class===&lt;br /&gt;
The DAO PHP files should have been generated by ModuleBuilder after creating an object.&lt;br /&gt;
&lt;br /&gt;
You can however create them manually by copying existing object however using ModuleBuilder is highly recommended. You should find examples into &#039;&#039;&#039;htdocs/modulebuilder/templates/class/myobject.class.php&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this class, there are already operational CRUD (Create/Read/Update/Delete) methods to perform an insert, a fetch (select), an update, a delete of a table row. Edit the file to use the correct module name, tables and place this file in the class subdirectory of the module. The Module Builder allows you to do this with just a few mouse clicks.&lt;br /&gt;
&lt;br /&gt;
==タブ管理 (任意)==&lt;br /&gt;
&lt;br /&gt;
===Add or remove your own tabs on object sheets===&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: To add a tab on an object (invoices, orders, proposals, member ...)&lt;br /&gt;
&lt;br /&gt;
To do this go into the file descriptor of module previously created and edit the $this-&amp;gt;tabs array:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The table should contain a list of strings, each string representing a new tab. &lt;br /&gt;
The format of the string consisting of 5 parts separated by &amp;quot;:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*Part 1: The element type (object type) where the tab should appear is a value from the following:&lt;br /&gt;
{{TemplateModuleTabs}}&lt;br /&gt;
&lt;br /&gt;
*Part 2: A code to identify tab to add (start with +) or to remove (start with -)&lt;br /&gt;
*Part 3: The title of the tab. This can be a hard read or better code translation in a file lang.&lt;br /&gt;
*Part 4: The name of the file &amp;quot;*.lang&amp;quot; which contains correspondence between the code translation and language to display. If this name is followed with @mymodule, Dolibarr will search translation file &amp;quot;*.lang&amp;quot; within the module, so htdocs/mymodule/langs/code_CODE/mylangfile.lang, otherwise Dolibarr will look for file htdocs/langs/code_CODE/mylangfile.lang&lt;br /&gt;
*Part 5: A condition to test if tab must be visible. Put 1 to be always visible.&lt;br /&gt;
*Part 6: The URL of the page to display when you click on the tab. The __ID__ string will be replaced automatically by the Id of the element concerned.&lt;br /&gt;
&lt;br /&gt;
To feed the contents of the tab with data from the database, see the next chapter.&lt;br /&gt;
&lt;br /&gt;
In order to get the names  &#039;tabname&#039; of existing tabs, you have to check the names used in the function &#039;product_prepare_head&#039; of the file  &#039;core/lib/module.lib.php&#039; corresponding to section &#039;$head[$h][2]&#039;.&lt;br /&gt;
&lt;br /&gt;
===Show tabs navigation into your own pages===&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: To show all standard tabs of an object (product, tiers, etc.) on your page.&lt;br /&gt;
&lt;br /&gt;
You must follow these steps :&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1. Include files you need into your file&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each object type, there are two files to include with line&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;require_once($url_fichier) ;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is example of files to include (DOL_DOCUMENT_ROOT is often dolibarr/htdocs/) :&lt;br /&gt;
&lt;br /&gt;
*Object thirdparty (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;
*Object product (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;
*Object invoice (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. Create and load the object to show into your tab&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create an instance of an object of the correct class and load object from the database by using the fetch method of an object in providing to this method the id you get from URL (ie : /mytab.php?id=1).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Get a list of all tabs to show for your object type&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function XXX_prepare_head($obj), where XXX is name of object. This will return an array with all definition of tab entries to show. The parameter to put into this method is the instance of an object you want tabs.&lt;br /&gt;
&lt;br /&gt;
The resulting array has the following structure&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$head = product_prepare_head($product, $user) ; // parameter $user is present for some function anly&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4. show tabs into your page&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function dol_fiche_head() to show all tabs defined into array $head returned by XX_prepare_head().&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&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;When&#039;&#039;&#039;: If the purpose of your module is to add features that require new or modified screens.&lt;br /&gt;
&lt;br /&gt;
===Create a new PHP screen===&lt;br /&gt;
You must then create your PHP pages that will show/edit data from tables using the skeleton templates provided as an example in the directory &#039;&#039;&#039;modulebuilder/myobject_page.php&#039;&#039;&#039; (For the development of a script from the command line, see [[Script development]]).&lt;br /&gt;
&lt;br /&gt;
To create a new user screen, create a subdirectory of &#039;&#039;&#039;htdocs&#039;&#039;&#039; (if not already done) for your module (in &#039;&#039;&#039;htdocs/mymodule&#039;&#039;&#039; for example) to store the pages you will create.&lt;br /&gt;
&lt;br /&gt;
Copy, into that directory, the file &#039;&#039;&#039;myobject_page.phpp&#039;&#039;&#039; that will serve as a starting point for your page file.&lt;br /&gt;
Edit the file to have a correct relative path to the main.inc.php file. &lt;br /&gt;
&amp;lt;syntaxhighlight 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 calculated 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
As you can see, there are several tries to load the main.inc.php (or master.inc.php). The goal is to succeed in the most cases as possible. The minimum is 2 lines: one to try to load the master/main.inc.php into the dolibarr root directory and another one to try to load the file to support the case when the module is deployed into the &amp;quot;custom&amp;quot; directory. But you can have more to deal more situation. The provided example should be able to load the file main/master.inc.php in nearly all situation/setups.&lt;br /&gt;
&lt;br /&gt;
Note that you may add more &amp;quot;../&amp;quot; depending on the depth of the file relative to your module directory tree.&lt;br /&gt;
&lt;br /&gt;
It&#039;s in the main.inc.php file that is loaded technical environment variables and permissions. The following variables are objects positioned in this file:&lt;br /&gt;
&lt;br /&gt;
*$user    Object that contains the characteristics of the user + his permissions.&lt;br /&gt;
*$conf    Object that contains Dolibarr configuration.&lt;br /&gt;
*$db      Object that contains an opened connection handler to the database.&lt;br /&gt;
*$langs   Object that contains the user&#039;s language.&lt;br /&gt;
&lt;br /&gt;
Then enter your code to display the page.&lt;br /&gt;
&lt;br /&gt;
*To include a class or library dedicated to the module is done using a Dolibarr function (and not using directly include_once):&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*To include classes provided with Dolibarr, use the following syntax:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add some fields into existing forms===&lt;br /&gt;
You may want to provide a module that adds more fields into forms (input and view) of some elements. &lt;br /&gt;
&lt;br /&gt;
A heavy solution (but not so bad) may be to replace all pages used to create element (this means to disable the &amp;quot;New element&amp;quot; menu entry and adding yours, and disable tab that shows element to replace with a tab that is your own full page (copied/pasted from original) to do same than original page but modified to add your fields and stored added data into your own table). Go to menu [[#Define your entries in the menu (optional)]] and [[#The tab management (optional)]] if this solution suits you (this solution is more powerful since you can change everything you want into the page). &lt;br /&gt;
&lt;br /&gt;
We will describe here another solution, that works only to &amp;quot;add fields&amp;quot; at end of existing fields, using the element &amp;quot;category&amp;quot; as an example but you can convert this tutorial for invoice, proposal ...&lt;br /&gt;
&lt;br /&gt;
*First thing is to add a table, owned by your module, to store the value of new fields. This table will have only one column called &amp;quot;rowid&amp;quot; (will contain the same value than field rowid of element table) + one column for each new field you want to add. Then create a class with CRUD (Create/Read/Update/Delete) methods for this new table. For this two tasks, go back to previous chapter [[#Create your SQL tables and the PHP DAO class]].&lt;br /&gt;
*Next step is to add a hook into your module to add the new fields into the form. See chapter [[Hooks_system#Implement_the_Hook]] for generic documentation to use hooks.&lt;br /&gt;
&lt;br /&gt;
If you follow this tutorial, to be able to add fields into category forms, you must do:&lt;br /&gt;
{{ToComplete}}&lt;br /&gt;
&lt;br /&gt;
===Add/replace part of fields supported by hooks===&lt;br /&gt;
See chapter [[Hooks_system#Implement_the_Hook]] to know how to use Dolibarr existing hooks to add/replace code at Dolibarr hooks place.&lt;br /&gt;
&lt;br /&gt;
===Database access===&lt;br /&gt;
If you need to edit some data in the database inside your own table, use the PHP class generated before.&lt;br /&gt;
&lt;br /&gt;
If you to make access to tables with no dedicated PHP class available, this is always possible (for example if you want to get a list of records with a particular join or filter). In this case, this is a code samples to follow:&lt;br /&gt;
&lt;br /&gt;
To make an insert, update or delete:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To read:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Define style of your pages===&lt;br /&gt;
To have the look of your own pages to match the Dolibarr theme, it is necessary to use the Dolibarr CSS styles.&lt;br /&gt;
&lt;br /&gt;
You can use for example:&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;
===Use the Dolibarr date picker===&lt;br /&gt;
If you want to use the Dolibarr date selector (with its calendar popup) into your pages, use the following line:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
The string mykey will identify the date selector in the form. You must use different values if you use several date selectors in same page.&lt;br /&gt;
The string myform is the name of the FORM in which the selector is included (value found in the form name=&amp;quot;myform&amp;quot; in HTML page).&lt;br /&gt;
This means a date selector must be included necessarily into an html FORM.&lt;br /&gt;
&lt;br /&gt;
To get value after the POST of your form, the command is:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$mydate = dol_mktime(12, 0 , 0, $GETPOST(&#039;mykeymonth&#039;, &#039;int&#039;), GETPOST(&#039;mykeyday&#039;, &#039;int&#039;), GETPOST(&#039;mykeyyear&#039;, &#039;int&#039;));&lt;br /&gt;
print strftime(&#039;%A %d %B %Y&#039;, $mydate);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Overwrite template file (tpl)===&lt;br /&gt;
If you want to overwrite tpl file on your module, you need to declare it on the module_parts :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
&#039;tpl&#039; =&amp;gt; 1,&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Then you can put any tpl file on &#039;&#039;&#039;mymodule/core/tpl&#039;&#039;&#039;&lt;br /&gt;
as soon as the module is activate, the tpl will be overwrited&lt;br /&gt;
&lt;br /&gt;
==自前の準備ページを追加 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs parameters, which are to be provided by the user, for proper setting up of the module.&lt;br /&gt;
&lt;br /&gt;
===Create your page to edit parameters===&lt;br /&gt;
If your module needs several parameters to be setup, you must create a page to edit options (these options will be saved in the [[Table llx_const|table &#039;&#039;&#039;llx_const&#039;&#039;&#039;]]).&lt;br /&gt;
Create a page named &#039;&#039;&#039;mymodule_setuppage.php&#039;&#039;&#039; that shows a form for possible options to update them into the above-mentioned table.&lt;br /&gt;
It is necessary to take an example from a page of the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; that will show you the way to read/save your parameters.&lt;br /&gt;
Put this PHP page into the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; of your module (e.g. mymodule/admin/mymodule_setuppage.php).&lt;br /&gt;
&lt;br /&gt;
===Modify the descriptor file of your module===&lt;br /&gt;
Then, within the descriptor file of your module, modify the variable &#039;&#039;&#039;config_page_url&#039;&#039;&#039; to set the name of this PHP page.&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;admin/&#039;&#039;&#039;, then the path is not required, e.g. like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;mymodule/admin/&#039;&#039;&#039;, then like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test your page===&lt;br /&gt;
Go into page &#039;&#039;&#039;Home-&amp;gt;Setup-&amp;gt;Modules&#039;&#039;&#039;, you should see a picture at the end of the line of your module to reach your setup page. Click on it, you should be able to view/edit parameters from your page.&lt;br /&gt;
&lt;br /&gt;
==メニューに自前項目を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If you have created PHP pages, it is necessary that those pages can be reached from menu entries in Dolibarr menu.&lt;br /&gt;
&lt;br /&gt;
===Define your menu entries===&lt;br /&gt;
For this, you must define into the module descriptor, the array this-&amp;gt;menu that declares 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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To show the menu or not depending on a permission, modify property &#039;&#039;&#039;perms&#039;&#039;&#039; in the array. See chapter on permissions later to see how to add permissions.&lt;br /&gt;
&lt;br /&gt;
===Test your menu entries===&lt;br /&gt;
Disable and re-enable your module under the 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;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;rights_class = &#039;mymodule&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight 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][2] = &#039;r&#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;/syntaxhighlight&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][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; Translation key should be &amp;quot;Permission10001=My permission Label&amp;quot;).&lt;br /&gt;
Into $this-&amp;gt;rights[$r][2], types of the permission. There are three type of permission, &#039;r&#039; for read, list or expert permission, &#039;w&#039; for write or update permission and &#039;d&#039; for delete permission.&lt;br /&gt;
Into $this-&amp;gt;rights[$r][3], put 1 if this permission must be granted automatically by default to any newly created user.&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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==自前の box を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs to provide one or several new boxes to show on home page.&lt;br /&gt;
&lt;br /&gt;
===Define your box===&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;syntaxhighlight 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;/syntaxhighlight&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 activate. Activate the box and go on the home page to see if the box is showing correctly.&lt;br /&gt;
&lt;br /&gt;
==自前のエキスポートを定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module provides new predefined database export profiles (for its own tables or for already existing tables of another module).&lt;br /&gt;
&lt;br /&gt;
===Define export===&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 a 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;
==自前の CSS スタイルを定義 (任意)==&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 several CSS files 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 files only if you need absolutely to add not already existing styles.&lt;br /&gt;
&lt;br /&gt;
Once your style sheets are ready, declare them 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 an array of relative URLs to your CSS files.&lt;br /&gt;
For example&lt;br /&gt;
&amp;lt;syntaxhighlight 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;,&#039;/mymodule/css/myother.css&#039;));&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 the 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 declares your style sheet.&lt;br /&gt;
&lt;br /&gt;
==自前の Javascript 関数を追加 (任意)==&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;syntaxhighlight 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;/syntaxhighlight&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;
==Dolibarr フックポジションの内部に、自前コードを挿入 (任意)==&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 the 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 are not covered by existing rules.&lt;br /&gt;
&lt;br /&gt;
See page [[Create numbering module]].&lt;br /&gt;
&lt;br /&gt;
==自前の文書テンプレートを追加 (任意)==&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;
==自前のスキンを追加 (任意)==&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;
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 marketplace.&lt;br /&gt;
But you can use it to have a package easy to distribute on your own 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 a 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
perl makepack-dolibarrmodule.pl&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
tar -xvf mymodule.zip&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 marketplace website: {{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 built correctly, the file will be validated later.&lt;br /&gt;
**If quality is enough and license permits it, the code might be added inside main Dolibarr sources (except if you disagree for that).&lt;br /&gt;
&lt;br /&gt;
=DoliStore での外部モジュール 有効化/活性化 条件=&lt;br /&gt;
&lt;br /&gt;
See [[Module_Dolistore_Validation_Rules|Validation Rules]]&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56408</id>
		<title>モジュール 開発</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56408"/>
		<updated>2023-05-03T12:58:57Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: /* 自前のモジュール説明 (module descriptor) を作成する */&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:Développement_module]]&lt;br /&gt;
[[es:Desarrollo_de_un_módulo]]&lt;br /&gt;
[[de:Modul_Entwicklung]]&lt;br /&gt;
[[zh:模块开发]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Core]]&lt;br /&gt;
{{TemplateDocDevEn}}&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;
etc...&lt;br /&gt;
&lt;br /&gt;
以下の章では、これらすべてを手作業で簡単に行う方法を示す.&lt;br /&gt;
&lt;br /&gt;
=モジュールビルダ によるモジュールの生成=&lt;br /&gt;
Dolibarr 9.0 から、モジュールビルダにより、自前モジュールのメインページ作成が可能. 起動方法は:&lt;br /&gt;
&lt;br /&gt;
*モジュールリストにて、&amp;quot;モジュールビルダ(Module Builder)&amp;quot;を有効化する,&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_2.png|400px]]&lt;br /&gt;
&lt;br /&gt;
*その後 &amp;quot;バグ(bug)&amp;quot; 画像をクリック、場所は画面右上.&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_3.png|400px]]&lt;br /&gt;
&lt;br /&gt;
=テンプレート外部モジュールの例=&lt;br /&gt;
外部モジュールの開発を開始するのによいお手本は、ここで見つかるだろう : [https://github.com/Dolibarr/dolibarr/tree/develop/htdocs/modulebuilder/template GitHub Dolibarr Module Modèle]&lt;br /&gt;
&lt;br /&gt;
=自前モジュールを作る=&lt;br /&gt;
==自前モジュールに関するモジュール説明(Module descriptor)を作る (必須)==&lt;br /&gt;
&#039;&#039;&#039;必須となる時期&#039;&#039;&#039;: アドオンを開発すると早急に必要、たとえゴールが何であれ (例外はスキンの追加).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Dolibarr 9.0 から, モジュールビルダ (ModuleBuilder) モジュールを使用すべきだ、モジュール説明を生成するための標準モデルとして使える&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===自前のモジュール説明 (module descriptor) を作成する===&lt;br /&gt;
最初のステップは、モジュールに対するファイル説明 (file descriptor) を作成すること. &lt;br /&gt;
&lt;br /&gt;
*ディレクトリ作成： &#039;&#039;&#039;/htdocs/custom/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; (外部モジュール向け) または &#039;&#039;&#039;/htdocs/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; ここはDolibarr の公式コアモジュール (official core module) とする場合. 次にファイル modMyModule.class.php をディレクトリ &#039;&#039;&#039;htdocs/modulebuilder/template&#039;&#039;&#039; からコピーして上記のディレクトリに作成. ファイルの名称を modMyModule.class.php から 自前モジュールの目的に合致した名称に変更. ファイル名は、先頭に &#039;mod&#039; があり、最後が .class.php で終わる (例えば、ファイル名を &#039;新名&#039; にするなら, &#039;mod新名.class.php&#039; となる).&lt;br /&gt;
&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;
*番号を変更: $this-&amp;gt;numero = 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;
Dolibarrを起動し、&#039;&#039;&#039;設定-&amp;gt;モジュール (Setup-&amp;gt;module&#039;&#039;&#039;?) ページを表示.&lt;br /&gt;
モジュール説明でプロパティバージョン (property version) を設定すると、自前の新規モジュールを載せた新規行とそれを有効化するかどうかの選択が表示されるはず. プロパティバージョンを &amp;quot;develop&amp;quot; または &amp;quot;experimental&amp;quot; に設定した場合、自前モジュールを見るには、まず &#039;&#039;&#039;設定-&amp;gt;その他 (Setup-Others)&#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;
これは、新しいモジュールを構築する際に、ファイルをどう整理するかを示している (ZIPファイルもこのルールに合わせる必要あり).&lt;br /&gt;
注：2行目だけが必須.&lt;br /&gt;
&lt;br /&gt;
{{TemplateModuleTreeSimple}}&lt;br /&gt;
&lt;br /&gt;
==自前 SQL テーブル と PHP DAO クラス (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs to manage data of its own&lt;br /&gt;
&lt;br /&gt;
===Create your .sql file===&lt;br /&gt;
If your module is designed to manage data of its own, which are not available in the standard version of Dolibarr, it is necessary to define SQL tables to store the data.&lt;br /&gt;
&lt;br /&gt;
Scripts for creating tables and loading data by your own module are saved into a subdirectory sql (&#039;&#039;&#039;&amp;quot;mymodule/sql&amp;quot;&#039;&#039;&#039;) of your module. (With ModuleBuilder, the directory and all sql files will be created automatically when you will create a new Object from tab Object).&lt;br /&gt;
&lt;br /&gt;
Then check into your descriptor file, into function &#039;&#039;&#039;init&#039;&#039;&#039; that the line&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;$this-&amp;gt;_load_tables(&#039;/mymodule/sql/&#039;);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
is not commented.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Rules to follow:&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*Add the files about creating tables commands on the principle of a file &#039;&#039;&#039;llx_matable.sql&#039;&#039;&#039; per table, with a possibly file &#039;&#039;&#039;llx_matable.key.sql&#039;&#039;&#039; (see existing files in &#039;&#039;&#039;install/mysql/tables&#039;&#039;&#039; for examples).&lt;br /&gt;
*The recommended type and name for SQL fields are defined into page [[Language_and_development_rules#Table_and_fields_structures]].&lt;br /&gt;
*To manage data, you must create a file called &#039;&#039;&#039;data.sql&#039;&#039;&#039; inside directory &#039;&#039;&#039;/mymodule/sql/&#039;&#039;&#039; that contains SQL command to add/edit/delete data.&lt;br /&gt;
*Don&#039;t use the double quote for strings (eg &#039;chaine&#039; not &amp;quot;chaine&amp;quot;) because the double quote have a specific meaning in PostGreSQL&lt;br /&gt;
&lt;br /&gt;
Example of content of a file data.sql&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Files must be operational for the database mysql. Rem: The files of other databases are not maintained. They will be read and converted on the fly by the driver of the other database.&lt;br /&gt;
&lt;br /&gt;
===Test your .sql files===&lt;br /&gt;
&lt;br /&gt;
Once the files ready, you can return to the page to enable Dolibarr modules and disable the module, drop those tables in the database (if they already exists) and reactivate the module. The tables should be recreated by the activation of the module. If this is not the case, check your scripts by passing them by hand, or check the Dolibarr logs.&lt;br /&gt;
&lt;br /&gt;
===Generate the PHP DAO class===&lt;br /&gt;
The DAO PHP files should have been generated by ModuleBuilder after creating an object.&lt;br /&gt;
&lt;br /&gt;
You can however create them manually by copying existing object however using ModuleBuilder is highly recommended. You should find examples into &#039;&#039;&#039;htdocs/modulebuilder/templates/class/myobject.class.php&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this class, there are already operational CRUD (Create/Read/Update/Delete) methods to perform an insert, a fetch (select), an update, a delete of a table row. Edit the file to use the correct module name, tables and place this file in the class subdirectory of the module. The Module Builder allows you to do this with just a few mouse clicks.&lt;br /&gt;
&lt;br /&gt;
==タブ管理 (任意)==&lt;br /&gt;
&lt;br /&gt;
===Add or remove your own tabs on object sheets===&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: To add a tab on an object (invoices, orders, proposals, member ...)&lt;br /&gt;
&lt;br /&gt;
To do this go into the file descriptor of module previously created and edit the $this-&amp;gt;tabs array:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The table should contain a list of strings, each string representing a new tab. &lt;br /&gt;
The format of the string consisting of 5 parts separated by &amp;quot;:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*Part 1: The element type (object type) where the tab should appear is a value from the following:&lt;br /&gt;
{{TemplateModuleTabs}}&lt;br /&gt;
&lt;br /&gt;
*Part 2: A code to identify tab to add (start with +) or to remove (start with -)&lt;br /&gt;
*Part 3: The title of the tab. This can be a hard read or better code translation in a file lang.&lt;br /&gt;
*Part 4: The name of the file &amp;quot;*.lang&amp;quot; which contains correspondence between the code translation and language to display. If this name is followed with @mymodule, Dolibarr will search translation file &amp;quot;*.lang&amp;quot; within the module, so htdocs/mymodule/langs/code_CODE/mylangfile.lang, otherwise Dolibarr will look for file htdocs/langs/code_CODE/mylangfile.lang&lt;br /&gt;
*Part 5: A condition to test if tab must be visible. Put 1 to be always visible.&lt;br /&gt;
*Part 6: The URL of the page to display when you click on the tab. The __ID__ string will be replaced automatically by the Id of the element concerned.&lt;br /&gt;
&lt;br /&gt;
To feed the contents of the tab with data from the database, see the next chapter.&lt;br /&gt;
&lt;br /&gt;
In order to get the names  &#039;tabname&#039; of existing tabs, you have to check the names used in the function &#039;product_prepare_head&#039; of the file  &#039;core/lib/module.lib.php&#039; corresponding to section &#039;$head[$h][2]&#039;.&lt;br /&gt;
&lt;br /&gt;
===Show tabs navigation into your own pages===&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: To show all standard tabs of an object (product, tiers, etc.) on your page.&lt;br /&gt;
&lt;br /&gt;
You must follow these steps :&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1. Include files you need into your file&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each object type, there are two files to include with line&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;require_once($url_fichier) ;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is example of files to include (DOL_DOCUMENT_ROOT is often dolibarr/htdocs/) :&lt;br /&gt;
&lt;br /&gt;
*Object thirdparty (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;
*Object product (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;
*Object invoice (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. Create and load the object to show into your tab&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create an instance of an object of the correct class and load object from the database by using the fetch method of an object in providing to this method the id you get from URL (ie : /mytab.php?id=1).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Get a list of all tabs to show for your object type&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function XXX_prepare_head($obj), where XXX is name of object. This will return an array with all definition of tab entries to show. The parameter to put into this method is the instance of an object you want tabs.&lt;br /&gt;
&lt;br /&gt;
The resulting array has the following structure&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$head = product_prepare_head($product, $user) ; // parameter $user is present for some function anly&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4. show tabs into your page&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function dol_fiche_head() to show all tabs defined into array $head returned by XX_prepare_head().&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&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;When&#039;&#039;&#039;: If the purpose of your module is to add features that require new or modified screens.&lt;br /&gt;
&lt;br /&gt;
===Create a new PHP screen===&lt;br /&gt;
You must then create your PHP pages that will show/edit data from tables using the skeleton templates provided as an example in the directory &#039;&#039;&#039;modulebuilder/myobject_page.php&#039;&#039;&#039; (For the development of a script from the command line, see [[Script development]]).&lt;br /&gt;
&lt;br /&gt;
To create a new user screen, create a subdirectory of &#039;&#039;&#039;htdocs&#039;&#039;&#039; (if not already done) for your module (in &#039;&#039;&#039;htdocs/mymodule&#039;&#039;&#039; for example) to store the pages you will create.&lt;br /&gt;
&lt;br /&gt;
Copy, into that directory, the file &#039;&#039;&#039;myobject_page.phpp&#039;&#039;&#039; that will serve as a starting point for your page file.&lt;br /&gt;
Edit the file to have a correct relative path to the main.inc.php file. &lt;br /&gt;
&amp;lt;syntaxhighlight 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 calculated 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
As you can see, there are several tries to load the main.inc.php (or master.inc.php). The goal is to succeed in the most cases as possible. The minimum is 2 lines: one to try to load the master/main.inc.php into the dolibarr root directory and another one to try to load the file to support the case when the module is deployed into the &amp;quot;custom&amp;quot; directory. But you can have more to deal more situation. The provided example should be able to load the file main/master.inc.php in nearly all situation/setups.&lt;br /&gt;
&lt;br /&gt;
Note that you may add more &amp;quot;../&amp;quot; depending on the depth of the file relative to your module directory tree.&lt;br /&gt;
&lt;br /&gt;
It&#039;s in the main.inc.php file that is loaded technical environment variables and permissions. The following variables are objects positioned in this file:&lt;br /&gt;
&lt;br /&gt;
*$user    Object that contains the characteristics of the user + his permissions.&lt;br /&gt;
*$conf    Object that contains Dolibarr configuration.&lt;br /&gt;
*$db      Object that contains an opened connection handler to the database.&lt;br /&gt;
*$langs   Object that contains the user&#039;s language.&lt;br /&gt;
&lt;br /&gt;
Then enter your code to display the page.&lt;br /&gt;
&lt;br /&gt;
*To include a class or library dedicated to the module is done using a Dolibarr function (and not using directly include_once):&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*To include classes provided with Dolibarr, use the following syntax:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add some fields into existing forms===&lt;br /&gt;
You may want to provide a module that adds more fields into forms (input and view) of some elements. &lt;br /&gt;
&lt;br /&gt;
A heavy solution (but not so bad) may be to replace all pages used to create element (this means to disable the &amp;quot;New element&amp;quot; menu entry and adding yours, and disable tab that shows element to replace with a tab that is your own full page (copied/pasted from original) to do same than original page but modified to add your fields and stored added data into your own table). Go to menu [[#Define your entries in the menu (optional)]] and [[#The tab management (optional)]] if this solution suits you (this solution is more powerful since you can change everything you want into the page). &lt;br /&gt;
&lt;br /&gt;
We will describe here another solution, that works only to &amp;quot;add fields&amp;quot; at end of existing fields, using the element &amp;quot;category&amp;quot; as an example but you can convert this tutorial for invoice, proposal ...&lt;br /&gt;
&lt;br /&gt;
*First thing is to add a table, owned by your module, to store the value of new fields. This table will have only one column called &amp;quot;rowid&amp;quot; (will contain the same value than field rowid of element table) + one column for each new field you want to add. Then create a class with CRUD (Create/Read/Update/Delete) methods for this new table. For this two tasks, go back to previous chapter [[#Create your SQL tables and the PHP DAO class]].&lt;br /&gt;
*Next step is to add a hook into your module to add the new fields into the form. See chapter [[Hooks_system#Implement_the_Hook]] for generic documentation to use hooks.&lt;br /&gt;
&lt;br /&gt;
If you follow this tutorial, to be able to add fields into category forms, you must do:&lt;br /&gt;
{{ToComplete}}&lt;br /&gt;
&lt;br /&gt;
===Add/replace part of fields supported by hooks===&lt;br /&gt;
See chapter [[Hooks_system#Implement_the_Hook]] to know how to use Dolibarr existing hooks to add/replace code at Dolibarr hooks place.&lt;br /&gt;
&lt;br /&gt;
===Database access===&lt;br /&gt;
If you need to edit some data in the database inside your own table, use the PHP class generated before.&lt;br /&gt;
&lt;br /&gt;
If you to make access to tables with no dedicated PHP class available, this is always possible (for example if you want to get a list of records with a particular join or filter). In this case, this is a code samples to follow:&lt;br /&gt;
&lt;br /&gt;
To make an insert, update or delete:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To read:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Define style of your pages===&lt;br /&gt;
To have the look of your own pages to match the Dolibarr theme, it is necessary to use the Dolibarr CSS styles.&lt;br /&gt;
&lt;br /&gt;
You can use for example:&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;
===Use the Dolibarr date picker===&lt;br /&gt;
If you want to use the Dolibarr date selector (with its calendar popup) into your pages, use the following line:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
The string mykey will identify the date selector in the form. You must use different values if you use several date selectors in same page.&lt;br /&gt;
The string myform is the name of the FORM in which the selector is included (value found in the form name=&amp;quot;myform&amp;quot; in HTML page).&lt;br /&gt;
This means a date selector must be included necessarily into an html FORM.&lt;br /&gt;
&lt;br /&gt;
To get value after the POST of your form, the command is:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$mydate = dol_mktime(12, 0 , 0, $GETPOST(&#039;mykeymonth&#039;, &#039;int&#039;), GETPOST(&#039;mykeyday&#039;, &#039;int&#039;), GETPOST(&#039;mykeyyear&#039;, &#039;int&#039;));&lt;br /&gt;
print strftime(&#039;%A %d %B %Y&#039;, $mydate);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Overwrite template file (tpl)===&lt;br /&gt;
If you want to overwrite tpl file on your module, you need to declare it on the module_parts :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
&#039;tpl&#039; =&amp;gt; 1,&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Then you can put any tpl file on &#039;&#039;&#039;mymodule/core/tpl&#039;&#039;&#039;&lt;br /&gt;
as soon as the module is activate, the tpl will be overwrited&lt;br /&gt;
&lt;br /&gt;
==自前の準備ページを追加 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs parameters, which are to be provided by the user, for proper setting up of the module.&lt;br /&gt;
&lt;br /&gt;
===Create your page to edit parameters===&lt;br /&gt;
If your module needs several parameters to be setup, you must create a page to edit options (these options will be saved in the [[Table llx_const|table &#039;&#039;&#039;llx_const&#039;&#039;&#039;]]).&lt;br /&gt;
Create a page named &#039;&#039;&#039;mymodule_setuppage.php&#039;&#039;&#039; that shows a form for possible options to update them into the above-mentioned table.&lt;br /&gt;
It is necessary to take an example from a page of the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; that will show you the way to read/save your parameters.&lt;br /&gt;
Put this PHP page into the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; of your module (e.g. mymodule/admin/mymodule_setuppage.php).&lt;br /&gt;
&lt;br /&gt;
===Modify the descriptor file of your module===&lt;br /&gt;
Then, within the descriptor file of your module, modify the variable &#039;&#039;&#039;config_page_url&#039;&#039;&#039; to set the name of this PHP page.&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;admin/&#039;&#039;&#039;, then the path is not required, e.g. like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;mymodule/admin/&#039;&#039;&#039;, then like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test your page===&lt;br /&gt;
Go into page &#039;&#039;&#039;Home-&amp;gt;Setup-&amp;gt;Modules&#039;&#039;&#039;, you should see a picture at the end of the line of your module to reach your setup page. Click on it, you should be able to view/edit parameters from your page.&lt;br /&gt;
&lt;br /&gt;
==メニューに自前項目を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If you have created PHP pages, it is necessary that those pages can be reached from menu entries in Dolibarr menu.&lt;br /&gt;
&lt;br /&gt;
===Define your menu entries===&lt;br /&gt;
For this, you must define into the module descriptor, the array this-&amp;gt;menu that declares 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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To show the menu or not depending on a permission, modify property &#039;&#039;&#039;perms&#039;&#039;&#039; in the array. See chapter on permissions later to see how to add permissions.&lt;br /&gt;
&lt;br /&gt;
===Test your menu entries===&lt;br /&gt;
Disable and re-enable your module under the 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;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;rights_class = &#039;mymodule&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight 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][2] = &#039;r&#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;/syntaxhighlight&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][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; Translation key should be &amp;quot;Permission10001=My permission Label&amp;quot;).&lt;br /&gt;
Into $this-&amp;gt;rights[$r][2], types of the permission. There are three type of permission, &#039;r&#039; for read, list or expert permission, &#039;w&#039; for write or update permission and &#039;d&#039; for delete permission.&lt;br /&gt;
Into $this-&amp;gt;rights[$r][3], put 1 if this permission must be granted automatically by default to any newly created user.&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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==自前の box を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs to provide one or several new boxes to show on home page.&lt;br /&gt;
&lt;br /&gt;
===Define your box===&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;syntaxhighlight 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;/syntaxhighlight&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 activate. Activate the box and go on the home page to see if the box is showing correctly.&lt;br /&gt;
&lt;br /&gt;
==自前のエキスポートを定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module provides new predefined database export profiles (for its own tables or for already existing tables of another module).&lt;br /&gt;
&lt;br /&gt;
===Define export===&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 a 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;
==自前の CSS スタイルを定義 (任意)==&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 several CSS files 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 files only if you need absolutely to add not already existing styles.&lt;br /&gt;
&lt;br /&gt;
Once your style sheets are ready, declare them 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 an array of relative URLs to your CSS files.&lt;br /&gt;
For example&lt;br /&gt;
&amp;lt;syntaxhighlight 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;,&#039;/mymodule/css/myother.css&#039;));&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 the 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 declares your style sheet.&lt;br /&gt;
&lt;br /&gt;
==自前の Javascript 関数を追加 (任意)==&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;syntaxhighlight 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;/syntaxhighlight&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;
==Dolibarr フックポジションの内部に、自前コードを挿入 (任意)==&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 the 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 are not covered by existing rules.&lt;br /&gt;
&lt;br /&gt;
See page [[Create numbering module]].&lt;br /&gt;
&lt;br /&gt;
==自前の文書テンプレートを追加 (任意)==&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;
==自前のスキンを追加 (任意)==&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;
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 marketplace.&lt;br /&gt;
But you can use it to have a package easy to distribute on your own 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 a 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
perl makepack-dolibarrmodule.pl&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
tar -xvf mymodule.zip&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 marketplace website: {{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 built correctly, the file will be validated later.&lt;br /&gt;
**If quality is enough and license permits it, the code might be added inside main Dolibarr sources (except if you disagree for that).&lt;br /&gt;
&lt;br /&gt;
=DoliStore での外部モジュール 有効化/活性化 条件=&lt;br /&gt;
&lt;br /&gt;
See [[Module_Dolistore_Validation_Rules|Validation Rules]]&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=JA_Developer_documentation&amp;diff=56407</id>
		<title>JA Developer documentation</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=JA_Developer_documentation&amp;diff=56407"/>
		<updated>2023-05-03T12:31:19Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: /* バッチまたはコマンドラインスクリプトを作るには */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:開発者手引き}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;seo metak=&amp;quot;developer, development, documentation, guide, doc, tutorial, usage, help, api, coding, standard, rules&amp;quot; /&amp;gt;&lt;br /&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 : Developer_documentation --&amp;gt;&lt;br /&gt;
[[fr:Documentation_Développeur]]&lt;br /&gt;
[[es:Documentación_Desarrolladores]]&lt;br /&gt;
[[de:Entwickler_Dokumentation]]&lt;br /&gt;
[[zh:开发文档]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This page is main index of documents relating to developer documentation. For user documentation [[User documentation|see here]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=開発組織とツール=&lt;br /&gt;
This chapter contains global information that must be read before starting any development on Dolibarr.&lt;br /&gt;
&lt;br /&gt;
#[[Dolibarr Project|Organization of project]]&lt;br /&gt;
#[[To known before to start|To be known before starting to develop]]&lt;br /&gt;
#[[Environment and development tools]]&lt;br /&gt;
#[[Dependencies and external libraries]]&lt;br /&gt;
#[[FAQ_Get,update_project_sources|Get or update sources of a development version]]&lt;br /&gt;
&lt;br /&gt;
=コーディング規約とベストプラクティス=&lt;br /&gt;
&lt;br /&gt;
#[[Prerequisite|Prerequisites]]&lt;br /&gt;
#[[Language and development rules|Language and development rules (PHP, SQL, HTML)]]&lt;br /&gt;
#[[:Category:Table SQL|List of tables]]&lt;br /&gt;
#Tree structure of files and classes are available in the [http://doxygen.dolibarr.org/ doxygen generated documentation]&lt;br /&gt;
&lt;br /&gt;
=モジュールリスト=&lt;br /&gt;
標準ビジネスモデルの技術文書は、それぞれのモジュール開発者の文書ページ (documentation pages) にある.  関心に応じて適切なページを選ぶとよい:&lt;br /&gt;
&lt;br /&gt;
*[[:Category:List of Modules (developer)‎|List of standard modules]]&lt;br /&gt;
*[[:Category:Complementary modules|List of complementary modules]]&lt;br /&gt;
&lt;br /&gt;
=GUI 向けの新 モジュール/アドオン を作るには=&lt;br /&gt;
この項では、Dolibarr のユーザインタフェースを変更する新規モジュールの開発方法を述べる. 該当するのは、スクリーン、テーマ、データ、保有するCSSスタイルシート 、ソースコード、またはそれらのすべて.&lt;br /&gt;
&lt;br /&gt;
スクリプト開発はこの項には含まれない (これは次章で述べる).&lt;br /&gt;
&lt;br /&gt;
自分のモジュールを開発するには、[[モジュール 開発|モジュール開発]] チュートリアルを確認すること.&lt;br /&gt;
&lt;br /&gt;
=バッチまたはコマンドラインスクリプトを作るには=&lt;br /&gt;
この章では、Dolibarr でタスクを実行するためのコマンドラインスクリプト開発方法について説明する (read, update data...).&lt;br /&gt;
&lt;br /&gt;
グラフィカルユーザーインターフェイス（GUI）への変更作成は、本章には含まれない。これについては、前章を参照.&lt;br /&gt;
&lt;br /&gt;
cronスクリプトや外部ソースからデータを取り込むためのコマンドライン インポートツールなど、スクリプトを開発するには、スクリプト開発 ([[Script development]]) ページをご覧ください.&lt;br /&gt;
&lt;br /&gt;
=Dolibarr の技術的要素 (Technical components)=&lt;br /&gt;
==ツリー構造 (Tree structure)==&lt;br /&gt;
現バージョンのファイルのパス階層は、 [http://doxygen.dolibarr.org/ doxygen generated documentation] (&amp;quot;javadoc&amp;quot; 文書に類似) から把握できる.&lt;br /&gt;
&lt;br /&gt;
新規モジュールによる新規ファイルの追加で使用するパスは、新規モジュール開発の文書 ([[Module development|Module development 参照]]) で定義される.&lt;br /&gt;
&lt;br /&gt;
==ストレージ準備 (Setup storage)==&lt;br /&gt;
Dolibarr 設定パラメータは3か所存在する.&lt;br /&gt;
&lt;br /&gt;
*Dolibarr 技術的設定パラメータ (認証モード, データベースログインとファイル向けストレージ領域) が定義される設定ファイルは1つだけ: &amp;lt;code&amp;gt;/conf/conf.php&amp;lt;/code&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
:さらに詳細は [[Configuration file]] を参照.&lt;br /&gt;
&lt;br /&gt;
*グローバル特質パラメータは [[Table llx_const]] に保存.&lt;br /&gt;
&lt;br /&gt;
:さらに詳細は [[Constants]] ページを参照.&lt;br /&gt;
&lt;br /&gt;
*ユーザに対する特質パラメータは [[Table llx_user_param]] に保存.&lt;br /&gt;
&lt;br /&gt;
==ビジネスオブジェクト (Business objects)==&lt;br /&gt;
参照 [[ビジネス オブジェクト|ビジネスオブジェクト]] &lt;br /&gt;
&lt;br /&gt;
==メニューシステム (Menu system)==&lt;br /&gt;
参照 [[Menus system]] &lt;br /&gt;
&lt;br /&gt;
==タブシステム (Tabs system)==&lt;br /&gt;
参照 [[Tabs system]] &lt;br /&gt;
&lt;br /&gt;
==スキンシステム (Skins system)==&lt;br /&gt;
参照 [[Skins]] &lt;br /&gt;
&lt;br /&gt;
==ウィジェットシステム (Widget system)==&lt;br /&gt;
参照 [[Widget system]]&lt;br /&gt;
&lt;br /&gt;
==認証システム (Authentication system)==&lt;br /&gt;
参照 [[Authentication]] &lt;br /&gt;
&lt;br /&gt;
==許可システム (Permission system)==&lt;br /&gt;
参照 [[Permissions En|Permissions]] &lt;br /&gt;
&lt;br /&gt;
==翻訳システム (Translation system)==&lt;br /&gt;
参照 [[Translation system]] &lt;br /&gt;
&lt;br /&gt;
==エラー管理 (Error management)==&lt;br /&gt;
参照 [[Error reporting|Error reporting]] &lt;br /&gt;
&lt;br /&gt;
==キャンバスシステム (Canvas system)==&lt;br /&gt;
Canvasは、レコード（商品、取引先、連絡先など）を作成、更新、閲覧するための画面を置き換える開発者向けの機能. 例えば、取引先の新規作成に使用する入力フォームやその編集フォームを置き換えたり、閲覧テンプレートを置き換えたりすることがでる.&lt;br /&gt;
 &lt;br /&gt;
参照 [[Canvas development]] &lt;br /&gt;
&lt;br /&gt;
==トリガーシステム (Triggers system)==&lt;br /&gt;
トリガーは、Dolibarrの &amp;quot;ビジネスイベント&amp;quot; （請求書の作成、ユーザーの削除、取引先の更新など） に付随して、パーソナライズされたコードを実行するための開発機能で、ビジネスイベントに対してのみ有効. 他のコンテキストでコードをパーソナライズするには、代わりにフックシステム (&#039;&#039;&#039;Hooks system) の章を参照&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
トリガーの使用に関して、参照 [[Interfaces Dolibarr toward foreign systems|this page]].&lt;br /&gt;
&lt;br /&gt;
==フックシステム (Hooks system)==&lt;br /&gt;
参照 [[Hooks system]] &lt;br /&gt;
&lt;br /&gt;
==変数置換システム (Variable substitution system)==&lt;br /&gt;
参照 [[Variable substitution system]] &lt;br /&gt;
&lt;br /&gt;
==ウェブサービス (Web services)==&lt;br /&gt;
Dolibarr はいくつかのサービスを提供するように設定可能.&lt;br /&gt;
&lt;br /&gt;
参照 [[Module Web Services API REST (developer)]] &lt;br /&gt;
&lt;br /&gt;
注: [[Module Web Services API SOAP (developer)]]  は非推奨.&lt;br /&gt;
&lt;br /&gt;
==ファイル/書類 ストレージ管理 (Files/Documents storage management)==&lt;br /&gt;
参照 [[Generated documents]] &lt;br /&gt;
&lt;br /&gt;
==番号付けモジュール (Numbering modules)==&lt;br /&gt;
For each entity created in the application, Dolibarr assigns a reference. In order to adapt the reference to any use, Dolibarr use modules to define the reference generation rule. Several standard modules are supplied. Some are generic and are used to define the numbering mask (number on x characters, with or without prefix, including the date or not, etc.), which can meet most needs. However, there are still cases where the modules provided don&#039;t meet the needs. In this case it is necessary to develop a custom numbering module.&lt;br /&gt;
&lt;br /&gt;
For more information, see [[Create numeration module|Create numbering module]].&lt;br /&gt;
&lt;br /&gt;
==文書テンプレートと文書生成 (Document templates and documents generation)==&lt;br /&gt;
&lt;br /&gt;
More documentation about document generation from templates is available to [[Create a PDF document template]] or [[Create an ODT document template]].&lt;br /&gt;
&lt;br /&gt;
==エクストラフィールド (Extrafields)==&lt;br /&gt;
参照 [[Extrafields]]&lt;br /&gt;
&lt;br /&gt;
==オンライン決済システム (Online payment system)==&lt;br /&gt;
参照 [[Online payment system]]&lt;br /&gt;
&lt;br /&gt;
==他内部機能 (Other internal function)==&lt;br /&gt;
There are many internal libraries your code can use.&lt;br /&gt;
You may find a lot of generic functions in the functions.lib.php, functions2.lib.php or admin.lib.php. Any function found in htdocs/core/lib/*.lib files can be used.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;To specify a requirement based on Dolibarr version number&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For example, to make a condition based on requiring Dolibarr version &amp;gt; 3.5, you can use versioncompare and versiondolibarrarray found in admin.lib.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
if (versioncompare(versiondolibarrarray(), array(3,5,0)) &amp;gt; 0)&lt;br /&gt;
{&lt;br /&gt;
 ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=大量 エクスポート/インポート (Mass exports/imports)=&lt;br /&gt;
&lt;br /&gt;
#[[Mass imports]]&lt;br /&gt;
#[[Module Exports En|Mass exports]]&lt;br /&gt;
&lt;br /&gt;
=他のアプリとのインタフェースやリンク (Interfaces and links with other applications)=&lt;br /&gt;
&lt;br /&gt;
#[[Interfaces Dolibarr toward foreign systems]] or Dolibarr toward Dolibarr (Dolibarr Triggers or Hooks)&lt;br /&gt;
#[[Interfaces from foreign systems toward Dolibarr]]&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
すべての FAQs は FAQ インデックスページ [[:Category:FAQ EN|FAQ EN]] から利用可能&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=JA_Developer_documentation&amp;diff=56373</id>
		<title>JA Developer documentation</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=JA_Developer_documentation&amp;diff=56373"/>
		<updated>2023-04-28T11:47:09Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: /* モジュールリスト */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:開発者手引き}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;seo metak=&amp;quot;developer, development, documentation, guide, doc, tutorial, usage, help, api, coding, standard, rules&amp;quot; /&amp;gt;&lt;br /&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 : Developer_documentation --&amp;gt;&lt;br /&gt;
[[fr:Documentation_Développeur]]&lt;br /&gt;
[[es:Documentación_Desarrolladores]]&lt;br /&gt;
[[de:Entwickler_Dokumentation]]&lt;br /&gt;
[[zh:开发文档]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This page is main index of documents relating to developer documentation. For user documentation [[User documentation|see here]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=開発組織とツール=&lt;br /&gt;
This chapter contains global information that must be read before starting any development on Dolibarr.&lt;br /&gt;
&lt;br /&gt;
#[[Dolibarr Project|Organization of project]]&lt;br /&gt;
#[[To known before to start|To be known before starting to develop]]&lt;br /&gt;
#[[Environment and development tools]]&lt;br /&gt;
#[[Dependencies and external libraries]]&lt;br /&gt;
#[[FAQ_Get,update_project_sources|Get or update sources of a development version]]&lt;br /&gt;
&lt;br /&gt;
=コーディング規約とベストプラクティス=&lt;br /&gt;
&lt;br /&gt;
#[[Prerequisite|Prerequisites]]&lt;br /&gt;
#[[Language and development rules|Language and development rules (PHP, SQL, HTML)]]&lt;br /&gt;
#[[:Category:Table SQL|List of tables]]&lt;br /&gt;
#Tree structure of files and classes are available in the [http://doxygen.dolibarr.org/ doxygen generated documentation]&lt;br /&gt;
&lt;br /&gt;
=モジュールリスト=&lt;br /&gt;
標準ビジネスモデルの技術文書は、それぞれのモジュール開発者の文書ページ (documentation pages) にある.  関心に応じて適切なページを選ぶとよい:&lt;br /&gt;
&lt;br /&gt;
*[[:Category:List of Modules (developer)‎|List of standard modules]]&lt;br /&gt;
*[[:Category:Complementary modules|List of complementary modules]]&lt;br /&gt;
&lt;br /&gt;
=GUI 向けの新 モジュール/アドオン を作るには=&lt;br /&gt;
この項では、Dolibarr のユーザインタフェースを変更する新規モジュールの開発方法を述べる. 該当するのは、スクリーン、テーマ、データ、保有するCSSスタイルシート 、ソースコード、またはそれらのすべて.&lt;br /&gt;
&lt;br /&gt;
スクリプト開発はこの項には含まれない (これは次章で述べる).&lt;br /&gt;
&lt;br /&gt;
自分のモジュールを開発するには、[[モジュール 開発|モジュール開発]] チュートリアルを確認すること.&lt;br /&gt;
&lt;br /&gt;
=バッチまたはコマンドラインスクリプトを作るには=&lt;br /&gt;
この章では、Dolibarr でタスクを実行するためのコマンドラインスクリプト開発方法について説明する (read, update data...).&lt;br /&gt;
&lt;br /&gt;
Making modifications to the graphical user interface (GUI) is not included in this chapter. See the previous chapter for this.&lt;br /&gt;
&lt;br /&gt;
To develop a script, like a cron script or a command line import tool to import data from an external source, you can have a look at the [[Script development]] page.&lt;br /&gt;
&lt;br /&gt;
=Dolibarr の技術的要素 (Technical components)=&lt;br /&gt;
==ツリー構造 (Tree structure)==&lt;br /&gt;
現バージョンのファイルのパス階層は、 [http://doxygen.dolibarr.org/ doxygen generated documentation] (&amp;quot;javadoc&amp;quot; 文書に類似) から把握できる.&lt;br /&gt;
&lt;br /&gt;
新規モジュールによる新規ファイルの追加で使用するパスは、新規モジュール開発の文書 ([[Module development|Module development 参照]]) で定義される.&lt;br /&gt;
&lt;br /&gt;
==ストレージ準備 (Setup storage)==&lt;br /&gt;
Dolibarr 設定パラメータは3か所存在する.&lt;br /&gt;
&lt;br /&gt;
*Dolibarr 技術的設定パラメータ (認証モード, データベースログインとファイル向けストレージ領域) が定義される設定ファイルは1つだけ: &amp;lt;code&amp;gt;/conf/conf.php&amp;lt;/code&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
:さらに詳細は [[Configuration file]] を参照.&lt;br /&gt;
&lt;br /&gt;
*グローバル特質パラメータは [[Table llx_const]] に保存.&lt;br /&gt;
&lt;br /&gt;
:さらに詳細は [[Constants]] ページを参照.&lt;br /&gt;
&lt;br /&gt;
*ユーザに対する特質パラメータは [[Table llx_user_param]] に保存.&lt;br /&gt;
&lt;br /&gt;
==ビジネスオブジェクト (Business objects)==&lt;br /&gt;
参照 [[ビジネス オブジェクト|ビジネスオブジェクト]] &lt;br /&gt;
&lt;br /&gt;
==メニューシステム (Menu system)==&lt;br /&gt;
参照 [[Menus system]] &lt;br /&gt;
&lt;br /&gt;
==タブシステム (Tabs system)==&lt;br /&gt;
参照 [[Tabs system]] &lt;br /&gt;
&lt;br /&gt;
==スキンシステム (Skins system)==&lt;br /&gt;
参照 [[Skins]] &lt;br /&gt;
&lt;br /&gt;
==ウィジェットシステム (Widget system)==&lt;br /&gt;
参照 [[Widget system]]&lt;br /&gt;
&lt;br /&gt;
==認証システム (Authentication system)==&lt;br /&gt;
参照 [[Authentication]] &lt;br /&gt;
&lt;br /&gt;
==許可システム (Permission system)==&lt;br /&gt;
参照 [[Permissions En|Permissions]] &lt;br /&gt;
&lt;br /&gt;
==翻訳システム (Translation system)==&lt;br /&gt;
参照 [[Translation system]] &lt;br /&gt;
&lt;br /&gt;
==エラー管理 (Error management)==&lt;br /&gt;
参照 [[Error reporting|Error reporting]] &lt;br /&gt;
&lt;br /&gt;
==キャンバスシステム (Canvas system)==&lt;br /&gt;
Canvas is a developer feature to replace screens to create, update or view a record (products, thirdparties, contacts, ...). For example, you can replace the input form used to create a new third party, or its editing form, or replace its viewing template.&lt;br /&gt;
 &lt;br /&gt;
See [[Canvas development]] &lt;br /&gt;
&lt;br /&gt;
==トリガーシステム (Triggers system)==&lt;br /&gt;
Triggers are a development feature to execute personalized code during a Dolibarr &amp;quot;business event&amp;quot; (creation of an invoice, deleting a user, update of third party, etc...), and only for a business event. To personalize code for other contexts, see the &#039;&#039;&#039;Hooks system&#039;&#039;&#039; chapter instead.&lt;br /&gt;
&lt;br /&gt;
For triggers usage, see [[Interfaces Dolibarr toward foreign systems|this page]].&lt;br /&gt;
&lt;br /&gt;
==フックシステム (Hooks system)==&lt;br /&gt;
参照 [[Hooks system]] &lt;br /&gt;
&lt;br /&gt;
==変数置換システム (Variable substitution system)==&lt;br /&gt;
参照 [[Variable substitution system]] &lt;br /&gt;
&lt;br /&gt;
==ウェブサービス (Web services)==&lt;br /&gt;
Dolibarr はいくつかのサービスを提供するように設定可能.&lt;br /&gt;
&lt;br /&gt;
参照 [[Module Web Services API REST (developer)]] &lt;br /&gt;
&lt;br /&gt;
注: [[Module Web Services API SOAP (developer)]]  は非推奨.&lt;br /&gt;
&lt;br /&gt;
==ファイル/書類 ストレージ管理 (Files/Documents storage management)==&lt;br /&gt;
参照 [[Generated documents]] &lt;br /&gt;
&lt;br /&gt;
==番号付けモジュール (Numbering modules)==&lt;br /&gt;
For each entity created in the application, Dolibarr assigns a reference. In order to adapt the reference to any use, Dolibarr use modules to define the reference generation rule. Several standard modules are supplied. Some are generic and are used to define the numbering mask (number on x characters, with or without prefix, including the date or not, etc.), which can meet most needs. However, there are still cases where the modules provided don&#039;t meet the needs. In this case it is necessary to develop a custom numbering module.&lt;br /&gt;
&lt;br /&gt;
For more information, see [[Create numeration module|Create numbering module]].&lt;br /&gt;
&lt;br /&gt;
==文書テンプレートと文書生成 (Document templates and documents generation)==&lt;br /&gt;
&lt;br /&gt;
More documentation about document generation from templates is available to [[Create a PDF document template]] or [[Create an ODT document template]].&lt;br /&gt;
&lt;br /&gt;
==エクストラフィールド (Extrafields)==&lt;br /&gt;
参照 [[Extrafields]]&lt;br /&gt;
&lt;br /&gt;
==オンライン決済システム (Online payment system)==&lt;br /&gt;
参照 [[Online payment system]]&lt;br /&gt;
&lt;br /&gt;
==他内部機能 (Other internal function)==&lt;br /&gt;
There are many internal libraries your code can use.&lt;br /&gt;
You may find a lot of generic functions in the functions.lib.php, functions2.lib.php or admin.lib.php. Any function found in htdocs/core/lib/*.lib files can be used.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;To specify a requirement based on Dolibarr version number&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For example, to make a condition based on requiring Dolibarr version &amp;gt; 3.5, you can use versioncompare and versiondolibarrarray found in admin.lib.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
if (versioncompare(versiondolibarrarray(), array(3,5,0)) &amp;gt; 0)&lt;br /&gt;
{&lt;br /&gt;
 ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=大量 エクスポート/インポート (Mass exports/imports)=&lt;br /&gt;
&lt;br /&gt;
#[[Mass imports]]&lt;br /&gt;
#[[Module Exports En|Mass exports]]&lt;br /&gt;
&lt;br /&gt;
=他のアプリとのインタフェースやリンク (Interfaces and links with other applications)=&lt;br /&gt;
&lt;br /&gt;
#[[Interfaces Dolibarr toward foreign systems]] or Dolibarr toward Dolibarr (Dolibarr Triggers or Hooks)&lt;br /&gt;
#[[Interfaces from foreign systems toward Dolibarr]]&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
すべての FAQs は FAQ インデックスページ [[:Category:FAQ EN|FAQ EN]] から利用可能&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56372</id>
		<title>モジュール 開発</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56372"/>
		<updated>2023-04-28T11:17:43Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: &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:Développement_module]]&lt;br /&gt;
[[es:Desarrollo_de_un_módulo]]&lt;br /&gt;
[[de:Modul_Entwicklung]]&lt;br /&gt;
[[zh:模块开发]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Core]]&lt;br /&gt;
{{TemplateDocDevEn}}&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;
etc...&lt;br /&gt;
&lt;br /&gt;
以下の章では、これらすべてを手作業で簡単に行う方法を示す.&lt;br /&gt;
&lt;br /&gt;
=モジュールビルダ によるモジュールの生成=&lt;br /&gt;
Dolibarr 9.0 から、モジュールビルダにより、自前モジュールのメインページ作成が可能. 起動方法は:&lt;br /&gt;
&lt;br /&gt;
*モジュールリストにて、&amp;quot;モジュールビルダ(Module Builder)&amp;quot;を有効化する,&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_2.png|400px]]&lt;br /&gt;
&lt;br /&gt;
*その後 &amp;quot;バグ(bug)&amp;quot; 画像をクリック、場所は画面右上.&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_3.png|400px]]&lt;br /&gt;
&lt;br /&gt;
=テンプレート外部モジュールの例=&lt;br /&gt;
外部モジュールの開発を開始するのによいお手本は、ここで見つかるだろう : [https://github.com/Dolibarr/dolibarr/tree/develop/htdocs/modulebuilder/template GitHub Dolibarr Module Modèle]&lt;br /&gt;
&lt;br /&gt;
=自前モジュールを作る=&lt;br /&gt;
==自前モジュールに関するモジュール説明(Module descriptor)を作る (必須)==&lt;br /&gt;
&#039;&#039;&#039;必須となる時期&#039;&#039;&#039;: アドオンを開発すると早急に必要、たとえゴールが何であれ (例外はスキンの追加).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Dolibarr 9.0 から, モジュールビルダ (ModuleBuilder) モジュールを使用すべきだ、モジュール説明を生成するための標準モデルとして使える&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===自前のモジュール説明 (module descriptor) を作成する===&lt;br /&gt;
最初のステップは、モジュールに対するファイル説明 (file descriptor) を作成すること. &lt;br /&gt;
&lt;br /&gt;
*ディレクトリ作成： &#039;&#039;&#039;/htdocs/custom/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; (外部モジュール向け) または &#039;&#039;&#039;/htdocs/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; 、 Dolibarr の公式コアモジュール (official core module) とする場合は. 次にファイル modMyModule.class.php をディレクトリ &#039;&#039;&#039;htdocs/modulebuilder/template&#039;&#039;&#039; からコピーして上記のディレクトリに作成する. ファイルの名称を modMyModule.class.php から 自前モジュールの目的に合致した名称に変える. ファイル名は、先頭に &#039;mod&#039; があり、最後が .class.php で終わる (例えば、ファイル名を &#039;新名&#039; にするなら, &#039;mod新名.class.php&#039; となる).&lt;br /&gt;
&lt;br /&gt;
次は、ファイルの内容を以下のように変える:&lt;br /&gt;
&lt;br /&gt;
*Replace all &amp;quot;modMyModule&amp;quot; with a value which corresponds to the purpose of your module. This value must always start with &#039;mod&#039; and contain only alpha characters (again, if the name given to the file was &#039;NewName&#039;, then replace all &amp;quot;modMyModule&amp;quot; with &amp;quot;modNewName&amp;quot;).&lt;br /&gt;
*Change the number in: $this-&amp;gt;numero = 100000 by a number that designates your module id. To avoid conflicts with other modules, you can consult the page that lists already reserved id numbers: [[List of modules id|List of modules id]].&lt;br /&gt;
*Modify any other variables defined in the constructor (see comment in the code skeleton for their meaning).&lt;br /&gt;
&lt;br /&gt;
Your file descriptor for your module is ready. See the next step to activate it.&lt;br /&gt;
&lt;br /&gt;
===自前の説明をテストする===&lt;br /&gt;
&lt;br /&gt;
Launch Dolibarr and go to page &#039;&#039;&#039;Setup-&amp;gt;module&#039;&#039;&#039;? &lt;br /&gt;
If you set the property version in the module description you should see a new line with your new module and the possibility to activate it or not. If you set the property version to &amp;quot;develop&amp;quot; or &amp;quot;experiental&amp;quot;, to see your module, you must first go into &#039;&#039;&#039;Setup-Others&#039;&#039;&#039; and set MAIN_FEATURES_LEVEL to 1 to see &amp;quot;experimental&amp;quot; modules or 2 to see &amp;quot;development&amp;quot; modules.&lt;br /&gt;
&lt;br /&gt;
==新規モジュールファイルに関するパスツリー (必須)==&lt;br /&gt;
これは、新しいモジュールを構築する際に、ファイルをどう整理するかを示している (ZIPファイルもこのルールに合わせる必要あり).&lt;br /&gt;
注：2行目だけが必須.&lt;br /&gt;
&lt;br /&gt;
{{TemplateModuleTreeSimple}}&lt;br /&gt;
&lt;br /&gt;
==自前 SQL テーブル と PHP DAO クラス (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs to manage data of its own&lt;br /&gt;
&lt;br /&gt;
===Create your .sql file===&lt;br /&gt;
If your module is designed to manage data of its own, which are not available in the standard version of Dolibarr, it is necessary to define SQL tables to store the data.&lt;br /&gt;
&lt;br /&gt;
Scripts for creating tables and loading data by your own module are saved into a subdirectory sql (&#039;&#039;&#039;&amp;quot;mymodule/sql&amp;quot;&#039;&#039;&#039;) of your module. (With ModuleBuilder, the directory and all sql files will be created automatically when you will create a new Object from tab Object).&lt;br /&gt;
&lt;br /&gt;
Then check into your descriptor file, into function &#039;&#039;&#039;init&#039;&#039;&#039; that the line&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;$this-&amp;gt;_load_tables(&#039;/mymodule/sql/&#039;);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
is not commented.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Rules to follow:&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*Add the files about creating tables commands on the principle of a file &#039;&#039;&#039;llx_matable.sql&#039;&#039;&#039; per table, with a possibly file &#039;&#039;&#039;llx_matable.key.sql&#039;&#039;&#039; (see existing files in &#039;&#039;&#039;install/mysql/tables&#039;&#039;&#039; for examples).&lt;br /&gt;
*The recommended type and name for SQL fields are defined into page [[Language_and_development_rules#Table_and_fields_structures]].&lt;br /&gt;
*To manage data, you must create a file called &#039;&#039;&#039;data.sql&#039;&#039;&#039; inside directory &#039;&#039;&#039;/mymodule/sql/&#039;&#039;&#039; that contains SQL command to add/edit/delete data.&lt;br /&gt;
*Don&#039;t use the double quote for strings (eg &#039;chaine&#039; not &amp;quot;chaine&amp;quot;) because the double quote have a specific meaning in PostGreSQL&lt;br /&gt;
&lt;br /&gt;
Example of content of a file data.sql&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Files must be operational for the database mysql. Rem: The files of other databases are not maintained. They will be read and converted on the fly by the driver of the other database.&lt;br /&gt;
&lt;br /&gt;
===Test your .sql files===&lt;br /&gt;
&lt;br /&gt;
Once the files ready, you can return to the page to enable Dolibarr modules and disable the module, drop those tables in the database (if they already exists) and reactivate the module. The tables should be recreated by the activation of the module. If this is not the case, check your scripts by passing them by hand, or check the Dolibarr logs.&lt;br /&gt;
&lt;br /&gt;
===Generate the PHP DAO class===&lt;br /&gt;
The DAO PHP files should have been generated by ModuleBuilder after creating an object.&lt;br /&gt;
&lt;br /&gt;
You can however create them manually by copying existing object however using ModuleBuilder is highly recommended. You should find examples into &#039;&#039;&#039;htdocs/modulebuilder/templates/class/myobject.class.php&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this class, there are already operational CRUD (Create/Read/Update/Delete) methods to perform an insert, a fetch (select), an update, a delete of a table row. Edit the file to use the correct module name, tables and place this file in the class subdirectory of the module. The Module Builder allows you to do this with just a few mouse clicks.&lt;br /&gt;
&lt;br /&gt;
==タブ管理 (任意)==&lt;br /&gt;
&lt;br /&gt;
===Add or remove your own tabs on object sheets===&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: To add a tab on an object (invoices, orders, proposals, member ...)&lt;br /&gt;
&lt;br /&gt;
To do this go into the file descriptor of module previously created and edit the $this-&amp;gt;tabs array:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The table should contain a list of strings, each string representing a new tab. &lt;br /&gt;
The format of the string consisting of 5 parts separated by &amp;quot;:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*Part 1: The element type (object type) where the tab should appear is a value from the following:&lt;br /&gt;
{{TemplateModuleTabs}}&lt;br /&gt;
&lt;br /&gt;
*Part 2: A code to identify tab to add (start with +) or to remove (start with -)&lt;br /&gt;
*Part 3: The title of the tab. This can be a hard read or better code translation in a file lang.&lt;br /&gt;
*Part 4: The name of the file &amp;quot;*.lang&amp;quot; which contains correspondence between the code translation and language to display. If this name is followed with @mymodule, Dolibarr will search translation file &amp;quot;*.lang&amp;quot; within the module, so htdocs/mymodule/langs/code_CODE/mylangfile.lang, otherwise Dolibarr will look for file htdocs/langs/code_CODE/mylangfile.lang&lt;br /&gt;
*Part 5: A condition to test if tab must be visible. Put 1 to be always visible.&lt;br /&gt;
*Part 6: The URL of the page to display when you click on the tab. The __ID__ string will be replaced automatically by the Id of the element concerned.&lt;br /&gt;
&lt;br /&gt;
To feed the contents of the tab with data from the database, see the next chapter.&lt;br /&gt;
&lt;br /&gt;
In order to get the names  &#039;tabname&#039; of existing tabs, you have to check the names used in the function &#039;product_prepare_head&#039; of the file  &#039;core/lib/module.lib.php&#039; corresponding to section &#039;$head[$h][2]&#039;.&lt;br /&gt;
&lt;br /&gt;
===Show tabs navigation into your own pages===&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: To show all standard tabs of an object (product, tiers, etc.) on your page.&lt;br /&gt;
&lt;br /&gt;
You must follow these steps :&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1. Include files you need into your file&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each object type, there are two files to include with line&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;require_once($url_fichier) ;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is example of files to include (DOL_DOCUMENT_ROOT is often dolibarr/htdocs/) :&lt;br /&gt;
&lt;br /&gt;
*Object thirdparty (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;
*Object product (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;
*Object invoice (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. Create and load the object to show into your tab&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create an instance of an object of the correct class and load object from the database by using the fetch method of an object in providing to this method the id you get from URL (ie : /mytab.php?id=1).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Get a list of all tabs to show for your object type&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function XXX_prepare_head($obj), where XXX is name of object. This will return an array with all definition of tab entries to show. The parameter to put into this method is the instance of an object you want tabs.&lt;br /&gt;
&lt;br /&gt;
The resulting array has the following structure&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$head = product_prepare_head($product, $user) ; // parameter $user is present for some function anly&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4. show tabs into your page&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function dol_fiche_head() to show all tabs defined into array $head returned by XX_prepare_head().&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&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;When&#039;&#039;&#039;: If the purpose of your module is to add features that require new or modified screens.&lt;br /&gt;
&lt;br /&gt;
===Create a new PHP screen===&lt;br /&gt;
You must then create your PHP pages that will show/edit data from tables using the skeleton templates provided as an example in the directory &#039;&#039;&#039;modulebuilder/myobject_page.php&#039;&#039;&#039; (For the development of a script from the command line, see [[Script development]]).&lt;br /&gt;
&lt;br /&gt;
To create a new user screen, create a subdirectory of &#039;&#039;&#039;htdocs&#039;&#039;&#039; (if not already done) for your module (in &#039;&#039;&#039;htdocs/mymodule&#039;&#039;&#039; for example) to store the pages you will create.&lt;br /&gt;
&lt;br /&gt;
Copy, into that directory, the file &#039;&#039;&#039;myobject_page.phpp&#039;&#039;&#039; that will serve as a starting point for your page file.&lt;br /&gt;
Edit the file to have a correct relative path to the main.inc.php file. &lt;br /&gt;
&amp;lt;syntaxhighlight 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 calculated 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
As you can see, there are several tries to load the main.inc.php (or master.inc.php). The goal is to succeed in the most cases as possible. The minimum is 2 lines: one to try to load the master/main.inc.php into the dolibarr root directory and another one to try to load the file to support the case when the module is deployed into the &amp;quot;custom&amp;quot; directory. But you can have more to deal more situation. The provided example should be able to load the file main/master.inc.php in nearly all situation/setups.&lt;br /&gt;
&lt;br /&gt;
Note that you may add more &amp;quot;../&amp;quot; depending on the depth of the file relative to your module directory tree.&lt;br /&gt;
&lt;br /&gt;
It&#039;s in the main.inc.php file that is loaded technical environment variables and permissions. The following variables are objects positioned in this file:&lt;br /&gt;
&lt;br /&gt;
*$user    Object that contains the characteristics of the user + his permissions.&lt;br /&gt;
*$conf    Object that contains Dolibarr configuration.&lt;br /&gt;
*$db      Object that contains an opened connection handler to the database.&lt;br /&gt;
*$langs   Object that contains the user&#039;s language.&lt;br /&gt;
&lt;br /&gt;
Then enter your code to display the page.&lt;br /&gt;
&lt;br /&gt;
*To include a class or library dedicated to the module is done using a Dolibarr function (and not using directly include_once):&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*To include classes provided with Dolibarr, use the following syntax:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add some fields into existing forms===&lt;br /&gt;
You may want to provide a module that adds more fields into forms (input and view) of some elements. &lt;br /&gt;
&lt;br /&gt;
A heavy solution (but not so bad) may be to replace all pages used to create element (this means to disable the &amp;quot;New element&amp;quot; menu entry and adding yours, and disable tab that shows element to replace with a tab that is your own full page (copied/pasted from original) to do same than original page but modified to add your fields and stored added data into your own table). Go to menu [[#Define your entries in the menu (optional)]] and [[#The tab management (optional)]] if this solution suits you (this solution is more powerful since you can change everything you want into the page). &lt;br /&gt;
&lt;br /&gt;
We will describe here another solution, that works only to &amp;quot;add fields&amp;quot; at end of existing fields, using the element &amp;quot;category&amp;quot; as an example but you can convert this tutorial for invoice, proposal ...&lt;br /&gt;
&lt;br /&gt;
*First thing is to add a table, owned by your module, to store the value of new fields. This table will have only one column called &amp;quot;rowid&amp;quot; (will contain the same value than field rowid of element table) + one column for each new field you want to add. Then create a class with CRUD (Create/Read/Update/Delete) methods for this new table. For this two tasks, go back to previous chapter [[#Create your SQL tables and the PHP DAO class]].&lt;br /&gt;
*Next step is to add a hook into your module to add the new fields into the form. See chapter [[Hooks_system#Implement_the_Hook]] for generic documentation to use hooks.&lt;br /&gt;
&lt;br /&gt;
If you follow this tutorial, to be able to add fields into category forms, you must do:&lt;br /&gt;
{{ToComplete}}&lt;br /&gt;
&lt;br /&gt;
===Add/replace part of fields supported by hooks===&lt;br /&gt;
See chapter [[Hooks_system#Implement_the_Hook]] to know how to use Dolibarr existing hooks to add/replace code at Dolibarr hooks place.&lt;br /&gt;
&lt;br /&gt;
===Database access===&lt;br /&gt;
If you need to edit some data in the database inside your own table, use the PHP class generated before.&lt;br /&gt;
&lt;br /&gt;
If you to make access to tables with no dedicated PHP class available, this is always possible (for example if you want to get a list of records with a particular join or filter). In this case, this is a code samples to follow:&lt;br /&gt;
&lt;br /&gt;
To make an insert, update or delete:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To read:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Define style of your pages===&lt;br /&gt;
To have the look of your own pages to match the Dolibarr theme, it is necessary to use the Dolibarr CSS styles.&lt;br /&gt;
&lt;br /&gt;
You can use for example:&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;
===Use the Dolibarr date picker===&lt;br /&gt;
If you want to use the Dolibarr date selector (with its calendar popup) into your pages, use the following line:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
The string mykey will identify the date selector in the form. You must use different values if you use several date selectors in same page.&lt;br /&gt;
The string myform is the name of the FORM in which the selector is included (value found in the form name=&amp;quot;myform&amp;quot; in HTML page).&lt;br /&gt;
This means a date selector must be included necessarily into an html FORM.&lt;br /&gt;
&lt;br /&gt;
To get value after the POST of your form, the command is:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$mydate = dol_mktime(12, 0 , 0, $GETPOST(&#039;mykeymonth&#039;, &#039;int&#039;), GETPOST(&#039;mykeyday&#039;, &#039;int&#039;), GETPOST(&#039;mykeyyear&#039;, &#039;int&#039;));&lt;br /&gt;
print strftime(&#039;%A %d %B %Y&#039;, $mydate);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Overwrite template file (tpl)===&lt;br /&gt;
If you want to overwrite tpl file on your module, you need to declare it on the module_parts :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
&#039;tpl&#039; =&amp;gt; 1,&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Then you can put any tpl file on &#039;&#039;&#039;mymodule/core/tpl&#039;&#039;&#039;&lt;br /&gt;
as soon as the module is activate, the tpl will be overwrited&lt;br /&gt;
&lt;br /&gt;
==自前の準備ページを追加 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs parameters, which are to be provided by the user, for proper setting up of the module.&lt;br /&gt;
&lt;br /&gt;
===Create your page to edit parameters===&lt;br /&gt;
If your module needs several parameters to be setup, you must create a page to edit options (these options will be saved in the [[Table llx_const|table &#039;&#039;&#039;llx_const&#039;&#039;&#039;]]).&lt;br /&gt;
Create a page named &#039;&#039;&#039;mymodule_setuppage.php&#039;&#039;&#039; that shows a form for possible options to update them into the above-mentioned table.&lt;br /&gt;
It is necessary to take an example from a page of the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; that will show you the way to read/save your parameters.&lt;br /&gt;
Put this PHP page into the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; of your module (e.g. mymodule/admin/mymodule_setuppage.php).&lt;br /&gt;
&lt;br /&gt;
===Modify the descriptor file of your module===&lt;br /&gt;
Then, within the descriptor file of your module, modify the variable &#039;&#039;&#039;config_page_url&#039;&#039;&#039; to set the name of this PHP page.&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;admin/&#039;&#039;&#039;, then the path is not required, e.g. like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;mymodule/admin/&#039;&#039;&#039;, then like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test your page===&lt;br /&gt;
Go into page &#039;&#039;&#039;Home-&amp;gt;Setup-&amp;gt;Modules&#039;&#039;&#039;, you should see a picture at the end of the line of your module to reach your setup page. Click on it, you should be able to view/edit parameters from your page.&lt;br /&gt;
&lt;br /&gt;
==メニューに自前項目を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If you have created PHP pages, it is necessary that those pages can be reached from menu entries in Dolibarr menu.&lt;br /&gt;
&lt;br /&gt;
===Define your menu entries===&lt;br /&gt;
For this, you must define into the module descriptor, the array this-&amp;gt;menu that declares 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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To show the menu or not depending on a permission, modify property &#039;&#039;&#039;perms&#039;&#039;&#039; in the array. See chapter on permissions later to see how to add permissions.&lt;br /&gt;
&lt;br /&gt;
===Test your menu entries===&lt;br /&gt;
Disable and re-enable your module under the 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;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;rights_class = &#039;mymodule&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight 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][2] = &#039;r&#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;/syntaxhighlight&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][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; Translation key should be &amp;quot;Permission10001=My permission Label&amp;quot;).&lt;br /&gt;
Into $this-&amp;gt;rights[$r][2], types of the permission. There are three type of permission, &#039;r&#039; for read, list or expert permission, &#039;w&#039; for write or update permission and &#039;d&#039; for delete permission.&lt;br /&gt;
Into $this-&amp;gt;rights[$r][3], put 1 if this permission must be granted automatically by default to any newly created user.&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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==自前の box を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs to provide one or several new boxes to show on home page.&lt;br /&gt;
&lt;br /&gt;
===Define your box===&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;syntaxhighlight 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;/syntaxhighlight&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 activate. Activate the box and go on the home page to see if the box is showing correctly.&lt;br /&gt;
&lt;br /&gt;
==自前のエキスポートを定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module provides new predefined database export profiles (for its own tables or for already existing tables of another module).&lt;br /&gt;
&lt;br /&gt;
===Define export===&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 a 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;
==自前の CSS スタイルを定義 (任意)==&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 several CSS files 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 files only if you need absolutely to add not already existing styles.&lt;br /&gt;
&lt;br /&gt;
Once your style sheets are ready, declare them 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 an array of relative URLs to your CSS files.&lt;br /&gt;
For example&lt;br /&gt;
&amp;lt;syntaxhighlight 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;,&#039;/mymodule/css/myother.css&#039;));&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 the 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 declares your style sheet.&lt;br /&gt;
&lt;br /&gt;
==自前の Javascript 関数を追加 (任意)==&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;syntaxhighlight 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;/syntaxhighlight&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;
==Dolibarr フックポジションの内部に、自前コードを挿入 (任意)==&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 the 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 are not covered by existing rules.&lt;br /&gt;
&lt;br /&gt;
See page [[Create numbering module]].&lt;br /&gt;
&lt;br /&gt;
==自前の文書テンプレートを追加 (任意)==&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;
==自前のスキンを追加 (任意)==&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;
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 marketplace.&lt;br /&gt;
But you can use it to have a package easy to distribute on your own 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 a 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
perl makepack-dolibarrmodule.pl&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
tar -xvf mymodule.zip&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 marketplace website: {{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 built correctly, the file will be validated later.&lt;br /&gt;
**If quality is enough and license permits it, the code might be added inside main Dolibarr sources (except if you disagree for that).&lt;br /&gt;
&lt;br /&gt;
=DoliStore での外部モジュール 有効化/活性化 条件=&lt;br /&gt;
&lt;br /&gt;
See [[Module_Dolistore_Validation_Rules|Validation Rules]]&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56371</id>
		<title>モジュール 開発</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56371"/>
		<updated>2023-04-27T10:35:01Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: 見出し翻訳&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:Développement_module]]&lt;br /&gt;
[[es:Desarrollo_de_un_módulo]]&lt;br /&gt;
[[de:Modul_Entwicklung]]&lt;br /&gt;
[[zh:模块开发]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Core]]&lt;br /&gt;
{{TemplateDocDevEn}}&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;
etc...&lt;br /&gt;
&lt;br /&gt;
以下の章では、これらすべてを手作業で簡単に行う方法を示す.&lt;br /&gt;
&lt;br /&gt;
=モジュールビルダ によるモジュールの生成=&lt;br /&gt;
Dolibarr 9.0 から、モジュールビルダにより、自前モジュールのメインページ作成が可能. 起動方法は:&lt;br /&gt;
&lt;br /&gt;
*モジュールリストにて、&amp;quot;モジュールビルダ(Module Builder)&amp;quot;を有効化する,&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_2.png|400px]]&lt;br /&gt;
&lt;br /&gt;
*その後 &amp;quot;バグ(bug)&amp;quot; 画像をクリック、場所は画面右上.&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_3.png|400px]]&lt;br /&gt;
&lt;br /&gt;
=テンプレート外部モジュールの例=&lt;br /&gt;
A good model to start development of external module can be found here : [https://github.com/Dolibarr/dolibarr/tree/develop/htdocs/modulebuilder/template GitHub Dolibarr Module Modèle]&lt;br /&gt;
&lt;br /&gt;
=自前モジュールを作る=&lt;br /&gt;
==自前モジュールに関するモジュール説明(Module descriptor)を作る (必須)==&lt;br /&gt;
&#039;&#039;&#039;When it is required&#039;&#039;&#039;: Required as soon as an addon is developed, whatever its goal is (except for adding a skin).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since Dolibarr 9.0, you should use the ModuleBuilder module provided as a standard module to generate the module descriptor&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Create your module descriptor===&lt;br /&gt;
The first step is to create a file descriptor for the module. &lt;br /&gt;
&lt;br /&gt;
*Create directory &#039;&#039;&#039;/htdocs/custom/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; (for an external module) or &#039;&#039;&#039;/htdocs/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; if you plan to have this module an official core module of Dolibarr. Then copy the file modMyModule.class.php from the directory &#039;&#039;&#039;htdocs/modulebuilder/template&#039;&#039;&#039; into this directory. Change the name of the file modMyModule.class.php to the name corresponding to the purpose of your module. Name of the file must start with initial &#039;mod&#039; and end with .class.php (for example if you want to give the name &#039;NewName&#039; to this file, then the name should be &#039;modNewName.class.php&#039;).&lt;br /&gt;
&lt;br /&gt;
Next modify the contents of this file as follows:&lt;br /&gt;
&lt;br /&gt;
*Replace all &amp;quot;modMyModule&amp;quot; with a value which corresponds to the purpose of your module. This value must always start with &#039;mod&#039; and contain only alpha characters (again, if the name given to the file was &#039;NewName&#039;, then replace all &amp;quot;modMyModule&amp;quot; with &amp;quot;modNewName&amp;quot;).&lt;br /&gt;
*Change the number in: $this-&amp;gt;numero = 100000 by a number that designates your module id. To avoid conflicts with other modules, you can consult the page that lists already reserved id numbers: [[List of modules id|List of modules id]].&lt;br /&gt;
*Modify any other variables defined in the constructor (see comment in the code skeleton for their meaning).&lt;br /&gt;
&lt;br /&gt;
Your file descriptor for your module is ready. See the next step to activate it.&lt;br /&gt;
&lt;br /&gt;
===Test your descriptor===&lt;br /&gt;
&lt;br /&gt;
Launch Dolibarr and go to page &#039;&#039;&#039;Setup-&amp;gt;module&#039;&#039;&#039;? &lt;br /&gt;
If you set the property version in the module description you should see a new line with your new module and the possibility to activate it or not. If you set the property version to &amp;quot;develop&amp;quot; or &amp;quot;experiental&amp;quot;, to see your module, you must first go into &#039;&#039;&#039;Setup-Others&#039;&#039;&#039; and set MAIN_FEATURES_LEVEL to 1 to see &amp;quot;experimental&amp;quot; modules or 2 to see &amp;quot;development&amp;quot; modules.&lt;br /&gt;
&lt;br /&gt;
==新規モジュールファイルに関するパスツリー (必須)==&lt;br /&gt;
This is how your files must be organized when building a new module (the zip file must also match this rule).&lt;br /&gt;
Note: Only the second line is mandatory.&lt;br /&gt;
&lt;br /&gt;
{{TemplateModuleTreeSimple}}&lt;br /&gt;
&lt;br /&gt;
==自前 SQL テーブル と PHP DAO クラス (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs to manage data of its own&lt;br /&gt;
&lt;br /&gt;
===Create your .sql file===&lt;br /&gt;
If your module is designed to manage data of its own, which are not available in the standard version of Dolibarr, it is necessary to define SQL tables to store the data.&lt;br /&gt;
&lt;br /&gt;
Scripts for creating tables and loading data by your own module are saved into a subdirectory sql (&#039;&#039;&#039;&amp;quot;mymodule/sql&amp;quot;&#039;&#039;&#039;) of your module. (With ModuleBuilder, the directory and all sql files will be created automatically when you will create a new Object from tab Object).&lt;br /&gt;
&lt;br /&gt;
Then check into your descriptor file, into function &#039;&#039;&#039;init&#039;&#039;&#039; that the line&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;$this-&amp;gt;_load_tables(&#039;/mymodule/sql/&#039;);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
is not commented.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Rules to follow:&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*Add the files about creating tables commands on the principle of a file &#039;&#039;&#039;llx_matable.sql&#039;&#039;&#039; per table, with a possibly file &#039;&#039;&#039;llx_matable.key.sql&#039;&#039;&#039; (see existing files in &#039;&#039;&#039;install/mysql/tables&#039;&#039;&#039; for examples).&lt;br /&gt;
*The recommended type and name for SQL fields are defined into page [[Language_and_development_rules#Table_and_fields_structures]].&lt;br /&gt;
*To manage data, you must create a file called &#039;&#039;&#039;data.sql&#039;&#039;&#039; inside directory &#039;&#039;&#039;/mymodule/sql/&#039;&#039;&#039; that contains SQL command to add/edit/delete data.&lt;br /&gt;
*Don&#039;t use the double quote for strings (eg &#039;chaine&#039; not &amp;quot;chaine&amp;quot;) because the double quote have a specific meaning in PostGreSQL&lt;br /&gt;
&lt;br /&gt;
Example of content of a file data.sql&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Files must be operational for the database mysql. Rem: The files of other databases are not maintained. They will be read and converted on the fly by the driver of the other database.&lt;br /&gt;
&lt;br /&gt;
===Test your .sql files===&lt;br /&gt;
&lt;br /&gt;
Once the files ready, you can return to the page to enable Dolibarr modules and disable the module, drop those tables in the database (if they already exists) and reactivate the module. The tables should be recreated by the activation of the module. If this is not the case, check your scripts by passing them by hand, or check the Dolibarr logs.&lt;br /&gt;
&lt;br /&gt;
===Generate the PHP DAO class===&lt;br /&gt;
The DAO PHP files should have been generated by ModuleBuilder after creating an object.&lt;br /&gt;
&lt;br /&gt;
You can however create them manually by copying existing object however using ModuleBuilder is highly recommended. You should find examples into &#039;&#039;&#039;htdocs/modulebuilder/templates/class/myobject.class.php&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this class, there are already operational CRUD (Create/Read/Update/Delete) methods to perform an insert, a fetch (select), an update, a delete of a table row. Edit the file to use the correct module name, tables and place this file in the class subdirectory of the module. The Module Builder allows you to do this with just a few mouse clicks.&lt;br /&gt;
&lt;br /&gt;
==タブ管理 (任意)==&lt;br /&gt;
&lt;br /&gt;
===Add or remove your own tabs on object sheets===&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: To add a tab on an object (invoices, orders, proposals, member ...)&lt;br /&gt;
&lt;br /&gt;
To do this go into the file descriptor of module previously created and edit the $this-&amp;gt;tabs array:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The table should contain a list of strings, each string representing a new tab. &lt;br /&gt;
The format of the string consisting of 5 parts separated by &amp;quot;:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*Part 1: The element type (object type) where the tab should appear is a value from the following:&lt;br /&gt;
{{TemplateModuleTabs}}&lt;br /&gt;
&lt;br /&gt;
*Part 2: A code to identify tab to add (start with +) or to remove (start with -)&lt;br /&gt;
*Part 3: The title of the tab. This can be a hard read or better code translation in a file lang.&lt;br /&gt;
*Part 4: The name of the file &amp;quot;*.lang&amp;quot; which contains correspondence between the code translation and language to display. If this name is followed with @mymodule, Dolibarr will search translation file &amp;quot;*.lang&amp;quot; within the module, so htdocs/mymodule/langs/code_CODE/mylangfile.lang, otherwise Dolibarr will look for file htdocs/langs/code_CODE/mylangfile.lang&lt;br /&gt;
*Part 5: A condition to test if tab must be visible. Put 1 to be always visible.&lt;br /&gt;
*Part 6: The URL of the page to display when you click on the tab. The __ID__ string will be replaced automatically by the Id of the element concerned.&lt;br /&gt;
&lt;br /&gt;
To feed the contents of the tab with data from the database, see the next chapter.&lt;br /&gt;
&lt;br /&gt;
In order to get the names  &#039;tabname&#039; of existing tabs, you have to check the names used in the function &#039;product_prepare_head&#039; of the file  &#039;core/lib/module.lib.php&#039; corresponding to section &#039;$head[$h][2]&#039;.&lt;br /&gt;
&lt;br /&gt;
===Show tabs navigation into your own pages===&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: To show all standard tabs of an object (product, tiers, etc.) on your page.&lt;br /&gt;
&lt;br /&gt;
You must follow these steps :&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1. Include files you need into your file&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each object type, there are two files to include with line&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;require_once($url_fichier) ;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is example of files to include (DOL_DOCUMENT_ROOT is often dolibarr/htdocs/) :&lt;br /&gt;
&lt;br /&gt;
*Object thirdparty (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;
*Object product (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;
*Object invoice (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. Create and load the object to show into your tab&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create an instance of an object of the correct class and load object from the database by using the fetch method of an object in providing to this method the id you get from URL (ie : /mytab.php?id=1).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Get a list of all tabs to show for your object type&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function XXX_prepare_head($obj), where XXX is name of object. This will return an array with all definition of tab entries to show. The parameter to put into this method is the instance of an object you want tabs.&lt;br /&gt;
&lt;br /&gt;
The resulting array has the following structure&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$head = product_prepare_head($product, $user) ; // parameter $user is present for some function anly&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4. show tabs into your page&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function dol_fiche_head() to show all tabs defined into array $head returned by XX_prepare_head().&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&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;When&#039;&#039;&#039;: If the purpose of your module is to add features that require new or modified screens.&lt;br /&gt;
&lt;br /&gt;
===Create a new PHP screen===&lt;br /&gt;
You must then create your PHP pages that will show/edit data from tables using the skeleton templates provided as an example in the directory &#039;&#039;&#039;modulebuilder/myobject_page.php&#039;&#039;&#039; (For the development of a script from the command line, see [[Script development]]).&lt;br /&gt;
&lt;br /&gt;
To create a new user screen, create a subdirectory of &#039;&#039;&#039;htdocs&#039;&#039;&#039; (if not already done) for your module (in &#039;&#039;&#039;htdocs/mymodule&#039;&#039;&#039; for example) to store the pages you will create.&lt;br /&gt;
&lt;br /&gt;
Copy, into that directory, the file &#039;&#039;&#039;myobject_page.phpp&#039;&#039;&#039; that will serve as a starting point for your page file.&lt;br /&gt;
Edit the file to have a correct relative path to the main.inc.php file. &lt;br /&gt;
&amp;lt;syntaxhighlight 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 calculated 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
As you can see, there are several tries to load the main.inc.php (or master.inc.php). The goal is to succeed in the most cases as possible. The minimum is 2 lines: one to try to load the master/main.inc.php into the dolibarr root directory and another one to try to load the file to support the case when the module is deployed into the &amp;quot;custom&amp;quot; directory. But you can have more to deal more situation. The provided example should be able to load the file main/master.inc.php in nearly all situation/setups.&lt;br /&gt;
&lt;br /&gt;
Note that you may add more &amp;quot;../&amp;quot; depending on the depth of the file relative to your module directory tree.&lt;br /&gt;
&lt;br /&gt;
It&#039;s in the main.inc.php file that is loaded technical environment variables and permissions. The following variables are objects positioned in this file:&lt;br /&gt;
&lt;br /&gt;
*$user    Object that contains the characteristics of the user + his permissions.&lt;br /&gt;
*$conf    Object that contains Dolibarr configuration.&lt;br /&gt;
*$db      Object that contains an opened connection handler to the database.&lt;br /&gt;
*$langs   Object that contains the user&#039;s language.&lt;br /&gt;
&lt;br /&gt;
Then enter your code to display the page.&lt;br /&gt;
&lt;br /&gt;
*To include a class or library dedicated to the module is done using a Dolibarr function (and not using directly include_once):&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*To include classes provided with Dolibarr, use the following syntax:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add some fields into existing forms===&lt;br /&gt;
You may want to provide a module that adds more fields into forms (input and view) of some elements. &lt;br /&gt;
&lt;br /&gt;
A heavy solution (but not so bad) may be to replace all pages used to create element (this means to disable the &amp;quot;New element&amp;quot; menu entry and adding yours, and disable tab that shows element to replace with a tab that is your own full page (copied/pasted from original) to do same than original page but modified to add your fields and stored added data into your own table). Go to menu [[#Define your entries in the menu (optional)]] and [[#The tab management (optional)]] if this solution suits you (this solution is more powerful since you can change everything you want into the page). &lt;br /&gt;
&lt;br /&gt;
We will describe here another solution, that works only to &amp;quot;add fields&amp;quot; at end of existing fields, using the element &amp;quot;category&amp;quot; as an example but you can convert this tutorial for invoice, proposal ...&lt;br /&gt;
&lt;br /&gt;
*First thing is to add a table, owned by your module, to store the value of new fields. This table will have only one column called &amp;quot;rowid&amp;quot; (will contain the same value than field rowid of element table) + one column for each new field you want to add. Then create a class with CRUD (Create/Read/Update/Delete) methods for this new table. For this two tasks, go back to previous chapter [[#Create your SQL tables and the PHP DAO class]].&lt;br /&gt;
*Next step is to add a hook into your module to add the new fields into the form. See chapter [[Hooks_system#Implement_the_Hook]] for generic documentation to use hooks.&lt;br /&gt;
&lt;br /&gt;
If you follow this tutorial, to be able to add fields into category forms, you must do:&lt;br /&gt;
{{ToComplete}}&lt;br /&gt;
&lt;br /&gt;
===Add/replace part of fields supported by hooks===&lt;br /&gt;
See chapter [[Hooks_system#Implement_the_Hook]] to know how to use Dolibarr existing hooks to add/replace code at Dolibarr hooks place.&lt;br /&gt;
&lt;br /&gt;
===Database access===&lt;br /&gt;
If you need to edit some data in the database inside your own table, use the PHP class generated before.&lt;br /&gt;
&lt;br /&gt;
If you to make access to tables with no dedicated PHP class available, this is always possible (for example if you want to get a list of records with a particular join or filter). In this case, this is a code samples to follow:&lt;br /&gt;
&lt;br /&gt;
To make an insert, update or delete:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To read:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Define style of your pages===&lt;br /&gt;
To have the look of your own pages to match the Dolibarr theme, it is necessary to use the Dolibarr CSS styles.&lt;br /&gt;
&lt;br /&gt;
You can use for example:&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;
===Use the Dolibarr date picker===&lt;br /&gt;
If you want to use the Dolibarr date selector (with its calendar popup) into your pages, use the following line:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
The string mykey will identify the date selector in the form. You must use different values if you use several date selectors in same page.&lt;br /&gt;
The string myform is the name of the FORM in which the selector is included (value found in the form name=&amp;quot;myform&amp;quot; in HTML page).&lt;br /&gt;
This means a date selector must be included necessarily into an html FORM.&lt;br /&gt;
&lt;br /&gt;
To get value after the POST of your form, the command is:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$mydate = dol_mktime(12, 0 , 0, $GETPOST(&#039;mykeymonth&#039;, &#039;int&#039;), GETPOST(&#039;mykeyday&#039;, &#039;int&#039;), GETPOST(&#039;mykeyyear&#039;, &#039;int&#039;));&lt;br /&gt;
print strftime(&#039;%A %d %B %Y&#039;, $mydate);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Overwrite template file (tpl)===&lt;br /&gt;
If you want to overwrite tpl file on your module, you need to declare it on the module_parts :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
&#039;tpl&#039; =&amp;gt; 1,&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Then you can put any tpl file on &#039;&#039;&#039;mymodule/core/tpl&#039;&#039;&#039;&lt;br /&gt;
as soon as the module is activate, the tpl will be overwrited&lt;br /&gt;
&lt;br /&gt;
==自前の準備ページを追加 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs parameters, which are to be provided by the user, for proper setting up of the module.&lt;br /&gt;
&lt;br /&gt;
===Create your page to edit parameters===&lt;br /&gt;
If your module needs several parameters to be setup, you must create a page to edit options (these options will be saved in the [[Table llx_const|table &#039;&#039;&#039;llx_const&#039;&#039;&#039;]]).&lt;br /&gt;
Create a page named &#039;&#039;&#039;mymodule_setuppage.php&#039;&#039;&#039; that shows a form for possible options to update them into the above-mentioned table.&lt;br /&gt;
It is necessary to take an example from a page of the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; that will show you the way to read/save your parameters.&lt;br /&gt;
Put this PHP page into the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; of your module (e.g. mymodule/admin/mymodule_setuppage.php).&lt;br /&gt;
&lt;br /&gt;
===Modify the descriptor file of your module===&lt;br /&gt;
Then, within the descriptor file of your module, modify the variable &#039;&#039;&#039;config_page_url&#039;&#039;&#039; to set the name of this PHP page.&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;admin/&#039;&#039;&#039;, then the path is not required, e.g. like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;mymodule/admin/&#039;&#039;&#039;, then like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test your page===&lt;br /&gt;
Go into page &#039;&#039;&#039;Home-&amp;gt;Setup-&amp;gt;Modules&#039;&#039;&#039;, you should see a picture at the end of the line of your module to reach your setup page. Click on it, you should be able to view/edit parameters from your page.&lt;br /&gt;
&lt;br /&gt;
==メニューに自前項目を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If you have created PHP pages, it is necessary that those pages can be reached from menu entries in Dolibarr menu.&lt;br /&gt;
&lt;br /&gt;
===Define your menu entries===&lt;br /&gt;
For this, you must define into the module descriptor, the array this-&amp;gt;menu that declares 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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To show the menu or not depending on a permission, modify property &#039;&#039;&#039;perms&#039;&#039;&#039; in the array. See chapter on permissions later to see how to add permissions.&lt;br /&gt;
&lt;br /&gt;
===Test your menu entries===&lt;br /&gt;
Disable and re-enable your module under the 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;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;rights_class = &#039;mymodule&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight 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][2] = &#039;r&#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;/syntaxhighlight&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][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; Translation key should be &amp;quot;Permission10001=My permission Label&amp;quot;).&lt;br /&gt;
Into $this-&amp;gt;rights[$r][2], types of the permission. There are three type of permission, &#039;r&#039; for read, list or expert permission, &#039;w&#039; for write or update permission and &#039;d&#039; for delete permission.&lt;br /&gt;
Into $this-&amp;gt;rights[$r][3], put 1 if this permission must be granted automatically by default to any newly created user.&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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==自前の box を定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs to provide one or several new boxes to show on home page.&lt;br /&gt;
&lt;br /&gt;
===Define your box===&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;syntaxhighlight 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;/syntaxhighlight&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 activate. Activate the box and go on the home page to see if the box is showing correctly.&lt;br /&gt;
&lt;br /&gt;
==自前のエキスポートを定義 (任意)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module provides new predefined database export profiles (for its own tables or for already existing tables of another module).&lt;br /&gt;
&lt;br /&gt;
===Define export===&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 a 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;
==自前の CSS スタイルを定義 (任意)==&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 several CSS files 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 files only if you need absolutely to add not already existing styles.&lt;br /&gt;
&lt;br /&gt;
Once your style sheets are ready, declare them 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 an array of relative URLs to your CSS files.&lt;br /&gt;
For example&lt;br /&gt;
&amp;lt;syntaxhighlight 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;,&#039;/mymodule/css/myother.css&#039;));&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 the 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 declares your style sheet.&lt;br /&gt;
&lt;br /&gt;
==自前の Javascript 関数を追加 (任意)==&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;syntaxhighlight 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;/syntaxhighlight&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;
==Dolibarr フックポジションの内部に、自前コードを挿入 (任意)==&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 the 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 are not covered by existing rules.&lt;br /&gt;
&lt;br /&gt;
See page [[Create numbering module]].&lt;br /&gt;
&lt;br /&gt;
==自前の文書テンプレートを追加 (任意)==&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;
==自前のスキンを追加 (任意)==&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;
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 marketplace.&lt;br /&gt;
But you can use it to have a package easy to distribute on your own 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 a 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
perl makepack-dolibarrmodule.pl&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
tar -xvf mymodule.zip&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 marketplace website: {{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 built correctly, the file will be validated later.&lt;br /&gt;
**If quality is enough and license permits it, the code might be added inside main Dolibarr sources (except if you disagree for that).&lt;br /&gt;
&lt;br /&gt;
=DoliStore での外部モジュール 有効化/活性化 条件=&lt;br /&gt;
&lt;br /&gt;
See [[Module_Dolistore_Validation_Rules|Validation Rules]]&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56366</id>
		<title>モジュール 開発</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=%E3%83%A2%E3%82%B8%E3%83%A5%E3%83%BC%E3%83%AB_%E9%96%8B%E7%99%BA&amp;diff=56366"/>
		<updated>2023-04-27T07:50:48Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: 初期翻訳： Enから複製&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:Développement_module]]&lt;br /&gt;
[[es:Desarrollo_de_un_módulo]]&lt;br /&gt;
[[de:Modul_Entwicklung]]&lt;br /&gt;
[[zh:模块开发]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Core]]&lt;br /&gt;
{{TemplateDocDevEn}}&lt;br /&gt;
&lt;br /&gt;
Dolibarr向け新規 モジュール/アドオン を作成するには, 複数のステップがある. このチュートリアルで説明するのは、Dolibarrの特質拡張用モジュールを作るステップのそれぞれである, 以下の１つとか、複数の組み合わせとかのように :&lt;br /&gt;
&lt;br /&gt;
*Add new tables in database.&lt;br /&gt;
*Add your own menu entries.&lt;br /&gt;
*Add new screens to edit new tables.&lt;br /&gt;
*Add or remove tabs on object view (invoice, product, order, event, ...).&lt;br /&gt;
*Add predefined exports for the internal export tool.&lt;br /&gt;
*Add new information widget in the home page.&lt;br /&gt;
*Add new substitutions variables.&lt;br /&gt;
*Define new permissions.&lt;br /&gt;
*Execute code automatically triggered by a particular Dolibarr action.&lt;br /&gt;
*Insert your code inside Dolibarr hooks positions.&lt;br /&gt;
*Add your numbering rule to generate the reference of objects&lt;br /&gt;
*Add a new document template.&lt;br /&gt;
*Add a new skin.&lt;br /&gt;
&lt;br /&gt;
etc...&lt;br /&gt;
&lt;br /&gt;
Following chapters presents how to do all of this manually with an easy way.&lt;br /&gt;
&lt;br /&gt;
=Module creation with the module builder=&lt;br /&gt;
From Dolibarr 9.0 it is possible to create the main pages of your module with the Module Builder. To activate it:&lt;br /&gt;
&lt;br /&gt;
*Go into the list of module and enable the module &amp;quot;Module Builder&amp;quot;,&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_2.png|400px]]&lt;br /&gt;
&lt;br /&gt;
*Then click on the &amp;quot;bug&amp;quot; image in the top right of screen.&lt;br /&gt;
&lt;br /&gt;
[[File:Mod_builder_3.png|400px]]&lt;br /&gt;
&lt;br /&gt;
=Example of Template External Module=&lt;br /&gt;
A good model to start development of external module can be found here : [https://github.com/Dolibarr/dolibarr/tree/develop/htdocs/modulebuilder/template GitHub Dolibarr Module Modèle]&lt;br /&gt;
&lt;br /&gt;
=Create your module=&lt;br /&gt;
==Create a Module descriptor for your Module (required)==&lt;br /&gt;
&#039;&#039;&#039;When it is required&#039;&#039;&#039;: Required as soon as an addon is developed, whatever its goal is (except for adding a skin).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Since Dolibarr 9.0, you should use the ModuleBuilder module provided as a standard module to generate the module descriptor&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
===Create your module descriptor===&lt;br /&gt;
The first step is to create a file descriptor for the module. &lt;br /&gt;
&lt;br /&gt;
*Create directory &#039;&#039;&#039;/htdocs/custom/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; (for an external module) or &#039;&#039;&#039;/htdocs/&#039;&#039;mymodule&#039;&#039;/core/modules&#039;&#039;&#039; if you plan to have this module an official core module of Dolibarr. Then copy the file modMyModule.class.php from the directory &#039;&#039;&#039;htdocs/modulebuilder/template&#039;&#039;&#039; into this directory. Change the name of the file modMyModule.class.php to the name corresponding to the purpose of your module. Name of the file must start with initial &#039;mod&#039; and end with .class.php (for example if you want to give the name &#039;NewName&#039; to this file, then the name should be &#039;modNewName.class.php&#039;).&lt;br /&gt;
&lt;br /&gt;
Next modify the contents of this file as follows:&lt;br /&gt;
&lt;br /&gt;
*Replace all &amp;quot;modMyModule&amp;quot; with a value which corresponds to the purpose of your module. This value must always start with &#039;mod&#039; and contain only alpha characters (again, if the name given to the file was &#039;NewName&#039;, then replace all &amp;quot;modMyModule&amp;quot; with &amp;quot;modNewName&amp;quot;).&lt;br /&gt;
*Change the number in: $this-&amp;gt;numero = 100000 by a number that designates your module id. To avoid conflicts with other modules, you can consult the page that lists already reserved id numbers: [[List of modules id|List of modules id]].&lt;br /&gt;
*Modify any other variables defined in the constructor (see comment in the code skeleton for their meaning).&lt;br /&gt;
&lt;br /&gt;
Your file descriptor for your module is ready. See the next step to activate it.&lt;br /&gt;
&lt;br /&gt;
===Test your descriptor===&lt;br /&gt;
&lt;br /&gt;
Launch Dolibarr and go to page &#039;&#039;&#039;Setup-&amp;gt;module&#039;&#039;&#039;? &lt;br /&gt;
If you set the property version in the module description you should see a new line with your new module and the possibility to activate it or not. If you set the property version to &amp;quot;develop&amp;quot; or &amp;quot;experiental&amp;quot;, to see your module, you must first go into &#039;&#039;&#039;Setup-Others&#039;&#039;&#039; and set MAIN_FEATURES_LEVEL to 1 to see &amp;quot;experimental&amp;quot; modules or 2 to see &amp;quot;development&amp;quot; modules.&lt;br /&gt;
&lt;br /&gt;
==Tree of path for new module files (required)==&lt;br /&gt;
This is how your files must be organized when building a new module (the zip file must also match this rule).&lt;br /&gt;
Note: Only the second line is mandatory.&lt;br /&gt;
&lt;br /&gt;
{{TemplateModuleTreeSimple}}&lt;br /&gt;
&lt;br /&gt;
==Create your SQL tables and the PHP DAO class (optional)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs to manage data of its own&lt;br /&gt;
&lt;br /&gt;
===Create your .sql file===&lt;br /&gt;
If your module is designed to manage data of its own, which are not available in the standard version of Dolibarr, it is necessary to define SQL tables to store the data.&lt;br /&gt;
&lt;br /&gt;
Scripts for creating tables and loading data by your own module are saved into a subdirectory sql (&#039;&#039;&#039;&amp;quot;mymodule/sql&amp;quot;&#039;&#039;&#039;) of your module. (With ModuleBuilder, the directory and all sql files will be created automatically when you will create a new Object from tab Object).&lt;br /&gt;
&lt;br /&gt;
Then check into your descriptor file, into function &#039;&#039;&#039;init&#039;&#039;&#039; that the line&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;$this-&amp;gt;_load_tables(&#039;/mymodule/sql/&#039;);&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
is not commented.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Rules to follow:&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
*Add the files about creating tables commands on the principle of a file &#039;&#039;&#039;llx_matable.sql&#039;&#039;&#039; per table, with a possibly file &#039;&#039;&#039;llx_matable.key.sql&#039;&#039;&#039; (see existing files in &#039;&#039;&#039;install/mysql/tables&#039;&#039;&#039; for examples).&lt;br /&gt;
*The recommended type and name for SQL fields are defined into page [[Language_and_development_rules#Table_and_fields_structures]].&lt;br /&gt;
*To manage data, you must create a file called &#039;&#039;&#039;data.sql&#039;&#039;&#039; inside directory &#039;&#039;&#039;/mymodule/sql/&#039;&#039;&#039; that contains SQL command to add/edit/delete data.&lt;br /&gt;
*Don&#039;t use the double quote for strings (eg &#039;chaine&#039; not &amp;quot;chaine&amp;quot;) because the double quote have a specific meaning in PostGreSQL&lt;br /&gt;
&lt;br /&gt;
Example of content of a file data.sql&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Files must be operational for the database mysql. Rem: The files of other databases are not maintained. They will be read and converted on the fly by the driver of the other database.&lt;br /&gt;
&lt;br /&gt;
===Test your .sql files===&lt;br /&gt;
&lt;br /&gt;
Once the files ready, you can return to the page to enable Dolibarr modules and disable the module, drop those tables in the database (if they already exists) and reactivate the module. The tables should be recreated by the activation of the module. If this is not the case, check your scripts by passing them by hand, or check the Dolibarr logs.&lt;br /&gt;
&lt;br /&gt;
===Generate the PHP DAO class===&lt;br /&gt;
The DAO PHP files should have been generated by ModuleBuilder after creating an object.&lt;br /&gt;
&lt;br /&gt;
You can however create them manually by copying existing object however using ModuleBuilder is highly recommended. You should find examples into &#039;&#039;&#039;htdocs/modulebuilder/templates/class/myobject.class.php&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In this class, there are already operational CRUD (Create/Read/Update/Delete) methods to perform an insert, a fetch (select), an update, a delete of a table row. Edit the file to use the correct module name, tables and place this file in the class subdirectory of the module. The Module Builder allows you to do this with just a few mouse clicks.&lt;br /&gt;
&lt;br /&gt;
==The tab management (optional)==&lt;br /&gt;
&lt;br /&gt;
===Add or remove your own tabs on object sheets===&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: To add a tab on an object (invoices, orders, proposals, member ...)&lt;br /&gt;
&lt;br /&gt;
To do this go into the file descriptor of module previously created and edit the $this-&amp;gt;tabs array:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The table should contain a list of strings, each string representing a new tab. &lt;br /&gt;
The format of the string consisting of 5 parts separated by &amp;quot;:&amp;quot;&lt;br /&gt;
&lt;br /&gt;
*Part 1: The element type (object type) where the tab should appear is a value from the following:&lt;br /&gt;
{{TemplateModuleTabs}}&lt;br /&gt;
&lt;br /&gt;
*Part 2: A code to identify tab to add (start with +) or to remove (start with -)&lt;br /&gt;
*Part 3: The title of the tab. This can be a hard read or better code translation in a file lang.&lt;br /&gt;
*Part 4: The name of the file &amp;quot;*.lang&amp;quot; which contains correspondence between the code translation and language to display. If this name is followed with @mymodule, Dolibarr will search translation file &amp;quot;*.lang&amp;quot; within the module, so htdocs/mymodule/langs/code_CODE/mylangfile.lang, otherwise Dolibarr will look for file htdocs/langs/code_CODE/mylangfile.lang&lt;br /&gt;
*Part 5: A condition to test if tab must be visible. Put 1 to be always visible.&lt;br /&gt;
*Part 6: The URL of the page to display when you click on the tab. The __ID__ string will be replaced automatically by the Id of the element concerned.&lt;br /&gt;
&lt;br /&gt;
To feed the contents of the tab with data from the database, see the next chapter.&lt;br /&gt;
&lt;br /&gt;
In order to get the names  &#039;tabname&#039; of existing tabs, you have to check the names used in the function &#039;product_prepare_head&#039; of the file  &#039;core/lib/module.lib.php&#039; corresponding to section &#039;$head[$h][2]&#039;.&lt;br /&gt;
&lt;br /&gt;
===Show tabs navigation into your own pages===&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: To show all standard tabs of an object (product, tiers, etc.) on your page.&lt;br /&gt;
&lt;br /&gt;
You must follow these steps :&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;1. Include files you need into your file&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For each object type, there are two files to include with line&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;require_once($url_fichier) ;&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is example of files to include (DOL_DOCUMENT_ROOT is often dolibarr/htdocs/) :&lt;br /&gt;
&lt;br /&gt;
*Object thirdparty (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;
*Object product (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;
*Object invoice (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. Create and load the object to show into your tab&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Create an instance of an object of the correct class and load object from the database by using the fetch method of an object in providing to this method the id you get from URL (ie : /mytab.php?id=1).&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Get a list of all tabs to show for your object type&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function XXX_prepare_head($obj), where XXX is name of object. This will return an array with all definition of tab entries to show. The parameter to put into this method is the instance of an object you want tabs.&lt;br /&gt;
&lt;br /&gt;
The resulting array has the following structure&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$head = product_prepare_head($product, $user) ; // parameter $user is present for some function anly&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;4. show tabs into your page&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use function dol_fiche_head() to show all tabs defined into array $head returned by XX_prepare_head().&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&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;
==Create or modify PHP screens (optional)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If the purpose of your module is to add features that require new or modified screens.&lt;br /&gt;
&lt;br /&gt;
===Create a new PHP screen===&lt;br /&gt;
You must then create your PHP pages that will show/edit data from tables using the skeleton templates provided as an example in the directory &#039;&#039;&#039;modulebuilder/myobject_page.php&#039;&#039;&#039; (For the development of a script from the command line, see [[Script development]]).&lt;br /&gt;
&lt;br /&gt;
To create a new user screen, create a subdirectory of &#039;&#039;&#039;htdocs&#039;&#039;&#039; (if not already done) for your module (in &#039;&#039;&#039;htdocs/mymodule&#039;&#039;&#039; for example) to store the pages you will create.&lt;br /&gt;
&lt;br /&gt;
Copy, into that directory, the file &#039;&#039;&#039;myobject_page.phpp&#039;&#039;&#039; that will serve as a starting point for your page file.&lt;br /&gt;
Edit the file to have a correct relative path to the main.inc.php file. &lt;br /&gt;
&amp;lt;syntaxhighlight 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 calculated 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
As you can see, there are several tries to load the main.inc.php (or master.inc.php). The goal is to succeed in the most cases as possible. The minimum is 2 lines: one to try to load the master/main.inc.php into the dolibarr root directory and another one to try to load the file to support the case when the module is deployed into the &amp;quot;custom&amp;quot; directory. But you can have more to deal more situation. The provided example should be able to load the file main/master.inc.php in nearly all situation/setups.&lt;br /&gt;
&lt;br /&gt;
Note that you may add more &amp;quot;../&amp;quot; depending on the depth of the file relative to your module directory tree.&lt;br /&gt;
&lt;br /&gt;
It&#039;s in the main.inc.php file that is loaded technical environment variables and permissions. The following variables are objects positioned in this file:&lt;br /&gt;
&lt;br /&gt;
*$user    Object that contains the characteristics of the user + his permissions.&lt;br /&gt;
*$conf    Object that contains Dolibarr configuration.&lt;br /&gt;
*$db      Object that contains an opened connection handler to the database.&lt;br /&gt;
*$langs   Object that contains the user&#039;s language.&lt;br /&gt;
&lt;br /&gt;
Then enter your code to display the page.&lt;br /&gt;
&lt;br /&gt;
*To include a class or library dedicated to the module is done using a Dolibarr function (and not using directly include_once):&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
*To include classes provided with Dolibarr, use the following syntax:&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Add some fields into existing forms===&lt;br /&gt;
You may want to provide a module that adds more fields into forms (input and view) of some elements. &lt;br /&gt;
&lt;br /&gt;
A heavy solution (but not so bad) may be to replace all pages used to create element (this means to disable the &amp;quot;New element&amp;quot; menu entry and adding yours, and disable tab that shows element to replace with a tab that is your own full page (copied/pasted from original) to do same than original page but modified to add your fields and stored added data into your own table). Go to menu [[#Define your entries in the menu (optional)]] and [[#The tab management (optional)]] if this solution suits you (this solution is more powerful since you can change everything you want into the page). &lt;br /&gt;
&lt;br /&gt;
We will describe here another solution, that works only to &amp;quot;add fields&amp;quot; at end of existing fields, using the element &amp;quot;category&amp;quot; as an example but you can convert this tutorial for invoice, proposal ...&lt;br /&gt;
&lt;br /&gt;
*First thing is to add a table, owned by your module, to store the value of new fields. This table will have only one column called &amp;quot;rowid&amp;quot; (will contain the same value than field rowid of element table) + one column for each new field you want to add. Then create a class with CRUD (Create/Read/Update/Delete) methods for this new table. For this two tasks, go back to previous chapter [[#Create your SQL tables and the PHP DAO class]].&lt;br /&gt;
*Next step is to add a hook into your module to add the new fields into the form. See chapter [[Hooks_system#Implement_the_Hook]] for generic documentation to use hooks.&lt;br /&gt;
&lt;br /&gt;
If you follow this tutorial, to be able to add fields into category forms, you must do:&lt;br /&gt;
{{ToComplete}}&lt;br /&gt;
&lt;br /&gt;
===Add/replace part of fields supported by hooks===&lt;br /&gt;
See chapter [[Hooks_system#Implement_the_Hook]] to know how to use Dolibarr existing hooks to add/replace code at Dolibarr hooks place.&lt;br /&gt;
&lt;br /&gt;
===Database access===&lt;br /&gt;
If you need to edit some data in the database inside your own table, use the PHP class generated before.&lt;br /&gt;
&lt;br /&gt;
If you to make access to tables with no dedicated PHP class available, this is always possible (for example if you want to get a list of records with a particular join or filter). In this case, this is a code samples to follow:&lt;br /&gt;
&lt;br /&gt;
To make an insert, update or delete:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To read:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Define style of your pages===&lt;br /&gt;
To have the look of your own pages to match the Dolibarr theme, it is necessary to use the Dolibarr CSS styles.&lt;br /&gt;
&lt;br /&gt;
You can use for example:&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;
===Use the Dolibarr date picker===&lt;br /&gt;
If you want to use the Dolibarr date selector (with its calendar popup) into your pages, use the following line:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
The string mykey will identify the date selector in the form. You must use different values if you use several date selectors in same page.&lt;br /&gt;
The string myform is the name of the FORM in which the selector is included (value found in the form name=&amp;quot;myform&amp;quot; in HTML page).&lt;br /&gt;
This means a date selector must be included necessarily into an html FORM.&lt;br /&gt;
&lt;br /&gt;
To get value after the POST of your form, the command is:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$mydate = dol_mktime(12, 0 , 0, $GETPOST(&#039;mykeymonth&#039;, &#039;int&#039;), GETPOST(&#039;mykeyday&#039;, &#039;int&#039;), GETPOST(&#039;mykeyyear&#039;, &#039;int&#039;));&lt;br /&gt;
print strftime(&#039;%A %d %B %Y&#039;, $mydate);&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Overwrite template file (tpl)===&lt;br /&gt;
If you want to overwrite tpl file on your module, you need to declare it on the module_parts :&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
&#039;tpl&#039; =&amp;gt; 1,&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
Then you can put any tpl file on &#039;&#039;&#039;mymodule/core/tpl&#039;&#039;&#039;&lt;br /&gt;
as soon as the module is activate, the tpl will be overwrited&lt;br /&gt;
&lt;br /&gt;
==Add your own setup page (optional)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs parameters, which are to be provided by the user, for proper setting up of the module.&lt;br /&gt;
&lt;br /&gt;
===Create your page to edit parameters===&lt;br /&gt;
If your module needs several parameters to be setup, you must create a page to edit options (these options will be saved in the [[Table llx_const|table &#039;&#039;&#039;llx_const&#039;&#039;&#039;]]).&lt;br /&gt;
Create a page named &#039;&#039;&#039;mymodule_setuppage.php&#039;&#039;&#039; that shows a form for possible options to update them into the above-mentioned table.&lt;br /&gt;
It is necessary to take an example from a page of the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; that will show you the way to read/save your parameters.&lt;br /&gt;
Put this PHP page into the directory &#039;&#039;&#039;/admin&#039;&#039;&#039; of your module (e.g. mymodule/admin/mymodule_setuppage.php).&lt;br /&gt;
&lt;br /&gt;
===Modify the descriptor file of your module===&lt;br /&gt;
Then, within the descriptor file of your module, modify the variable &#039;&#039;&#039;config_page_url&#039;&#039;&#039; to set the name of this PHP page.&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;admin/&#039;&#039;&#039;, then the path is not required, e.g. like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
If the page is in the directory &#039;&#039;&#039;mymodule/admin/&#039;&#039;&#039;, then like this:&lt;br /&gt;
&amp;lt;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Test your page===&lt;br /&gt;
Go into page &#039;&#039;&#039;Home-&amp;gt;Setup-&amp;gt;Modules&#039;&#039;&#039;, you should see a picture at the end of the line of your module to reach your setup page. Click on it, you should be able to view/edit parameters from your page.&lt;br /&gt;
&lt;br /&gt;
==Define your entries in menu (optional)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If you have created PHP pages, it is necessary that those pages can be reached from menu entries in Dolibarr menu.&lt;br /&gt;
&lt;br /&gt;
===Define your menu entries===&lt;br /&gt;
For this, you must define into the module descriptor, the array this-&amp;gt;menu that declares 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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To show the menu or not depending on a permission, modify property &#039;&#039;&#039;perms&#039;&#039;&#039; in the array. See chapter on permissions later to see how to add permissions.&lt;br /&gt;
&lt;br /&gt;
===Test your menu entries===&lt;br /&gt;
Disable and re-enable your module under the Dolibarr module setup page, menus entries must appear (if property &#039;enabled&#039; is declaration array is ok).&lt;br /&gt;
&lt;br /&gt;
==Add your own permissions (optional)==&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;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;rights_class = &#039;mymodule&#039;&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight 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][2] = &#039;r&#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;/syntaxhighlight&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][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; Translation key should be &amp;quot;Permission10001=My permission Label&amp;quot;).&lt;br /&gt;
Into $this-&amp;gt;rights[$r][2], types of the permission. There are three type of permission, &#039;r&#039; for read, list or expert permission, &#039;w&#039; for write or update permission and &#039;d&#039; for delete permission.&lt;br /&gt;
Into $this-&amp;gt;rights[$r][3], put 1 if this permission must be granted automatically by default to any newly created user.&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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Define your own box (optional)==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module needs to provide one or several new boxes to show on home page.&lt;br /&gt;
&lt;br /&gt;
===Define your box===&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;syntaxhighlight 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;/syntaxhighlight&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 activate. Activate the box and go on the 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 provides new predefined database export profiles (for its own tables or for already existing tables of another module).&lt;br /&gt;
&lt;br /&gt;
===Define export===&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 a 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 several CSS files 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 files only if you need absolutely to add not already existing styles.&lt;br /&gt;
&lt;br /&gt;
Once your style sheets are ready, declare them 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 an array of relative URLs to your CSS files.&lt;br /&gt;
For example&lt;br /&gt;
&amp;lt;syntaxhighlight 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;,&#039;/mymodule/css/myother.css&#039;));&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 the 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 declares your style sheet.&lt;br /&gt;
&lt;br /&gt;
==Add your Javascript functions (optional)==&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;syntaxhighlight 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;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Run your own code on any Dolibarr event (optional)==&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;
==Insert your code inside Dolibarr hooks positions (optional)==&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 the 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;
==Add your own numbering rules==&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: When you need a new rule for generated ref of elements that are not covered by existing rules.&lt;br /&gt;
&lt;br /&gt;
See page [[Create numbering module]].&lt;br /&gt;
&lt;br /&gt;
==Add your document template (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;
==Add your skin (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;
=Some coding rules and predefined functions=&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;
=Create a package to distribute and install your module=&lt;br /&gt;
This process must be used to generate a package to submit it on the http://www.dolistore.com marketplace.&lt;br /&gt;
But you can use it to have a package easy to distribute on your own 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 a 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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
perl makepack-dolibarrmodule.pl&lt;br /&gt;
&amp;lt;/syntaxhighlight&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;syntaxhighlight lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
tar -xvf mymodule.zip&lt;br /&gt;
&amp;lt;/syntaxhighlight&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 marketplace website: {{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 built correctly, the file will be validated later.&lt;br /&gt;
**If quality is enough and license permits it, the code might be added inside main Dolibarr sources (except if you disagree for that).&lt;br /&gt;
&lt;br /&gt;
=Enabling/activation condition of external module on DoliStore=&lt;br /&gt;
&lt;br /&gt;
See [[Module_Dolistore_Validation_Rules|Validation Rules]]&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=JA_Developer_documentation&amp;diff=56365</id>
		<title>JA Developer documentation</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=JA_Developer_documentation&amp;diff=56365"/>
		<updated>2023-04-27T07:40:02Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: /* ツリー構造 (Tree structure) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:開発者手引き}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;seo metak=&amp;quot;developer, development, documentation, guide, doc, tutorial, usage, help, api, coding, standard, rules&amp;quot; /&amp;gt;&lt;br /&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 : Developer_documentation --&amp;gt;&lt;br /&gt;
[[fr:Documentation_Développeur]]&lt;br /&gt;
[[es:Documentación_Desarrolladores]]&lt;br /&gt;
[[de:Entwickler_Dokumentation]]&lt;br /&gt;
[[zh:开发文档]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This page is main index of documents relating to developer documentation. For user documentation [[User documentation|see here]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=開発組織とツール=&lt;br /&gt;
This chapter contains global information that must be read before starting any development on Dolibarr.&lt;br /&gt;
&lt;br /&gt;
#[[Dolibarr Project|Organization of project]]&lt;br /&gt;
#[[To known before to start|To be known before starting to develop]]&lt;br /&gt;
#[[Environment and development tools]]&lt;br /&gt;
#[[Dependencies and external libraries]]&lt;br /&gt;
#[[FAQ_Get,update_project_sources|Get or update sources of a development version]]&lt;br /&gt;
&lt;br /&gt;
=コーディング規約とベストプラクティス=&lt;br /&gt;
&lt;br /&gt;
#[[Prerequisite|Prerequisites]]&lt;br /&gt;
#[[Language and development rules|Language and development rules (PHP, SQL, HTML)]]&lt;br /&gt;
#[[:Category:Table SQL|List of tables]]&lt;br /&gt;
#Tree structure of files and classes are available in the [http://doxygen.dolibarr.org/ doxygen generated documentation]&lt;br /&gt;
&lt;br /&gt;
=モジュールリスト=&lt;br /&gt;
Technical documentation on standard business modules is available in each module&#039;s developer documentation pages. Choose the appropriate page you are interested in:&lt;br /&gt;
&lt;br /&gt;
*[[:Category:List of Modules (developer)‎|List of standard modules]]&lt;br /&gt;
*[[:Category:Complementary modules|List of complementary modules]]&lt;br /&gt;
&lt;br /&gt;
=GUI 向けの新 モジュール/アドオン を作るには=&lt;br /&gt;
この項では、Dolibarr のユーザインタフェースを変更する新規モジュールの開発方法を述べる. 該当するのは、スクリーン、テーマ、データ、保有するCSSスタイルシート 、ソースコード、またはそれらのすべて.&lt;br /&gt;
&lt;br /&gt;
スクリプト開発はこの項には含まれない (これは次章で述べる).&lt;br /&gt;
&lt;br /&gt;
自分のモジュールを開発するには、[[モジュール 開発|モジュール開発]] チュートリアルを確認すること.&lt;br /&gt;
&lt;br /&gt;
=バッチまたはコマンドラインスクリプトを作るには=&lt;br /&gt;
This chapter describes how to develop command line scripts to execute tasks in Dolibarr (read, update data...).&lt;br /&gt;
&lt;br /&gt;
Making modifications to the graphical user interface (GUI) is not included in this chapter. See the previous chapter for this.&lt;br /&gt;
&lt;br /&gt;
To develop a script, like a cron script or a command line import tool to import data from an external source, you can have a look at the [[Script development]] page.&lt;br /&gt;
&lt;br /&gt;
=Dolibarr の技術的要素 (Technical components)=&lt;br /&gt;
==ツリー構造 (Tree structure)==&lt;br /&gt;
現バージョンのファイルのパス階層は、 [http://doxygen.dolibarr.org/ doxygen generated documentation] (&amp;quot;javadoc&amp;quot; 文書に類似) から把握できる.&lt;br /&gt;
&lt;br /&gt;
新規モジュールによる新規ファイルの追加で使用するパスは、新規モジュール開発の文書 ([[Module development|Module development 参照]]) で定義される.&lt;br /&gt;
&lt;br /&gt;
==ストレージ準備 (Setup storage)==&lt;br /&gt;
There are 3 places for Dolibarr setup parameters.&lt;br /&gt;
&lt;br /&gt;
*Dolibarr technical setup parameters (authentication mode, database logins and storage area for files) are defined in only one setup file: &amp;lt;code&amp;gt;/conf/conf.php&amp;lt;/code&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
:See [[Configuration file]] for more information.&lt;br /&gt;
&lt;br /&gt;
*Global features parameters are stored in [[Table llx_const]].&lt;br /&gt;
&lt;br /&gt;
:See the [[Constants]] page for more information.&lt;br /&gt;
&lt;br /&gt;
*Feature parameters specific to a user are stored in [[Table llx_user_param]].&lt;br /&gt;
&lt;br /&gt;
==ビジネスオブジェクト (Business objects)==&lt;br /&gt;
See [[ビジネス オブジェクト|ビジネスオブジェクト]] &lt;br /&gt;
&lt;br /&gt;
==メニューシステム (Menu system)==&lt;br /&gt;
See [[Menus system]] &lt;br /&gt;
&lt;br /&gt;
==タブシステム (Tabs system)==&lt;br /&gt;
See [[Tabs system]] &lt;br /&gt;
&lt;br /&gt;
==スキンシステム (Skins system)==&lt;br /&gt;
See [[Skins]] &lt;br /&gt;
&lt;br /&gt;
==ウィジェットシステム (Widget system)==&lt;br /&gt;
See [[Widget system]]&lt;br /&gt;
&lt;br /&gt;
==認証システム (Authentication system)==&lt;br /&gt;
See [[Authentication]] &lt;br /&gt;
&lt;br /&gt;
==許可システム (Permission system)==&lt;br /&gt;
See [[Permissions En|Permissions]] &lt;br /&gt;
&lt;br /&gt;
==翻訳システム (Translation system)==&lt;br /&gt;
See [[Translation system]] &lt;br /&gt;
&lt;br /&gt;
==エラー管理 (Error management)==&lt;br /&gt;
See [[Error reporting|Error reporting]] &lt;br /&gt;
&lt;br /&gt;
==キャンバスシステム (Canvas system)==&lt;br /&gt;
Canvas is a developer feature to replace screens to create, update or view a record (products, thirdparties, contacts, ...). For example, you can replace the input form used to create a new third party, or its editing form, or replace its viewing template.&lt;br /&gt;
 &lt;br /&gt;
See [[Canvas development]] &lt;br /&gt;
&lt;br /&gt;
==トリガーシステム (Triggers system)==&lt;br /&gt;
Triggers are a development feature to execute personalized code during a Dolibarr &amp;quot;business event&amp;quot; (creation of an invoice, deleting a user, update of third party, etc...), and only for a business event. To personalize code for other contexts, see the &#039;&#039;&#039;Hooks system&#039;&#039;&#039; chapter instead.&lt;br /&gt;
&lt;br /&gt;
For triggers usage, see [[Interfaces Dolibarr toward foreign systems|this page]].&lt;br /&gt;
&lt;br /&gt;
==フックシステム (Hooks system)==&lt;br /&gt;
See [[Hooks system]] &lt;br /&gt;
&lt;br /&gt;
==変数置換システム (Variable substitution system)==&lt;br /&gt;
See [[Variable substitution system]] &lt;br /&gt;
&lt;br /&gt;
==ウェブサービス (Web services)==&lt;br /&gt;
Dolibarr can be setup to provide some services.&lt;br /&gt;
&lt;br /&gt;
See [[Module Web Services API REST (developer)]] &lt;br /&gt;
&lt;br /&gt;
Note: The [[Module Web Services API SOAP (developer)]] is deprecated.&lt;br /&gt;
&lt;br /&gt;
==ファイル/書類 ストレージ管理 (Files/Documents storage management)==&lt;br /&gt;
See [[Generated documents]] &lt;br /&gt;
&lt;br /&gt;
==番号付けモジュール (Numbering modules)==&lt;br /&gt;
For each entity created in the application, Dolibarr assigns a reference. In order to adapt the reference to any use, Dolibarr use modules to define the reference generation rule. Several standard modules are supplied. Some are generic and are used to define the numbering mask (number on x characters, with or without prefix, including the date or not, etc.), which can meet most needs. However, there are still cases where the modules provided don&#039;t meet the needs. In this case it is necessary to develop a custom numbering module.&lt;br /&gt;
&lt;br /&gt;
For more information, see [[Create numeration module|Create numbering module]].&lt;br /&gt;
&lt;br /&gt;
==文書テンプレートと文書生成 (Document templates and documents generation)==&lt;br /&gt;
&lt;br /&gt;
More documentation about document generation from templates is available to [[Create a PDF document template]] or [[Create an ODT document template]].&lt;br /&gt;
&lt;br /&gt;
==エクストラフィールド (Extrafields)==&lt;br /&gt;
See [[Extrafields]]&lt;br /&gt;
&lt;br /&gt;
==オンライン決済システム (Online payment system)==&lt;br /&gt;
See [[Online payment system]]&lt;br /&gt;
&lt;br /&gt;
==他内部機能 (Other internal function)==&lt;br /&gt;
There are many internal libraries your code can use.&lt;br /&gt;
You may find a lot of generic functions in the functions.lib.php, functions2.lib.php or admin.lib.php. Any function found in htdocs/core/lib/*.lib files can be used.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;To specify a requirement based on Dolibarr version number&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For example, to make a condition based on requiring Dolibarr version &amp;gt; 3.5, you can use versioncompare and versiondolibarrarray found in admin.lib.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
if (versioncompare(versiondolibarrarray(), array(3,5,0)) &amp;gt; 0)&lt;br /&gt;
{&lt;br /&gt;
 ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=大量 エクスポート/インポート (Mass exports/imports)=&lt;br /&gt;
&lt;br /&gt;
#[[Mass imports]]&lt;br /&gt;
#[[Module Exports En|Mass exports]]&lt;br /&gt;
&lt;br /&gt;
=他のアプリとのインタフェースやリンク (Interfaces and links with other applications)=&lt;br /&gt;
&lt;br /&gt;
#[[Interfaces Dolibarr toward foreign systems]] or Dolibarr toward Dolibarr (Dolibarr Triggers or Hooks)&lt;br /&gt;
#[[Interfaces from foreign systems toward Dolibarr]]&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
All FAQs are available through the FAQ index page [[:Category:FAQ EN|FAQ EN]]&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=JA_Developer_documentation&amp;diff=56363</id>
		<title>JA Developer documentation</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=JA_Developer_documentation&amp;diff=56363"/>
		<updated>2023-04-26T11:21:03Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: /* GUI 向けの新 モジュール/アドオン を作るには */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:開発者手引き}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;seo metak=&amp;quot;developer, development, documentation, guide, doc, tutorial, usage, help, api, coding, standard, rules&amp;quot; /&amp;gt;&lt;br /&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 : Developer_documentation --&amp;gt;&lt;br /&gt;
[[fr:Documentation_Développeur]]&lt;br /&gt;
[[es:Documentación_Desarrolladores]]&lt;br /&gt;
[[de:Entwickler_Dokumentation]]&lt;br /&gt;
[[zh:开发文档]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This page is main index of documents relating to developer documentation. For user documentation [[User documentation|see here]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=開発組織とツール=&lt;br /&gt;
This chapter contains global information that must be read before starting any development on Dolibarr.&lt;br /&gt;
&lt;br /&gt;
#[[Dolibarr Project|Organization of project]]&lt;br /&gt;
#[[To known before to start|To be known before starting to develop]]&lt;br /&gt;
#[[Environment and development tools]]&lt;br /&gt;
#[[Dependencies and external libraries]]&lt;br /&gt;
#[[FAQ_Get,update_project_sources|Get or update sources of a development version]]&lt;br /&gt;
&lt;br /&gt;
=コーディング規約とベストプラクティス=&lt;br /&gt;
&lt;br /&gt;
#[[Prerequisite|Prerequisites]]&lt;br /&gt;
#[[Language and development rules|Language and development rules (PHP, SQL, HTML)]]&lt;br /&gt;
#[[:Category:Table SQL|List of tables]]&lt;br /&gt;
#Tree structure of files and classes are available in the [http://doxygen.dolibarr.org/ doxygen generated documentation]&lt;br /&gt;
&lt;br /&gt;
=モジュールリスト=&lt;br /&gt;
Technical documentation on standard business modules is available in each module&#039;s developer documentation pages. Choose the appropriate page you are interested in:&lt;br /&gt;
&lt;br /&gt;
*[[:Category:List of Modules (developer)‎|List of standard modules]]&lt;br /&gt;
*[[:Category:Complementary modules|List of complementary modules]]&lt;br /&gt;
&lt;br /&gt;
=GUI 向けの新 モジュール/アドオン を作るには=&lt;br /&gt;
この項では、Dolibarr のユーザインタフェースを変更する新規モジュールの開発方法を述べる. 該当するのは、スクリーン、テーマ、データ、保有するCSSスタイルシート 、ソースコード、またはそれらのすべて.&lt;br /&gt;
&lt;br /&gt;
スクリプト開発はこの項には含まれない (これは次章で述べる).&lt;br /&gt;
&lt;br /&gt;
自分のモジュールを開発するには、[[モジュール 開発|モジュール開発]] チュートリアルを確認すること.&lt;br /&gt;
&lt;br /&gt;
=バッチまたはコマンドラインスクリプトを作るには=&lt;br /&gt;
This chapter describes how to develop command line scripts to execute tasks in Dolibarr (read, update data...).&lt;br /&gt;
&lt;br /&gt;
Making modifications to the graphical user interface (GUI) is not included in this chapter. See the previous chapter for this.&lt;br /&gt;
&lt;br /&gt;
To develop a script, like a cron script or a command line import tool to import data from an external source, you can have a look at the [[Script development]] page.&lt;br /&gt;
&lt;br /&gt;
=Dolibarr の技術的要素 (Technical components)=&lt;br /&gt;
==ツリー構造 (Tree structure)==&lt;br /&gt;
The path hierarchy of the current version files is available from the [http://doxygen.dolibarr.org/ doxygen generated documentation] (similar to generated &amp;quot;javadoc&amp;quot; documentation).&lt;br /&gt;
&lt;br /&gt;
Paths to use to add new files by a new module are defined in the documentation to develop a new module (see [[Module development]]).&lt;br /&gt;
&lt;br /&gt;
==ストレージ準備 (Setup storage)==&lt;br /&gt;
There are 3 places for Dolibarr setup parameters.&lt;br /&gt;
&lt;br /&gt;
*Dolibarr technical setup parameters (authentication mode, database logins and storage area for files) are defined in only one setup file: &amp;lt;code&amp;gt;/conf/conf.php&amp;lt;/code&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
:See [[Configuration file]] for more information.&lt;br /&gt;
&lt;br /&gt;
*Global features parameters are stored in [[Table llx_const]].&lt;br /&gt;
&lt;br /&gt;
:See the [[Constants]] page for more information.&lt;br /&gt;
&lt;br /&gt;
*Feature parameters specific to a user are stored in [[Table llx_user_param]].&lt;br /&gt;
&lt;br /&gt;
==ビジネスオブジェクト (Business objects)==&lt;br /&gt;
See [[ビジネス オブジェクト|ビジネスオブジェクト]] &lt;br /&gt;
&lt;br /&gt;
==メニューシステム (Menu system)==&lt;br /&gt;
See [[Menus system]] &lt;br /&gt;
&lt;br /&gt;
==タブシステム (Tabs system)==&lt;br /&gt;
See [[Tabs system]] &lt;br /&gt;
&lt;br /&gt;
==スキンシステム (Skins system)==&lt;br /&gt;
See [[Skins]] &lt;br /&gt;
&lt;br /&gt;
==ウィジェットシステム (Widget system)==&lt;br /&gt;
See [[Widget system]]&lt;br /&gt;
&lt;br /&gt;
==認証システム (Authentication system)==&lt;br /&gt;
See [[Authentication]] &lt;br /&gt;
&lt;br /&gt;
==許可システム (Permission system)==&lt;br /&gt;
See [[Permissions En|Permissions]] &lt;br /&gt;
&lt;br /&gt;
==翻訳システム (Translation system)==&lt;br /&gt;
See [[Translation system]] &lt;br /&gt;
&lt;br /&gt;
==エラー管理 (Error management)==&lt;br /&gt;
See [[Error reporting|Error reporting]] &lt;br /&gt;
&lt;br /&gt;
==キャンバスシステム (Canvas system)==&lt;br /&gt;
Canvas is a developer feature to replace screens to create, update or view a record (products, thirdparties, contacts, ...). For example, you can replace the input form used to create a new third party, or its editing form, or replace its viewing template.&lt;br /&gt;
 &lt;br /&gt;
See [[Canvas development]] &lt;br /&gt;
&lt;br /&gt;
==トリガーシステム (Triggers system)==&lt;br /&gt;
Triggers are a development feature to execute personalized code during a Dolibarr &amp;quot;business event&amp;quot; (creation of an invoice, deleting a user, update of third party, etc...), and only for a business event. To personalize code for other contexts, see the &#039;&#039;&#039;Hooks system&#039;&#039;&#039; chapter instead.&lt;br /&gt;
&lt;br /&gt;
For triggers usage, see [[Interfaces Dolibarr toward foreign systems|this page]].&lt;br /&gt;
&lt;br /&gt;
==フックシステム (Hooks system)==&lt;br /&gt;
See [[Hooks system]] &lt;br /&gt;
&lt;br /&gt;
==変数置換システム (Variable substitution system)==&lt;br /&gt;
See [[Variable substitution system]] &lt;br /&gt;
&lt;br /&gt;
==ウェブサービス (Web services)==&lt;br /&gt;
Dolibarr can be setup to provide some services.&lt;br /&gt;
&lt;br /&gt;
See [[Module Web Services API REST (developer)]] &lt;br /&gt;
&lt;br /&gt;
Note: The [[Module Web Services API SOAP (developer)]] is deprecated.&lt;br /&gt;
&lt;br /&gt;
==ファイル/書類 ストレージ管理 (Files/Documents storage management)==&lt;br /&gt;
See [[Generated documents]] &lt;br /&gt;
&lt;br /&gt;
==番号付けモジュール (Numbering modules)==&lt;br /&gt;
For each entity created in the application, Dolibarr assigns a reference. In order to adapt the reference to any use, Dolibarr use modules to define the reference generation rule. Several standard modules are supplied. Some are generic and are used to define the numbering mask (number on x characters, with or without prefix, including the date or not, etc.), which can meet most needs. However, there are still cases where the modules provided don&#039;t meet the needs. In this case it is necessary to develop a custom numbering module.&lt;br /&gt;
&lt;br /&gt;
For more information, see [[Create numeration module|Create numbering module]].&lt;br /&gt;
&lt;br /&gt;
==文書テンプレートと文書生成 (Document templates and documents generation)==&lt;br /&gt;
&lt;br /&gt;
More documentation about document generation from templates is available to [[Create a PDF document template]] or [[Create an ODT document template]].&lt;br /&gt;
&lt;br /&gt;
==エクストラフィールド (Extrafields)==&lt;br /&gt;
See [[Extrafields]]&lt;br /&gt;
&lt;br /&gt;
==オンライン決済システム (Online payment system)==&lt;br /&gt;
See [[Online payment system]]&lt;br /&gt;
&lt;br /&gt;
==他内部機能 (Other internal function)==&lt;br /&gt;
There are many internal libraries your code can use.&lt;br /&gt;
You may find a lot of generic functions in the functions.lib.php, functions2.lib.php or admin.lib.php. Any function found in htdocs/core/lib/*.lib files can be used.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;To specify a requirement based on Dolibarr version number&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For example, to make a condition based on requiring Dolibarr version &amp;gt; 3.5, you can use versioncompare and versiondolibarrarray found in admin.lib.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
if (versioncompare(versiondolibarrarray(), array(3,5,0)) &amp;gt; 0)&lt;br /&gt;
{&lt;br /&gt;
 ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=大量 エクスポート/インポート (Mass exports/imports)=&lt;br /&gt;
&lt;br /&gt;
#[[Mass imports]]&lt;br /&gt;
#[[Module Exports En|Mass exports]]&lt;br /&gt;
&lt;br /&gt;
=他のアプリとのインタフェースやリンク (Interfaces and links with other applications)=&lt;br /&gt;
&lt;br /&gt;
#[[Interfaces Dolibarr toward foreign systems]] or Dolibarr toward Dolibarr (Dolibarr Triggers or Hooks)&lt;br /&gt;
#[[Interfaces from foreign systems toward Dolibarr]]&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
All FAQs are available through the FAQ index page [[:Category:FAQ EN|FAQ EN]]&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=JA_Developer_documentation&amp;diff=56362</id>
		<title>JA Developer documentation</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=JA_Developer_documentation&amp;diff=56362"/>
		<updated>2023-04-26T11:19:30Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: /* GUI 向けの新 モジュール/アドオン を作るには */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:開発者手引き}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;seo metak=&amp;quot;developer, development, documentation, guide, doc, tutorial, usage, help, api, coding, standard, rules&amp;quot; /&amp;gt;&lt;br /&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 : Developer_documentation --&amp;gt;&lt;br /&gt;
[[fr:Documentation_Développeur]]&lt;br /&gt;
[[es:Documentación_Desarrolladores]]&lt;br /&gt;
[[de:Entwickler_Dokumentation]]&lt;br /&gt;
[[zh:开发文档]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This page is main index of documents relating to developer documentation. For user documentation [[User documentation|see here]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=開発組織とツール=&lt;br /&gt;
This chapter contains global information that must be read before starting any development on Dolibarr.&lt;br /&gt;
&lt;br /&gt;
#[[Dolibarr Project|Organization of project]]&lt;br /&gt;
#[[To known before to start|To be known before starting to develop]]&lt;br /&gt;
#[[Environment and development tools]]&lt;br /&gt;
#[[Dependencies and external libraries]]&lt;br /&gt;
#[[FAQ_Get,update_project_sources|Get or update sources of a development version]]&lt;br /&gt;
&lt;br /&gt;
=コーディング規約とベストプラクティス=&lt;br /&gt;
&lt;br /&gt;
#[[Prerequisite|Prerequisites]]&lt;br /&gt;
#[[Language and development rules|Language and development rules (PHP, SQL, HTML)]]&lt;br /&gt;
#[[:Category:Table SQL|List of tables]]&lt;br /&gt;
#Tree structure of files and classes are available in the [http://doxygen.dolibarr.org/ doxygen generated documentation]&lt;br /&gt;
&lt;br /&gt;
=モジュールリスト=&lt;br /&gt;
Technical documentation on standard business modules is available in each module&#039;s developer documentation pages. Choose the appropriate page you are interested in:&lt;br /&gt;
&lt;br /&gt;
*[[:Category:List of Modules (developer)‎|List of standard modules]]&lt;br /&gt;
*[[:Category:Complementary modules|List of complementary modules]]&lt;br /&gt;
&lt;br /&gt;
=GUI 向けの新 モジュール/アドオン を作るには=&lt;br /&gt;
この項では、Dolibarr のユーザインタフェースを変更する新規モジュールの開発方法を述べる. 該当するのは、スクリーン、テーマ、データ、保有するCSSスタイルシート 、ソースコード、またはそれらのすべて.&lt;br /&gt;
&lt;br /&gt;
スクリプト開発はこの項には含まれない (これは次章で述べる).&lt;br /&gt;
&lt;br /&gt;
自分のモジュールを開発するには、[[Module development]] tutorial を確認すること.&lt;br /&gt;
&lt;br /&gt;
=バッチまたはコマンドラインスクリプトを作るには=&lt;br /&gt;
This chapter describes how to develop command line scripts to execute tasks in Dolibarr (read, update data...).&lt;br /&gt;
&lt;br /&gt;
Making modifications to the graphical user interface (GUI) is not included in this chapter. See the previous chapter for this.&lt;br /&gt;
&lt;br /&gt;
To develop a script, like a cron script or a command line import tool to import data from an external source, you can have a look at the [[Script development]] page.&lt;br /&gt;
&lt;br /&gt;
=Dolibarr の技術的要素 (Technical components)=&lt;br /&gt;
==ツリー構造 (Tree structure)==&lt;br /&gt;
The path hierarchy of the current version files is available from the [http://doxygen.dolibarr.org/ doxygen generated documentation] (similar to generated &amp;quot;javadoc&amp;quot; documentation).&lt;br /&gt;
&lt;br /&gt;
Paths to use to add new files by a new module are defined in the documentation to develop a new module (see [[Module development]]).&lt;br /&gt;
&lt;br /&gt;
==ストレージ準備 (Setup storage)==&lt;br /&gt;
There are 3 places for Dolibarr setup parameters.&lt;br /&gt;
&lt;br /&gt;
*Dolibarr technical setup parameters (authentication mode, database logins and storage area for files) are defined in only one setup file: &amp;lt;code&amp;gt;/conf/conf.php&amp;lt;/code&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
:See [[Configuration file]] for more information.&lt;br /&gt;
&lt;br /&gt;
*Global features parameters are stored in [[Table llx_const]].&lt;br /&gt;
&lt;br /&gt;
:See the [[Constants]] page for more information.&lt;br /&gt;
&lt;br /&gt;
*Feature parameters specific to a user are stored in [[Table llx_user_param]].&lt;br /&gt;
&lt;br /&gt;
==ビジネスオブジェクト (Business objects)==&lt;br /&gt;
See [[ビジネス オブジェクト|ビジネスオブジェクト]] &lt;br /&gt;
&lt;br /&gt;
==メニューシステム (Menu system)==&lt;br /&gt;
See [[Menus system]] &lt;br /&gt;
&lt;br /&gt;
==タブシステム (Tabs system)==&lt;br /&gt;
See [[Tabs system]] &lt;br /&gt;
&lt;br /&gt;
==スキンシステム (Skins system)==&lt;br /&gt;
See [[Skins]] &lt;br /&gt;
&lt;br /&gt;
==ウィジェットシステム (Widget system)==&lt;br /&gt;
See [[Widget system]]&lt;br /&gt;
&lt;br /&gt;
==認証システム (Authentication system)==&lt;br /&gt;
See [[Authentication]] &lt;br /&gt;
&lt;br /&gt;
==許可システム (Permission system)==&lt;br /&gt;
See [[Permissions En|Permissions]] &lt;br /&gt;
&lt;br /&gt;
==翻訳システム (Translation system)==&lt;br /&gt;
See [[Translation system]] &lt;br /&gt;
&lt;br /&gt;
==エラー管理 (Error management)==&lt;br /&gt;
See [[Error reporting|Error reporting]] &lt;br /&gt;
&lt;br /&gt;
==キャンバスシステム (Canvas system)==&lt;br /&gt;
Canvas is a developer feature to replace screens to create, update or view a record (products, thirdparties, contacts, ...). For example, you can replace the input form used to create a new third party, or its editing form, or replace its viewing template.&lt;br /&gt;
 &lt;br /&gt;
See [[Canvas development]] &lt;br /&gt;
&lt;br /&gt;
==トリガーシステム (Triggers system)==&lt;br /&gt;
Triggers are a development feature to execute personalized code during a Dolibarr &amp;quot;business event&amp;quot; (creation of an invoice, deleting a user, update of third party, etc...), and only for a business event. To personalize code for other contexts, see the &#039;&#039;&#039;Hooks system&#039;&#039;&#039; chapter instead.&lt;br /&gt;
&lt;br /&gt;
For triggers usage, see [[Interfaces Dolibarr toward foreign systems|this page]].&lt;br /&gt;
&lt;br /&gt;
==フックシステム (Hooks system)==&lt;br /&gt;
See [[Hooks system]] &lt;br /&gt;
&lt;br /&gt;
==変数置換システム (Variable substitution system)==&lt;br /&gt;
See [[Variable substitution system]] &lt;br /&gt;
&lt;br /&gt;
==ウェブサービス (Web services)==&lt;br /&gt;
Dolibarr can be setup to provide some services.&lt;br /&gt;
&lt;br /&gt;
See [[Module Web Services API REST (developer)]] &lt;br /&gt;
&lt;br /&gt;
Note: The [[Module Web Services API SOAP (developer)]] is deprecated.&lt;br /&gt;
&lt;br /&gt;
==ファイル/書類 ストレージ管理 (Files/Documents storage management)==&lt;br /&gt;
See [[Generated documents]] &lt;br /&gt;
&lt;br /&gt;
==番号付けモジュール (Numbering modules)==&lt;br /&gt;
For each entity created in the application, Dolibarr assigns a reference. In order to adapt the reference to any use, Dolibarr use modules to define the reference generation rule. Several standard modules are supplied. Some are generic and are used to define the numbering mask (number on x characters, with or without prefix, including the date or not, etc.), which can meet most needs. However, there are still cases where the modules provided don&#039;t meet the needs. In this case it is necessary to develop a custom numbering module.&lt;br /&gt;
&lt;br /&gt;
For more information, see [[Create numeration module|Create numbering module]].&lt;br /&gt;
&lt;br /&gt;
==文書テンプレートと文書生成 (Document templates and documents generation)==&lt;br /&gt;
&lt;br /&gt;
More documentation about document generation from templates is available to [[Create a PDF document template]] or [[Create an ODT document template]].&lt;br /&gt;
&lt;br /&gt;
==エクストラフィールド (Extrafields)==&lt;br /&gt;
See [[Extrafields]]&lt;br /&gt;
&lt;br /&gt;
==オンライン決済システム (Online payment system)==&lt;br /&gt;
See [[Online payment system]]&lt;br /&gt;
&lt;br /&gt;
==他内部機能 (Other internal function)==&lt;br /&gt;
There are many internal libraries your code can use.&lt;br /&gt;
You may find a lot of generic functions in the functions.lib.php, functions2.lib.php or admin.lib.php. Any function found in htdocs/core/lib/*.lib files can be used.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;To specify a requirement based on Dolibarr version number&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For example, to make a condition based on requiring Dolibarr version &amp;gt; 3.5, you can use versioncompare and versiondolibarrarray found in admin.lib.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
if (versioncompare(versiondolibarrarray(), array(3,5,0)) &amp;gt; 0)&lt;br /&gt;
{&lt;br /&gt;
 ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=大量 エクスポート/インポート (Mass exports/imports)=&lt;br /&gt;
&lt;br /&gt;
#[[Mass imports]]&lt;br /&gt;
#[[Module Exports En|Mass exports]]&lt;br /&gt;
&lt;br /&gt;
=他のアプリとのインタフェースやリンク (Interfaces and links with other applications)=&lt;br /&gt;
&lt;br /&gt;
#[[Interfaces Dolibarr toward foreign systems]] or Dolibarr toward Dolibarr (Dolibarr Triggers or Hooks)&lt;br /&gt;
#[[Interfaces from foreign systems toward Dolibarr]]&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
All FAQs are available through the FAQ index page [[:Category:FAQ EN|FAQ EN]]&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=JA_Developer_documentation&amp;diff=56361</id>
		<title>JA Developer documentation</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=JA_Developer_documentation&amp;diff=56361"/>
		<updated>2023-04-26T11:08:52Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: /* ビジネスオブジェクト (Business objects) */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:開発者手引き}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;seo metak=&amp;quot;developer, development, documentation, guide, doc, tutorial, usage, help, api, coding, standard, rules&amp;quot; /&amp;gt;&lt;br /&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 : Developer_documentation --&amp;gt;&lt;br /&gt;
[[fr:Documentation_Développeur]]&lt;br /&gt;
[[es:Documentación_Desarrolladores]]&lt;br /&gt;
[[de:Entwickler_Dokumentation]]&lt;br /&gt;
[[zh:开发文档]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This page is main index of documents relating to developer documentation. For user documentation [[User documentation|see here]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=開発組織とツール=&lt;br /&gt;
This chapter contains global information that must be read before starting any development on Dolibarr.&lt;br /&gt;
&lt;br /&gt;
#[[Dolibarr Project|Organization of project]]&lt;br /&gt;
#[[To known before to start|To be known before starting to develop]]&lt;br /&gt;
#[[Environment and development tools]]&lt;br /&gt;
#[[Dependencies and external libraries]]&lt;br /&gt;
#[[FAQ_Get,update_project_sources|Get or update sources of a development version]]&lt;br /&gt;
&lt;br /&gt;
=コーディング規約とベストプラクティス=&lt;br /&gt;
&lt;br /&gt;
#[[Prerequisite|Prerequisites]]&lt;br /&gt;
#[[Language and development rules|Language and development rules (PHP, SQL, HTML)]]&lt;br /&gt;
#[[:Category:Table SQL|List of tables]]&lt;br /&gt;
#Tree structure of files and classes are available in the [http://doxygen.dolibarr.org/ doxygen generated documentation]&lt;br /&gt;
&lt;br /&gt;
=モジュールリスト=&lt;br /&gt;
Technical documentation on standard business modules is available in each module&#039;s developer documentation pages. Choose the appropriate page you are interested in:&lt;br /&gt;
&lt;br /&gt;
*[[:Category:List of Modules (developer)‎|List of standard modules]]&lt;br /&gt;
*[[:Category:Complementary modules|List of complementary modules]]&lt;br /&gt;
&lt;br /&gt;
=GUI 向けの新 モジュール/アドオン を作るには=&lt;br /&gt;
This section describes how to develop a new module changing the Dolibarr user interface. This can be screens, themes, data, its own CSS stylesheet, source code or all of this.&lt;br /&gt;
&lt;br /&gt;
Script development is not included in this section (this is described in the next chapter).&lt;br /&gt;
&lt;br /&gt;
To develop your own module, check the [[Module development]] tutorial.&lt;br /&gt;
&lt;br /&gt;
=バッチまたはコマンドラインスクリプトを作るには=&lt;br /&gt;
This chapter describes how to develop command line scripts to execute tasks in Dolibarr (read, update data...).&lt;br /&gt;
&lt;br /&gt;
Making modifications to the graphical user interface (GUI) is not included in this chapter. See the previous chapter for this.&lt;br /&gt;
&lt;br /&gt;
To develop a script, like a cron script or a command line import tool to import data from an external source, you can have a look at the [[Script development]] page.&lt;br /&gt;
&lt;br /&gt;
=Dolibarr の技術的要素 (Technical components)=&lt;br /&gt;
==ツリー構造 (Tree structure)==&lt;br /&gt;
The path hierarchy of the current version files is available from the [http://doxygen.dolibarr.org/ doxygen generated documentation] (similar to generated &amp;quot;javadoc&amp;quot; documentation).&lt;br /&gt;
&lt;br /&gt;
Paths to use to add new files by a new module are defined in the documentation to develop a new module (see [[Module development]]).&lt;br /&gt;
&lt;br /&gt;
==ストレージ準備 (Setup storage)==&lt;br /&gt;
There are 3 places for Dolibarr setup parameters.&lt;br /&gt;
&lt;br /&gt;
*Dolibarr technical setup parameters (authentication mode, database logins and storage area for files) are defined in only one setup file: &amp;lt;code&amp;gt;/conf/conf.php&amp;lt;/code&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
:See [[Configuration file]] for more information.&lt;br /&gt;
&lt;br /&gt;
*Global features parameters are stored in [[Table llx_const]].&lt;br /&gt;
&lt;br /&gt;
:See the [[Constants]] page for more information.&lt;br /&gt;
&lt;br /&gt;
*Feature parameters specific to a user are stored in [[Table llx_user_param]].&lt;br /&gt;
&lt;br /&gt;
==ビジネスオブジェクト (Business objects)==&lt;br /&gt;
See [[ビジネス オブジェクト|ビジネスオブジェクト]] &lt;br /&gt;
&lt;br /&gt;
==メニューシステム (Menu system)==&lt;br /&gt;
See [[Menus system]] &lt;br /&gt;
&lt;br /&gt;
==タブシステム (Tabs system)==&lt;br /&gt;
See [[Tabs system]] &lt;br /&gt;
&lt;br /&gt;
==スキンシステム (Skins system)==&lt;br /&gt;
See [[Skins]] &lt;br /&gt;
&lt;br /&gt;
==ウィジェットシステム (Widget system)==&lt;br /&gt;
See [[Widget system]]&lt;br /&gt;
&lt;br /&gt;
==認証システム (Authentication system)==&lt;br /&gt;
See [[Authentication]] &lt;br /&gt;
&lt;br /&gt;
==許可システム (Permission system)==&lt;br /&gt;
See [[Permissions En|Permissions]] &lt;br /&gt;
&lt;br /&gt;
==翻訳システム (Translation system)==&lt;br /&gt;
See [[Translation system]] &lt;br /&gt;
&lt;br /&gt;
==エラー管理 (Error management)==&lt;br /&gt;
See [[Error reporting|Error reporting]] &lt;br /&gt;
&lt;br /&gt;
==キャンバスシステム (Canvas system)==&lt;br /&gt;
Canvas is a developer feature to replace screens to create, update or view a record (products, thirdparties, contacts, ...). For example, you can replace the input form used to create a new third party, or its editing form, or replace its viewing template.&lt;br /&gt;
 &lt;br /&gt;
See [[Canvas development]] &lt;br /&gt;
&lt;br /&gt;
==トリガーシステム (Triggers system)==&lt;br /&gt;
Triggers are a development feature to execute personalized code during a Dolibarr &amp;quot;business event&amp;quot; (creation of an invoice, deleting a user, update of third party, etc...), and only for a business event. To personalize code for other contexts, see the &#039;&#039;&#039;Hooks system&#039;&#039;&#039; chapter instead.&lt;br /&gt;
&lt;br /&gt;
For triggers usage, see [[Interfaces Dolibarr toward foreign systems|this page]].&lt;br /&gt;
&lt;br /&gt;
==フックシステム (Hooks system)==&lt;br /&gt;
See [[Hooks system]] &lt;br /&gt;
&lt;br /&gt;
==変数置換システム (Variable substitution system)==&lt;br /&gt;
See [[Variable substitution system]] &lt;br /&gt;
&lt;br /&gt;
==ウェブサービス (Web services)==&lt;br /&gt;
Dolibarr can be setup to provide some services.&lt;br /&gt;
&lt;br /&gt;
See [[Module Web Services API REST (developer)]] &lt;br /&gt;
&lt;br /&gt;
Note: The [[Module Web Services API SOAP (developer)]] is deprecated.&lt;br /&gt;
&lt;br /&gt;
==ファイル/書類 ストレージ管理 (Files/Documents storage management)==&lt;br /&gt;
See [[Generated documents]] &lt;br /&gt;
&lt;br /&gt;
==番号付けモジュール (Numbering modules)==&lt;br /&gt;
For each entity created in the application, Dolibarr assigns a reference. In order to adapt the reference to any use, Dolibarr use modules to define the reference generation rule. Several standard modules are supplied. Some are generic and are used to define the numbering mask (number on x characters, with or without prefix, including the date or not, etc.), which can meet most needs. However, there are still cases where the modules provided don&#039;t meet the needs. In this case it is necessary to develop a custom numbering module.&lt;br /&gt;
&lt;br /&gt;
For more information, see [[Create numeration module|Create numbering module]].&lt;br /&gt;
&lt;br /&gt;
==文書テンプレートと文書生成 (Document templates and documents generation)==&lt;br /&gt;
&lt;br /&gt;
More documentation about document generation from templates is available to [[Create a PDF document template]] or [[Create an ODT document template]].&lt;br /&gt;
&lt;br /&gt;
==エクストラフィールド (Extrafields)==&lt;br /&gt;
See [[Extrafields]]&lt;br /&gt;
&lt;br /&gt;
==オンライン決済システム (Online payment system)==&lt;br /&gt;
See [[Online payment system]]&lt;br /&gt;
&lt;br /&gt;
==他内部機能 (Other internal function)==&lt;br /&gt;
There are many internal libraries your code can use.&lt;br /&gt;
You may find a lot of generic functions in the functions.lib.php, functions2.lib.php or admin.lib.php. Any function found in htdocs/core/lib/*.lib files can be used.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;To specify a requirement based on Dolibarr version number&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For example, to make a condition based on requiring Dolibarr version &amp;gt; 3.5, you can use versioncompare and versiondolibarrarray found in admin.lib.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
if (versioncompare(versiondolibarrarray(), array(3,5,0)) &amp;gt; 0)&lt;br /&gt;
{&lt;br /&gt;
 ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=大量 エクスポート/インポート (Mass exports/imports)=&lt;br /&gt;
&lt;br /&gt;
#[[Mass imports]]&lt;br /&gt;
#[[Module Exports En|Mass exports]]&lt;br /&gt;
&lt;br /&gt;
=他のアプリとのインタフェースやリンク (Interfaces and links with other applications)=&lt;br /&gt;
&lt;br /&gt;
#[[Interfaces Dolibarr toward foreign systems]] or Dolibarr toward Dolibarr (Dolibarr Triggers or Hooks)&lt;br /&gt;
#[[Interfaces from foreign systems toward Dolibarr]]&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
All FAQs are available through the FAQ index page [[:Category:FAQ EN|FAQ EN]]&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=JA_Developer_documentation&amp;diff=56360</id>
		<title>JA Developer documentation</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=JA_Developer_documentation&amp;diff=56360"/>
		<updated>2023-04-26T11:07:22Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: 見出し翻訳&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{DISPLAYTITLE:開発者手引き}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;seo metak=&amp;quot;developer, development, documentation, guide, doc, tutorial, usage, help, api, coding, standard, rules&amp;quot; /&amp;gt;&lt;br /&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 : Developer_documentation --&amp;gt;&lt;br /&gt;
[[fr:Documentation_Développeur]]&lt;br /&gt;
[[es:Documentación_Desarrolladores]]&lt;br /&gt;
[[de:Entwickler_Dokumentation]]&lt;br /&gt;
[[zh:开发文档]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This page is main index of documents relating to developer documentation. For user documentation [[User documentation|see here]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=開発組織とツール=&lt;br /&gt;
This chapter contains global information that must be read before starting any development on Dolibarr.&lt;br /&gt;
&lt;br /&gt;
#[[Dolibarr Project|Organization of project]]&lt;br /&gt;
#[[To known before to start|To be known before starting to develop]]&lt;br /&gt;
#[[Environment and development tools]]&lt;br /&gt;
#[[Dependencies and external libraries]]&lt;br /&gt;
#[[FAQ_Get,update_project_sources|Get or update sources of a development version]]&lt;br /&gt;
&lt;br /&gt;
=コーディング規約とベストプラクティス=&lt;br /&gt;
&lt;br /&gt;
#[[Prerequisite|Prerequisites]]&lt;br /&gt;
#[[Language and development rules|Language and development rules (PHP, SQL, HTML)]]&lt;br /&gt;
#[[:Category:Table SQL|List of tables]]&lt;br /&gt;
#Tree structure of files and classes are available in the [http://doxygen.dolibarr.org/ doxygen generated documentation]&lt;br /&gt;
&lt;br /&gt;
=モジュールリスト=&lt;br /&gt;
Technical documentation on standard business modules is available in each module&#039;s developer documentation pages. Choose the appropriate page you are interested in:&lt;br /&gt;
&lt;br /&gt;
*[[:Category:List of Modules (developer)‎|List of standard modules]]&lt;br /&gt;
*[[:Category:Complementary modules|List of complementary modules]]&lt;br /&gt;
&lt;br /&gt;
=GUI 向けの新 モジュール/アドオン を作るには=&lt;br /&gt;
This section describes how to develop a new module changing the Dolibarr user interface. This can be screens, themes, data, its own CSS stylesheet, source code or all of this.&lt;br /&gt;
&lt;br /&gt;
Script development is not included in this section (this is described in the next chapter).&lt;br /&gt;
&lt;br /&gt;
To develop your own module, check the [[Module development]] tutorial.&lt;br /&gt;
&lt;br /&gt;
=バッチまたはコマンドラインスクリプトを作るには=&lt;br /&gt;
This chapter describes how to develop command line scripts to execute tasks in Dolibarr (read, update data...).&lt;br /&gt;
&lt;br /&gt;
Making modifications to the graphical user interface (GUI) is not included in this chapter. See the previous chapter for this.&lt;br /&gt;
&lt;br /&gt;
To develop a script, like a cron script or a command line import tool to import data from an external source, you can have a look at the [[Script development]] page.&lt;br /&gt;
&lt;br /&gt;
=Dolibarr の技術的要素 (Technical components)=&lt;br /&gt;
==ツリー構造 (Tree structure)==&lt;br /&gt;
The path hierarchy of the current version files is available from the [http://doxygen.dolibarr.org/ doxygen generated documentation] (similar to generated &amp;quot;javadoc&amp;quot; documentation).&lt;br /&gt;
&lt;br /&gt;
Paths to use to add new files by a new module are defined in the documentation to develop a new module (see [[Module development]]).&lt;br /&gt;
&lt;br /&gt;
==ストレージ準備 (Setup storage)==&lt;br /&gt;
There are 3 places for Dolibarr setup parameters.&lt;br /&gt;
&lt;br /&gt;
*Dolibarr technical setup parameters (authentication mode, database logins and storage area for files) are defined in only one setup file: &amp;lt;code&amp;gt;/conf/conf.php&amp;lt;/code&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
:See [[Configuration file]] for more information.&lt;br /&gt;
&lt;br /&gt;
*Global features parameters are stored in [[Table llx_const]].&lt;br /&gt;
&lt;br /&gt;
:See the [[Constants]] page for more information.&lt;br /&gt;
&lt;br /&gt;
*Feature parameters specific to a user are stored in [[Table llx_user_param]].&lt;br /&gt;
&lt;br /&gt;
==ビジネスオブジェクト (Business objects)==&lt;br /&gt;
See [[ビジネスオブジェクト]] &lt;br /&gt;
&lt;br /&gt;
==メニューシステム (Menu system)==&lt;br /&gt;
See [[Menus system]] &lt;br /&gt;
&lt;br /&gt;
==タブシステム (Tabs system)==&lt;br /&gt;
See [[Tabs system]] &lt;br /&gt;
&lt;br /&gt;
==スキンシステム (Skins system)==&lt;br /&gt;
See [[Skins]] &lt;br /&gt;
&lt;br /&gt;
==ウィジェットシステム (Widget system)==&lt;br /&gt;
See [[Widget system]]&lt;br /&gt;
&lt;br /&gt;
==認証システム (Authentication system)==&lt;br /&gt;
See [[Authentication]] &lt;br /&gt;
&lt;br /&gt;
==許可システム (Permission system)==&lt;br /&gt;
See [[Permissions En|Permissions]] &lt;br /&gt;
&lt;br /&gt;
==翻訳システム (Translation system)==&lt;br /&gt;
See [[Translation system]] &lt;br /&gt;
&lt;br /&gt;
==エラー管理 (Error management)==&lt;br /&gt;
See [[Error reporting|Error reporting]] &lt;br /&gt;
&lt;br /&gt;
==キャンバスシステム (Canvas system)==&lt;br /&gt;
Canvas is a developer feature to replace screens to create, update or view a record (products, thirdparties, contacts, ...). For example, you can replace the input form used to create a new third party, or its editing form, or replace its viewing template.&lt;br /&gt;
 &lt;br /&gt;
See [[Canvas development]] &lt;br /&gt;
&lt;br /&gt;
==トリガーシステム (Triggers system)==&lt;br /&gt;
Triggers are a development feature to execute personalized code during a Dolibarr &amp;quot;business event&amp;quot; (creation of an invoice, deleting a user, update of third party, etc...), and only for a business event. To personalize code for other contexts, see the &#039;&#039;&#039;Hooks system&#039;&#039;&#039; chapter instead.&lt;br /&gt;
&lt;br /&gt;
For triggers usage, see [[Interfaces Dolibarr toward foreign systems|this page]].&lt;br /&gt;
&lt;br /&gt;
==フックシステム (Hooks system)==&lt;br /&gt;
See [[Hooks system]] &lt;br /&gt;
&lt;br /&gt;
==変数置換システム (Variable substitution system)==&lt;br /&gt;
See [[Variable substitution system]] &lt;br /&gt;
&lt;br /&gt;
==ウェブサービス (Web services)==&lt;br /&gt;
Dolibarr can be setup to provide some services.&lt;br /&gt;
&lt;br /&gt;
See [[Module Web Services API REST (developer)]] &lt;br /&gt;
&lt;br /&gt;
Note: The [[Module Web Services API SOAP (developer)]] is deprecated.&lt;br /&gt;
&lt;br /&gt;
==ファイル/書類 ストレージ管理 (Files/Documents storage management)==&lt;br /&gt;
See [[Generated documents]] &lt;br /&gt;
&lt;br /&gt;
==番号付けモジュール (Numbering modules)==&lt;br /&gt;
For each entity created in the application, Dolibarr assigns a reference. In order to adapt the reference to any use, Dolibarr use modules to define the reference generation rule. Several standard modules are supplied. Some are generic and are used to define the numbering mask (number on x characters, with or without prefix, including the date or not, etc.), which can meet most needs. However, there are still cases where the modules provided don&#039;t meet the needs. In this case it is necessary to develop a custom numbering module.&lt;br /&gt;
&lt;br /&gt;
For more information, see [[Create numeration module|Create numbering module]].&lt;br /&gt;
&lt;br /&gt;
==文書テンプレートと文書生成 (Document templates and documents generation)==&lt;br /&gt;
&lt;br /&gt;
More documentation about document generation from templates is available to [[Create a PDF document template]] or [[Create an ODT document template]].&lt;br /&gt;
&lt;br /&gt;
==エクストラフィールド (Extrafields)==&lt;br /&gt;
See [[Extrafields]]&lt;br /&gt;
&lt;br /&gt;
==オンライン決済システム (Online payment system)==&lt;br /&gt;
See [[Online payment system]]&lt;br /&gt;
&lt;br /&gt;
==他内部機能 (Other internal function)==&lt;br /&gt;
There are many internal libraries your code can use.&lt;br /&gt;
You may find a lot of generic functions in the functions.lib.php, functions2.lib.php or admin.lib.php. Any function found in htdocs/core/lib/*.lib files can be used.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;To specify a requirement based on Dolibarr version number&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For example, to make a condition based on requiring Dolibarr version &amp;gt; 3.5, you can use versioncompare and versiondolibarrarray found in admin.lib.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;PHP&amp;quot;&amp;gt;&lt;br /&gt;
if (versioncompare(versiondolibarrarray(), array(3,5,0)) &amp;gt; 0)&lt;br /&gt;
{&lt;br /&gt;
 ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=大量 エクスポート/インポート (Mass exports/imports)=&lt;br /&gt;
&lt;br /&gt;
#[[Mass imports]]&lt;br /&gt;
#[[Module Exports En|Mass exports]]&lt;br /&gt;
&lt;br /&gt;
=他のアプリとのインタフェースやリンク (Interfaces and links with other applications)=&lt;br /&gt;
&lt;br /&gt;
#[[Interfaces Dolibarr toward foreign systems]] or Dolibarr toward Dolibarr (Dolibarr Triggers or Hooks)&lt;br /&gt;
#[[Interfaces from foreign systems toward Dolibarr]]&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
All FAQs are available through the FAQ index page [[:Category:FAQ EN|FAQ EN]]&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=JA_Developer_documentation&amp;diff=56359</id>
		<title>JA Developer documentation</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=JA_Developer_documentation&amp;diff=56359"/>
		<updated>2023-04-26T10:48:43Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: Duplicate From En page&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&amp;lt;seo metak=&amp;quot;developer, development, documentation, guide, doc, tutorial, usage, help, api, coding, standard, rules&amp;quot; /&amp;gt;&lt;br /&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 : Developer_documentation --&amp;gt;&lt;br /&gt;
[[fr:Documentation_Développeur]]&lt;br /&gt;
[[es:Documentación_Desarrolladores]]&lt;br /&gt;
[[de:Entwickler_Dokumentation]]&lt;br /&gt;
[[zh:开发文档]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This page is main index of documents relating to developer documentation. For user documentation [[User documentation|see here]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Development organization and tools=&lt;br /&gt;
This chapter contains global information that must be read before starting any development on Dolibarr.&lt;br /&gt;
&lt;br /&gt;
#[[Dolibarr Project|Organization of project]]&lt;br /&gt;
#[[To known before to start|To be known before starting to develop]]&lt;br /&gt;
#[[Environment and development tools]]&lt;br /&gt;
#[[Dependencies and external libraries]]&lt;br /&gt;
#[[FAQ_Get,update_project_sources|Get or update sources of a development version]]&lt;br /&gt;
&lt;br /&gt;
=Coding rules and best practices=&lt;br /&gt;
&lt;br /&gt;
#[[Prerequisite|Prerequisites]]&lt;br /&gt;
#[[Language and development rules|Language and development rules (PHP, SQL, HTML)]]&lt;br /&gt;
#[[:Category:Table SQL|List of tables]]&lt;br /&gt;
#Tree structure of files and classes are available in the [http://doxygen.dolibarr.org/ doxygen generated documentation]&lt;br /&gt;
&lt;br /&gt;
=List of modules=&lt;br /&gt;
Technical documentation on standard business modules is available in each module&#039;s developer documentation pages. Choose the appropriate page you are interested in:&lt;br /&gt;
&lt;br /&gt;
*[[:Category:List of Modules (developer)‎|List of standard modules]]&lt;br /&gt;
*[[:Category:Complementary modules|List of complementary modules]]&lt;br /&gt;
&lt;br /&gt;
=To develop a new module/addon for GUI=&lt;br /&gt;
This section describes how to develop a new module changing the Dolibarr user interface. This can be screens, themes, data, its own CSS stylesheet, source code or all of this.&lt;br /&gt;
&lt;br /&gt;
Script development is not included in this section (this is described in the next chapter).&lt;br /&gt;
&lt;br /&gt;
To develop your own module, check the [[Module development]] tutorial.&lt;br /&gt;
&lt;br /&gt;
=To develop a batch or command line script=&lt;br /&gt;
This chapter describes how to develop command line scripts to execute tasks in Dolibarr (read, update data...).&lt;br /&gt;
&lt;br /&gt;
Making modifications to the graphical user interface (GUI) is not included in this chapter. See the previous chapter for this.&lt;br /&gt;
&lt;br /&gt;
To develop a script, like a cron script or a command line import tool to import data from an external source, you can have a look at the [[Script development]] page.&lt;br /&gt;
&lt;br /&gt;
=Technical components of Dolibarr=&lt;br /&gt;
==Tree structure==&lt;br /&gt;
The path hierarchy of the current version files is available from the [http://doxygen.dolibarr.org/ doxygen generated documentation] (similar to generated &amp;quot;javadoc&amp;quot; documentation).&lt;br /&gt;
&lt;br /&gt;
Paths to use to add new files by a new module are defined in the documentation to develop a new module (see [[Module development]]).&lt;br /&gt;
&lt;br /&gt;
==Setup storage==&lt;br /&gt;
There are 3 places for Dolibarr setup parameters.&lt;br /&gt;
&lt;br /&gt;
*Dolibarr technical setup parameters (authentication mode, database logins and storage area for files) are defined in only one setup file: &amp;lt;code&amp;gt;/conf/conf.php&amp;lt;/code&amp;gt; .&lt;br /&gt;
&lt;br /&gt;
:See [[Configuration file]] for more information.&lt;br /&gt;
&lt;br /&gt;
*Global features parameters are stored in [[Table llx_const]].&lt;br /&gt;
&lt;br /&gt;
:See the [[Constants]] page for more information.&lt;br /&gt;
&lt;br /&gt;
*Feature parameters specific to a user are stored in [[Table llx_user_param]].&lt;br /&gt;
&lt;br /&gt;
==Business objects==&lt;br /&gt;
See [[Business Objects]] &lt;br /&gt;
&lt;br /&gt;
==Menus system==&lt;br /&gt;
See [[Menus system]] &lt;br /&gt;
&lt;br /&gt;
==Tabs system==&lt;br /&gt;
See [[Tabs system]] &lt;br /&gt;
&lt;br /&gt;
==Skins system==&lt;br /&gt;
See [[Skins]] &lt;br /&gt;
&lt;br /&gt;
==Widget system==&lt;br /&gt;
See [[Widget system]]&lt;br /&gt;
&lt;br /&gt;
==Authentication system==&lt;br /&gt;
See [[Authentication]] &lt;br /&gt;
&lt;br /&gt;
==Permission system==&lt;br /&gt;
See [[Permissions En|Permissions]] &lt;br /&gt;
&lt;br /&gt;
==Translation system==&lt;br /&gt;
See [[Translation system]] &lt;br /&gt;
&lt;br /&gt;
==Error management==&lt;br /&gt;
See [[Error reporting|Error reporting]] &lt;br /&gt;
&lt;br /&gt;
==Canvas system==&lt;br /&gt;
Canvas is a developer feature to replace screens to create, update or view a record (products, thirdparties, contacts, ...). For example, you can replace the input form used to create a new third party, or its editing form, or replace its viewing template.&lt;br /&gt;
 &lt;br /&gt;
See [[Canvas development]] &lt;br /&gt;
&lt;br /&gt;
==Triggers system==&lt;br /&gt;
Triggers are a development feature to execute personalized code during a Dolibarr &amp;quot;business event&amp;quot; (creation of an invoice, deleting a user, update of third party, etc...), and only for a business event. To personalize code for other contexts, see the &#039;&#039;&#039;Hooks system&#039;&#039;&#039; chapter instead.&lt;br /&gt;
&lt;br /&gt;
For triggers usage, see [[Interfaces Dolibarr toward foreign systems|this page]].&lt;br /&gt;
&lt;br /&gt;
==Hooks system==&lt;br /&gt;
See [[Hooks system]] &lt;br /&gt;
&lt;br /&gt;
==Variable substitution system==&lt;br /&gt;
See [[Variable substitution system]] &lt;br /&gt;
&lt;br /&gt;
==Web services==&lt;br /&gt;
Dolibarr can be setup to provide some services.&lt;br /&gt;
&lt;br /&gt;
See [[Module Web Services API REST (developer)]] &lt;br /&gt;
&lt;br /&gt;
Note: The [[Module Web Services API SOAP (developer)]] is deprecated.&lt;br /&gt;
&lt;br /&gt;
==Files/Documents storage management==&lt;br /&gt;
See [[Generated documents]] &lt;br /&gt;
&lt;br /&gt;
==Numbering modules==&lt;br /&gt;
For each entity created in the application, Dolibarr assigns a reference. In order to adapt the reference to any use, Dolibarr use modules to define the reference generation rule. Several standard modules are supplied. Some are generic and are used to define the numbering mask (number on x characters, with or without prefix, including the date or not, etc.), which can meet most needs. However, there are still cases where the modules provided don&#039;t meet the needs. In this case it is necessary to develop a custom numbering module.&lt;br /&gt;
&lt;br /&gt;
For more information, see [[Create numeration module|Create numbering module]].&lt;br /&gt;
&lt;br /&gt;
==Document templates and documents generation==&lt;br /&gt;
&lt;br /&gt;
More documentation about document generation from templates is available to [[Create a PDF document template]] or [[Create an ODT document template]].&lt;br /&gt;
&lt;br /&gt;
==Extrafields==&lt;br /&gt;
See [[Extrafields]]&lt;br /&gt;
&lt;br /&gt;
==Online payment system==&lt;br /&gt;
See [[Online payment system]]&lt;br /&gt;
&lt;br /&gt;
==Other internal function==&lt;br /&gt;
There are many internal libraries your code can use.&lt;br /&gt;
You may find a lot of generic functions in the functions.lib.php, functions2.lib.php or admin.lib.php. Any function found in htdocs/core/lib/*.lib files can be used.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;To specify a requirement based on Dolibarr version number&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
For example, to make a condition based on requiring Dolibarr version &amp;gt; 3.5, you can use versioncompare and versiondolibarrarray found in admin.lib.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxHighlight lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
if (versioncompare(versiondolibarrarray(), array(3,5,0)) &amp;gt; 0)&lt;br /&gt;
{&lt;br /&gt;
 ...&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/syntaxHighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=Mass exports/imports=&lt;br /&gt;
&lt;br /&gt;
#[[Mass imports]]&lt;br /&gt;
#[[Module Exports En|Mass exports]]&lt;br /&gt;
&lt;br /&gt;
=Interfaces and links with other applications=&lt;br /&gt;
&lt;br /&gt;
#[[Interfaces Dolibarr toward foreign systems]] or Dolibarr toward Dolibarr (Dolibarr Triggers or Hooks)&lt;br /&gt;
#[[Interfaces from foreign systems toward Dolibarr]]&lt;br /&gt;
&lt;br /&gt;
=FAQ=&lt;br /&gt;
All FAQs are available through the FAQ index page [[:Category:FAQ EN|FAQ EN]]&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=Template:InfoJa&amp;diff=56358</id>
		<title>Template:InfoJa</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=Template:InfoJa&amp;diff=56358"/>
		<updated>2023-04-26T10:43:17Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: 日本語版Infoテンプレ&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:Template:InfoFr]]&lt;br /&gt;
[[es:Template:InfoEs]]&lt;br /&gt;
[[pt:Template:InfoPT]]&lt;br /&gt;
&amp;lt;!-- END interlang links --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
&amp;lt;div&amp;gt;&lt;br /&gt;
&amp;lt;table&amp;gt;&lt;br /&gt;
&amp;lt;tr&amp;gt;&amp;lt;td width=&amp;quot;200&amp;quot;&amp;gt;&lt;br /&gt;
Thanks to take time to vote for Dolibarr (category Best software for enterprises). Just click on following logo:&lt;br /&gt;
&amp;lt;/td&amp;gt;&amp;lt;td&amp;gt;&lt;br /&gt;
{{#rawmsg:form_vote_en}}&lt;br /&gt;
&amp;lt;/td&amp;gt;&lt;br /&gt;
&amp;lt;/tr&amp;gt;&lt;br /&gt;
&amp;lt;/table&amp;gt;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=%E3%83%93%E3%82%B8%E3%83%8D%E3%82%B9_%E3%82%AA%E3%83%96%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88&amp;diff=56357</id>
		<title>ビジネス オブジェクト</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=%E3%83%93%E3%82%B8%E3%83%8D%E3%82%B9_%E3%82%AA%E3%83%96%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88&amp;diff=56357"/>
		<updated>2023-04-26T10:08:23Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: 日本語本文&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TemplateDocDevEn}}&lt;br /&gt;
=ビジネスオブジェクト(Business objects)=&lt;br /&gt;
すべての ビジネスオブジェクト は、PHPのクラスであり、 CommonObject (定義ファイルは、 commonobject.class.php) を継承する.&lt;br /&gt;
それぞれの ビジネスオブジェクト は 4つの CRUD メソッドを持ち、データベースとの読み書きに使用できる:&lt;br /&gt;
&lt;br /&gt;
*作成(Create): create()&lt;br /&gt;
*読込(Read): fetch()&lt;br /&gt;
*更新(Update): update()&lt;br /&gt;
*削除(Delete): delete()&lt;br /&gt;
&lt;br /&gt;
後述の具体例を参照...&lt;br /&gt;
&lt;br /&gt;
=ビジネスオブジェクト間のリンク=&lt;br /&gt;
ビジネスオブジェトの中には、他のビジネスオブジェクトとリンクしているものもある。Dolibarr においては、テーブル [[Table llx_element_element]] を使うことで実現している. しかし他とリンクしているオブジェクトを取得するために、このテーブルを読む必要はない.&lt;br /&gt;
&lt;br /&gt;
ここで使い方を示す (Dolibarr 3.1 以上):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// get invoices from an already loaded order:&lt;br /&gt;
$result = $order-&amp;gt;fetchObjectLinked($order-&amp;gt;id, &#039;commande&#039;, null, &#039;facture&#039;);&lt;br /&gt;
if ($result &amp;lt;= 0) {&lt;br /&gt;
    // handle error&lt;br /&gt;
}&lt;br /&gt;
// important notice : the newly populated arrays are associative. Keys are llx_element_element row ids.&lt;br /&gt;
&lt;br /&gt;
// now if we expect only one linked invoice:&lt;br /&gt;
&lt;br /&gt;
// WRONG way to get it ($invoice_id will be NULL): &lt;br /&gt;
$invoice_id = $order-&amp;gt;linkedObjectsIds[&#039;facture&#039;][0]&lt;br /&gt;
&lt;br /&gt;
// CORRECT way ($invoice_id will hold the ID):&lt;br /&gt;
$invoice_id = array_values($order-&amp;gt;linkedObjectsIds[&#039;facture&#039;])[0]&lt;br /&gt;
&lt;br /&gt;
// Better (if there are more than one linked invoices) :&lt;br /&gt;
foreach ($order-&amp;gt;linkedObjectsIds[&#039;facture&#039;] as $element_element_id =&amp;gt; $facture_id) {&lt;br /&gt;
    // process it&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Dolibarr 3.1 より旧版:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// This load the array linked_object with objects that link to this one&lt;br /&gt;
$object-&amp;gt;load_object_linked($object-&amp;gt;id, $object-&amp;gt;element);&lt;br /&gt;
// To load array linked_object with objects that are linked by this one&lt;br /&gt;
$object-&amp;gt;load_object_linked($object-&amp;gt;id, $object-&amp;gt;element);&lt;br /&gt;
&lt;br /&gt;
// Then choose id with objects type you need&lt;br /&gt;
$org_order_array = $object-&amp;gt;linked_object[&amp;quot;commande&amp;quot;];&lt;br /&gt;
&lt;br /&gt;
// Now use them&lt;br /&gt;
$thelinkedobjectid = $org_order_array[0];&lt;br /&gt;
// new order instance&lt;br /&gt;
$thelinkedobject = new Commande($object-&amp;gt;db);&lt;br /&gt;
// load the object&lt;br /&gt;
$thelinkedobject-&amp;gt;fetch($thelinkedobjectid);&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;
新スクリプトや外部スクリプトを作る時、最初に他のものを作る前に:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
include(&#039;/pathofdolibarrhtdocs/master.inc.php&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This will initialize Dolibarr environment objects ($conf, $db, $lang and $user).&lt;br /&gt;
If we want that actions (create, update) are tagged with a particular user as the create/update user, we must do after the include of master.inc.php and before calling any create or update method&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$user-&amp;gt;fetch(0,&#039;loginuser&#039;);&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;
// We declare the class we want to use&lt;br /&gt;
include_once(&#039;/pathofdolibarrhtdocs/societe/class/societe.class.php&#039;);&lt;br /&gt;
&lt;br /&gt;
// We create an instance of object to manipulate&lt;br /&gt;
$mycompany = new Societe($db);&lt;br /&gt;
&lt;br /&gt;
// We set properties on object&lt;br /&gt;
$mycompany-&amp;gt;nom=&#039;Big Brother&#039;;&lt;br /&gt;
$mycompany-&amp;gt;client=1;&lt;br /&gt;
&lt;br /&gt;
// If we want that creation is tagged as done by a particular user &#039;loginuser&#039;,&lt;br /&gt;
// you must uncomment this line to load all characteristics of this user.&lt;br /&gt;
// If we keep the comment, Dolibarr will use null into fields that should store the create or update user.&lt;br /&gt;
// $user-&amp;gt;fetch(&#039;loginuser&#039;);&lt;br /&gt;
&lt;br /&gt;
// We call method to create&lt;br /&gt;
$id=$mycompany-&amp;gt;create($user);&lt;br /&gt;
&lt;br /&gt;
// This is to read/load an already created object&lt;br /&gt;
$mycompany-&amp;gt;fetch($id);&lt;br /&gt;
&lt;br /&gt;
// To update object&lt;br /&gt;
$mycompany-&amp;gt;nom=&#039;Big Brother 2&#039;;&lt;br /&gt;
$mycompany-&amp;gt;update($user);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==その他の事例==&lt;br /&gt;
他の事例を見つけるには、Dolibarr スナップショットの &#039;&#039;&#039;dev/samples&#039;&#039;&#039; ディレクトリを見るといいかも。そこには、Dolibarr オブジェクトの操作事例 (作成, 読込, 更新, 削除) があるはず .&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=%E3%83%93%E3%82%B8%E3%83%8D%E3%82%B9_%E3%82%AA%E3%83%96%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88&amp;diff=56356</id>
		<title>ビジネス オブジェクト</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=%E3%83%93%E3%82%B8%E3%83%8D%E3%82%B9_%E3%82%AA%E3%83%96%E3%82%B8%E3%82%A7%E3%82%AF%E3%83%88&amp;diff=56356"/>
		<updated>2023-04-26T06:39:58Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: WIP&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TemplateDocDevEn}}&lt;br /&gt;
=ビジネスオブジェクト(Business objects)=&lt;br /&gt;
すべての ビジネスオブジェクト は、PHPのクラスであり、 CommonObject (定義ファイルは、 commonobject.class.php) を継承する.&lt;br /&gt;
それぞれの ビジネスオブジェクト は 4つの CRUD メソッドを持ち、データベースとの読込と書込に使用できる:&lt;br /&gt;
&lt;br /&gt;
*作成(Create): create()&lt;br /&gt;
*読込(Read): fetch()&lt;br /&gt;
*更新(Update): update()&lt;br /&gt;
*書込(Delete): delete()&lt;br /&gt;
&lt;br /&gt;
後述の具体例を参照...&lt;br /&gt;
&lt;br /&gt;
=ビジネスオブジェクト間のリンク=&lt;br /&gt;
Some business objects are linked to other business objects. This is done in Dolibarr using the [[Table llx_element_element]]. But you don&#039;t have to read this table to get objects linked to another.&lt;br /&gt;
&lt;br /&gt;
Here is how you can use this (Dolibarr 3.1 and higher):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// get invoices from an already loaded order:&lt;br /&gt;
$result = $order-&amp;gt;fetchObjectLinked($order-&amp;gt;id, &#039;commande&#039;, null, &#039;facture&#039;);&lt;br /&gt;
if ($result &amp;lt;= 0) {&lt;br /&gt;
    // handle error&lt;br /&gt;
}&lt;br /&gt;
// important notice : the newly populated arrays are associative. Keys are llx_element_element row ids.&lt;br /&gt;
&lt;br /&gt;
// now if we expect only one linked invoice:&lt;br /&gt;
&lt;br /&gt;
// WRONG way to get it ($invoice_id will be NULL): &lt;br /&gt;
$invoice_id = $order-&amp;gt;linkedObjectsIds[&#039;facture&#039;][0]&lt;br /&gt;
&lt;br /&gt;
// CORRECT way ($invoice_id will hold the ID):&lt;br /&gt;
$invoice_id = array_values($order-&amp;gt;linkedObjectsIds[&#039;facture&#039;])[0]&lt;br /&gt;
&lt;br /&gt;
// Better (if there are more than one linked invoices) :&lt;br /&gt;
foreach ($order-&amp;gt;linkedObjectsIds[&#039;facture&#039;] as $element_element_id =&amp;gt; $facture_id) {&lt;br /&gt;
    // process it&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Prior to Dolibarr &amp;lt; 3.1:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// This load the array linked_object with objects that link to this one&lt;br /&gt;
$object-&amp;gt;load_object_linked($object-&amp;gt;id, $object-&amp;gt;element);&lt;br /&gt;
// To load array linked_object with objects that are linked by this one&lt;br /&gt;
$object-&amp;gt;load_object_linked($object-&amp;gt;id, $object-&amp;gt;element);&lt;br /&gt;
&lt;br /&gt;
// Then choose id with objects type you need&lt;br /&gt;
$org_order_array = $object-&amp;gt;linked_object[&amp;quot;commande&amp;quot;];&lt;br /&gt;
&lt;br /&gt;
// Now use them&lt;br /&gt;
$thelinkedobjectid = $org_order_array[0];&lt;br /&gt;
// new order instance&lt;br /&gt;
$thelinkedobject = new Commande($object-&amp;gt;db);&lt;br /&gt;
// load the object&lt;br /&gt;
$thelinkedobject-&amp;gt;fetch($thelinkedobjectid);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=具体例=&lt;br /&gt;
&lt;br /&gt;
==取引先に対する具体例==&lt;br /&gt;
Here is an example for the creation of a third party (eg customer company):&lt;br /&gt;
&lt;br /&gt;
If we make a new script or an external script, we must add at the beginning, before making anything else:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
include(&#039;/pathofdolibarrhtdocs/master.inc.php&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This will initialize Dolibarr environment objects ($conf, $db, $lang and $user).&lt;br /&gt;
If we want that actions (create, update) are tagged with a particular user as the create/update user, we must do after the include of master.inc.php and before calling any create or update method&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$user-&amp;gt;fetch(0,&#039;loginuser&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Now we can make our business code.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// We declare the class we want to use&lt;br /&gt;
include_once(&#039;/pathofdolibarrhtdocs/societe/class/societe.class.php&#039;);&lt;br /&gt;
&lt;br /&gt;
// We create an instance of object to manipulate&lt;br /&gt;
$mycompany = new Societe($db);&lt;br /&gt;
&lt;br /&gt;
// We set properties on object&lt;br /&gt;
$mycompany-&amp;gt;nom=&#039;Big Brother&#039;;&lt;br /&gt;
$mycompany-&amp;gt;client=1;&lt;br /&gt;
&lt;br /&gt;
// If we want that creation is tagged as done by a particular user &#039;loginuser&#039;,&lt;br /&gt;
// you must uncomment this line to load all characteristics of this user.&lt;br /&gt;
// If we keep the comment, Dolibarr will use null into fields that should store the create or update user.&lt;br /&gt;
// $user-&amp;gt;fetch(&#039;loginuser&#039;);&lt;br /&gt;
&lt;br /&gt;
// We call method to create&lt;br /&gt;
$id=$mycompany-&amp;gt;create($user);&lt;br /&gt;
&lt;br /&gt;
// This is to read/load an already created object&lt;br /&gt;
$mycompany-&amp;gt;fetch($id);&lt;br /&gt;
&lt;br /&gt;
// To update object&lt;br /&gt;
$mycompany-&amp;gt;nom=&#039;Big Brother 2&#039;;&lt;br /&gt;
$mycompany-&amp;gt;update($user);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==その他の具体例==&lt;br /&gt;
You may find other example for manipulating Dolibarr objects (Create, Read, Update, Delete) into directory &#039;&#039;&#039;dev/samples&#039;&#039;&#039; of Dolibarr snapshot.&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=Template:ActivationModuleJa&amp;diff=48500</id>
		<title>Template:ActivationModuleJa</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=Template:ActivationModuleJa&amp;diff=48500"/>
		<updated>2020-10-08T13:33:46Z</updated>

		<summary type="html">&lt;p&gt;Cin TAKE: Translated to Japanese&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;このモジュールを使うには、初めに管理者アカウントで入ってモジュールを有効化すること、使うメニューは &amp;quot;&#039;&#039;&#039;ホーム - 設定 - モジュール&#039;&#039;&#039;&amp;quot; 。&lt;br /&gt;
&lt;br /&gt;
一覧からモジュールのタブを選択し、 &amp;quot;&#039;&#039;&#039;有効化(Activate)&#039;&#039;&#039;&amp;quot; をクリック。&lt;br /&gt;
&lt;br /&gt;
これでモジュールが活性化される。&lt;br /&gt;
&lt;br /&gt;
もし、アイコンがモジュールの行末に表示される場合は、それをクリックして、当該モジュール専用の設定ページにアクセスすること。&lt;/div&gt;</summary>
		<author><name>Cin TAKE</name></author>
	</entry>
</feed>