MyField

De Documentations Patas-monkey
Version datée du 12 février 2025 à 17:20 par Liam (discussion | contributions) (Page créée avec « A granted permission is symbolized by a green check mark (file:tick.png). »)
Aller à la navigation Aller à la recherche
The myField module allows you to customize the labels of menus, tabs, buttons, fields of Dolibarr cards and lists.

You can choose the label, color and access of your menus, buttons, tabs and fields of cards and lists yourself

Presentation

Depending on the type of myfield (fields of a form, list, tab, ...), several other options can be applied to the fields of the forms such as a background color, display/hide them, add an input mask, input in uppercase ...

The combined set of user permissions and myFields access rights allows you to configure user access to the view of fields, their content and their modification.

MyField also allows you to hide menus from groups of users and change their destination URL.

Settings

The module is configured from the module administration page accessible via the menus Home > Configuration > Modules by clicking on the icon or the icon at the end of the line.

Module Configuration Page

Activating the context for development

MyField allows you to display on certain Dolibarr pages the contexts that can be used to limit the customization actions of myFields. These contexts will be useful when creating myFields to limit the action of the module to only the pages that have in their code the context indicated on the myField sheet. Configuring the display of contexts on your pages will allow you to identify them to best configure your myfields.

Enabling the display of contexts results in messages like the one opposite

Administrators are above access rules

You can also choose to disable the use of access rights for the administrator user.

If this setting is enabled, the administrator will see, outside of any group, the myfields in operation.

Background color of input areas

By default, input areas in dolibarr are transparent, which does not help readability It is possible to change the background color of input areas

Default button color

There are three types of buttons in Dolibarr:

  • Buttons associated with an action
  • Disabled buttons
  • Buttons performing a deletion

myField allows you to change the color of these

Replacing native buttons

MyField allows replacing standard Dolibarr buttons with icons.

instead of

Support Information

At the bottom of the configuration page you will find technical information related to your installation. This technical information will be useful and may be requested if you encounter a bug in using the module:

Permissions

Access to the module's features can be restricted to existing users and groups or those created after the module is installed.

Click on the – to add a permission.

A granted permission is symbolized by a green check mark ().

Warning: there are other settings that can impact access to fields, especially when using an administrator account


User and group permissions

Fichier:Myfield-Permissions-Utilisateur.png

Access to the module's features can be restricted to users and groups, from their profile then Permissions tab, according to the permissions opposite

Default Permissions

The default permissions (Home > Configuration > Security > Default Permissions), granted to any user created after the installation of the module, if he is not added to a group, are the following

Startup

MyField features are accessible from the Patastools main menu tab. Your secondary menu then presents the following menu entries:

MyField The main entry displays a list of all myFields in your environment

New mf Field
New mf Tab
New mf Tab
New mf List
New mf Menu
New mf Button

These entries will display the page for creating a new myField according to its type:
  • form field
  • tab
  • button
  • list fields
  • menu
List of elements This entry will also display the list of myFields saved on your environment
Access rights to elements This page will allow you to configure the authorizations of user groups to the features of MyFields, tabs and menus.
Import XML This entry will display a page to copy an import file of a myfield in XML format.

Customizations

Menus

Creating the myField

The page for creating a menu-type myField is accessible from the secondary menu link Patas-tools > MyField > New myMenu.

myField Type

the field automatically filled in based on the menu link you clicked to display this creation page (menu).

Native Label

enter here the native label of the menu as it is displayed on your interface.

Menu Type

select from the drop-down list the type of menu you want to customize depending on whether it is a main menu, a secondary menu or a secondary menu entry.

Replacement text

text of your choice that will be displayed instead of the native label.

Author

the name of the creator of the myField

Display

  • Visible: the field will be displayed. This is the standard operation of Dolibarr.
  • Invisible: the field will be absent from the cards
  • Hidden: the field will be absent from the cards but can be displayed (Show/Hide).

Background color

use the color selector to determine the background color of the field.

Move

enter -1 to move the menu tab to the left, 1 to the right.

Redirect URL

Enter here the URL of the page that will be displayed when clicking on the menu tab. If this field is left blank, the native URL of the menu will be kept.

Following the creation of a myField, it will be necessary to define the access rights by user groups from the secondary menu link of the same name (See further)

Example of customizing a main menu

Let's customize the Home menu.

Example of customizing a menu and a secondary menu entry

Let's customize the Commercial Proposals secondary menu and the New Proposal secondary menu entry.

The secondary menu entry will be moved down one rank with the code -1 in the Move field of its record

Following the application of these two customizations, the secondary menu becomes:

rather than
Fichier:Myfield-menu-secondary.png

Special case of secondary menu entries "List"

