Changes

Jump to navigation Jump to search
Line 12: Line 12:     
To create a new module/addon for Dolibarr, there is several steps. This tutorial will describe you each of them to build a module to extend Dolibarr features, like one or several of the following :
 
To create a new module/addon for Dolibarr, there is several steps. This tutorial will describe you each of them to build a module to extend Dolibarr features, like one or several of the following :
* Add new tables in database
+
 
* Add your own menu entries
+
*Add new tables in database
* Add new screens to edit new tables
+
*Add your own menu entries
* Add or remove tabs on object view (invoice, product, order, event, ...)
+
*Add new screens to edit new tables
* Add predefined exports for the internal export tool
+
*Add or remove tabs on object view (invoice, product, order, event, ...)
* Add new information boxes in the home page
+
*Add predefined exports for the internal export tool
* Add new substitutions variables
+
*Add new information boxes in the home page
* Define new permissions
+
*Add new substitutions variables
* Execute code automatically triggered by a particular Dolibarr action
+
*Define new permissions
* Insert your code inside Dolibarr hooks positions
+
*Execute code automatically triggered by a particular Dolibarr action
* Add your numbering module
+
*Insert your code inside Dolibarr hooks positions
* Add a new document template
+
*Add your numbering module
* Add a new skin
+
*Add a new document template
 +
*Add a new skin
 +
 
 
etc...
 
etc...
   Line 35: Line 37:  
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]
 
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]
   −
=Create your module =
+
=Create your module=
== Create a Module descriptor for your Module (required) ==
+
==Create a Module descriptor for your Module (required)==
 
'''When it is required''': Required as soon as an addon is developed, whatever its goal is (except for adding a skin).
 
'''When it is required''': Required as soon as an addon is developed, whatever its goal is (except for adding a skin).
    
'''Since Dolibarr 9.0, you should use the ModuleBuilder module provided as a standard module to generate the module descriptor'''
 
'''Since Dolibarr 9.0, you should use the ModuleBuilder module provided as a standard module to generate the module descriptor'''
   −
=== Create your module descriptor ===
+
===Create your module descriptor===
 
The first step is to create a file descriptor for the module.  
 
The first step is to create a file descriptor for the module.  
* Create directory '''/htdocs/''mymodule''/core/modules'''. Then copy the file modMyModule.class.php from the directory dev/skeletons into this directory '''htdocs/''mymodule''/core/modules'''. 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 'mod' and end with .class.php (for example if you want to give the name 'NewName' to this file, then the name should be 'modNewName.class.php').
+
 
 +
*Create directory '''/htdocs/''mymodule''/core/modules'''. Then copy the file modMyModule.class.php from the directory dev/skeletons into this directory '''htdocs/''mymodule''/core/modules'''. 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 'mod' and end with .class.php (for example if you want to give the name 'NewName' to this file, then the name should be 'modNewName.class.php').
 +
 
 
Next modify the contents of this file as follows:
 
Next modify the contents of this file as follows:
* Replace all "modMyModule" with a value which corresponds to the purpose of your module. This value must always start with 'mod' and contain only alpha characters (again, if the name given to the file was 'NewName', then replace all "modMyModule" with "modNewName").
+
 
* Change the number in: $this->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]].
+
*Replace all "modMyModule" with a value which corresponds to the purpose of your module. This value must always start with 'mod' and contain only alpha characters (again, if the name given to the file was 'NewName', then replace all "modMyModule" with "modNewName").
* Modify any other variables defined in the constructor (see comment in the code skeleton for their meaning).  
+
*Change the number in: $this->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]].
 +
*Modify any other variables defined in the constructor (see comment in the code skeleton for their meaning).
 +
 
 
Your file descriptor for your module is ready. See the next step to activate it.
 
Your file descriptor for your module is ready. See the next step to activate it.
   −
=== Test your descriptor ===
+
===Test your descriptor===
    
Launch Dolibarr and go to page '''Setup->module'''?  
 
Launch Dolibarr and go to page '''Setup->module'''?  
 
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 "develop" or "experiental", to see your module, you must first go into '''Setup-Others''' and set MAIN_FEATURES_LEVEL to 1 to see "experimental" modules or 2 to see "development" modules.
 
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 "develop" or "experiental", to see your module, you must first go into '''Setup-Others''' and set MAIN_FEATURES_LEVEL to 1 to see "experimental" modules or 2 to see "development" modules.
   −
