CustomTabs

De Documentations Patas-monkey
Version datée du 2 avril 2025 à 14:49 par Liam (discussion | contributions) (Page créée avec « New: The number of fields and lines entered is displayed in the tab badge. »)
Aller à la navigation Aller à la recherche
The CustomTabs module allows you to add your own tabs to item cards.

The fields contained in these custom tabs replicate the functionality of Dolibarr's native additional fields.

Access to customTabs tabs can be configured according to user groups

The tab can be presented as a card or a list (with import/export functions)

Lists can be used as custom dictionaries

It is possible to use formatting templates

New: The number of fields and lines entered is displayed in the tab badge.

Presentation

Fichier:Customtabs records-multiples1.png Access to tab content is managed by group permissions for access, reading, editing, and deleting.

Tab content can be organized as a list or as a card. The page display can be customized with an HTML template.

Custom tabs can contain a document manager. Combined with the tab access rights setting, this feature improves native document management in Dolibarr by limiting the view and access of user groups to documents.

The information stored in customTabs can be retrieved with the myList and ExtraODT modules.

Settings

CustomTabs has no specific settings. Access to its features is found in the menu items Patas-tools > CustomTabs

List of tabs present

The menu title allows you to display the list of customTabs present in Dolibarr.

When you update the module (deactivation/activation) this also deactivates the customtabs, the button at the bottom of the list allows you to reactivate them en masse.

Creating a New Tab

Fields on the Tab Creation Page

Open the new tab creation page from the Patas-M Tools > CustomTabs > New Tab menu link:

A tab can also be created from the tab list using the dedicated button
  • Label: The label will be displayed as the name of the tab displayed on the item pages.
  • Table Name: The information you enter in a tab is saved in a table. Enter its name here.
