31,034
edits
mNo edit summary |
mNo edit summary |
||
| Line 1: | Line 1: | ||
{{TemplateDocDev}} | {{TemplateDocDev}} | ||
= Location = | |||
The Dolibarr command line scripts must be located in the '''scripts''' directory in Dolibarr root. The scripts are then divided into sub-directories according to their vocation. A number of scripts is provided as standard. | The Dolibarr command line scripts must be located in the '''scripts''' directory in Dolibarr root. The scripts are then divided into sub-directories according to their vocation. A number of scripts is provided as standard. | ||
= Develop a new script = | |||
The scripts are often made for a specific need, it is likely that you do not find the one you want. In this case, we'll explain how to develop your own script. | The scripts are often made for a specific need, it is likely that you do not find the one you want. In this case, we'll explain how to develop your own script. | ||
== Step 1 - Create the skeletonn of the script == | |||
The first step is to take the skeleton script available in '''dev/skeletons/skeleton_scripts.php''' and copy and renaming it in directory '''scripts/mydir/myscript.php''' | The first step is to take the skeleton script available in '''dev/skeletons/skeleton_scripts.php''' and copy and renaming it in directory '''scripts/mydir/myscript.php''' | ||
| Line 26: | Line 26: | ||
</pre> | </pre> | ||
== Step 2 - Editing script code == | |||
Modify the contents of the script to perform operations that interest you. | Modify the contents of the script to perform operations that interest you. | ||
All the code that lies between the tags | All the code that lies between the tags | ||
| Line 36: | Line 36: | ||
Note that in this section, you can use the variable $db that is the resource to access Dolibarr database and is already initialized. The $conf object that contains Dolibarr configuration is also available. | Note that in this section, you can use the variable $db that is the resource to access Dolibarr database and is already initialized. The $conf object that contains Dolibarr configuration is also available. | ||
=== Example to insert a product === | |||
For example to insert a product in the database Dolibarr, you can place the following code: | For example to insert a product in the database Dolibarr, you can place the following code: | ||
<pre> | <pre> | ||