== Tree of path for new module files (required) ==
+
==Tree of path for new module files (required)==
 
This is how your files must be organized when building a new module (the zip file must also match this rule).
 
This is how your files must be organized when building a new module (the zip file must also match this rule).
 
Note: Only the second line is mandatory.
 
Note: Only the second line is mandatory.
Line 61: Line 67:  
{{TemplateModuleTreeSimple}}
 
{{TemplateModuleTreeSimple}}
   −
== Create your SQL tables and the PHP DAO class (optional) ==
+
==Create your SQL tables and the PHP DAO class (optional)==
 
'''When''': If your module needs to manage data of its own
 
'''When''': If your module needs to manage data of its own
   −
=== Create your .sql file ===
+
===Create your .sql file===
 
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.
 
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.
   Line 76: Line 82:     
''Rules to follow:''
 
''Rules to follow:''
* Add the files about creating tables commands on the principle of a file '''llx_matable.sql''' per table, with a possibly file '''llx_matable.key.sql''' (see existing files in '''install/mysql/tables''' for examples).
+
 
* The recommended type and name for SQL fields are defined into page [[Language_and_development_rules#Table_and_fields_structures]].
+
*Add the files about creating tables commands on the principle of a file '''llx_matable.sql''' per table, with a possibly file '''llx_matable.key.sql''' (see existing files in '''install/mysql/tables''' for examples).
* To manage data, you must create a file called '''data.sql''' inside directory '''/mymodule/sql/''' that contains SQL command to add/edit/delete data.
+
*The recommended type and name for SQL fields are defined into page [[Language_and_development_rules#Table_and_fields_structures]].
* Don't use the double quote for strings (eg 'chaine' not "chaine") because the double quote have a specific meaning in PostGreSQL
+
*To manage data, you must create a file called '''data.sql''' inside directory '''/mymodule/sql/''' that contains SQL command to add/edit/delete data.
 +
*Don't use the double quote for strings (eg 'chaine' not "chaine") because the double quote have a specific meaning in PostGreSQL
 +
 
 
Example of content of a file data.sql
 
Example of content of a file data.sql
 
<source lang="sql">
 
<source lang="sql">
Line 88: Line 96:  
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.
 
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.
   −
=== Test your .sql files ===
+
===Test your .sql files===
    
Once the files ready, you can return to Dolibarr to disable the module, drop those tables in the database 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.
 
Once the files ready, you can return to Dolibarr to disable the module, drop those tables in the database 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.
   −
=== Generate the PHP DAO class ===
+
===Generate the PHP DAO class===
 
Once you have created your tables into the database, move to the dev/skeletons directory and run the script
 
Once you have created your tables into the database, move to the dev/skeletons directory and run the script
   Line 106: Line 114:  
'''Since Dolibarr 6.0, the file dev/skeletons/build_class_from_table.php is no more provided. To build a class from a table you should use the ModuleBuilder modules provided as a standard module.'''
 
'''Since Dolibarr 6.0, the file dev/skeletons/build_class_from_table.php is no more provided. To build a class from a table you should use the ModuleBuilder modules provided as a standard module.'''
   −
== The tab management (optional) ==
+
==The tab management (optional)==
   −
=== Add or remove your own tabs on object sheets ===
+
===Add or remove your own tabs on object sheets===
 
'''When''': To add a tab on an object (invoices, orders, proposals, member ...)
 
'''When''': To add a tab on an object (invoices, orders, proposals, member ...)
   Line 122: Line 130:  
The table should contain a list of strings, each string representing a new tab.  
 
The table should contain a list of strings, each string representing a new tab.  
 
The format of the string consisting of 5 parts separated by ":"
 
The format of the string consisting of 5 parts separated by ":"
* Part 1: The element type (object type) where the tab should appear is a value from the following:
+
 
 +
*Part 1: The element type (object type) where the tab should appear is a value from the following:
 
{{TemplateModuleTabs}}
 
{{TemplateModuleTabs}}
* Part 2: A code to identify tab to add (start with +) or to remove (start with -)
+
 
* Part 3: The title of the tab. This can be a hard read or better code translation in a file lang.
+
*Part 2: A code to identify tab to add (start with +) or to remove (start with -)
* Part 4: The name of the file "*.lang" which contains correspondence between the code translation and language to display. If this name is followed with @mymodule, Dolibarr will search translation file "*.lang" within the module, so htdocs/mymodule/langs/code_CODE/mylangfile.lang, otherwise Dolibarr will look for file htdocs/langs/code_CODE/mylangfile.lang  
+
*Part 3: The title of the tab. This can be a hard read or better code translation in a file lang.
* Part 5: A condition to test if tab must be visible. Put 1 to be always visible.
+
*Part 4: The name of the file "*.lang" which contains correspondence between the code translation and language to display. If this name is followed with @mymodule, Dolibarr will search translation file "*.lang" within the module, so htdocs/mymodule/langs/code_CODE/mylangfile.lang, otherwise Dolibarr will look for file htdocs/langs/code_CODE/mylangfile.lang
* 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.
+
*Part 5: A condition to test if tab must be visible. Put 1 to be always visible.
 +
*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.
    
To feed the contents of the tab with data from the database, see the next chapter.
 
To feed the contents of the tab with data from the database, see the next chapter.
   −
=== Show tabs navigation into your own pages ===
+
===Show tabs navigation into your own pages===
 
'''When''': To show all standard tabs of an object (product, tiers, etc.) on your page.
 
'''When''': To show all standard tabs of an object (product, tiers, etc.) on your page.
   Line 143: Line 153:     
This is example of files to include (DOL_DOCUMENT_ROOT is often dolibarr/htdocs/) :
 
This is example of files to include (DOL_DOCUMENT_ROOT is often dolibarr/htdocs/) :
* Object thirdparty (thirdparty) :
+
 
** DOL_DOCUMENT_ROOT/societe/class/societe.class.php
+
*Object thirdparty (thirdparty) :
** DOL_DOCUMENT_ROOT/core/lib/company.lib.php
+
**DOL_DOCUMENT_ROOT/societe/class/societe.class.php
* Object product (product) :
+
**DOL_DOCUMENT_ROOT/core/lib/company.lib.php
** DOL_DOCUMENT_ROOT/product/class/product.class.php
+
*Object product (product) :
** DOL_DOCUMENT_ROOT/core/lib/product.lib.php
+
**DOL_DOCUMENT_ROOT/product/class/product.class.php
* Object invoice (invoice) :
+
**DOL_DOCUMENT_ROOT/core/lib/product.lib.php
** DOL_DOCUMENT_ROOT/compta/facture/class/facture.class.php
+
*Object invoice (invoice) :
** DOL_DOCUMENT_ROOT/core/lib/invoice.lib.php
+
**DOL_DOCUMENT_ROOT/compta/facture/class/facture.class.php
 +
**DOL_DOCUMENT_ROOT/core/lib/invoice.lib.php
 +
 
 
...
 
...
   Line 202: Line 214:  
This function will show required tabs and open an html element ''< div class="" >'' that correspond to the area under the tabs. To close area of a tab, just use ''< /div >'' into your PHP page.
 
This function will show required tabs and open an html element ''< div class="" >'' that correspond to the area under the tabs. To close area of a tab, just use ''< /div >'' into your PHP page.
   −
== Create or modify PHP screens (optional) ==
+
==Create or modify PHP screens (optional)==
 
'''When''': If the purpose of your module is to add features that require new or modified screens.
 
'''When''': If the purpose of your module is to add features that require new or modified screens.
   −
=== Create a new PHP screen ===
+
===Create a new PHP screen===
 
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 '''modulebuilder/myobject_page.php''' (For the development of a script from the command line, see [[Script development]]).
 
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 '''modulebuilder/myobject_page.php''' (For the development of a script from the command line, see [[Script development]]).
   Line 234: Line 246:  
It's in the main.inc.php file that is loaded technical environment variables and permissions. The following variables are objects positioned in this file:
 
It's in the main.inc.php file that is loaded technical environment variables and permissions. The following variables are objects positioned in this file:
   −
* $user    Object that contains the characteristics of the user + his permissions.
+
*$user    Object that contains the characteristics of the user + his permissions.
* $conf    Object that contains Dolibarr configuration.
+
*$conf    Object that contains Dolibarr configuration.
* $db      Object that contains an opened connection handler to the database.
+
*$db      Object that contains an opened connection handler to the database.
* $langs  Object that contains the user's language.
+
*$langs  Object that contains the user's language.
    
Then enter your code to display the page.
 
Then enter your code to display the page.
   −
* To include a class or library dedicated to the module is done using a Dolibarr function (and not using directly include_once):
+
*To include a class or library dedicated to the module is done using a Dolibarr function (and not using directly include_once):
 +
 
 
''Example :''
 
''Example :''
 
<source lang="php">
 
<source lang="php">
Line 247: Line 260:  
</source>
 
</source>
   −
* To include classes provided with Dolibarr, use the following syntax:
+
*To include classes provided with Dolibarr, use the following syntax:
 +
 
 
''Example :''
 
''Example :''
 
<source lang="php">
 
<source lang="php">
Line 253: Line 267:  
</source>
 
</source>
   −
=== Add some fields into existing forms ===
+
===Add some fields into existing forms===
 
You may want to provide a module that adds more fields into forms (input and view) of some elements.  
 
You may want to provide a module that adds more fields into forms (input and view) of some elements.  
   Line 259: Line 273:     
We will describe here another solution, that works only to "add fields" at end of existing fields, using the element "category" as an example but you can convert this tutorial for invoice, proposal ...
 
We will describe here another solution, that works only to "add fields" at end of existing fields, using the element "category" as an example but you can convert this tutorial for invoice, proposal ...
* 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 "rowid" (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]].
+
 
* 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.
+
*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 "rowid" (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]].
 +
*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.
 +
 
 
If you follow this tutorial, to be able to add fields into category forms, you must do:
 
If you follow this tutorial, to be able to add fields into category forms, you must do:
 
{{ToComplete}}
 
{{ToComplete}}
   −
=== Replace parts of screen that are templated (version 3.3+) ===
+
===Replace parts of screen that are templated (version 3.3+)===
 
Some parts of Dolibarr screen are isolated into native PHP template files.
 
Some parts of Dolibarr screen are isolated into native PHP template files.
 
You can develop a module to overwrite such templates with yours.
 
You can develop a module to overwrite such templates with yours.
 
{{ToComplete}}
 
{{ToComplete}}
   −
=== Add/replace part of fields supported by hooks ===
+
===Add/replace part of fields supported by hooks===
 
See chapter [[Hooks_system#Implement_the_Hook]] to know how to use Dolibarr existing hooks to add/replace code at Dolibarr hooks place.
 
See chapter [[Hooks_system#Implement_the_Hook]] to know how to use Dolibarr existing hooks to add/replace code at Dolibarr hooks place.
   −
=== Database access ===
+
===Database access===
 
If you need to edit some data in the database inside your own table, use the PHP class generated before.
 
If you need to edit some data in the database inside your own table, use the PHP class generated before.
   Line 311: Line 327:  
</source>
 
</source>
   −
=== Define style of your pages ===
+
===Define style of your pages===
 
To have the look of your own pages to match the Dolibarr theme, it is necessary to use the Dolibarr CSS styles.
 
To have the look of your own pages to match the Dolibarr theme, it is necessary to use the Dolibarr CSS styles.
    
You can use for example:
 
You can use for example:
   −
* class="'''liste_titre'''" on tags ''tr'' and ''td'' for the head row of a table.
+
*class="'''liste_titre'''" on tags ''tr'' and ''td'' for the head row of a table.
* class="'''pair'''" or class="'''impair'''" on tags ''tr'' and ''td'' of other rows of a table.
+
*class="'''pair'''" or class="'''impair'''" on tags ''tr'' and ''td'' of other rows of a table.
* class="'''flat'''" on all input fields (''input, select, textarea''...).
+
*class="'''flat'''" on all input fields (''input, select, textarea''...).
* class="'''button'''" on HTML fields with type ''input type="submit"''.
+
*class="'''button'''" on HTML fields with type ''input type="submit"''.
   −
=== Use the Dolibarr date picker ===
+
===Use the Dolibarr date picker===
 
If you want to use the Dolibarr date selector (with its calendar popup) into your pages, use the following line:
 
If you want to use the Dolibarr date selector (with its calendar popup) into your pages, use the following line:
 
<source lang="php">
 
<source lang="php">
Line 337: Line 353:  
</source>
 
</source>
   −
== Add your own setup page (optional) ==
+
==Add your own setup page (optional)==
 
'''When''': If your module needs parameters, which are to be provided by the user, for proper setting up of the module.
 
'''When''': If your module needs parameters, which are to be provided by the user, for proper setting up of the module.
   −
=== Create your page to edit parameters ===
+
===Create your page to edit parameters===
 
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 '''llx_const''']]).
 
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 '''llx_const''']]).
 
