<?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=Attilioscot</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=Attilioscot"/>
	<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php/Special:Contributions/Attilioscot"/>
	<updated>2026-12-03T06:30:18Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.17</generator>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=Module_development&amp;diff=22175</id>
		<title>Module development</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=Module_development&amp;diff=22175"/>
		<updated>2011-06-25T14:00:55Z</updated>

		<summary type="html">&lt;p&gt;Attilioscot: /* Show tabs navigation into your own pages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Core]]&lt;br /&gt;
{{TemplateDocDevEn}}&lt;br /&gt;
&lt;br /&gt;
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 :&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 predefined exports for the internal export tool&lt;br /&gt;
* Add new information boxes in the home page&lt;br /&gt;
* Define new permissions&lt;br /&gt;
* Execute code automatically triggered by a particular Dolibarr action&lt;br /&gt;
etc...&lt;br /&gt;
All those operations are possible with version 2.4 or more of Dolibarr.&lt;br /&gt;
&lt;br /&gt;
Following chapters presents how to do all of this manually with an easy way. For experienced developers, a method to do this using MDA generation is also on the work. See last chapter for this.&lt;br /&gt;
&lt;br /&gt;
= [[File:Art.png]] Create a descriptor of Module (required) =&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: Required as soon as an addon is developed, whatever is its goal.&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. To do this go into the directory dev/skeletons and copy the file modMyModule.class.php in the directory htdocs/includes/modules.&lt;br /&gt;
Then change the contents of this file to replace:&lt;br /&gt;
&lt;br /&gt;
* all &amp;quot;modMyModule&amp;quot; with a value which corresponds to the vocation of your module. This value must always start with &#039;mod&#039;.&lt;br /&gt;
WARNING: The MyModule &#039;&#039;&#039;MUST&#039;&#039;&#039; be set to a serie of alpha character, but &#039;&#039;&#039;the only character permit are [A-Za-z] and the MAX len of the XXX is 12 characters&#039;&#039;&#039;. In the 2.9 version will be add the support of the character &amp;quot;_&amp;quot; in the class name and the character permit will be [A-Za-z_].&lt;br /&gt;
* $this-&amp;gt;numero = 10000 by a number of free module (Go to &#039;&#039;&#039;Home page -&amp;gt; System Information -&amp;gt; Dolibarr -&amp;gt; Modules&#039;&#039;&#039; to know id the list of modules used).&lt;br /&gt;
* Modify any other variables defined in the constructor (see comment in the code skeleton for their meaning). &lt;br /&gt;
* Create directory /htdocs/mymodule/&lt;br /&gt;
Your file descriptor for your module is ready.&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;? You must see a new line with your new module and the possibility to activate it or not (browse all the tabs of each category of modules to find it). It&#039;s value of $this-&amp;gt;special that determines in which tab will be your module.&lt;br /&gt;
&lt;br /&gt;
= [[File:Art.png]] Tree of path for new module files (required) =&lt;br /&gt;
Create a directory &#039;mymodule&#039; that will receive all files of your module. This directory must be inside the &#039;&#039;&#039;htdocs&#039;&#039;&#039; directory and will contains following subdirectories:&lt;br /&gt;
[[File:Arbo_module.png]]&lt;br /&gt;
&lt;br /&gt;
= [[File:Art.png]] Create your SQL tables and the PHP accessor 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;
Files for your own module must be placed in a directory.&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory called &amp;quot;sql&amp;quot; into directory of your module (eg htdocs/mymodule/sql) to put the sql scripts that you will create. Then in the &amp;quot;load_tables&amp;quot; function of your file descriptor module, modify the line&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;$dir = DOL_DOCUMENT_ROOT.&#039;/mymodule/sql/&#039;;&amp;lt;/source&amp;gt;&lt;br /&gt;
by&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;$dir = DOL_DOCUMENT_ROOT.&#039;/valuechooseformymodule/sql/&#039;;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Rules to follow:&#039;&#039;&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;includes/mysql/tables&#039;&#039;&#039; for examples).&lt;br /&gt;
&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 datas.&lt;br /&gt;
&lt;br /&gt;
Example of content of a file data.sql&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sql&amp;quot;&amp;gt;&lt;br /&gt;
 delete from llx_const where name=&#039;MYMODULE_IT_WORKS&#039; and entity=&#039;__ENTITY__&#039;;&lt;br /&gt;
 insert into llx_const (name, value, type, note, visible, entity) values (&#039;MYMODULE_IT_WORKS&#039;,&#039;1&#039;,&#039;chaine&#039;,&#039;A constant vor my module&#039;,1,&#039;__ENTITY__&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 Dolibarr to disable the module, dropper tables in 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.&lt;br /&gt;
&lt;br /&gt;
== Generate the accessors PHP class (DAO) ==&lt;br /&gt;
Once you have created your tables into the database, move to the dev/skeletons directory and run the script&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;php build_class_from_table.php tablename&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: If the command does not work, try to use php-cli php instead.&lt;br /&gt;
&lt;br /&gt;
This will generate a file &#039;&#039;&#039;out.tablename.class.php&#039;&#039;&#039; that contains the class to manage table tablename. &lt;br /&gt;
In this class, you can find the CRUD methods (Create / Read / Update / Delete) already working to do an insert, a fetch (select), an update, a delete of a row in table.&lt;br /&gt;
Remove just the &amp;quot;out&amp;quot; from the file name and put the file in a subdirectory of &#039;&#039;&#039;htdocs&#039;&#039;&#039; specific to your module (in htdocs/mymodule for example).&lt;br /&gt;
&lt;br /&gt;
A file &#039;&#039;&#039;out.tablename_script.php&#039;&#039;&#039; has been generated and contains a sample code to use the class for each of the 4 CRUD methods.&lt;br /&gt;
&lt;br /&gt;
= [[File:Art.png]] The tab management =&lt;br /&gt;
&lt;br /&gt;
== Add your own tabs on object sheets (optional) ==&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;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
	// Array to add new pages in new tabs or remove existing one&lt;br /&gt;
	$this-&amp;gt;tabs = array(&#039;objecttype:+tabname1:Title1:@mymodule:/mymodule/mynewtab1.php?id=__ID__&#039;,  // To add a new tab identified by code tabname1&lt;br /&gt;
                            &#039;objecttype:+tabname2:Title2:@mymodule:/mymodule/mynewtab2.php?id=__ID__&#039;,  // To add another 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;
	// where objecttype can be&lt;br /&gt;
	// &#039;thirdparty&#039;       to add a tab in third party view&lt;br /&gt;
	// &#039;intervention&#039;     to add a tab in intervention view&lt;br /&gt;
	// &#039;supplier_order&#039;   to add a tab in supplier order view&lt;br /&gt;
	// &#039;supplier_invoice&#039; to add a tab in supplier invoice view&lt;br /&gt;
	// &#039;invoice&#039;          to add a tab in customer invoice view&lt;br /&gt;
	// &#039;order&#039;            to add a tab in customer order view&lt;br /&gt;
	// &#039;product&#039;          to add a tab in product view&lt;br /&gt;
	// &#039;propal&#039;           to add a tab in proposal view&lt;br /&gt;
	// &#039;member&#039;           to add a tab in foundation member view&lt;br /&gt;
&amp;lt;/source&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;
* Part 1: The element code which should appear in the tab is a value from the following:&lt;br /&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;propal&#039;&lt;br /&gt;
** &#039;member&#039;&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. Lang which contains correspondence between the code translation and language to display. If this name start with @, Dolibarr will search translation file into the lang file of module, so htdocs/mymodule/langs/code_CODE/mymodule.lang, otherwise Dolibarr will look for file htdocs/langs/code_CODE/mymodyle.lang &lt;br /&gt;
* Part 5: 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;
&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 (produit, 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 pbject type, there is two files to include with line&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;require_once($url_fichier) ;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is list of those files to include (DOL_DOCUMENT_ROOT is often dolibarr/htdocs/) :&lt;br /&gt;
* Object thirdparty (thirdparty) :&lt;br /&gt;
** DOL_DOCUMENT_ROOT/societe.class.php&lt;br /&gt;
** DOL_DOCUMENT_ROOT/lib/company.lib.php&lt;br /&gt;
* Object product (product) :&lt;br /&gt;
** DOL_DOCUMENT_ROOT/product.class.php&lt;br /&gt;
** DOL_DOCUMENT_ROOT/lib/product.lib.php&lt;br /&gt;
* Object invoice (invoice) :&lt;br /&gt;
** DOL_DOCUMENT_ROOT/facture.class.php&lt;br /&gt;
** DOL_DOCUMENT_ROOT/lib/invoice.lib.php&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 instance of object of the correct class and load object from database by using the fetch method of object en 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;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$id=$_GET[&amp;quot;id&amp;quot;];&lt;br /&gt;
$product = new Product($db) ;&lt;br /&gt;
$result = $product-&amp;gt;fetch($id) ; //Test $result to check the database read is ok&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Get list of all tabs to show for your object type&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use fonction XXX_prepare_head($obj), where XXX is name of object. This will return an array with all definition of tab entries to show. Parameter to put into this method is the instance of object you want tabs.&lt;br /&gt;
&lt;br /&gt;
The resulting array has the following structure&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$head        // Array of tabs&lt;br /&gt;
$head[$h]    // Element to describe one tab.&lt;br /&gt;
$head[$h][0] // Url of page to show when you click on tab&lt;br /&gt;
$head[$h][1] // Title of tab&lt;br /&gt;
$head[$h][2] // Code name to identify the tab&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$head = product_prepare_head($product, $user) ; // parameter $user is present for some function anly&lt;br /&gt;
&amp;lt;/source&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;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
dol_fiche_head($links, $active=&#039;0&#039;, $title=&#039;&#039;, $notab=0, $picto=&#039;&#039;)&lt;br /&gt;
//$links  // Tableau des onglets, appelé $head plus haut.&lt;br /&gt;
//$active // Onglet actif (mettre le nom de l&#039;onglet défini dans votre fichier de module, ou un nom contenu dans $head[$h][2]). Cet onglet sera mis en surbrillance&lt;br /&gt;
//$title  // Title to show (shown into a special tab that you can&#039;t click)&lt;br /&gt;
//$notab&lt;br /&gt;
//$picto  // Name of image to show into title. Possible values are:&lt;br /&gt;
//            product&lt;br /&gt;
//            service&lt;br /&gt;
//            company&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This function will show required tabs and open an html element &#039;&#039;&amp;lt; div class=&amp;quot;&amp;quot; &amp;gt;&#039;&#039; that correspond to the area under the tabs. To close area of a tab, just use &#039;&#039;&amp;lt; /div &amp;gt;&#039;&#039; into your PHP page.&lt;br /&gt;
&lt;br /&gt;
= [[File:Art.png]] Create your own 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 screens.&lt;br /&gt;
&lt;br /&gt;
== Create a 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;dev/skeletons&#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/monmodule&#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;skeletons_page.php&#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;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
include(&amp;quot;../../main.inc.php)&amp;quot;;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This depends on the depth of the directory in which the file is (Add or remove &amp;quot;../&amp;quot;). &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    Objet that contains the characteristics of the user + his permissions.&lt;br /&gt;
* $conf    Objet that contains Dolibarr configuration.&lt;br /&gt;
* $db      Objet that contains an opened connection handler to the database.&lt;br /&gt;
* $langs   Objet 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;
== Database access ==&lt;br /&gt;
If you need to edit some data in database inside you 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;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$db-&amp;gt;begin();   // Start transaction&lt;br /&gt;
$db-&amp;gt;query(&amp;quot;My SQL request insert, update or delete&amp;quot;);&lt;br /&gt;
$db-&amp;gt;commit();       // Validate transaction&lt;br /&gt;
or $db-&amp;gt;rollback()  // Cancel transaction&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To read:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$resql=$db-&amp;gt;query(&amp;quot;My select request&amp;quot;);&lt;br /&gt;
if ($resql)&lt;br /&gt;
{&lt;br /&gt;
	$num = $db-&amp;gt;num_rows($resql);&lt;br /&gt;
	$i = 0;&lt;br /&gt;
	if ($num)&lt;br /&gt;
	{&lt;br /&gt;
		while ($i &amp;lt; $num)&lt;br /&gt;
		{&lt;br /&gt;
			$obj = $db-&amp;gt;fetch_object($resql);&lt;br /&gt;
			if ($obj)&lt;br /&gt;
			{&lt;br /&gt;
				// You can use here results&lt;br /&gt;
				print $obj-&amp;gt;field1;&lt;br /&gt;
				print $obj-&amp;gt;field2;&lt;br /&gt;
			}&lt;br /&gt;
			$i++;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 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;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
 $form=new Form($db);&lt;br /&gt;
 $form-&amp;gt;select_date(&#039;&#039;,&#039;mykey&#039;,0,0,0,&amp;quot;myform&amp;quot;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
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;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$mydate = dol_mktime(12, 0 , 0, $_POST[&#039;mykeymonth&#039;], $_POST[&#039;mykeyday&#039;], $_POST[&#039;mykeyyear&#039;]);&lt;br /&gt;
print strftime(&#039;%A %d %B %Y&#039;, $mydate);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= [[File:Art.png]] Add your own setup page (optional)  =&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module need to ask user several parameters.&lt;br /&gt;
&lt;br /&gt;
== Create your page to edit parameters ==&lt;br /&gt;
If your module need several parameters to be setup, you must create a page to edit options (that will be saved into [[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 show possibles options and update them into table from a form.&lt;br /&gt;
It is a necessary to take an example from a page into directory &#039;&#039;&#039;/admin&#039;&#039;&#039; that will show you the way to read/save your parameter.&lt;br /&gt;
Put this page into directory &#039;&#039;&#039;/admin&#039;&#039;&#039;.&lt;br /&gt;
Then, into the descriptor file of your module, modify the variable config_page_url to set name of this PHP page (without the path that is not necesary if page is inside directory admin).&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;config_page_url = array(&amp;quot;mymodule_setuppage.php&amp;quot;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 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;
= [[File:Art.png]] 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 declare all menus added by your module.&lt;br /&gt;
This array contains entries that will appear once your module is activated.&lt;br /&gt;
The example module descriptor file &#039;&#039;&#039;modMyModule.class.php&#039;&#039;&#039; contains an example to declare a top menu and also its left menu entries.&lt;br /&gt;
&lt;br /&gt;
This is the example of code to declare your own menu entries in a module descriptor file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Main menu entries&lt;br /&gt;
$this-&amp;gt;menu = array();			// List of menus to add&lt;br /&gt;
$r=0;&lt;br /&gt;
&lt;br /&gt;
// Add here entries to declare new menus&lt;br /&gt;
// Example to declare the Top Menu entry:&lt;br /&gt;
$this-&amp;gt;menu[$r]=array(	&#039;fk_menu&#039;=&amp;gt;0,			// Put 0 if this is a top menu&lt;br /&gt;
			&#039;type&#039;=&amp;gt;&#039;top&#039;,			// This is a Top menu entry&lt;br /&gt;
			&#039;titre&#039;=&amp;gt;&#039;MyModule top menu&#039;,&lt;br /&gt;
			&#039;mainmenu&#039;=&amp;gt;&#039;mymodule&#039;,&lt;br /&gt;
			&#039;leftmenu&#039;=&amp;gt;&#039;1&#039;,		// Use 1 if you also want to add left menu entries using this descriptor. Use 0 if left menu entries are defined in a file pre.inc.php (old school).&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;r=0&#039;,		// Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry)&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;mymodule&#039;,&lt;br /&gt;
			&#039;url&#039;=&amp;gt;&#039;/mymodule/pagelevel1.php&#039;,&lt;br /&gt;
			&#039;langs&#039;=&amp;gt;&#039;mylangfile&#039;,	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.&lt;br /&gt;
			&#039;position&#039;=&amp;gt;100,&lt;br /&gt;
			&#039;enabled&#039;=&amp;gt;&#039;1&#039;,			// Define condition to show or hide menu entry. Use &#039;$conf-&amp;gt;mymodule-&amp;gt;enabled&#039; if entry must be visible if module is enabled.&lt;br /&gt;
			&#039;perms&#039;=&amp;gt;&#039;1&#039;,			// Use &#039;perms&#039;=&amp;gt;&#039;$user-&amp;gt;rights-&amp;gt;mymodule-&amp;gt;level1-&amp;gt;level2&#039; if you want your menu with a permission rules&lt;br /&gt;
			&#039;target&#039;=&amp;gt;&#039;&#039;,&lt;br /&gt;
			&#039;user&#039;=&amp;gt;2);				// 0=Menu for internal users,1=external users, 2=both&lt;br /&gt;
$r++;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To show menu or not depending on a permission, modify property &#039;&#039;&#039;perms&#039;&#039;&#039; in array. See chapter on permissions later to see how to add permissions.&lt;br /&gt;
&lt;br /&gt;
== Test your menu entries ==&lt;br /&gt;
Disable and reenable your module under Dolibarr module setup page, menus entries must appear (if property &#039;enabled&#039; is declaration array is ok).&lt;br /&gt;
&lt;br /&gt;
= [[File:Art.png]] 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;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;rights_class = &#039;mymodule&#039;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
with correct value for mymodule.&lt;br /&gt;
&lt;br /&gt;
Then you must fill the array $this-&amp;gt;rights with as many entries than different permissions you need to manage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;rights[$r][0] = 10001;&lt;br /&gt;
$this-&amp;gt;rights[$r][1] = &#039;Label by default of permission&#039;;&lt;br /&gt;
$this-&amp;gt;rights[$r][3] = 1;&lt;br /&gt;
$this-&amp;gt;rights[$r][4] = &#039;action&#039;;&lt;br /&gt;
$this-&amp;gt;rights[$r][5] = &#039;subaction&#039;;&lt;br /&gt;
$r++;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Into $this-&amp;gt;rights[$r][0], put a permission id not already used (See into menu &#039;&#039;&#039;System info&#039;&#039;&#039; on a working installation of Dolibarr to know list of id already used by standard modules.&lt;br /&gt;
Into $this-&amp;gt;rights[$r][3], put 1 if this permission must be granted automatically by default to any new created user.&lt;br /&gt;
Into $this-&amp;gt;rights[$r][1], put a label by default for permission (This label will be used if no translation can be found into the file &#039;&#039;&#039;admin.lang&#039;&#039;&#039;).&lt;br /&gt;
Into $this-&amp;gt;rights[$r][4] and $this-&amp;gt;rights[$r][5], put an action and subaction string without spaces. You will be able to test if a user has the permission in your PHP source code with the sequence:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
if ($user-&amp;gt;rights-&amp;gt;mymodule-&amp;gt;action-&amp;gt;subaction) ...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= [[File:Art.png]] Define you own box (optional) =&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module need to provide one or several new boxes to show on home page.&lt;br /&gt;
&lt;br /&gt;
== 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 one line for each box file you will create into directory &#039;&#039;&#039;htdocs/includes/boxes&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example:&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
this-&amp;gt;boxes[0][1]=&#039;mybox0.php&#039;&lt;br /&gt;
this-&amp;gt;boxes[1][1]=&#039;mybox1.php&#039;&lt;br /&gt;
this-&amp;gt;boxes[2][1]=&#039;mybox2.php&#039;&lt;br /&gt;
...&lt;br /&gt;
this-&amp;gt;boxes[n][1]=&#039;myboxn.php&#039;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create files mybox0.php, mybox1.php... by copying an example from an existing box file (into directory htdocs/include/boxes).&lt;br /&gt;
&lt;br /&gt;
== Test if your box is detected by Dolibarr ==&lt;br /&gt;
Disable and enabled module.&lt;br /&gt;
&lt;br /&gt;
Go into menu &#039;&#039;&#039;Home - Setup - Boxes&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Your boxes must appear in the list of boxes you can activated. Activate the box and go on home page to see if the box is showing correctly.&lt;br /&gt;
&lt;br /&gt;
= [[File:Art.png]] Define your own export (optional) =&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module provide new predefined database export profiles (for its own tables or for already existing tables of another module).&lt;br /&gt;
&lt;br /&gt;
== 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 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;
= [[File:Art.png]] 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; and put it into directory &#039;&#039;&#039;htdocs/mymodule&#039;&#039;&#039;. You can have only one CSS file per module.&lt;br /&gt;
Remember it&#039;s better to use existing styles already available by default into Dolibarr (The CSS file used by Dolibarr is file &#039;&#039;&#039;themes/mytheme/&#039;&#039;themename&#039;&#039;.php.css&#039;&#039;&#039;. Create your own CSS file only if you need absolutely to add not already existing styles.&lt;br /&gt;
Once your style sheet is ready, declare it into your module descriptor file by modifying the property &#039;&#039;&#039;$this-&amp;gt;style_sheet&#039;&#039;&#039;.&lt;br /&gt;
Value to put here must be a relative URL to your CSS file.&lt;br /&gt;
For example &#039;/mymodule/myfile.css&#039;.&lt;br /&gt;
&lt;br /&gt;
== Test your style sheet ==&lt;br /&gt;
Disable and enable your module.&lt;br /&gt;
&lt;br /&gt;
Go on home page (index.php). Show the HTML source of the page.&lt;br /&gt;
&lt;br /&gt;
You should see into the HTML header, a line that declare your style sheet.&lt;br /&gt;
&lt;br /&gt;
= [[File:Art.png]] 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;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
require(&#039;../main.inc.php&#039;);&lt;br /&gt;
$morejs=array(&amp;quot;/mymodule/js/mymodule.js&amp;quot;);&lt;br /&gt;
llxHeader(&#039;&#039;,&#039;Titre&#039;,&#039;&#039;,&#039;&#039;,&#039;&#039;,&#039;&#039;,$morejs,&#039;&#039;,0,0); &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= [[File:Art.png]] 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;
= [[File:Art.png]] 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 market place.&lt;br /&gt;
But you can use it to have a package easy to distribute on your on network.&lt;br /&gt;
&lt;br /&gt;
* Go into the directory &#039;&#039;&#039;/build&#039;&#039;&#039; and copy the file &#039;&#039;&#039;makepack-dolibarrmodules.conf&#039;&#039;&#039; into &#039;&#039;&#039;makepack-mymodule.conf&#039;&#039;&#039;. Warning, this directory may not be provided in some packages of stable versions. If so, it can be retrieved from the CVS snapshot available for download on the Dolibarr website in area &amp;quot;Development version&amp;quot; (taken in this case the whole build directory which is autonomous and independent directory).&lt;br /&gt;
&lt;br /&gt;
Edit this file to add list of file names for all new files you created for your module (module descriptor, new sql tables files, php page, images, etc...)&lt;br /&gt;
&lt;br /&gt;
* Run the script via Perl (need the Perl version 5.0 or later):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
perl makepack-dolibarrmodule.pl&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The script asks you the name of your module, its major and minor version. A file &#039;&#039;&#039;mymodule.zip &#039;&#039;&#039; will then be manufactured containing your module ready to be deployed.&lt;br /&gt;
&lt;br /&gt;
* The person who receives your module must then place the file in the root directory of a Dolibarr installation and perform the command:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
tar -xvf monmodule.zip&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* If you want your module to be public, you can submit it (the zip file) on Dolibarr web site on download area: {{LinkToPluginDownload}} (you must create an account first and be logged to use the link &amp;quot;Submit a product&amp;quot;).&lt;br /&gt;
** If your module was build correctly, file will be validated later.&lt;br /&gt;
** If quality is enough and license permits it, code might be added inside main Dolibarr sources (except if you disagree for that).&lt;br /&gt;
&lt;br /&gt;
= [[File:Art.png]] Some coding rules =&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;
= [[File:Art.png]] Using MDA =&lt;br /&gt;
A method to generate a functional module from a UML model has been developed. More information on the page [[UML2Dolibarr - Build a module using MDA]].&lt;/div&gt;</summary>
		<author><name>Attilioscot</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=Module_development&amp;diff=22174</id>
		<title>Module development</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=Module_development&amp;diff=22174"/>
		<updated>2011-06-25T13:43:28Z</updated>

		<summary type="html">&lt;p&gt;Attilioscot: /* Show tabs navigation into your own pages */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Core]]&lt;br /&gt;
{{TemplateDocDevEn}}&lt;br /&gt;
&lt;br /&gt;
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 :&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 predefined exports for the internal export tool&lt;br /&gt;
* Add new information boxes in the home page&lt;br /&gt;
* Define new permissions&lt;br /&gt;
* Execute code automatically triggered by a particular Dolibarr action&lt;br /&gt;
etc...&lt;br /&gt;
All those operations are possible with version 2.4 or more of Dolibarr.&lt;br /&gt;
&lt;br /&gt;
Following chapters presents how to do all of this manually with an easy way. For experienced developers, a method to do this using MDA generation is also on the work. See last chapter for this.&lt;br /&gt;
&lt;br /&gt;
= [[File:Art.png]] Create a descriptor of Module (required) =&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: Required as soon as an addon is developed, whatever is its goal.&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. To do this go into the directory dev/skeletons and copy the file modMyModule.class.php in the directory htdocs/includes/modules.&lt;br /&gt;
Then change the contents of this file to replace:&lt;br /&gt;
&lt;br /&gt;
* all &amp;quot;modMyModule&amp;quot; with a value which corresponds to the vocation of your module. This value must always start with &#039;mod&#039;.&lt;br /&gt;
WARNING: The MyModule &#039;&#039;&#039;MUST&#039;&#039;&#039; be set to a serie of alpha character, but &#039;&#039;&#039;the only character permit are [A-Za-z] and the MAX len of the XXX is 12 characters&#039;&#039;&#039;. In the 2.9 version will be add the support of the character &amp;quot;_&amp;quot; in the class name and the character permit will be [A-Za-z_].&lt;br /&gt;
* $this-&amp;gt;numero = 10000 by a number of free module (Go to &#039;&#039;&#039;Home page -&amp;gt; System Information -&amp;gt; Dolibarr -&amp;gt; Modules&#039;&#039;&#039; to know id the list of modules used).&lt;br /&gt;
* Modify any other variables defined in the constructor (see comment in the code skeleton for their meaning). &lt;br /&gt;
* Create directory /htdocs/mymodule/&lt;br /&gt;
Your file descriptor for your module is ready.&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;? You must see a new line with your new module and the possibility to activate it or not (browse all the tabs of each category of modules to find it). It&#039;s value of $this-&amp;gt;special that determines in which tab will be your module.&lt;br /&gt;
&lt;br /&gt;
= [[File:Art.png]] Tree of path for new module files (required) =&lt;br /&gt;
Create a directory &#039;mymodule&#039; that will receive all files of your module. This directory must be inside the &#039;&#039;&#039;htdocs&#039;&#039;&#039; directory and will contains following subdirectories:&lt;br /&gt;
[[File:Arbo_module.png]]&lt;br /&gt;
&lt;br /&gt;
= [[File:Art.png]] Create your SQL tables and the PHP accessor 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;
Files for your own module must be placed in a directory.&lt;br /&gt;
&lt;br /&gt;
Create a subdirectory called &amp;quot;sql&amp;quot; into directory of your module (eg htdocs/mymodule/sql) to put the sql scripts that you will create. Then in the &amp;quot;load_tables&amp;quot; function of your file descriptor module, modify the line&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;$dir = DOL_DOCUMENT_ROOT.&#039;/mymodule/sql/&#039;;&amp;lt;/source&amp;gt;&lt;br /&gt;
by&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;$dir = DOL_DOCUMENT_ROOT.&#039;/valuechooseformymodule/sql/&#039;;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Rules to follow:&#039;&#039;&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;includes/mysql/tables&#039;&#039;&#039; for examples).&lt;br /&gt;
&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 datas.&lt;br /&gt;
&lt;br /&gt;
Example of content of a file data.sql&lt;br /&gt;
&amp;lt;source lang=&amp;quot;sql&amp;quot;&amp;gt;&lt;br /&gt;
 delete from llx_const where name=&#039;MYMODULE_IT_WORKS&#039; and entity=&#039;__ENTITY__&#039;;&lt;br /&gt;
 insert into llx_const (name, value, type, note, visible, entity) values (&#039;MYMODULE_IT_WORKS&#039;,&#039;1&#039;,&#039;chaine&#039;,&#039;A constant vor my module&#039;,1,&#039;__ENTITY__&#039;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
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 Dolibarr to disable the module, dropper tables in 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.&lt;br /&gt;
&lt;br /&gt;
== Generate the accessors PHP class (DAO) ==&lt;br /&gt;
Once you have created your tables into the database, move to the dev/skeletons directory and run the script&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;php build_class_from_table.php tablename&amp;lt;/source&amp;gt;&lt;br /&gt;
Note: If the command does not work, try to use php-cli php instead.&lt;br /&gt;
&lt;br /&gt;
This will generate a file &#039;&#039;&#039;out.tablename.class.php&#039;&#039;&#039; that contains the class to manage table tablename. &lt;br /&gt;
In this class, you can find the CRUD methods (Create / Read / Update / Delete) already working to do an insert, a fetch (select), an update, a delete of a row in table.&lt;br /&gt;
Remove just the &amp;quot;out&amp;quot; from the file name and put the file in a subdirectory of &#039;&#039;&#039;htdocs&#039;&#039;&#039; specific to your module (in htdocs/mymodule for example).&lt;br /&gt;
&lt;br /&gt;
A file &#039;&#039;&#039;out.tablename_script.php&#039;&#039;&#039; has been generated and contains a sample code to use the class for each of the 4 CRUD methods.&lt;br /&gt;
&lt;br /&gt;
= [[File:Art.png]] The tab management =&lt;br /&gt;
&lt;br /&gt;
== Add your own tabs on object sheets (optional) ==&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;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
	// Array to add new pages in new tabs or remove existing one&lt;br /&gt;
	$this-&amp;gt;tabs = array(&#039;objecttype:+tabname1:Title1:@mymodule:/mymodule/mynewtab1.php?id=__ID__&#039;,  // To add a new tab identified by code tabname1&lt;br /&gt;
                            &#039;objecttype:+tabname2:Title2:@mymodule:/mymodule/mynewtab2.php?id=__ID__&#039;,  // To add another 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;
	// where objecttype can be&lt;br /&gt;
	// &#039;thirdparty&#039;       to add a tab in third party view&lt;br /&gt;
	// &#039;intervention&#039;     to add a tab in intervention view&lt;br /&gt;
	// &#039;supplier_order&#039;   to add a tab in supplier order view&lt;br /&gt;
	// &#039;supplier_invoice&#039; to add a tab in supplier invoice view&lt;br /&gt;
	// &#039;invoice&#039;          to add a tab in customer invoice view&lt;br /&gt;
	// &#039;order&#039;            to add a tab in customer order view&lt;br /&gt;
	// &#039;product&#039;          to add a tab in product view&lt;br /&gt;
	// &#039;propal&#039;           to add a tab in proposal view&lt;br /&gt;
	// &#039;member&#039;           to add a tab in foundation member view&lt;br /&gt;
&amp;lt;/source&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;
* Part 1: The element code which should appear in the tab is a value from the following:&lt;br /&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;propal&#039;&lt;br /&gt;
** &#039;member&#039;&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. Lang which contains correspondence between the code translation and language to display. If this name start with @, Dolibarr will search translation file into the lang file of module, so htdocs/mymodule/langs/code_CODE/mymodule.lang, otherwise Dolibarr will look for file htdocs/langs/code_CODE/mymodyle.lang &lt;br /&gt;
* Part 5: 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;
&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 (produit, 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 pbject type, there is two files to include with line&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;require_once($url_fichier) ;&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is list of those files to include (DOL_DOCUMENT_ROOT is often dolibarr/htdocs/) :&lt;br /&gt;
* Object thirdparty (thirdparty) :&lt;br /&gt;
** DOL_DOCUMENT_ROOT/societe.class.php&lt;br /&gt;
** DOL_DOCUMENT_ROOT/lib/company.lib.php&lt;br /&gt;
* Object product (product) :&lt;br /&gt;
** DOL_DOCUMENT_ROOT/product.class.php&lt;br /&gt;
** DOL_DOCUMENT_ROOT/lib/product.lib.php&lt;br /&gt;
* Object invoice (invoice) :&lt;br /&gt;
** DOL_DOCUMENT_ROOT/facture.class.php&lt;br /&gt;
** DOL_DOCUMENT_ROOT/lib/invoice.lib.php&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 instance of object of the correct class and load object from database by using the fetch method of object en 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;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$id=$_GET[&amp;quot;id&amp;quot;];&lt;br /&gt;
$product = new Product($db) ;&lt;br /&gt;
$result = $product-&amp;gt;fetch($id) ; //Test $result to check the database read is ok&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;3. Get list of all tabs to show for your object type&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
Use fonction XXX_prepare_head($obj), where XXX is name of object. This will return an array with all definition of tab entries to show. Parameter to put into this method is the instance of object you want tabs.&lt;br /&gt;
&lt;br /&gt;
The resulting array has the following structure&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$head        // Array of tabs&lt;br /&gt;
$head[$h]    // Element to describe one tab.&lt;br /&gt;
$head[$h][0] // Url of page to show when you click on tab&lt;br /&gt;
$head[$h][1] // Title of tab&lt;br /&gt;
$head[$h][2] // Code name to identify the tab&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example :&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$head = product_prepare_head($product, $user) ; // parameter $user is present for some function anly&lt;br /&gt;
&amp;lt;/source&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;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
dol_fiche_head($links, $active=&#039;0&#039;, $title=&#039;&#039;, $notab=0, $picto=&#039;&#039;)&lt;br /&gt;
//$links  // Tableau des onglets, appelé $head plus haut.&lt;br /&gt;
//$active // Onglet actif (mettre le nom de l&#039;onglet défini dans votre fichier de module, ou un nom contenu dans $head[$h][2]). Cet onglet sera mis en surbrillance&lt;br /&gt;
//$title  // Title to show (shown into a special tab that you can&#039;t click)&lt;br /&gt;
//$notab&lt;br /&gt;
//$picto  // Name of image to show into title. Possible values are:&lt;br /&gt;
//            product&lt;br /&gt;
//            service&lt;br /&gt;
//            company&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This function will show required tabs and open an html element &#039;&#039;&amp;lt; div class=&amp;quot;&amp;quot; &amp;gt;&#039;&#039; that correspond to the area under the tabs. To close area of a tab, just use &#039;&#039;&amp;lt; /div &amp;gt;&#039;&#039; into your PHP page.&lt;br /&gt;
&lt;br /&gt;
= [[File:Art.png]] Create your own 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 screens.&lt;br /&gt;
&lt;br /&gt;
== Create a 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;dev/skeletons&#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/monmodule&#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;skeletons_page.php&#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;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
include(&amp;quot;../../main.inc.php)&amp;quot;;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This depends on the depth of the directory in which the file is (Add or remove &amp;quot;../&amp;quot;). &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    Objet that contains the characteristics of the user + his permissions.&lt;br /&gt;
* $conf    Objet that contains Dolibarr configuration.&lt;br /&gt;
* $db      Objet that contains an opened connection handler to the database.&lt;br /&gt;
* $langs   Objet 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;
== Database access ==&lt;br /&gt;
If you need to edit some data in database inside you 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;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$db-&amp;gt;begin();   // Start transaction&lt;br /&gt;
$db-&amp;gt;query(&amp;quot;My SQL request insert, update or delete&amp;quot;);&lt;br /&gt;
$db-&amp;gt;commit();       // Validate transaction&lt;br /&gt;
or $db-&amp;gt;rollback()  // Cancel transaction&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To read:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$resql=$db-&amp;gt;query(&amp;quot;My select request&amp;quot;);&lt;br /&gt;
if ($resql)&lt;br /&gt;
{&lt;br /&gt;
	$num = $db-&amp;gt;num_rows($resql);&lt;br /&gt;
	$i = 0;&lt;br /&gt;
	if ($num)&lt;br /&gt;
	{&lt;br /&gt;
		while ($i &amp;lt; $num)&lt;br /&gt;
		{&lt;br /&gt;
			$obj = $db-&amp;gt;fetch_object($resql);&lt;br /&gt;
			if ($obj)&lt;br /&gt;
			{&lt;br /&gt;
				// You can use here results&lt;br /&gt;
				print $obj-&amp;gt;field1;&lt;br /&gt;
				print $obj-&amp;gt;field2;&lt;br /&gt;
			}&lt;br /&gt;
			$i++;&lt;br /&gt;
		}&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 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;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
 $form=new Form($db);&lt;br /&gt;
 $form-&amp;gt;select_date(&#039;&#039;,&#039;mykey&#039;,0,0,0,&amp;quot;myform&amp;quot;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
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;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$mydate = dol_mktime(12, 0 , 0, $_POST[&#039;mykeymonth&#039;], $_POST[&#039;mykeyday&#039;], $_POST[&#039;mykeyyear&#039;]);&lt;br /&gt;
print strftime(&#039;%A %d %B %Y&#039;, $mydate);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= [[File:Art.png]] Add your own setup page (optional)  =&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module need to ask user several parameters.&lt;br /&gt;
&lt;br /&gt;
== Create your page to edit parameters ==&lt;br /&gt;
If your module need several parameters to be setup, you must create a page to edit options (that will be saved into [[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 show possibles options and update them into table from a form.&lt;br /&gt;
It is a necessary to take an example from a page into directory &#039;&#039;&#039;/admin&#039;&#039;&#039; that will show you the way to read/save your parameter.&lt;br /&gt;
Put this page into directory &#039;&#039;&#039;/admin&#039;&#039;&#039;.&lt;br /&gt;
Then, into the descriptor file of your module, modify the variable config_page_url to set name of this PHP page (without the path that is not necesary if page is inside directory admin).&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;config_page_url = array(&amp;quot;mymodule_setuppage.php&amp;quot;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== 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;
= [[File:Art.png]] 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 declare all menus added by your module.&lt;br /&gt;
This array contains entries that will appear once your module is activated.&lt;br /&gt;
The example module descriptor file &#039;&#039;&#039;modMyModule.class.php&#039;&#039;&#039; contains an example to declare a top menu and also its left menu entries.&lt;br /&gt;
&lt;br /&gt;
This is the example of code to declare your own menu entries in a module descriptor file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
// Main menu entries&lt;br /&gt;
$this-&amp;gt;menu = array();			// List of menus to add&lt;br /&gt;
$r=0;&lt;br /&gt;
&lt;br /&gt;
// Add here entries to declare new menus&lt;br /&gt;
// Example to declare the Top Menu entry:&lt;br /&gt;
$this-&amp;gt;menu[$r]=array(	&#039;fk_menu&#039;=&amp;gt;0,			// Put 0 if this is a top menu&lt;br /&gt;
			&#039;type&#039;=&amp;gt;&#039;top&#039;,			// This is a Top menu entry&lt;br /&gt;
			&#039;titre&#039;=&amp;gt;&#039;MyModule top menu&#039;,&lt;br /&gt;
			&#039;mainmenu&#039;=&amp;gt;&#039;mymodule&#039;,&lt;br /&gt;
			&#039;leftmenu&#039;=&amp;gt;&#039;1&#039;,		// Use 1 if you also want to add left menu entries using this descriptor. Use 0 if left menu entries are defined in a file pre.inc.php (old school).&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;r=0&#039;,		// Use r=value where r is index key used for the parent menu entry (higher parent must be a top menu entry)&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;mymodule&#039;,&lt;br /&gt;
			&#039;url&#039;=&amp;gt;&#039;/mymodule/pagelevel1.php&#039;,&lt;br /&gt;
			&#039;langs&#039;=&amp;gt;&#039;mylangfile&#039;,	// Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory.&lt;br /&gt;
			&#039;position&#039;=&amp;gt;100,&lt;br /&gt;
			&#039;enabled&#039;=&amp;gt;&#039;1&#039;,			// Define condition to show or hide menu entry. Use &#039;$conf-&amp;gt;mymodule-&amp;gt;enabled&#039; if entry must be visible if module is enabled.&lt;br /&gt;
			&#039;perms&#039;=&amp;gt;&#039;1&#039;,			// Use &#039;perms&#039;=&amp;gt;&#039;$user-&amp;gt;rights-&amp;gt;mymodule-&amp;gt;level1-&amp;gt;level2&#039; if you want your menu with a permission rules&lt;br /&gt;
			&#039;target&#039;=&amp;gt;&#039;&#039;,&lt;br /&gt;
			&#039;user&#039;=&amp;gt;2);				// 0=Menu for internal users,1=external users, 2=both&lt;br /&gt;
$r++;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
To show menu or not depending on a permission, modify property &#039;&#039;&#039;perms&#039;&#039;&#039; in array. See chapter on permissions later to see how to add permissions.&lt;br /&gt;
&lt;br /&gt;
== Test your menu entries ==&lt;br /&gt;
Disable and reenable your module under Dolibarr module setup page, menus entries must appear (if property &#039;enabled&#039; is declaration array is ok).&lt;br /&gt;
&lt;br /&gt;
= [[File:Art.png]] 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;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;rights_class = &#039;mymodule&#039;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
with correct value for mymodule.&lt;br /&gt;
&lt;br /&gt;
Then you must fill the array $this-&amp;gt;rights with as many entries than different permissions you need to manage.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
$this-&amp;gt;rights[$r][0] = 10001;&lt;br /&gt;
$this-&amp;gt;rights[$r][1] = &#039;Label by default of permission&#039;;&lt;br /&gt;
$this-&amp;gt;rights[$r][3] = 1;&lt;br /&gt;
$this-&amp;gt;rights[$r][4] = &#039;action&#039;;&lt;br /&gt;
$this-&amp;gt;rights[$r][5] = &#039;subaction&#039;;&lt;br /&gt;
$r++;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Into $this-&amp;gt;rights[$r][0], put a permission id not already used (See into menu &#039;&#039;&#039;System info&#039;&#039;&#039; on a working installation of Dolibarr to know list of id already used by standard modules.&lt;br /&gt;
Into $this-&amp;gt;rights[$r][3], put 1 if this permission must be granted automatically by default to any new created user.&lt;br /&gt;
Into $this-&amp;gt;rights[$r][1], put a label by default for permission (This label will be used if no translation can be found into the file &#039;&#039;&#039;admin.lang&#039;&#039;&#039;).&lt;br /&gt;
Into $this-&amp;gt;rights[$r][4] and $this-&amp;gt;rights[$r][5], put an action and subaction string without spaces. You will be able to test if a user has the permission in your PHP source code with the sequence:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
if ($user-&amp;gt;rights-&amp;gt;mymodule-&amp;gt;action-&amp;gt;subaction) ...&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= [[File:Art.png]] Define you own box (optional) =&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module need to provide one or several new boxes to show on home page.&lt;br /&gt;
&lt;br /&gt;
== 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 one line for each box file you will create into directory &#039;&#039;&#039;htdocs/includes/boxes&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;Example:&#039;&#039;&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
this-&amp;gt;boxes[0][1]=&#039;mybox0.php&#039;&lt;br /&gt;
this-&amp;gt;boxes[1][1]=&#039;mybox1.php&#039;&lt;br /&gt;
this-&amp;gt;boxes[2][1]=&#039;mybox2.php&#039;&lt;br /&gt;
...&lt;br /&gt;
this-&amp;gt;boxes[n][1]=&#039;myboxn.php&#039;&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then create files mybox0.php, mybox1.php... by copying an example from an existing box file (into directory htdocs/include/boxes).&lt;br /&gt;
&lt;br /&gt;
== Test if your box is detected by Dolibarr ==&lt;br /&gt;
Disable and enabled module.&lt;br /&gt;
&lt;br /&gt;
Go into menu &#039;&#039;&#039;Home - Setup - Boxes&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Your boxes must appear in the list of boxes you can activated. Activate the box and go on home page to see if the box is showing correctly.&lt;br /&gt;
&lt;br /&gt;
= [[File:Art.png]] Define your own export (optional) =&lt;br /&gt;
&#039;&#039;&#039;When&#039;&#039;&#039;: If your module provide new predefined database export profiles (for its own tables or for already existing tables of another module).&lt;br /&gt;
&lt;br /&gt;
== 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 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;
= [[File:Art.png]] 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; and put it into directory &#039;&#039;&#039;htdocs/mymodule&#039;&#039;&#039;. You can have only one CSS file per module.&lt;br /&gt;
Remember it&#039;s better to use existing styles already available by default into Dolibarr (The CSS file used by Dolibarr is file &#039;&#039;&#039;themes/mytheme/&#039;&#039;themename&#039;&#039;.php.css&#039;&#039;&#039;. Create your own CSS file only if you need absolutely to add not already existing styles.&lt;br /&gt;
Once your style sheet is ready, declare it into your module descriptor file by modifying the property &#039;&#039;&#039;$this-&amp;gt;style_sheet&#039;&#039;&#039;.&lt;br /&gt;
Value to put here must be a relative URL to your CSS file.&lt;br /&gt;
For example &#039;/mymodule/myfile.css&#039;.&lt;br /&gt;
&lt;br /&gt;
== Test your style sheet ==&lt;br /&gt;
Disable and enable your module.&lt;br /&gt;
&lt;br /&gt;
Go on home page (index.php). Show the HTML source of the page.&lt;br /&gt;
&lt;br /&gt;
You should see into the HTML header, a line that declare your style sheet.&lt;br /&gt;
&lt;br /&gt;
= [[File:Art.png]] 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;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
require(&#039;../main.inc.php&#039;);&lt;br /&gt;
$morejs=array(&amp;quot;/mymodule/js/mymodule.js&amp;quot;);&lt;br /&gt;
llxHeader(&#039;&#039;,&#039;Titre&#039;,&#039;&#039;,&#039;&#039;,&#039;&#039;,&#039;&#039;,$morejs,&#039;&#039;,0,0); &lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= [[File:Art.png]] 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;
= [[File:Art.png]] 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 market place.&lt;br /&gt;
But you can use it to have a package easy to distribute on your on network.&lt;br /&gt;
&lt;br /&gt;
* Go into the directory &#039;&#039;&#039;/build&#039;&#039;&#039; and copy the file &#039;&#039;&#039;makepack-dolibarrmodules.conf&#039;&#039;&#039; into &#039;&#039;&#039;makepack-mymodule.conf&#039;&#039;&#039;. Warning, this directory may not be provided in some packages of stable versions. If so, it can be retrieved from the CVS snapshot available for download on the Dolibarr website in area &amp;quot;Development version&amp;quot; (taken in this case the whole build directory which is autonomous and independent directory).&lt;br /&gt;
&lt;br /&gt;
Edit this file to add list of file names for all new files you created for your module (module descriptor, new sql tables files, php page, images, etc...)&lt;br /&gt;
&lt;br /&gt;
* Run the script via Perl (need the Perl version 5.0 or later):&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
perl makepack-dolibarrmodule.pl&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
The script asks you the name of your module, its major and minor version. A file &#039;&#039;&#039;mymodule.zip &#039;&#039;&#039; will then be manufactured containing your module ready to be deployed.&lt;br /&gt;
&lt;br /&gt;
* The person who receives your module must then place the file in the root directory of a Dolibarr installation and perform the command:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;bash&amp;quot;&amp;gt;&lt;br /&gt;
tar -xvf monmodule.zip&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* If you want your module to be public, you can submit it (the zip file) on Dolibarr web site on download area: {{LinkToPluginDownload}} (you must create an account first and be logged to use the link &amp;quot;Submit a product&amp;quot;).&lt;br /&gt;
** If your module was build correctly, file will be validated later.&lt;br /&gt;
** If quality is enough and license permits it, code might be added inside main Dolibarr sources (except if you disagree for that).&lt;br /&gt;
&lt;br /&gt;
= [[File:Art.png]] Some coding rules =&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;
= [[File:Art.png]] Using MDA =&lt;br /&gt;
A method to generate a functional module from a UML model has been developed. More information on the page [[UML2Dolibarr - Build a module using MDA]].&lt;/div&gt;</summary>
		<author><name>Attilioscot</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=Menus_system&amp;diff=22168</id>
		<title>Menus system</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=Menus_system&amp;diff=22168"/>
		<updated>2011-06-24T23:31:52Z</updated>

		<summary type="html">&lt;p&gt;Attilioscot: /* Develop you own menu manager */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Core]]&lt;br /&gt;
{{TemplateDocDev}}&lt;br /&gt;
&lt;br /&gt;
= The system of Dolibarr menus =&lt;br /&gt;
Dolibarr contains 2 systems to manage menus. One for the top menu and one for the left menu. There is no link between each other (so you can imagine to have a driver where menu entries are managed by top menu with combo lists and nothing on left menu). For explanation, we will call those 2 systems: &amp;quot;left menu&amp;quot; and &amp;quot;top menu&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
It is possible to develop your own menu manager (for left and/or top), that will replace completely the default one. You decide how you store your menu (database like with the menu manager &#039;&#039;&#039;auguria&#039;&#039;&#039;, centralized hard coded menu entries like in the menu &#039;&#039;&#039;eldy&#039;&#039;&#039;, xml files, ...). Like you see, you can offer a menu manager with the behavior you need and the technology you want.&lt;br /&gt;
&lt;br /&gt;
= Change your current menu manager =&lt;br /&gt;
Changing your menu manager with an existing one can be done from page Home -&amp;gt; Menus. &lt;br /&gt;
Take the menu manger you wnt in the list. If you enable menu manager &amp;quot;eldybackoffice&amp;quot;, provided by default (Activate the left menu manager &amp;quot;eldybackoffice&amp;quot; in the same time than the top menu &amp;quot;eldybackoffice&amp;quot;, both were developed to be used at the same time). All default menu managers provided by default are completely useful and offer some alternative.&lt;br /&gt;
&lt;br /&gt;
And if this does not suit your need, you can still develop yours. See next chapter for that.&lt;br /&gt;
&lt;br /&gt;
= Develop you own menu manager =&lt;br /&gt;
The aim of this paper is to describe how to create a new menu system in its entirety (to replace the entire menu entries, complete upheaval of the concept of navigation).&lt;br /&gt;
This does not relate how to add menu entries. If you just want to know how to add menu entries within an existing menu manager, when  developing an extension or a new module for example, you should look page [[Module development]] instead.&lt;br /&gt;
If you want to completely replace a system menu with your own, the easiest way is to use the menu Manager &amp;quot;eldy_backoffice&amp;quot; as an example:&lt;br /&gt;
&lt;br /&gt;
== To develop your own &#039;&#039;&#039;top menu&#039;&#039;&#039; ==&lt;br /&gt;
# Copy file htdocs/includes/menus/standard/eldy_backoffice.php into a file with a name like htdocs/includes/menus/standard/mymenu.php&lt;br /&gt;
# Edit this file mymenu.php. Function showmenu() of class MenuTop is the function called by Dolibarr, when generating a page, to show the top menu. You can put here the code you want, this function does not change any external vairable and must show using &amp;quot;print&amp;quot; the menu to show. So you can get menu to show from a configuration file, a database and personalized it according to environment. Environment Dolibarr is stored into 3 global variables: $user, $conf, $langs.&lt;br /&gt;
 $user contains information about current user.&lt;br /&gt;
 $conf contains information about setup (activated modules, permissions, options, etc...)&lt;br /&gt;
 $langs contains information about active language.&lt;br /&gt;
&lt;br /&gt;
Example of a function showmenu() into file htdocs/includes/menus/standard/mymenu.php&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
    function showmenu()&lt;br /&gt;
    {&lt;br /&gt;
        global $user,$conf,$langs,$dolibarr_main_db_name;;&lt;br /&gt;
        &lt;br /&gt;
        print &#039;&amp;lt;table class=&amp;quot;tmenu&amp;quot;&amp;gt;&amp;lt;tr class=&amp;quot;tmenu&amp;quot;&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
	    // Menu Home&lt;br /&gt;
	    print &#039;&amp;lt;td class=&amp;quot;tmenu&amp;quot;&amp;gt;&amp;lt;a &#039;.$class.&#039; href=&amp;quot;&#039;.DOL_URL_ROOT.&#039;/index.php?mainmenu=home&amp;amp;leftmenu=&amp;quot;&#039;.($this-&amp;gt;atarget?&amp;quot; target=&amp;quot;.$this-&amp;gt;atarget:&amp;quot;&amp;quot;).&#039;&amp;gt;&#039;.$langs-&amp;gt;trans(&amp;quot;Home&amp;quot;).&#039;&amp;lt;/a&amp;gt;&amp;lt;/td&amp;gt;&#039;;&lt;br /&gt;
	    &lt;br /&gt;
	    // Put here other entries&lt;br /&gt;
	    // ...&lt;br /&gt;
	    &lt;br /&gt;
        print &#039;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&#039;;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== To develop your own &#039;&#039;&#039;left menu&#039;&#039;&#039; ==&lt;br /&gt;
Principle is same than for top menu.&lt;br /&gt;
# You must edit function showmenu() of class MenuLeft to build your left menu. If you want to show standard menu with just minor changes without redoing everything, you have to loop on content of array $menu-&amp;gt;liste. If you want to build a menu completely different and controled only by yourself, you must, into the method showmenu(), create an object $newmenu=new Menu() and use methods $newmenu-&amp;gt;add and $newmenu-&amp;gt;add_submenu to defined list of left menu entries to show. Once this is done, you show those entries using some &amp;quot;print&amp;quot; to show content of array $newmenu-&amp;gt;liste (that we have just defined) instead of printing content of $menu-&amp;gt;liste.&lt;br /&gt;
&lt;br /&gt;
Example of file htdocs/includes/menus/standard/mymenu.php&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
    function showmenu()&lt;br /&gt;
    {&lt;br /&gt;
        global $user,$conf,$langs,$dolibarr_main_db_name;&lt;br /&gt;
        $newmenu = new Menu();&lt;br /&gt;
        &lt;br /&gt;
	// Put here left menu entries&lt;br /&gt;
	// ***** START *****&lt;br /&gt;
&lt;br /&gt;
	$langs-&amp;gt;load(&amp;quot;admin&amp;quot;);	// Load translation file admin.lang&lt;br /&gt;
	$newmenu-&amp;gt;add(DOL_URL_ROOT.&amp;quot;/admin/index.php?leftmenu=setup&amp;quot;, $langs-&amp;gt;trans(&amp;quot;Setup&amp;quot;));&lt;br /&gt;
	$newmenu-&amp;gt;add_submenu(DOL_URL_ROOT.&amp;quot;/admin/company.php&amp;quot;, $langs-&amp;gt;trans(&amp;quot;MenuCompanySetup&amp;quot;));&lt;br /&gt;
	$newmenu-&amp;gt;add_submenu(DOL_URL_ROOT.&amp;quot;/admin/modules.php&amp;quot;, $langs-&amp;gt;trans(&amp;quot;Modules&amp;quot;));&lt;br /&gt;
	$newmenu-&amp;gt;add_submenu(DOL_URL_ROOT.&amp;quot;/admin/ihm.php&amp;quot;, $langs-&amp;gt;trans(&amp;quot;GUISetup&amp;quot;));&lt;br /&gt;
	$newmenu-&amp;gt;add_submenu(DOL_URL_ROOT.&amp;quot;/admin/boxes.php&amp;quot;, $langs-&amp;gt;trans(&amp;quot;Boxes&amp;quot;));&lt;br /&gt;
	$newmenu-&amp;gt;add_submenu(DOL_URL_ROOT.&amp;quot;/admin/delais.php&amp;quot;,$langs-&amp;gt;trans(&amp;quot;Alerts&amp;quot;));&lt;br /&gt;
	$newmenu-&amp;gt;add_submenu(DOL_URL_ROOT.&amp;quot;/admin/triggers.php&amp;quot;, $langs-&amp;gt;trans(&amp;quot;Triggers&amp;quot;));&lt;br /&gt;
	$newmenu-&amp;gt;add_submenu(DOL_URL_ROOT.&amp;quot;/admin/perms.php&amp;quot;, $langs-&amp;gt;trans(&amp;quot;Security&amp;quot;));&lt;br /&gt;
	$newmenu-&amp;gt;add_submenu(DOL_URL_ROOT.&amp;quot;/admin/dict.php&amp;quot;, $langs-&amp;gt;trans(&amp;quot;DictionnarySetup&amp;quot;));&lt;br /&gt;
	$newmenu-&amp;gt;add_submenu(DOL_URL_ROOT.&amp;quot;/admin/const.php&amp;quot;, $langs-&amp;gt;trans(&amp;quot;OtherSetup&amp;quot;));&lt;br /&gt;
		&lt;br /&gt;
	// ***** END *****&lt;br /&gt;
		&lt;br /&gt;
        // do not change code after this&lt;br /&gt;
&lt;br /&gt;
        // override menu_array by value array in $newmenu&lt;br /&gt;
	$this-&amp;gt;menu_array=$newmenu-&amp;gt;liste;&lt;br /&gt;
&lt;br /&gt;
        $alt=0;&lt;br /&gt;
        for ($i = 0 ; $i &amp;lt; sizeof($this-&amp;gt;menu_array) ; $i++) &lt;br /&gt;
        {&lt;br /&gt;
            $alt++;&lt;br /&gt;
            if ($this-&amp;gt;menu_array[$i][&#039;level&#039;]==0) {&lt;br /&gt;
                if (($alt%2==0))&lt;br /&gt;
                {&lt;br /&gt;
                    print &#039;&amp;lt;div class=&amp;quot;blockvmenuimpair&amp;quot;&amp;gt;&#039;.&amp;quot;\n&amp;quot;;&lt;br /&gt;
                }&lt;br /&gt;
                else&lt;br /&gt;
                {&lt;br /&gt;
                    print &#039;&amp;lt;div class=&amp;quot;blockvmenupair&amp;quot;&amp;gt;&#039;.&amp;quot;\n&amp;quot;;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            if ($this-&amp;gt;menu_array[$i][&#039;level&#039;]==0) {&lt;br /&gt;
                if ($this-&amp;gt;menu_array[$i][&#039;enabled&#039;])&lt;br /&gt;
                    print &#039;&amp;lt;a class=&amp;quot;vmenu&amp;quot; href=&amp;quot;&#039;.$this-&amp;gt;menu_array[$i][&#039;url&#039;].&#039;&amp;quot;&amp;gt;&#039;.$this-&amp;gt;menu_array[$i][&#039;titre&#039;].&#039;&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&#039;;&lt;br /&gt;
                else &lt;br /&gt;
                    print &#039;&amp;lt;font class=&amp;quot;vmenudisabled&amp;quot;&amp;gt;&#039;.$this-&amp;gt;menu_array[$i][&#039;titre&#039;].&#039;&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&#039;;&lt;br /&gt;
            }&lt;br /&gt;
            if ($this-&amp;gt;menu_array[$i][&#039;level&#039;]==1) {&lt;br /&gt;
                if ($this-&amp;gt;menu_array[$i][&#039;enabled&#039;])&lt;br /&gt;
                    print &#039;&amp;lt;a class=&amp;quot;vsmenu&amp;quot; href=&amp;quot;&#039;.$this-&amp;gt;menu_array[$i][&#039;url&#039;].&#039;&amp;quot;&amp;gt;&#039;.$this-&amp;gt;menu_array[$i][&#039;titre&#039;].&#039;&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&#039;;&lt;br /&gt;
                else &lt;br /&gt;
                    print &#039;&amp;lt;font class=&amp;quot;vsmenudisabled&amp;quot;&amp;gt;&#039;.$this-&amp;gt;menu_array[$i][&#039;titre&#039;].&#039;&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&#039;;&lt;br /&gt;
            }&lt;br /&gt;
            if ($this-&amp;gt;menu_array[$i][&#039;level&#039;]==2) {&lt;br /&gt;
                if ($this-&amp;gt;menu_array[$i][&#039;enabled&#039;])&lt;br /&gt;
                    print &#039;&amp;amp;nbsp; &amp;amp;nbsp; &amp;lt;a class=&amp;quot;vsmenu&amp;quot; href=&amp;quot;&#039;.$this-&amp;gt;menu_array[$i][&#039;url&#039;].&#039;&amp;quot;&amp;gt;&#039;.$this-&amp;gt;menu_array[$i][&#039;titre&#039;].&#039;&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&#039;;&lt;br /&gt;
                else &lt;br /&gt;
                    print &#039;&amp;amp;nbsp; &amp;amp;nbsp; &amp;lt;font class=&amp;quot;vsmenudisabled&amp;quot;&amp;gt;&#039;.$this-&amp;gt;menu_array[$i][&#039;titre&#039;].&#039;&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&#039;;&lt;br /&gt;
            }&lt;br /&gt;
            if ($this-&amp;gt;menu_array[$i][&#039;level&#039;]==3) {&lt;br /&gt;
                if ($this-&amp;gt;menu_array[$i][&#039;enabled&#039;])&lt;br /&gt;
                    print &#039;&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;lt;a class=&amp;quot;vsmenu&amp;quot; href=&amp;quot;&#039;.$this-&amp;gt;menu_array[$i][&#039;url&#039;].&#039;&amp;quot;&amp;gt;&#039;.$this-&amp;gt;menu_array[$i][&#039;titre&#039;].&#039;&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&#039;;&lt;br /&gt;
                else &lt;br /&gt;
                    print &#039;&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;lt;font class=&amp;quot;vsmenudisabled&amp;quot;&amp;gt;&#039;.$this-&amp;gt;menu_array[$i][&#039;titre&#039;].&#039;&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&#039;;&lt;br /&gt;
            }&lt;br /&gt;
            &lt;br /&gt;
            if ($i == (sizeof($this-&amp;gt;menu_array)-1) || $this-&amp;gt;menu_array[$i+1][&#039;level&#039;]==0)  {&lt;br /&gt;
                print &amp;quot;&amp;lt;/div&amp;gt;\n&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= To force usage of your menu manager =&lt;br /&gt;
You can force usage of your own menu manager by creating a module.&lt;br /&gt;
For this , all you have to do is to declare the 4 following constants into the array $this-&amp;gt;const of your module descriptor file (See page [[Module development]]).&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
* 1=&amp;gt;array(&#039;MAIN_MENU_STANDARD_FORCED&#039;,&#039;chaine&#039;,&#039;mymodule.php&#039;,&#039;Force menu handler to this value&#039;,1,&#039;current&#039;,1),&lt;br /&gt;
* 2=&amp;gt;array(&#039;MAIN_MENUFRONT_STANDARD_FORCED&#039;,&#039;chaine&#039;,&#039;mymodule.php&#039;,&#039;Force menu handler to this value&#039;,1,&#039;current&#039;,1),&lt;br /&gt;
* 3=&amp;gt;array(&#039;MAIN_MENU_SMARTPHONE_FORCED&#039;,&#039;chaine&#039;,&#039;mymodule.php&#039;,&#039;Force menu handler to this value&#039;,1,&#039;current&#039;,1),&lt;br /&gt;
* 4=&amp;gt;array(&#039;MAIN_MENUFRONT_SMARTPHONE_FORCED&#039;,&#039;chaine&#039;,&#039;mymodule.php&#039;,&#039;Force menu handler to this value&#039;,1,&#039;current&#039;,1),&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Your menu manager will be used once the module is activated.&lt;/div&gt;</summary>
		<author><name>Attilioscot</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=Menus_system&amp;diff=22167</id>
		<title>Menus system</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=Menus_system&amp;diff=22167"/>
		<updated>2011-06-24T23:30:22Z</updated>

		<summary type="html">&lt;p&gt;Attilioscot: /* The system of Dolibarr menus */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Core]]&lt;br /&gt;
{{TemplateDocDev}}&lt;br /&gt;
&lt;br /&gt;
= The system of Dolibarr menus =&lt;br /&gt;
Dolibarr contains 2 systems to manage menus. One for the top menu and one for the left menu. There is no link between each other (so you can imagine to have a driver where menu entries are managed by top menu with combo lists and nothing on left menu). For explanation, we will call those 2 systems: &amp;quot;left menu&amp;quot; and &amp;quot;top menu&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
It is possible to develop your own menu manager (for left and/or top), that will replace completely the default one. You decide how you store your menu (database like with the menu manager &#039;&#039;&#039;auguria&#039;&#039;&#039;, centralized hard coded menu entries like in the menu &#039;&#039;&#039;eldy&#039;&#039;&#039;, xml files, ...). Like you see, you can offer a menu manager with the behavior you need and the technology you want.&lt;br /&gt;
&lt;br /&gt;
= Change your current menu manager =&lt;br /&gt;
Changing your menu manager with an existing one can be done from page Home -&amp;gt; Menus. &lt;br /&gt;
Take the menu manger you wnt in the list. If you enable menu manager &amp;quot;eldybackoffice&amp;quot;, provided by default (Activate the left menu manager &amp;quot;eldybackoffice&amp;quot; in the same time than the top menu &amp;quot;eldybackoffice&amp;quot;, both were developed to be used at the same time). All default menu managers provided by default are completely useful and offer some alternative.&lt;br /&gt;
&lt;br /&gt;
And if this does not suit your need, you can still develop yours. See next chapter for that.&lt;br /&gt;
&lt;br /&gt;
= Develop you own menu manager =&lt;br /&gt;
The aim of this paper is to describe how to create a new menu system in its entirety (to replace the entire menu entries, complete upheaval of the concept of navigation).&lt;br /&gt;
This does not relate how to add menu entries. If you just want to know how to add menu entries within an existing menu manager, when  developing an extension or a new module for example, you should look page [[Module development]] instead.&lt;br /&gt;
If you want to completely replace a system menu with your own, the easiest way is to use the menu Manager &amp;quot;eldy_backoffice&amp;quot; a an example:&lt;br /&gt;
&lt;br /&gt;
== To develop your own &#039;&#039;&#039;top menu&#039;&#039;&#039; ==&lt;br /&gt;
# Copy file htdocs/includes/menus/standard/eldy_backoffice.php into a file with a name like htdocs/includes/menus/standard/mymenu.php&lt;br /&gt;
# Edit this file mymenu.php. Function showmenu() of class MenuTop is the function called by Dolibarr, when generating a page, to show the top menu. You can put here the code you want, this function does not change any external vairable and must show using &amp;quot;print&amp;quot; the menu to show. So you can get menu to show from a configuration file, a database and personalized it according to environment. Environment Dolibarr is stored into 3 global variables: $user, $conf, $langs.&lt;br /&gt;
 $user contains information about current user.&lt;br /&gt;
 $conf contains information about setup (activated modules, permissions, options, etc...)&lt;br /&gt;
 $langs contains information about active language.&lt;br /&gt;
&lt;br /&gt;
Example of a function showmenu() into file htdocs/includes/menus/standard/mymenu.php&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
    function showmenu()&lt;br /&gt;
    {&lt;br /&gt;
        global $user,$conf,$langs,$dolibarr_main_db_name;;&lt;br /&gt;
        &lt;br /&gt;
        print &#039;&amp;lt;table class=&amp;quot;tmenu&amp;quot;&amp;gt;&amp;lt;tr class=&amp;quot;tmenu&amp;quot;&amp;gt;&#039;;&lt;br /&gt;
&lt;br /&gt;
	    // Menu Home&lt;br /&gt;
	    print &#039;&amp;lt;td class=&amp;quot;tmenu&amp;quot;&amp;gt;&amp;lt;a &#039;.$class.&#039; href=&amp;quot;&#039;.DOL_URL_ROOT.&#039;/index.php?mainmenu=home&amp;amp;leftmenu=&amp;quot;&#039;.($this-&amp;gt;atarget?&amp;quot; target=&amp;quot;.$this-&amp;gt;atarget:&amp;quot;&amp;quot;).&#039;&amp;gt;&#039;.$langs-&amp;gt;trans(&amp;quot;Home&amp;quot;).&#039;&amp;lt;/a&amp;gt;&amp;lt;/td&amp;gt;&#039;;&lt;br /&gt;
	    &lt;br /&gt;
	    // Put here other entries&lt;br /&gt;
	    // ...&lt;br /&gt;
	    &lt;br /&gt;
        print &#039;&amp;lt;/tr&amp;gt;&amp;lt;/table&amp;gt;&#039;;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== To develop your own &#039;&#039;&#039;left menu&#039;&#039;&#039; ==&lt;br /&gt;
Principle is same than for top menu.&lt;br /&gt;
# You must edit function showmenu() of class MenuLeft to build your left menu. If you want to show standard menu with just minor changes without redoing everything, you have to loop on content of array $menu-&amp;gt;liste. If you want to build a menu completely different and controled only by yourself, you must, into the method showmenu(), create an object $newmenu=new Menu() and use methods $newmenu-&amp;gt;add and $newmenu-&amp;gt;add_submenu to defined list of left menu entries to show. Once this is done, you show those entries using some &amp;quot;print&amp;quot; to show content of array $newmenu-&amp;gt;liste (that we have just defined) instead of printing content of $menu-&amp;gt;liste.&lt;br /&gt;
&lt;br /&gt;
Example of file htdocs/includes/menus/standard/mymenu.php&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
    function showmenu()&lt;br /&gt;
    {&lt;br /&gt;
        global $user,$conf,$langs,$dolibarr_main_db_name;&lt;br /&gt;
        $newmenu = new Menu();&lt;br /&gt;
        &lt;br /&gt;
	// Put here left menu entries&lt;br /&gt;
	// ***** START *****&lt;br /&gt;
&lt;br /&gt;
	$langs-&amp;gt;load(&amp;quot;admin&amp;quot;);	// Load translation file admin.lang&lt;br /&gt;
	$newmenu-&amp;gt;add(DOL_URL_ROOT.&amp;quot;/admin/index.php?leftmenu=setup&amp;quot;, $langs-&amp;gt;trans(&amp;quot;Setup&amp;quot;));&lt;br /&gt;
	$newmenu-&amp;gt;add_submenu(DOL_URL_ROOT.&amp;quot;/admin/company.php&amp;quot;, $langs-&amp;gt;trans(&amp;quot;MenuCompanySetup&amp;quot;));&lt;br /&gt;
	$newmenu-&amp;gt;add_submenu(DOL_URL_ROOT.&amp;quot;/admin/modules.php&amp;quot;, $langs-&amp;gt;trans(&amp;quot;Modules&amp;quot;));&lt;br /&gt;
	$newmenu-&amp;gt;add_submenu(DOL_URL_ROOT.&amp;quot;/admin/ihm.php&amp;quot;, $langs-&amp;gt;trans(&amp;quot;GUISetup&amp;quot;));&lt;br /&gt;
	$newmenu-&amp;gt;add_submenu(DOL_URL_ROOT.&amp;quot;/admin/boxes.php&amp;quot;, $langs-&amp;gt;trans(&amp;quot;Boxes&amp;quot;));&lt;br /&gt;
	$newmenu-&amp;gt;add_submenu(DOL_URL_ROOT.&amp;quot;/admin/delais.php&amp;quot;,$langs-&amp;gt;trans(&amp;quot;Alerts&amp;quot;));&lt;br /&gt;
	$newmenu-&amp;gt;add_submenu(DOL_URL_ROOT.&amp;quot;/admin/triggers.php&amp;quot;, $langs-&amp;gt;trans(&amp;quot;Triggers&amp;quot;));&lt;br /&gt;
	$newmenu-&amp;gt;add_submenu(DOL_URL_ROOT.&amp;quot;/admin/perms.php&amp;quot;, $langs-&amp;gt;trans(&amp;quot;Security&amp;quot;));&lt;br /&gt;
	$newmenu-&amp;gt;add_submenu(DOL_URL_ROOT.&amp;quot;/admin/dict.php&amp;quot;, $langs-&amp;gt;trans(&amp;quot;DictionnarySetup&amp;quot;));&lt;br /&gt;
	$newmenu-&amp;gt;add_submenu(DOL_URL_ROOT.&amp;quot;/admin/const.php&amp;quot;, $langs-&amp;gt;trans(&amp;quot;OtherSetup&amp;quot;));&lt;br /&gt;
		&lt;br /&gt;
	// ***** END *****&lt;br /&gt;
		&lt;br /&gt;
        // do not change code after this&lt;br /&gt;
&lt;br /&gt;
        // override menu_array by value array in $newmenu&lt;br /&gt;
	$this-&amp;gt;menu_array=$newmenu-&amp;gt;liste;&lt;br /&gt;
&lt;br /&gt;
        $alt=0;&lt;br /&gt;
        for ($i = 0 ; $i &amp;lt; sizeof($this-&amp;gt;menu_array) ; $i++) &lt;br /&gt;
        {&lt;br /&gt;
            $alt++;&lt;br /&gt;
            if ($this-&amp;gt;menu_array[$i][&#039;level&#039;]==0) {&lt;br /&gt;
                if (($alt%2==0))&lt;br /&gt;
                {&lt;br /&gt;
                    print &#039;&amp;lt;div class=&amp;quot;blockvmenuimpair&amp;quot;&amp;gt;&#039;.&amp;quot;\n&amp;quot;;&lt;br /&gt;
                }&lt;br /&gt;
                else&lt;br /&gt;
                {&lt;br /&gt;
                    print &#039;&amp;lt;div class=&amp;quot;blockvmenupair&amp;quot;&amp;gt;&#039;.&amp;quot;\n&amp;quot;;&lt;br /&gt;
                }&lt;br /&gt;
            }&lt;br /&gt;
&lt;br /&gt;
            if ($this-&amp;gt;menu_array[$i][&#039;level&#039;]==0) {&lt;br /&gt;
                if ($this-&amp;gt;menu_array[$i][&#039;enabled&#039;])&lt;br /&gt;
                    print &#039;&amp;lt;a class=&amp;quot;vmenu&amp;quot; href=&amp;quot;&#039;.$this-&amp;gt;menu_array[$i][&#039;url&#039;].&#039;&amp;quot;&amp;gt;&#039;.$this-&amp;gt;menu_array[$i][&#039;titre&#039;].&#039;&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&#039;;&lt;br /&gt;
                else &lt;br /&gt;
                    print &#039;&amp;lt;font class=&amp;quot;vmenudisabled&amp;quot;&amp;gt;&#039;.$this-&amp;gt;menu_array[$i][&#039;titre&#039;].&#039;&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&#039;;&lt;br /&gt;
            }&lt;br /&gt;
            if ($this-&amp;gt;menu_array[$i][&#039;level&#039;]==1) {&lt;br /&gt;
                if ($this-&amp;gt;menu_array[$i][&#039;enabled&#039;])&lt;br /&gt;
                    print &#039;&amp;lt;a class=&amp;quot;vsmenu&amp;quot; href=&amp;quot;&#039;.$this-&amp;gt;menu_array[$i][&#039;url&#039;].&#039;&amp;quot;&amp;gt;&#039;.$this-&amp;gt;menu_array[$i][&#039;titre&#039;].&#039;&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&#039;;&lt;br /&gt;
                else &lt;br /&gt;
                    print &#039;&amp;lt;font class=&amp;quot;vsmenudisabled&amp;quot;&amp;gt;&#039;.$this-&amp;gt;menu_array[$i][&#039;titre&#039;].&#039;&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&#039;;&lt;br /&gt;
            }&lt;br /&gt;
            if ($this-&amp;gt;menu_array[$i][&#039;level&#039;]==2) {&lt;br /&gt;
                if ($this-&amp;gt;menu_array[$i][&#039;enabled&#039;])&lt;br /&gt;
                    print &#039;&amp;amp;nbsp; &amp;amp;nbsp; &amp;lt;a class=&amp;quot;vsmenu&amp;quot; href=&amp;quot;&#039;.$this-&amp;gt;menu_array[$i][&#039;url&#039;].&#039;&amp;quot;&amp;gt;&#039;.$this-&amp;gt;menu_array[$i][&#039;titre&#039;].&#039;&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&#039;;&lt;br /&gt;
                else &lt;br /&gt;
                    print &#039;&amp;amp;nbsp; &amp;amp;nbsp; &amp;lt;font class=&amp;quot;vsmenudisabled&amp;quot;&amp;gt;&#039;.$this-&amp;gt;menu_array[$i][&#039;titre&#039;].&#039;&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&#039;;&lt;br /&gt;
            }&lt;br /&gt;
            if ($this-&amp;gt;menu_array[$i][&#039;level&#039;]==3) {&lt;br /&gt;
                if ($this-&amp;gt;menu_array[$i][&#039;enabled&#039;])&lt;br /&gt;
                    print &#039;&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;lt;a class=&amp;quot;vsmenu&amp;quot; href=&amp;quot;&#039;.$this-&amp;gt;menu_array[$i][&#039;url&#039;].&#039;&amp;quot;&amp;gt;&#039;.$this-&amp;gt;menu_array[$i][&#039;titre&#039;].&#039;&amp;lt;/a&amp;gt;&amp;lt;br&amp;gt;&#039;;&lt;br /&gt;
                else &lt;br /&gt;
                    print &#039;&amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;lt;font class=&amp;quot;vsmenudisabled&amp;quot;&amp;gt;&#039;.$this-&amp;gt;menu_array[$i][&#039;titre&#039;].&#039;&amp;lt;/font&amp;gt;&amp;lt;br&amp;gt;&#039;;&lt;br /&gt;
            }&lt;br /&gt;
            &lt;br /&gt;
            if ($i == (sizeof($this-&amp;gt;menu_array)-1) || $this-&amp;gt;menu_array[$i+1][&#039;level&#039;]==0)  {&lt;br /&gt;
                print &amp;quot;&amp;lt;/div&amp;gt;\n&amp;quot;;&lt;br /&gt;
            }&lt;br /&gt;
        }&lt;br /&gt;
&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
= To force usage of your menu manager =&lt;br /&gt;
You can force usage of your own menu manager by creating a module.&lt;br /&gt;
For this , all you have to do is to declare the 4 following constants into the array $this-&amp;gt;const of your module descriptor file (See page [[Module development]]).&lt;br /&gt;
&amp;lt;source lang=&amp;quot;php&amp;quot;&amp;gt;&lt;br /&gt;
* 1=&amp;gt;array(&#039;MAIN_MENU_STANDARD_FORCED&#039;,&#039;chaine&#039;,&#039;mymodule.php&#039;,&#039;Force menu handler to this value&#039;,1,&#039;current&#039;,1),&lt;br /&gt;
* 2=&amp;gt;array(&#039;MAIN_MENUFRONT_STANDARD_FORCED&#039;,&#039;chaine&#039;,&#039;mymodule.php&#039;,&#039;Force menu handler to this value&#039;,1,&#039;current&#039;,1),&lt;br /&gt;
* 3=&amp;gt;array(&#039;MAIN_MENU_SMARTPHONE_FORCED&#039;,&#039;chaine&#039;,&#039;mymodule.php&#039;,&#039;Force menu handler to this value&#039;,1,&#039;current&#039;,1),&lt;br /&gt;
* 4=&amp;gt;array(&#039;MAIN_MENUFRONT_SMARTPHONE_FORCED&#039;,&#039;chaine&#039;,&#039;mymodule.php&#039;,&#039;Force menu handler to this value&#039;,1,&#039;current&#039;,1),&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Your menu manager will be used once the module is activated.&lt;/div&gt;</summary>
		<author><name>Attilioscot</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=Business_Objects&amp;diff=22165</id>
		<title>Business Objects</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=Business_Objects&amp;diff=22165"/>
		<updated>2011-06-22T10:01:30Z</updated>

		<summary type="html">&lt;p&gt;Attilioscot: /* Link between Business objects */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{TemplateDocDevEn}}&lt;br /&gt;
= Business objects =&lt;br /&gt;
All business objects are defined by a PHP class that herits of class CommonObject (defined in file commonobject.class.php).&lt;br /&gt;
Every business object has the 4 CRUD methods you can use to read or save database:&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;
See examples later...&lt;br /&gt;
&lt;br /&gt;
= Link between Business objects =&lt;br /&gt;
Some business objects are linked to other. This is done into 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;
This is a portion of code that shows how you can do this:&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;
= Examples =&lt;br /&gt;
&lt;br /&gt;
== Example for a third party ==&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 if 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;
// On 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;
== Other examples ==&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 cvs snapshot.&lt;/div&gt;</summary>
		<author><name>Attilioscot</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=Module_Stocks_En&amp;diff=22158</id>
		<title>Module Stocks En</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=Module_Stocks_En&amp;diff=22158"/>
		<updated>2011-06-20T16:05:13Z</updated>

		<summary type="html">&lt;p&gt;Attilioscot: /* Manual stock updates */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Stock]]&lt;br /&gt;
{{TemplateDocUser}}&lt;br /&gt;
{{TemplateModEN}}&lt;br /&gt;
{{BasculeDevUser|&lt;br /&gt;
nom=Stock|&lt;br /&gt;
num=52|&lt;br /&gt;
devdoc=[[Module Stock (developer)]]|&lt;br /&gt;
userdoc=This page|}}&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
Stock management module can save status for stocks of products into warehouses, edit amounts of products you have and correct them.&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
{{NoInstallModuleEn}}&lt;br /&gt;
&lt;br /&gt;
= Configuration =&lt;br /&gt;
{{ActivationModuleEn}}&lt;br /&gt;
&lt;br /&gt;
The setup page allows you to choose, among four options, when the stock is automatically incremented or decreased (depending on events in orders or invoices cycle of life).&lt;br /&gt;
&lt;br /&gt;
= Create a warehouse =&lt;br /&gt;
The creation of a warehouse is the mandatory first step for stock management. You can create a warehouse on the &#039;&#039;Products/Services&#039;&#039; tab, clicking &#039;&#039;Stocks&#039;&#039; on the left menu and then &#039;&#039;New warehouse stock&#039;&#039;. The only required information is a reference code and a warehouse name, the other fields are optional. You must then set whether the warehouse is running or not (opened / closed).  A closed warehouse cannot be used by the other Dolibarr functions.  This is a good way to prepare a warehouse (by filling it up) before you turn it on, or to temporarily block during an inventory.&lt;br /&gt;
&lt;br /&gt;
= Allocate product stocks =&lt;br /&gt;
&lt;br /&gt;
Long but necessary step, it is then, for each product, to define the stock amount, in each warehouse. This has to be done from the &#039;&#039;stock&#039;&#039; tab on the page of the product, which can be found on the &#039;&#039;products&#039;&#039; section of the left menu.&lt;br /&gt;
&lt;br /&gt;
= Automatic stock updates =&lt;br /&gt;
&lt;br /&gt;
Depending on the option chosen in the module&#039;s configuration, the available stock amount is updated either at the time of the proposal, at the time of shipment, at the time of invoice, etc..  A movement of stock is then registered according to the chosen stocking criteria.&lt;br /&gt;
&lt;br /&gt;
Warning: in current version (3.0.0), automatic stock updates are only applied to warehouse number 1!&lt;br /&gt;
&lt;br /&gt;
= Manual stock updates =&lt;br /&gt;
&lt;br /&gt;
If you wish to make adjustments to the existing stock amounts (because of internal production, theft, loss, aging, ...), you can do it directly via the stock tab on the page of the product.&lt;br /&gt;
Use the label field to specify the reason for the change, or to add miscellaneous information.&lt;br /&gt;
&lt;br /&gt;
= Warehouse status =&lt;br /&gt;
&lt;br /&gt;
It is possible to obtain a detailed list of products and movements in a warehouse via a click on the name of the store from the list of warehouses.&lt;br /&gt;
&lt;br /&gt;
= Examples of use cases =&lt;br /&gt;
{{ToComplete}}&lt;br /&gt;
{{ExamplesCaseEn&lt;br /&gt;
|name=UCMS01: &lt;br /&gt;
|situation=&lt;br /&gt;
|actions=&lt;br /&gt;
}}&amp;amp;nbsp;&lt;/div&gt;</summary>
		<author><name>Attilioscot</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=Module_Stocks_En&amp;diff=22157</id>
		<title>Module Stocks En</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=Module_Stocks_En&amp;diff=22157"/>
		<updated>2011-06-20T15:27:48Z</updated>

		<summary type="html">&lt;p&gt;Attilioscot: /* Manual stock updates */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Stock]]&lt;br /&gt;
{{TemplateDocUser}}&lt;br /&gt;
{{TemplateModEN}}&lt;br /&gt;
{{BasculeDevUser|&lt;br /&gt;
nom=Stock|&lt;br /&gt;
num=52|&lt;br /&gt;
devdoc=[[Module Stock (developer)]]|&lt;br /&gt;
userdoc=This page|}}&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
Stock management module can save status for stocks of products into warehouses, edit amounts of products you have and correct them.&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
{{NoInstallModuleEn}}&lt;br /&gt;
&lt;br /&gt;
= Configuration =&lt;br /&gt;
{{ActivationModuleEn}}&lt;br /&gt;
&lt;br /&gt;
The setup page allows you to choose, among four options, when the stock is automatically incremented or decreased (depending on events in orders or invoices cycle of life).&lt;br /&gt;
&lt;br /&gt;
= Create a warehouse =&lt;br /&gt;
The creation of a warehouse is the mandatory first step for stock management. You can create a warehouse on the &#039;&#039;Products/Services&#039;&#039; tab, clicking &#039;&#039;Stocks&#039;&#039; on the left menu and then &#039;&#039;New warehouse stock&#039;&#039;. The only required information is a reference code and a warehouse name, the other fields are optional. You must then set whether the warehouse is running or not (opened / closed).  A closed warehouse cannot be used by the other Dolibarr functions.  This is a good way to prepare a warehouse (by filling it up) before you turn it on, or to temporarily block during an inventory.&lt;br /&gt;
&lt;br /&gt;
= Allocate product stocks =&lt;br /&gt;
&lt;br /&gt;
Long but necessary step, it is then, for each product, to define the stock amount, in each warehouse. This has to be done from the &#039;&#039;stock&#039;&#039; tab on the page of the product, which can be found on the &#039;&#039;products&#039;&#039; section of the left menu.&lt;br /&gt;
&lt;br /&gt;
= Automatic stock updates =&lt;br /&gt;
&lt;br /&gt;
Depending on the option chosen in the module&#039;s configuration, the available stock amount is updated either at the time of the proposal, at the time of shipment, at the time of invoice, etc..  A movement of stock is then registered according to the chosen stocking criteria.&lt;br /&gt;
&lt;br /&gt;
Warning: in current version (3.0.0), automatic stock updates are only applied to warehouse number 1!&lt;br /&gt;
&lt;br /&gt;
= Manual stock updates =&lt;br /&gt;
&lt;br /&gt;
If you wish to make adjustments to the existing stock amounts (because of internal production, theft, loss, aging, ...), you can do it directly via the stock tab on the page of the product.&lt;br /&gt;
&lt;br /&gt;
= Warehouse status =&lt;br /&gt;
&lt;br /&gt;
It is possible to obtain a detailed list of products and movements in a warehouse via a click on the name of the store from the list of warehouses.&lt;br /&gt;
&lt;br /&gt;
= Examples of use cases =&lt;br /&gt;
{{ToComplete}}&lt;br /&gt;
{{ExamplesCaseEn&lt;br /&gt;
|name=UCMS01: &lt;br /&gt;
|situation=&lt;br /&gt;
|actions=&lt;br /&gt;
}}&amp;amp;nbsp;&lt;/div&gt;</summary>
		<author><name>Attilioscot</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=Module_Stocks_En&amp;diff=22156</id>
		<title>Module Stocks En</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=Module_Stocks_En&amp;diff=22156"/>
		<updated>2011-06-20T15:22:36Z</updated>

		<summary type="html">&lt;p&gt;Attilioscot: /* Fiche entrepôt */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Stock]]&lt;br /&gt;
{{TemplateDocUser}}&lt;br /&gt;
{{TemplateModEN}}&lt;br /&gt;
{{BasculeDevUser|&lt;br /&gt;
nom=Stock|&lt;br /&gt;
num=52|&lt;br /&gt;
devdoc=[[Module Stock (developer)]]|&lt;br /&gt;
userdoc=This page|}}&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
Stock management module can save status for stocks of products into warehouses, edit amounts of products you have and correct them.&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
{{NoInstallModuleEn}}&lt;br /&gt;
&lt;br /&gt;
= Configuration =&lt;br /&gt;
{{ActivationModuleEn}}&lt;br /&gt;
&lt;br /&gt;
The setup page allows you to choose, among four options, when the stock is automatically incremented or decreased (depending on events in orders or invoices cycle of life).&lt;br /&gt;
&lt;br /&gt;
= Create a warehouse =&lt;br /&gt;
The creation of a warehouse is the mandatory first step for stock management. You can create a warehouse on the &#039;&#039;Products/Services&#039;&#039; tab, clicking &#039;&#039;Stocks&#039;&#039; on the left menu and then &#039;&#039;New warehouse stock&#039;&#039;. The only required information is a reference code and a warehouse name, the other fields are optional. You must then set whether the warehouse is running or not (opened / closed).  A closed warehouse cannot be used by the other Dolibarr functions.  This is a good way to prepare a warehouse (by filling it up) before you turn it on, or to temporarily block during an inventory.&lt;br /&gt;
&lt;br /&gt;
= Allocate product stocks =&lt;br /&gt;
&lt;br /&gt;
Long but necessary step, it is then, for each product, to define the stock amount, in each warehouse. This has to be done from the &#039;&#039;stock&#039;&#039; tab on the page of the product, which can be found on the &#039;&#039;products&#039;&#039; section of the left menu.&lt;br /&gt;
&lt;br /&gt;
= Automatic stock updates =&lt;br /&gt;
&lt;br /&gt;
Depending on the option chosen in the module&#039;s configuration, the available stock amount is updated either at the time of the proposal, at the time of shipment, at the time of invoice, etc..  A movement of stock is then registered according to the chosen stocking criteria.&lt;br /&gt;
&lt;br /&gt;
Warning: in current version (3.0.0), automatic stock updates are only applied to warehouse number 1!&lt;br /&gt;
&lt;br /&gt;
= Manual stock updates =&lt;br /&gt;
&lt;br /&gt;
If you wish to make adjustments to the existing stock amounts (because of theft, loss, aging, ...), you can do it directly via the stock tab on the page of the product.&lt;br /&gt;
&lt;br /&gt;
= Warehouse status =&lt;br /&gt;
&lt;br /&gt;
It is possible to obtain a detailed list of products and movements in a warehouse via a click on the name of the store from the list of warehouses.&lt;br /&gt;
&lt;br /&gt;
= Examples of use cases =&lt;br /&gt;
{{ToComplete}}&lt;br /&gt;
{{ExamplesCaseEn&lt;br /&gt;
|name=UCMS01: &lt;br /&gt;
|situation=&lt;br /&gt;
|actions=&lt;br /&gt;
}}&amp;amp;nbsp;&lt;/div&gt;</summary>
		<author><name>Attilioscot</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=Module_Stocks_En&amp;diff=22155</id>
		<title>Module Stocks En</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=Module_Stocks_En&amp;diff=22155"/>
		<updated>2011-06-20T15:16:52Z</updated>

		<summary type="html">&lt;p&gt;Attilioscot: /* Modification manuelle du stock */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Stock]]&lt;br /&gt;
{{TemplateDocUser}}&lt;br /&gt;
{{TemplateModEN}}&lt;br /&gt;
{{BasculeDevUser|&lt;br /&gt;
nom=Stock|&lt;br /&gt;
num=52|&lt;br /&gt;
devdoc=[[Module Stock (developer)]]|&lt;br /&gt;
userdoc=This page|}}&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
Stock management module can save status for stocks of products into warehouses, edit amounts of products you have and correct them.&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
{{NoInstallModuleEn}}&lt;br /&gt;
&lt;br /&gt;
= Configuration =&lt;br /&gt;
{{ActivationModuleEn}}&lt;br /&gt;
&lt;br /&gt;
The setup page allows you to choose, among four options, when the stock is automatically incremented or decreased (depending on events in orders or invoices cycle of life).&lt;br /&gt;
&lt;br /&gt;
= Create a warehouse =&lt;br /&gt;
The creation of a warehouse is the mandatory first step for stock management. You can create a warehouse on the &#039;&#039;Products/Services&#039;&#039; tab, clicking &#039;&#039;Stocks&#039;&#039; on the left menu and then &#039;&#039;New warehouse stock&#039;&#039;. The only required information is a reference code and a warehouse name, the other fields are optional. You must then set whether the warehouse is running or not (opened / closed).  A closed warehouse cannot be used by the other Dolibarr functions.  This is a good way to prepare a warehouse (by filling it up) before you turn it on, or to temporarily block during an inventory.&lt;br /&gt;
&lt;br /&gt;
= Allocate product stocks =&lt;br /&gt;
&lt;br /&gt;
Long but necessary step, it is then, for each product, to define the stock amount, in each warehouse. This has to be done from the &#039;&#039;stock&#039;&#039; tab on the page of the product, which can be found on the &#039;&#039;products&#039;&#039; section of the left menu.&lt;br /&gt;
&lt;br /&gt;
= Automatic stock updates =&lt;br /&gt;
&lt;br /&gt;
Depending on the option chosen in the module&#039;s configuration, the available stock amount is updated either at the time of the proposal, at the time of shipment, at the time of invoice, etc..  A movement of stock is then registered according to the chosen stocking criteria.&lt;br /&gt;
&lt;br /&gt;
Warning: in current version (3.0.0), automatic stock updates are only applied to warehouse number 1!&lt;br /&gt;
&lt;br /&gt;
= Manual stock updates =&lt;br /&gt;
&lt;br /&gt;
If you wish to make adjustments to the existing stock amounts (because of theft, loss, aging, ...), you can do it directly via the stock tab on the page of the product.&lt;br /&gt;
&lt;br /&gt;
= Fiche entrepôt =&lt;br /&gt;
&lt;br /&gt;
Il est possible d&#039;obtenir une liste détaillée des produits et mouvements enregistrés dans un entrepôt via un clic sur le nom de l&#039;entrepôt dans la liste des entrepôts.&lt;br /&gt;
&lt;br /&gt;
= Examples of use cases =&lt;br /&gt;
{{ToComplete}}&lt;br /&gt;
{{ExamplesCaseEn&lt;br /&gt;
|name=UCMS01: &lt;br /&gt;
|situation=&lt;br /&gt;
|actions=&lt;br /&gt;
}}&amp;amp;nbsp;&lt;/div&gt;</summary>
		<author><name>Attilioscot</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=Module_Stocks_En&amp;diff=22154</id>
		<title>Module Stocks En</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=Module_Stocks_En&amp;diff=22154"/>
		<updated>2011-06-20T15:13:23Z</updated>

		<summary type="html">&lt;p&gt;Attilioscot: /* Modification automatique du stock */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Stock]]&lt;br /&gt;
{{TemplateDocUser}}&lt;br /&gt;
{{TemplateModEN}}&lt;br /&gt;
{{BasculeDevUser|&lt;br /&gt;
nom=Stock|&lt;br /&gt;
num=52|&lt;br /&gt;
devdoc=[[Module Stock (developer)]]|&lt;br /&gt;
userdoc=This page|}}&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
Stock management module can save status for stocks of products into warehouses, edit amounts of products you have and correct them.&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
{{NoInstallModuleEn}}&lt;br /&gt;
&lt;br /&gt;
= Configuration =&lt;br /&gt;
{{ActivationModuleEn}}&lt;br /&gt;
&lt;br /&gt;
The setup page allows you to choose, among four options, when the stock is automatically incremented or decreased (depending on events in orders or invoices cycle of life).&lt;br /&gt;
&lt;br /&gt;
= Create a warehouse =&lt;br /&gt;
The creation of a warehouse is the mandatory first step for stock management. You can create a warehouse on the &#039;&#039;Products/Services&#039;&#039; tab, clicking &#039;&#039;Stocks&#039;&#039; on the left menu and then &#039;&#039;New warehouse stock&#039;&#039;. The only required information is a reference code and a warehouse name, the other fields are optional. You must then set whether the warehouse is running or not (opened / closed).  A closed warehouse cannot be used by the other Dolibarr functions.  This is a good way to prepare a warehouse (by filling it up) before you turn it on, or to temporarily block during an inventory.&lt;br /&gt;
&lt;br /&gt;
= Allocate product stocks =&lt;br /&gt;
&lt;br /&gt;
Long but necessary step, it is then, for each product, to define the stock amount, in each warehouse. This has to be done from the &#039;&#039;stock&#039;&#039; tab on the page of the product, which can be found on the &#039;&#039;products&#039;&#039; section of the left menu.&lt;br /&gt;
&lt;br /&gt;
= Automatic stock updates =&lt;br /&gt;
&lt;br /&gt;
Depending on the option chosen in the module&#039;s configuration, the available stock amount is updated either at the time of the proposal, at the time of shipment, at the time of invoice, etc..  A movement of stock is then registered according to the chosen stocking criteria.&lt;br /&gt;
&lt;br /&gt;
Warning: in current version (3.0.0), automatic stock updates are only applied to warehouse number 1!&lt;br /&gt;
&lt;br /&gt;
= Modification manuelle du stock =&lt;br /&gt;
&lt;br /&gt;
Si l&#039;on désire apporter des correctifs au stock existant (vol, disparition, vieillissement, ...), il est possible de le faire directement via l&#039;onglet &#039;&#039;stock&#039;&#039; de la fiche produit.&lt;br /&gt;
&lt;br /&gt;
= Fiche entrepôt =&lt;br /&gt;
&lt;br /&gt;
Il est possible d&#039;obtenir une liste détaillée des produits et mouvements enregistrés dans un entrepôt via un clic sur le nom de l&#039;entrepôt dans la liste des entrepôts.&lt;br /&gt;
&lt;br /&gt;
= Examples of use cases =&lt;br /&gt;
{{ToComplete}}&lt;br /&gt;
{{ExamplesCaseEn&lt;br /&gt;
|name=UCMS01: &lt;br /&gt;
|situation=&lt;br /&gt;
|actions=&lt;br /&gt;
}}&amp;amp;nbsp;&lt;/div&gt;</summary>
		<author><name>Attilioscot</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=Module_Stocks_En&amp;diff=22153</id>
		<title>Module Stocks En</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=Module_Stocks_En&amp;diff=22153"/>
		<updated>2011-06-20T14:05:47Z</updated>

		<summary type="html">&lt;p&gt;Attilioscot: /* Allouer un stock aux produits */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Stock]]&lt;br /&gt;
{{TemplateDocUser}}&lt;br /&gt;
{{TemplateModEN}}&lt;br /&gt;
{{BasculeDevUser|&lt;br /&gt;
nom=Stock|&lt;br /&gt;
num=52|&lt;br /&gt;
devdoc=[[Module Stock (developer)]]|&lt;br /&gt;
userdoc=This page|}}&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
Stock management module can save status for stocks of products into warehouses, edit amounts of products you have and correct them.&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
{{NoInstallModuleEn}}&lt;br /&gt;
&lt;br /&gt;
= Configuration =&lt;br /&gt;
{{ActivationModuleEn}}&lt;br /&gt;
&lt;br /&gt;
The setup page allows you to choose, among four options, when the stock is automatically incremented or decreased (depending on events in orders or invoices cycle of life).&lt;br /&gt;
&lt;br /&gt;
= Create a warehouse =&lt;br /&gt;
The creation of a warehouse is the mandatory first step for stock management. You can create a warehouse on the &#039;&#039;Products/Services&#039;&#039; tab, clicking &#039;&#039;Stocks&#039;&#039; on the left menu and then &#039;&#039;New warehouse stock&#039;&#039;. The only required information is a reference code and a warehouse name, the other fields are optional. You must then set whether the warehouse is running or not (opened / closed).  A closed warehouse cannot be used by the other Dolibarr functions.  This is a good way to prepare a warehouse (by filling it up) before you turn it on, or to temporarily block during an inventory.&lt;br /&gt;
&lt;br /&gt;
= Allocate product stocks =&lt;br /&gt;
&lt;br /&gt;
Long but necessary step, it is then, for each product, to define the stock amount, in each warehouse. This has to be done from the &#039;&#039;stock&#039;&#039; tab on the page of the product, which can be found on the &#039;&#039;products&#039;&#039; section of the left menu.&lt;br /&gt;
&lt;br /&gt;
= Modification automatique du stock =&lt;br /&gt;
&lt;br /&gt;
Selon l&#039;option choisie dans la configuration du module, une modification prend place au moment de la commande, au moment de la livraison, au moment de la facture, etc.&lt;br /&gt;
Un mouvement de stock est alors enregistré selon les critères de déstockage choisis.&lt;br /&gt;
&lt;br /&gt;
= Modification manuelle du stock =&lt;br /&gt;
&lt;br /&gt;
Si l&#039;on désire apporter des correctifs au stock existant (vol, disparition, vieillissement, ...), il est possible de le faire directement via l&#039;onglet &#039;&#039;stock&#039;&#039; de la fiche produit.&lt;br /&gt;
&lt;br /&gt;
= Fiche entrepôt =&lt;br /&gt;
&lt;br /&gt;
Il est possible d&#039;obtenir une liste détaillée des produits et mouvements enregistrés dans un entrepôt via un clic sur le nom de l&#039;entrepôt dans la liste des entrepôts.&lt;br /&gt;
&lt;br /&gt;
= Examples of use cases =&lt;br /&gt;
{{ToComplete}}&lt;br /&gt;
{{ExamplesCaseEn&lt;br /&gt;
|name=UCMS01: &lt;br /&gt;
|situation=&lt;br /&gt;
|actions=&lt;br /&gt;
}}&amp;amp;nbsp;&lt;/div&gt;</summary>
		<author><name>Attilioscot</name></author>
	</entry>
	<entry>
		<id>https://wiki.dolibarr.org/index.php?title=Module_Stocks_En&amp;diff=22152</id>
		<title>Module Stocks En</title>
		<link rel="alternate" type="text/html" href="https://wiki.dolibarr.org/index.php?title=Module_Stocks_En&amp;diff=22152"/>
		<updated>2011-06-20T13:30:52Z</updated>

		<summary type="html">&lt;p&gt;Attilioscot: /* Create a warehouse */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Stock]]&lt;br /&gt;
{{TemplateDocUser}}&lt;br /&gt;
{{TemplateModEN}}&lt;br /&gt;
{{BasculeDevUser|&lt;br /&gt;
nom=Stock|&lt;br /&gt;
num=52|&lt;br /&gt;
devdoc=[[Module Stock (developer)]]|&lt;br /&gt;
userdoc=This page|}}&lt;br /&gt;
&lt;br /&gt;
= Introduction =&lt;br /&gt;
Stock management module can save status for stocks of products into warehouses, edit amounts of products you have and correct them.&lt;br /&gt;
&lt;br /&gt;
= Installation =&lt;br /&gt;
{{NoInstallModuleEn}}&lt;br /&gt;
&lt;br /&gt;
= Configuration =&lt;br /&gt;
{{ActivationModuleEn}}&lt;br /&gt;
&lt;br /&gt;
The setup page allows you to choose, among four options, when the stock is automatically incremented or decreased (depending on events in orders or invoices cycle of life).&lt;br /&gt;
&lt;br /&gt;
= Create a warehouse =&lt;br /&gt;
The creation of a warehouse is the mandatory first step for stock management. You can create a warehouse on the &#039;&#039;Products/Services&#039;&#039; tab, clicking &#039;&#039;Stocks&#039;&#039; on the left menu and then &#039;&#039;New warehouse stock&#039;&#039;. The only required information is a reference code and a warehouse name, the other fields are optional. You must then set whether the warehouse is running or not (opened / closed).  A closed warehouse cannot be used by the other Dolibarr functions.  This is a good way to prepare a warehouse (by filling it up) before you turn it on, or to temporarily block during an inventory.&lt;br /&gt;
&lt;br /&gt;
= Allouer un stock aux produits =&lt;br /&gt;
&lt;br /&gt;
Étape longue mais nécessaire, il s&#039;agit ensuite, pour chaque produit, d&#039;utiliser son onglet &#039;&#039;stock&#039;&#039; pour lui définir un stock de base, dans chaque entrepôt.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Identificar cantidades(stock)de productos&lt;br /&gt;
&lt;br /&gt;
Paso requerido para cada producto, crear la definicion de cada item de almacenamiento en una ficha de cada producto y establecer las cantidades  (stock) en cada bodega definida.&lt;br /&gt;
&lt;br /&gt;
= Modification automatique du stock =&lt;br /&gt;
&lt;br /&gt;
Selon l&#039;option choisie dans la configuration du module, une modification prend place au moment de la commande, au moment de la livraison, au moment de la facture, etc.&lt;br /&gt;
Un mouvement de stock est alors enregistré selon les critères de déstockage choisis.&lt;br /&gt;
&lt;br /&gt;
= Modification manuelle du stock =&lt;br /&gt;
&lt;br /&gt;
Si l&#039;on désire apporter des correctifs au stock existant (vol, disparition, vieillissement, ...), il est possible de le faire directement via l&#039;onglet &#039;&#039;stock&#039;&#039; de la fiche produit.&lt;br /&gt;
&lt;br /&gt;
= Fiche entrepôt =&lt;br /&gt;
&lt;br /&gt;
Il est possible d&#039;obtenir une liste détaillée des produits et mouvements enregistrés dans un entrepôt via un clic sur le nom de l&#039;entrepôt dans la liste des entrepôts.&lt;br /&gt;
&lt;br /&gt;
= Examples of use cases =&lt;br /&gt;
{{ToComplete}}&lt;br /&gt;
{{ExamplesCaseEn&lt;br /&gt;
|name=UCMS01: &lt;br /&gt;
|situation=&lt;br /&gt;
|actions=&lt;br /&gt;
}}&amp;amp;nbsp;&lt;/div&gt;</summary>
		<author><name>Attilioscot</name></author>
	</entry>
</feed>