31,003
edits
| Line 80: | Line 80: | ||
A file '''out.tablename_script.php''' has been generated and contains a sample code to use the class for each of the 4 CRUD methods. | A file '''out.tablename_script.php''' has been generated and contains a sample code to use the class for each of the 4 CRUD methods. | ||
= [[File:Art.png]] Add your own tabs on | = [[File:Art.png]] The tab management = | ||
'''When''': To add a tab on an | |||
== Add your own tabs on object sheets (optional) == | |||
'''When''': To add a tab on an object (invoices, orders, proposals, member ...) | |||
To do this go into the file descriptor of module previously created and edit the $this->tabs array: | To do this go into the file descriptor of module previously created and edit the $this->tabs array: | ||
| Line 120: | Line 122: | ||
To feed the contents of the tab with data from the database, see the next chapter. | To feed the contents of the tab with data from the database, see the next chapter. | ||
== Show tabs navigation into your own pages == | |||
'''Quand''' : To show all standard tabs of an object (produit, tiers, etc.) on your page. | |||
You must follow these steps : | |||
'''1. Include files you need into your file''' | |||
For each pbject type, there is two files to include with line | |||
<source lang="php">require_once($url_fichier) ;</source> | |||
This is list of those files to include (DOL_DOCUMENT_ROOT is often dolibarr/htdocs/) : | |||
* Object thirdparty (thirdparty) : | |||
** DOL_DOCUMENT_ROOT/societe.class.php | |||
** DOL_DOCUMENT_ROOT/lib/company.lib.php | |||
* Object product (product) : | |||
** DOL_DOCUMENT_ROOT/product.class.php | |||
** DOL_DOCUMENT_ROOT/lib/product.lib.php | |||
* Object invoice (invoice) : | |||
** DOL_DOCUMENT_ROOT/facture.class.php | |||
** DOL_DOCUMENT_ROOT/lib/invoice.lib.php | |||
'''2. Create and load the object to show into your tab''' | |||
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). | |||
''Example :'' | |||
<source lang="php"> | |||
$id=$_GET["id"]; | |||
$product = new Product($db) ; | |||
$result = $product->fetch($id) ; //Test $result to check the database read is ok | |||
</source> | |||
'''3. Get list of all tabs to show for your object type''' | |||
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. | |||
The resulting array has the following structure | |||
<source lang="php"> | |||
$head // Array of tabs | |||
$head[$h] // Element to describe one tab. | |||
$head[$h][0] // Url of page to show when you click on tab | |||
$head[$h][1] // Title of tab | |||
$head[$h][2] // Code name to identify the tab | |||
</source> | |||
''Example :'' | |||
<source lang="php"> | |||
$head = product_prepare_head($product, $user) ; // parameter $user is present for some function anly | |||
</source> | |||
'''4. show tabs into your page''' | |||
Use function dol_fiche_head() to show all tabs defined into array $head returned by XX_prepare_head(). | |||
<source lang="php"> | |||
dol_fiche_head($links, $active='0', $title='', $notab=0, $picto='') | |||
$links // Tableau des onglets, appelé $head plus haut. | |||
$active // Onglet actif (mettre le nom de l'onglet défini dans votre fichier de module, ou un nom contenu dans $head[$h][2]). Cet onglet sera mis en surbrillance | |||
$title // ? | |||
$notab // Mettre ce paramètre à 1 permet de ne pas afficher de zone bleue en dessous des onglets. | |||
$picto // Nom de l'image à utiliser au début de la barre des onglet. Les choix suivant sont possibles : | |||
// product | |||
// service | |||
// company | |||
</source> | |||
Cette fonction affiche les onglets voulus et ouvre un élément ''< div class="" >'' qui correspond à la zone bleue sous les onglets (si paramètre $notab = 0). Pour fermer la zone bleue, il suffit de fermer l'élément ''< /div >'' dans le code PHP. | |||
''Remarque'': | |||
Pour plus de détail, se référer à la [http://www.dolibarr.fr/doxygen/ documentation Doxygen] ou directement au code de Dolibarr. | |||
= [[File:Art.png]] Create your own PHP screens (optional) = | = [[File:Art.png]] Create your own PHP screens (optional) = | ||