Create a page named '''mymodule_setuppage.php''' that shows a form for possible options to update them into the above-mentioned table.
 
Create a page named '''mymodule_setuppage.php''' that shows a form for possible options to update them into the above-mentioned table.
Line 346: Line 362:  
Put this PHP page into the directory '''/admin''' of your module (e.g. mymodule/admin/mymodule_setuppage.php).
 
Put this PHP page into the directory '''/admin''' of your module (e.g. mymodule/admin/mymodule_setuppage.php).
   −
=== Modify the descriptor file of your module ===
+
===Modify the descriptor file of your module===
 
Then, within the descriptor file of your module, modify the variable '''config_page_url''' to set the name of this PHP page.
 
Then, within the descriptor file of your module, modify the variable '''config_page_url''' to set the name of this PHP page.
 
If the page is in the directory '''admin/''', then the path is not required, e.g. like this:
 
If the page is in the directory '''admin/''', then the path is not required, e.g. like this:
Line 357: Line 373:  
</source>
 
</source>
   −
=== Test your page ===
+
===Test your page===
 
Go into page '''Home->Setup->Modules''', 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.
 
Go into page '''Home->Setup->Modules''', 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.
   −
== Define your entries in menu (optional) ==
+
==Define your entries in menu (optional)==
 
'''When''': If you have created PHP pages, it is necessary that those pages can be reached from menu entries in Dolibarr menu.
 