To differentiate secondary menu entries of the same name, enter the top-level menu to which they are attached separated by a hash mark (#):

Add to the label the secondary menu: Commercial proposals#List

To get

Tabs

Creating the myField tab

The myField creation page is accessible from the secondary menu link Patastools > MyField > New MyTab.

myField Type

the field automatically filled in based on the menu link you clicked.

Native Label

enter here the native label of the menu as it is displayed on the screen.

Activation Context

The activation context allows you to limit the action of myFields to only the fields of the pages with the context indicated here.

Attention, for tabs, the context corresponds to the tabTitleText (the name of the first tab) (eg: "Third Party" for the Third Party element, "Product" for the Product element)

If no context is entered, changes made to the tab by the myfield will apply to all fields with the same label on all records.


Replacement text

text of your choice that will be displayed instead of the native label.

Author

the name of the creator of the myField

Display

  • Visible: the field will be displayed. This is the standard operation of Dolibarr.
  • Invisible: the field will be absent from the cards
  • Hidden: the field will be absent from the cards but can be displayed (Show/Hide).

Background Color

Use the color picker to determine the background color of the myField.

Move

Enter -1 to move the menu tab to the left, 1 to move the right.

Redirect URL

Enter the URL of the page that will be displayed when the menu tab is clicked. If this field is left blank, the native URL of the menu will be kept.


Indicate here only the part of the URL following /htdocs/

Display request: see Operation section, below

Following the creation of a myField, it will be necessary to define the access rights to the myFields by user groups from the secondary menu link of the same name (See section Configuring access rights).

Example of customizing a tab

Let's customize the tab sheet of the element sheets.

The sheet then becomes

If the tab is active, the color will be displayed on its edges

Fields

Creating myField

The myField creation page is accessible from the secondary menu link Patastools > MyField > New MyField.


myField Type

the field automatically filled in based on the menu link you clicked.

Native Label

enter here the native label of the field as it is displayed on the screen.

Activation Context

the activation context allows you to limit the action of myFields to only the fields of the pages with the context indicated here. If no context is entered, changes made to the tab by the myfield will apply to all fields with the same label on all records.

List of main contexts

Replacement text

text of your choice that will be displayed instead of the native label.

Author

the name of the creator of the myField

Display

  • Visible: the field will be displayed. This is the standard operation of Dolibarr.
  • Invisible: the field will be absent from the cards
  • Hidden: the field will be absent from the cards but can be displayed (Show/Hide).
on the latest versions of the module, (Show/Hide) is no longer used, you must now click on the Dolibarr version number (top right)

Background color

use the color selector to determine the background color of the myField.

Move

enter 1 to move up one field, -1 to move down one field.

Default value

Input field size

to be defined according to your needs. If left blank, the native value of the field is kept.

Mandatory:

check this box to make entering values ​​in the field mandatory to save the creation or modifications of the page

The control of the field in creation and modification is only carried out if you enter the edition of the field itself

Input mask

the input mask can be configured with the following characters:

  • a for a letter (A-Z,a-z)
  • 9 for a number (0-9)
  • for an alphanumeric character (A-Z,a-z,0-9)
You can add the characters you want to the field to make up your mask. For example, if you want to add an international code to the phone field, the mask will be: +0099-(9)999999999
  • UPPERCASE to force uppercase input.
  • LOWERCASE to force lowercase input.

Display request

See Operation section

Moving a field in a form is only done within its table. It is therefore possible to move a field up or down, but not to change its column

Following the creation of a field type myField, it will be necessary to define the access rights to the myFields by user groups from the secondary menu link of the same name (See section Configuring access rights).

Example of customizing a field

Let's customize the field Id. prof. 2 (SIRET) of third-party files.

The field has been set to invisible with a number input mask (999 999 999 99999)

By clicking on the Show/Hide link above the table, the field will be displayed according to the settings saved on the myField sheet


Lors de l'édition du champ, le masque sera activé et ne permettra que la saisie prédéfinie et sa complétion vérifiée (rendu obligatoire) pour empêcher l'enregistrement de la page sans qu'il ne soit rempli.

Listes

Il est possible de modifier les champs des listes natives de dolibarr (celle avec une icone de sélection de champs en bout de liste)


Création du myField

Les myfields de liste permettent de limiter l'affichage de champs. il est nécessaire d'ouvrir la page de liste pour récupérer des informations propre à ce type de myField

  • le contexte d'activation
  • le libellé non traduit du champs

Exemple de paramétrage

Nous allons modifier la colonne "Tiers" sur la liste des interventions

Selon les habilitations, le champs sera aussi inaccessible dans le sélecteur de champs.

Si vous rendez un myField de liste invisible, il sera invisible de tous les utilisateur. Pour le cacher seulement à un ou des groupes d'utilisateurs, laissez le visible et jouter ensuite avec les droits d'accès !


Boutons

Il est possible de modifier les boutons présent sur les fiches de dolibarr

Création du myField

Les myfield de boutons permettent de rendre invisible bouton, remplacer le libellé, l'url associé au bouton et de rendre son accès visible selon le résultat d'une requete SQL

Avec le thème natif de Dolibarr, le libellé du bouton est mis en majuscule, il faut donc utiliser le texte d'origine que l'on récupère avec le click droit et le menu inspecter.

Requête SQL d'affichage conditionnel

La requête de traitement va conditionner l'affichage des champs selon la correspondance de l'objet à la requête. Il est alors possible, par exemple, d'afficher des champs différents selon que l'objet est un produits ou un service. Il est possible de transmettre en paramètre deux valeurs :

  • #ID# : l'id de l'objet principale de la page
  • #USERID# : l'id de l'utilisateur actif

Fonctionnement

Saisissez ici la requête d'affichage applicable au champs sur l'exemple suivant :

  1. SEL# permet de remplacer le SELECT de la requête SQL qui sera bloqué par la sécurité native de Dolibarr (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 permet d'autoriser ou non l'affichage globale du champ write permet d'autoriser ou non sa modification (pas nécessaire dans le cas d'un bouton un un onglet...)

Si la valeur est à 0, le champs est caché, dans le cas contraire il est affiché Attention, si on laisse le paramètre du champs à caché, il n'apparaitra pas quel que soit la valeur

Exemple

Avec le myfield suivant

On obtient la fiche suivante sur un produit

Tandis que sur la fiche d'un service

Paramétrage des droits d'accès aux myFields, tabs et menus

Configuration des droits d'accès

En tant qu'utilisateur administrateur, tous les myFields vous sont visibles.

Sur la page d'accueil du module MyField, l'application des personnalisations est désactivée

Si vous n'avez pas défini de groupes utilisateurs, les myfields sont affichés sur les interfaces de tous les utilsiateurs.

Depuis l'entrée de menu secondaire Patas-Tools > MyField > droits d'accès aux onglets, paramétrez les accès des groupes d'utilisateurs :

Il existe quatre droits d'accès :

Bloqué en accès

Accès en lecture

Bloqué en modification

Accès en modification

Comportement selon les droits d'accès

Bloqué en accès ()

Le champ sera caché aux utilisateurs du groupe. Ils ne pourront pas l'afficher

le lien Show/Hide ne sera pas actif

Accès en lecture mais bloqué en modification ()

Les utilisateurs du groupe pourront afficher le champ, mais ne pourront pas en modifier le contenu.

Accès en lecture et Accès en modification ()

Les utilisateurs du groupe pourront afficher le champ et le modifier si leurs permissions de groupe ou d'utilisateur le leur permettent. Les paramètres du champ s'appliquent alors (obligatoire, masque de saisie,...)

Autres fonctionnalités

Import des myField

Il est possible d'enregistrer une liste de myfields et leurs paramétrages en important un fichier XML. Depuis la page Outils Patas-M > MyField > Importer un onglet, collez le fichier XML dans la zone de saisie et cliquez sur le bouton Lancer l'importation.

Si vous cochez la case Écraser les données précédentes, votre liste de myfields se résumera à ceux présent dans le ficher que vous importez

Paramétrer ensuite les droits d'accès des utilisateurs au myField.

Contexte d'activation

Une liste de tous les contextes disponible est présent sur le wiki de dolibarr: https://wiki.dolibarr.org/index.php?title=Syst%C3%A8me_de_Hooks#Liste_des_Contexts_disponibles_dans_Dolibarr

quelque uns des plus courants

Fiche Contexte
Adhérent membertypecard
Catégories categorycard
Commandes ordercard
Commande fournisseur ordersuppliercard
Contact contactcard
Contrat contractcard
Don doncard
Entrepôt warehousecard
Expédition expeditioncard
Facture client invoicecard
Facture fournisseur suppliercard


Fiche Contexte
Intervention interventioncard
Livraison deliverycard
Note de frais tripandexpensecard
Produit productcard
Projet projectcard
Proposition commerciale propalcard
Règlement client paiementcard
Règlement fournisseur paymentsupplier
Salaire salarycard
Tache projecttaskcard
Tiers thirdpartycard
Utilisateur usercard

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.

Affichage d'un message en haut des pages de Dolibarr

Si vos pages de Dolibarr affichent un message semblable à l'image suivante, il ne s'agit pas d'un message d'erreur, mais de l'affichage des contextes de la page courante. Pour ne plus voir ces lignes affichées, désactivez l'affichage du contexte (voir Configuration).

Message erreur d'ordonnancement

Certaines pages de certaines versions de Dolibarr présentent un erreur dans leur code empêchant la bonne application de la personnalisation des champs. MyField permet de les identifier pour les corriger.

Le message d'erreur s'affiche en bas de page et est le suivant

En vous aidant de l'URL de la page, ouvrez le fichier du noyau de Dolibarr pour le modifier. Par exemple, si la page qui comporte le message est http://.../htdocs/custom/myField/admin/extrafields.php, ouvrez successivement les dossiers htdocs, custom, myField, admin et ouvrez le fichier extrafields.php.

L'erreur vient de l'inversion des lignes llxFooter(); et $db->close(); en fin de fichier.

Modifiez le code de la page pour obtenir

au lieu de

Multicompany

Avec le module multicompany, il convient d'activer le module sur chaque entité