Interfaces from foreign systems toward Dolibarr: Difference between revisions

Jump to navigation Jump to search
m
mNo edit summary
Line 26: Line 26:
Here is an example for the creation of a third party (eg customer company):
Here is an example for the creation of a third party (eg customer company):


<pre>
<source lang="php">
// We declare the class we want to use
// We declare the class we want to use
include_once('/pathofdolibarrhtdocs/societe.class.php');
include_once('/pathofdolibarrhtdocs/societe.class.php');
Line 50: Line 50:
// To update object
// To update object
$mycompany->update($user);
$mycompany->update($user);
</pre>
</source>


Note: If we are inside an external script, you must add at the beginning of script, before the include of class we want to use:
Note: If we are inside an external script, you must add at the beginning of script, before the include of class we want to use:
<pre>include('/pathofdolibarrhtdocs/master.inc.php');</pre>
<source lang="php">
include('/pathofdolibarrhtdocs/master.inc.php');
</pre>
This will create objects $db, $lang and $user.
This will create objects $db, $lang and $user.
If we want that actions (create, update), are tagged with a particular user as the create/update user, uou must do before
If we want that actions (create, update), are tagged with a particular user as the create/update user, you must do after the include of master.inc.php and before callong the create or update methode
<source lang="php">
$user->fetch('loginuser');
</source>

Navigation menu