'''When''': If you have created PHP pages, it is necessary that those pages can be reached from menu entries in Dolibarr menu.
   −
=== Define your menu entries ===
+
===Define your menu entries===
 
For this, you must define into the module descriptor, the array this->menu that declares all menus added by your module.
 
For this, you must define into the module descriptor, the array this->menu that declares all menus added by your module.
 
This array contains entries that will appear once your module is activated.
 
This array contains entries that will appear once your module is activated.
Line 408: Line 424:  
To show the menu or not depending on a permission, modify property '''perms''' in the array. See chapter on permissions later to see how to add permissions.
 
To show the menu or not depending on a permission, modify property '''perms''' in the array. See chapter on permissions later to see how to add permissions.
   −
=== Test your menu entries ===
+
===Test your menu entries===
 
Disable and re-enable your module under the Dolibarr module setup page, menus entries must appear (if property 'enabled' is declaration array is ok).
 
Disable and re-enable your module under the Dolibarr module setup page, menus entries must appear (if property 'enabled' is declaration array is ok).
   −
== Add your own permissions (optional) ==
+
==Add your own permissions (optional)==
 
'''When''': If you want to add new permissions.
 
'''When''': If you want to add new permissions.
   Line 441: Line 457:  
</source>
 
</source>
   −
== Define your own box (optional) ==
+
==Define your own box (optional)==
 
