Système d'onglets

From Dolibarr ERP CRM Wiki
Jump to navigation Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Le système des onglets Dolibarr

Dolibarr affiche les informations d'un élément (facture, entrepot, utilisateur, etc...) dans une vue composée en général de plusieurs onglets.

Il est possible d'ajouter vos propres onglets, d'en supprimer ou remplacer des existants.

Pour ajouter votre onglet

1) Dans un premier temps, vous devez identifier le type de l'objet sur lequel porte l'onglet à ajouter, supprimer ou modifier et son code 'objecttype'. Pour cela, voici la liste:

  • 'thirdparty' to add a tab in third party view
  • 'intervention' to add a tab in intervention view
  • 'supplier_order' to add a tab in supplier order view
  • 'supplier_invoice' to add a tab in supplier invoice view
  • 'invoice' to add a tab in customer invoice view
  • 'order' to add a tab in customer order view
  • 'product' to add a tab in product view
  • 'stock' to add a tab in stock view
  • 'propal' to add a tab in propal view
  • 'member' to add a tab in fundation member view
  • 'contract' to add a tab in contract view
  • 'user' to add a tab in user view
  • 'group' to add a tab in group view
  • 'contact' to add a tab in contact view
  • 'bank' to add a tab in bank view
  • 'categories_x' to add a tab in category view (replace 'x' by type of category (0=product, 1=supplier, 2=customer, 3=member)
  • 'member_stats', 'order_stats', 'supplier_order_stats', 'invoice_stats', 'supplier_invoice_stats', 'trip_stats', 'propal_stats' to add a tab in statistic view of elements.
  • 'member_admin', 'company_admin', 'product_admin' pour les pages d'administration

2) Pour ajouter votre propre onglet, créer un module et son fichier descripteur. Voir la page Développement module pour cela.

3) Ensuite dans le descripteur de fichier, éditer la propriétés this->tab pour ajouter votre onglet en suivant la syntaxe:

$this->tabs = array(
'objecttype:+tabname:TitleOfTab:@mymodule:conditiontohavetab:urlfortab?id=__ID__'
);

Example:

$this->tabs = array(
'product:+tabname1:Title1:@mymodule:$user->rights->mymodule->read:/mymodule/mynewtab1.php?id=__ID__',     // Pour ajouter un onglet sur les objects de type product (produits/services), onglet identifié par l'id tabname1
'product:+tabname2:Title2:@mymodule:$user->rights->othermodule->read:/mymodule/mynewtab2.php?id=__ID__',  // Pour ajouter un onglet sur les objects de type product (produits/services), onglet identifié par l'id tabname2
);

4) Activer ce module.

5) Tester que le nouvel onglet apparaît et que le lien ouvre votre page.

Pour supprimer un onglet existant

Le processus est identique à celui pour ajouter un onglet, mais utilisez dans le tableau this->tab du fichier descripteur la syntaxe suivante:

$this->tabs = array(
'objecttype:-tabname'
);                                                     // To remove an existing tab identified by code tabname

Pour pouvoir retrouver les noms 'tabname' des onglets existants, il faut aller voir les noms utilisés dans la fonction 'product_prepare_head' du fichier 'core/lib/module.lib.php' correspondant, à la section '$head[$h][2]'.

Pour remplacer un onglet avec le votre

Réaliser simplement les étapes "Ajouter votre propre onglet" puis "Supprimer un onglet existant". Si l'onglet ajouté à le même libellé que celui supprimé, l'illusion sera parfaite.

Afficher des onglets dans vos pages

Plus de l'information sur comment afficher des onglets dans vos propres pages, voir Développement_module#Affichage_des_onglets_(optionnel)