CustomTabs will automatically add a prefix to your table; simply enter the table name directly without a prefix. Furthermore, the table name must not contain spaces or special characters, nor be a word reserved for SQL language such as SELECT, FROM, DESC, etc.
  • Element: Select from the drop-down list the element on whose records the tab will be added: third parties, contacts, products, warehouse, sales proposal, customer order, supplier order, customer invoice, supplier invoice, project, bank account, shipment, user, user group, member, VAT payment, or special expenses.
{{Note|CustomTabs is interfaced with the Equipment and Factory modules. It is therefore possible to create custom tabs on equipment and production order records.
  • Tab type: A tab can be a record or a list. Enter the type according to your needs:
    • A list-type tab only allows one record to be modified according to the settings declared in the input fields.
    • A record-type tab allows the recording of multiple successive records.

The tab type determines how data is displayed and saved. Depending on the type selected, the previously created tab will then display:

  • List tab: only one record can be entered and can be edited.
  • Card tab: multiple records can be entered.
  • Parent: It is possible to create sub-tabs. Creating a sub-tab requires the prior creation of a parent tab, which you can select here.
Creating sub-tabs is similar to creating a new tab, requiring the selection of a parent tab.
A parent tab can only be of type card. It is not possible to create a sub-tab of another tab of type list
Configuring the sub-tab and the fields it will contain will work the same way as creating a new tab.
The sub-tab will then appear in the parent tab's file according to the permissions granted to the user groups.

Example of creating a custom tab

Creation page

Let's create a tab to record third-party prospecting tracking.

Open the new tab creation page and enter the following data:

Complete the first step of creating the tab by clicking the Create button.

Once the tab is created, several new fields are displayed and can be modified when editing the tab:
  • EDM (Electronic Document Management): By enabling the EDM option, you can store documents on the tab. Access to these documents will be limited to authorized groups. Please note that the EDM function is only available for screen-type custom tabs.
  • Order BY list: By default, the list is sorted on the first field. You can customize the sorting by entering it. Please note that the orderby function is only available for list-type custom tabs.
  • Active tab: After its creation, a tab is inactive by default. Change its status to enable its display on the tabs of the items selected in the previous step.
The Edit button will allow you to edit the tab to modify various information.
The Import/Export button for the tab will generate the XML file that you can edit before copying and exporting it.
The Delete button will delete the tab from your database. Always deactivate a tab before deleting it. If you delete the tab without first deactivating it, it will remain in your database and on the item cards, but will be emptied of its content

Tab Input Fields

From the page displayed after creating the additional tab, click the "Tab Input Fields" tab. The elements entered here will be the content lines of the custom tab added to the records of the element selected during creation.

To add a new field, click the New Attribute button.

Creating tab fields follows the procedure for creating and operating additional fields native to Dolibarr.

In the case of calculated fields, it will be possible to retrieve the id of the element to which the tab is associated with with the fk_element field

Continue creating the input fields using the following template:

To make the tab accessible from the Dolibarr menus, simply modify it to make it active and configure the access rights (see Configuring access rights to tabs below).

Tab Template

Entering a template is optional. If no template is entered, the default display is used. From the "Tab Template" tab, you can define your own display using HTML code.
The screen displays a list of fields on the tab, which you can copy and paste.

Tip: Drag and drop can be used to copy the field code into the template's input area.

To add edit and delete icons to the template, use the #EDITBTN# and #DELETEBTN# tags
The template is interpreted differently depending on the tab type: either block by block on a list tab, or for the entire page on a card tab

For example, you can enter the following template:

And you will get:

or

If a field present in the table is not defined in the template, it will not be displayed

Import/Export Tab

On the tab page, you can export the tab's settings and its fields to an XML file. You can then update a tab in the same way or import a new tab from scratch (see below in the documentation).

Calculated Fields and Concatenation

It is not necessarily easy to explain the use of calculated fields in customTabs, which is why I put here two examples of complex cases on calculated fields.


implode('/', array($object->array_options['options_urlcomp'], $objectoffield->array_options[$objectoffield->rowidextrafields]['options_no_contract'] ))

implode('-', array( ($tmpsoc = new Societe($db)) && ($tmpsoc->fetchNoCompute($objectoffield->array_options[$objectoffield->rowidextrafields]['options_soc'])) ? $tmpsoc->array_options['options_urlcomp']: '---', $objectoffield->array_options[$objectoffield->rowidextrafields]['options_no_contract']))


I would like to point out that it is possible to ask me for support services to carry out this type of thing.

User Access and Permissions on Tabs

Configuring Tab Access Rights

From the secondary menu entry Patas-Tools > CustomTabs > Tab Access Rights, configure user group access:

There are four access rights:

Access blocked

Access read

Access blocked

Access edit

The permissions vary depending on the tab type. On a form tab, the permissions for adding and deleting fields in the tab are not enabled.

Behavior based on access rights

Blocked access ()

A warning message will warn the user that they do not have the necessary permissions to view the tab's contents.

Read access but blocked from editing ()

Users in the group will be able to view the tab's fields, but will not be able to edit their contents.

Read Access and Edit Access (Fichier:Read-on.png)

Users in the group will be able to view the tab, its contents, and edit them.

Conditional Display SQL Query

The processing query will condition the display of fields based on whether the object matches the query. It is then possible, for example, to display different fields depending on whether the object is a product or a service. Two values ​​can be passed as parameters:

  • #ID#: the ID of the main object on the page
  • #USERID#: the ID of the active user

Operation

Enter here the display query applicable to the fields in the following example:

#SEL# allows you to replace the SELECT of the SQL query which will be blocked by Dolibarr's native security (SQL Injection)

#SEL# IF(fk_product_type=1, 1, 0) AS `read`, IF(fk_product_type=1, 1, 0) AS `write` FROM llx_product WHERE rowid=#ID#;

Read allows you to allow or disable the global display of the field Write allows you to allow or disable its modification (not necessary in the case of a button or a tab, etc.)

If the value is 0, the field is hidden; otherwise, it is displayed. Note: if you leave the field setting hidden, it will not appear regardless of the value.

Example

With the following myfield

We obtain the following information sheet for a product

While for the information sheet for a service

Other Features

Import/Export a Tab and Its Content

Import/Export Tab Settings

You can save a tab and its fields by importing an XML file. From the "Patas-M Tools > CustomTabs > Import a Tab" page, paste the XML file into the input area and click the "Start Import" button:

Activate the tab from its page and it will be added to your item pages. This import feature allows you to avoid the steps of creating a custom tab. To import the content of a custom tab's input fields, use the content import feature.

Importing and Exporting List Content

You can import the contents of tab fields by importing a .csv file. Tab imports and exports require these features to be enabled in the "Import/Export" tab of the custom tabs page.

Importing/exporting tab content is only possible for list tabs
Enable the tab content import feature first

Déclarez ensuite la ligne du fichier .csv ou se trouve le nom de la colonne, le séparateur de champ utilisé, le caractère utilisé en tant que séparateur du contenu des champs et le mode d'identification des colonnes :

  • Basé sur le libellé des champs : La première ligne de votre fichier .csv mentionnera le libellé des champs tel qu'affiché à l'écran. Dans notre exemple, Date de début, commentaire…
  • Basé sur le nom des champs : La première ligne de votre fichier .csv mentionnera le code des champs tel qu'enregistré pour chacun des champs de saisie. Dans notre exemple, début, commentaire…
  • Basé sur l'ordre des champs : Les champs de l'onglet seront remplis par les données telles qu'elle sont ordonnées dans votre fichier .csv.
Le paramétrage "Autorise la suppression de toute les lignes d'une table (DANGEREUX)" ajoutera un bouton de suppression de toutes les lignes d'un customTabs.

Prenons le fichier .csv suivant :

Depuis l'onglet de la fiche tiers, cliquez sur le bouton Import csv :

Sélectionnez le fichier à importer, et Ajoutez le fichier.

Cliquez ensuite sur l'icone pour lancer l'importation

Le customTabs affichera alors :

Dictionnaires

CustomTabs permet la création de dictionnaires de valeurs à afficher dans des champs supplémentaires des fiches des éléments.

Cette fonctionnalité est possible pour les onglets de types Liste seulement
Créez un nouvel onglet de type Liste pour l’élément Dictionnaire et notez le nom donné à la table
Dans l’onglet champs de saisie de l’onglet, créer 2 champs

Activez l'onglet, paramétrez les droits d'accès des groupes d'utilisateurs.

Dans le menu secondaire customTabs > Dictionnaires, ouvrez l'onglet nouvellement créé et ajoutez-lui autant de champs que nécessaires
Dans la configuration des modules (tiers et contacts dans notre exemple), créer un champ supplémentaire dans la fiche de l’élément souhaité (contact) en sélectionnant le type liste issue d’une table ou liste à cocher issue d'une table. Pour le champ Valeur, reprendre le nom de la table créée à l’étape précédente et le compléter du nom du champ, soit cust_languesparlees_extrafields:nomlangue.

Vos fiches afficheront alors le nouveau champ supplémentaire :

L'avantage d'utiliser les dictionnaires de CustomTabs est la rapidité de modification et duplication. Ajoutons la langue anglaise dans notre dictionnaire customTabs : La modification apportée au dictionnaire s'applique à tous les champs de toutes les fiches qui proposent ses valeurs.

et les fiches de vos contact afficheront :

Gestion des ODT

Il est possible de récupérer les valeurs saisies sur les customTabs de type fiches dans les modèles ODT pour cela il faut utiliser la balise {cust_<nom de l'onglet>_<nom de l'attribut>}

Questions fréquentes

Général

Ce chapitre répertorie les difficultés rencontrées avec le module. Vous y trouverez donc des éléments de réponse quant à son utilisation. Si vous rencontrez une autre erreur que celles décrites ci-dessous lors de l'utilisation de ce module :

  1. Désactivez et réactivez le module,
  2. Vérifier sur le ChangeLog si une nouvelle version a été publiée,
  3. Ré-installez/mettez à jour le module,
  4. Vérifiez que le remplacement de fichiers natifs de Dolibarr ne soit pas nécessaire au bon fonctionnement du module.
  5. Vérifiez qu'aucune incompatibilité avec un autre module ne soit indiquée. Le cas échéant, suivez nos préconisations.

Si, malgré ces manipulations, l'erreur persiste, contactez-nous en utilisant le formulaire dédié (http://docs.patas-monkey.com/support/). Ce formulaire est le mode de contact à privilégier pour toute difficulté d'utilisation ou remontée de bug. Aussi, nous vous remercions de ne pas multiplier les canaux d'échange pour un même objet.

Onglets n'apparaissant pas/plus sur vos fiches

Suite à une mise à jour du module ou des onglets eux-mêmes, même si vos onglets indiquent qu'ils sont activés, vous devrez les réactivez en entrant en édition du champ onglet actif et en enregistrant à nouveau.
Il est également possible d'effectuer cette manipulation pour tous les onglets en un clic avec le bouton Réactivation des onglets actifs de la liste des customTabs accessible depuis les menus Patas-tools > CustomTabs > CustomTabs :