'''When''': If your module needs to provide one or several new boxes to show on home page.
 
'''When''': If your module needs to provide one or several new boxes to show on home page.
   −
=== Define your box ===
+
===Define your box===
 
For this, modify the array $this->boxes into the module descriptor file.
 
For this, modify the array $this->boxes into the module descriptor file.
 
All you have to do is to add 2 lines for each box file you will create into directory '''htdocs/mymodule/core/boxes'''
 
All you have to do is to add 2 lines for each box file you will create into directory '''htdocs/mymodule/core/boxes'''
Line 459: Line 475:  
Then create files '''htdocs/mymodule/core/boxes/mybox0.php''', '''htdocs/mymodule/core/boxes/mybox1.php'''... by copying an example from an existing box file (found into directory '''htdocs/core/boxes''').
 
Then create files '''htdocs/mymodule/core/boxes/mybox0.php''', '''htdocs/mymodule/core/boxes/mybox1.php'''... by copying an example from an existing box file (found into directory '''htdocs/core/boxes''').
   −
=== Test if your box is detected by Dolibarr ===
+
===Test if your box is detected by Dolibarr===
 
Disable and enabled module.
 
Disable and enabled module.
   Line 466: Line 482:  
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.
 
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.
   −
== Define your own export (optional) ==
+
==Define your own export (optional)==
 
'''When''': If your module provides new predefined database export profiles (for its own tables or for already existing tables of another module).
 
'''When''': If your module provides new predefined database export profiles (for its own tables or for already existing tables of another module).
   −
=== Define export ===
+
===Define export===
 
For this uncomment and modify arrays $this->export_xxx in your module descriptor file.
 
For this uncomment and modify arrays $this->export_xxx in your module descriptor file.
   −
=== Test your export ===
+
===Test your export===
 
Go into menu Tools -> Export. Your export will appear in the list of available predefined exports (if your module is enabled).
 
Go into menu Tools -> Export. Your export will appear in the list of available predefined exports (if your module is enabled).
 
Choose it, you must see a list of all possible fields defined in the export arrays.
 
Choose it, you must see a list of all possible fields defined in the export arrays.
 
Choose on field and try to build an export file. If ok, try again with all fields.
 
Choose on field and try to build an export file. If ok, try again with all fields.
   −
== Define your CSS styles (optional) ==
+
==Define your CSS styles (optional)==
 
'''When''': If in your PHP pages, you use class styles that are not defined inside Dolibarr themes CSS (not recommanded).
 
'''When''': If in your PHP pages, you use class styles that are not defined inside Dolibarr themes CSS (not recommanded).
   −
=== Create and declare your style sheet ===
+
===Create and declare your style sheet===
Create a style sheet CSS named '''mymodule.css''' or '''mymodule.css.php''' and put it into directory '''htdocs/mymodule'''. You can have only one CSS file per module.
+
Create a style sheet CSS named '''mymodule.css''' or '''mymodule.css.php''' and put it into directory '''htdocs/mymodule'''. You can have several CSS file per module.
Remember it's better to use existing styles already available by default into Dolibarr (The CSS file used by Dolibarr is file '''themes/mytheme/''themename''.css.php'''. Create your own CSS file only if you need absolutely to add not already existing styles.
+
Remember it's better to use existing styles already available by default into Dolibarr (The CSS file used by Dolibarr is file '''themes/mytheme/''themename''.css.php'''. Create your own CSS files only if you need absolutely to add not already existing styles.
   −
Once your style sheet is ready, declare it into your module descriptor file by modifying the property '''$this->modules_parts'''.
+
Once your style sheets are ready, declare them into your module descriptor file by modifying the property '''$this->modules_parts'''.
Value to put here must be a relative URL to your CSS file.
+
Value to put here must be an array of relative URLs to your CSS files.
 
For example
 
For example
 
<source lang="php">
 
<source lang="php">
Line 491: Line 507:  
</source>
 
</source>
   −
=== Test your style sheet ===
+
===Test your style sheet===
 
Disable and enable your module.
 
Disable and enable your module.
   Line 498: Line 514:  
You should see into the HTML header, a line that declares your style sheet.
 
You should see into the HTML header, a line that declares your style sheet.
   −
== Add your Javascript functions (optional) ==
+
==Add your Javascript functions (optional)==
 
'''When''': If in your PHP pages, you use javascript functions not available in Dolibarr (in file lib_head.js)
 
'''When''': If in your PHP pages, you use javascript functions not available in Dolibarr (in file lib_head.js)
   Line 510: Line 526:  
</source>
 
</source>
   −
== Run your own code on any Dolibarr event (optional) ==
+
==Run your own code on any Dolibarr event (optional)==
 
'''When''': If you want to execute your own code once a common Dolibarr event has occurred (example: I want to update a table in my module when an invoice is created into Dolibarr), you must create a '''triggers'''.
 
'''When''': If you want to execute your own code once a common Dolibarr event has occurred (example: I want to update a table in my module when an invoice is created into Dolibarr), you must create a '''triggers'''.
   Line 516: Line 532:  
and [[Interfaces_from_foreign_systems_toward_Dolibarr]]
 
and [[Interfaces_from_foreign_systems_toward_Dolibarr]]
   −
== Insert your code inside Dolibarr hooks positions (optional) ==
+
==Insert your code inside Dolibarr hooks positions (optional)==
 
'''When''': 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).
 
'''When''': 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).
   Line 522: Line 538:       −
== Add your own numbering rules ==
+
==Add your own numbering rules==
 
'''When''': When you need a new rule for generated ref of elements that are not covered by existing rules.
 
'''When''': When you need a new rule for generated ref of elements that are not covered by existing rules.
    
See page [[Create numbering module]].
 
See page [[Create numbering module]].
   −
== Add your document template (optional) ==
+
==Add your document template (optional)==
 
'''When''': When you want to personalized your own generated PDF or ODT documents.
 
'''When''': When you want to personalized your own generated PDF or ODT documents.
   Line 534: Line 550:  
Documentation to add your own template is available on page [[Create_a_PDF_document_template]] or [[Create_an_ODT_document_template]].
 
Documentation to add your own template is available on page [[Create_a_PDF_document_template]] or [[Create_an_ODT_document_template]].
   −
== Add your skin (optional) ==
+
==Add your skin (optional)==
 
'''When''': When you want to personalized your colors/fonts/images.
 
'''When''': When you want to personalized your colors/fonts/images.
   Line 541: Line 557:  
To add your own skin, read page [[Skins]].
 
To add your own skin, read page [[Skins]].
   −
=Some coding rules and predefined functions =
+
=Some coding rules and predefined functions=
 
The coding rules to be followed are defined in the [[Developer documentation]], under section "General Information - Language and standards development".
 
The coding rules to be followed are defined in the [[Developer documentation]], under section "General Information - Language and standards development".
    
A lot of predefined features for developers are also available and described into page [[Developer documentation]] under section "Technical components of Dolibarr".
 
A lot of predefined features for developers are also available and described into page [[Developer documentation]] under section "Technical components of Dolibarr".
   −
=Create a package to distribute and install your module =
+
=Create a package to distribute and install your module=
 
This process must be used to generate a package to submit it on the http://www.dolistore.com marketplace.
 
This process must be used to generate a package to submit it on the http://www.dolistore.com marketplace.
 
But you can use it to have a package easy to distribute on your own network.
 
But you can use it to have a package easy to distribute on your own network.
   −
* Go into the directory '''/build''' and copy the file '''makepack-dolibarrmodules.conf''' into '''makepack-mymodule.conf'''. Warning, this directory may not be provided in some packages of stable versions. If so, it can be retrieved from the snapshot available for download on the Dolibarr website in area "Development version" (taken in this case the whole build directory which is autonomous and independent directory).
+
*Go into the directory '''/build''' and copy the file '''makepack-dolibarrmodules.conf''' into '''makepack-mymodule.conf'''. Warning, this directory may not be provided in some packages of stable versions. If so, it can be retrieved from the snapshot available for download on the Dolibarr website in area "Development version" (taken in this case the whole build directory which is autonomous and independent directory).
    
Edit this file to add a list of file names for all new files you created for your module (module descriptor, new sql tables files, php page, images, etc...)
 
Edit this file to add a list of file names for all new files you created for your module (module descriptor, new sql tables files, php page, images, etc...)
   −
* Run the script via Perl (need the Perl version 5.0 or later):
+
*Run the script via Perl (need the Perl version 5.0 or later):
 +
 
 
<source lang="bash">
 
<source lang="bash">
 
perl makepack-dolibarrmodule.pl
 
perl makepack-dolibarrmodule.pl
Line 560: Line 577:  
The script asks you the name of your module, its major and minor version. A file '''mymodule.zip ''' will then be manufactured containing your module ready to be deployed.
 
The script asks you the name of your module, its major and minor version. A file '''mymodule.zip ''' will then be manufactured containing your module ready to be deployed.
   −
* The person who receives your module must then place the file in the root directory of a Dolibarr installation and perform the command:
+
*The person who receives your module must then place the file in the root directory of a Dolibarr installation and perform the command:
 +
 
 
<source lang="bash">
 
<source lang="bash">
 
tar -xvf mymodule.zip
 
tar -xvf mymodule.zip
 
</source>
 
</source>
   −
* If you want your module to be public, you can submit it (the zip file) on Dolibarr marketplace website: {{LinkToPluginDownload}} (you must create an account first and be logged to use the link "Submit a module/product").
+
*If you want your module to be public, you can submit it (the zip file) on Dolibarr marketplace website: {{LinkToPluginDownload}} (you must create an account first and be logged to use the link "Submit a module/product").
** If your module was built correctly, the file will be validated later.
+
**If your module was built correctly, the file will be validated later.
** If quality is enough and license permits it, the code might be added inside main Dolibarr sources (except if you disagree for that).
+
**If quality is enough and license permits it, the code might be added inside main Dolibarr sources (except if you disagree for that).
   −
= Enabling/activation condition of external module on DoliStore =
+
=Enabling/activation condition of external module on DoliStore=
    
See [[Module_Dolistore_Validation_Rules|Validation Rules]]
 
See [[Module_Dolistore_Validation_Rules|Validation Rules]]
31

edits

Navigation menu