Module ModuleBuilder

Foundations
Numero/ID of module 3300
User doc. of module This page
Developer doc. of module

Introduction

The ModuleBuilder is a module for developpers only, to help you to develop a module. It is RAD, No Code or Low Code tool.

Installation

This module is included with the Dolibarr distribution, so there is no need to install it.

Configuration

To use this module, you must first enable it using an administrator account, via the menu option "Home - Setup - Modules".

Choose the tab where the module is listed. Then click on "Activate".

The module is now activated.

If a cog icon appears   on module thumb or at end of the line of the module, click on it to access the setup page specific to the module.

Usage

The ModuleBuilder within Dolibarr presents a lot of features designed for the comprehensive management and development of module.

Creating a new module

Click on the "Bug" picto on top right in the menu bar to reach the ModuleBuilder tool.

First, create a new module by clicking on the link "New module".

Choose a name and some options. First files to have a working module will be generated. You can already enable and disable your module from the common page to enabled/disable module of Dolibarr. However, it is recommended to work on the other steps of development of your module, with the module not enabled.

Work on your new module

Language Support

  • This function allows developers to introduce additional languages into a module, enhancing its accessibility and usability across different linguistic demographics.
  • It involves integrating new language files or entries that translate the module's interface and messages.



Menus

Enables the crafting of custom menus within the module's UI, allowing users to navigate through the module's features more efficiently. This might include adding new menu items linked to specific functionalities or adjusting the module's navigation structure.

  • Creating menus in the system is achieved through two distinct methods: Initially, when an object is created, three menus are automatically generated and displayed on the left sidebar. Alternatively, menus and sub-menus can be manually added by utilizing the form at the top of the table, which requires filling in specific fields such as title, URL, and position. Furthermore, permissions can be assigned to each menu to ensure they are only visible to users with the appropriate rights.
  • The editing process mirrors this approach closely.
  • For deletion, one needs to click on the trash can icon and confirm to proceed with the removal.


Object

  • To add an object, simply enter the name, choose an icon, and specify the name of an existing table, if nothing is specified, it creates a new table.
  • The three check-boxes depend on your preference: one for enabling automatic numbering generation, the second for enabling PDF document creation, and the third to generate permissions for the object created.


 
Add Object


In the description of an object within a Dolibarr module developed using ModuleBuilder, several essential components and functionalities are outlined. These include :

  • PHP DAO CRUD Class: This is the core PHP class that handles database operations such as create, read, update, and delete for the object, ensuring seamless data management.
  • Icon Representation: An icon specified for visual representation of the object in the user interface, aiding in quick identification.
  • Module API: Defines the application programming interface for the module, enabling external interactions and integrations.(one file contain CRUD methods for each object created).
  • Unit Testing: A set of PHP unit tests designed to verify the functionality and reliability of the object, ensuring robust operation.
  • Library Files: Comprise both a common library file for module-wide functions and an object-specific library file, which includes functions unique to the object's logic and operations.
  • SQL Scripts: Include the main SQL script for creating the object's database table, along with additional scripts for keys, indexes, and extra fields, ensuring optimized database structure and performance.
  • User Interface Pages:
    • A listing page for viewing all records of the object,
    • A detailed card page for creating, modifying, and displaying individual records,
    • Dedicated pages for managing related contacts, documents, notes, and events, each providing specialized functionalities within the object's context.

The setup also features a button, facilitating the generation, modification, or deletion of these components as needed. This system offers a comprehensive framework for extending and customizing the object within the module, providing developers with a robust set of tools for module customization and functionality enhancement.


Property Addition:

This feature permits the extension of entities or modules by adding new properties. These properties can be utilized to store additional information, customize behavior, or integrate with other modules, enhancing the module's flexibility and capability.

  • To add an additional attribute to a specific object, simply click on the "+" button to the right of the properties list, which will display a form allowing you to fill in fields such as label, type, code, etc.
  • To modify, simply click on the pencil icon that appears in the same row of the list, which brings up a form for editing.
  • For deletion, the trash can icon allows for the removal of a property after confirmation.




Permissions

For permissions, there are two ways to create them:

  • By ticking the box at the bottom of the form during the creation of the object and it creating the 3 default permissions (create, write, delete).
  • By manually creating them in the rights section, which provides a list of permissions for each object. The form at the top of the table allows you to select the object and choose a permission; the ID is automatically assigned, as well as the label, although you have the option to change it if desired.



Dictionaries

  • To create a dictionary, there is a dedicated section for this purpose. A create button (+) on the right displays a form to enter the name of the dictionary, which will become the name of the table in the database, preceded by "c_".
  • The other fields are automatically filled in, and it is recommended to leave them as they are. For editing, you have the option to change the label, the fields for sorting, and for inserting or editing.



 
Add dictionary

Hooks

  • Define in the module_parts['hooks'] property within the module descriptor the contexts in which the hooks should be executed (the list of contexts can be found by searching for 'initHooks(' in the core code). Then, edit the hook file to add the code for your hooked functions (hookable functions can be found by searching for 'executeHooks' in the core code).
  • Click the "+" button to generate the hooks code.

Triggers

  • In a module, the triggers part of the module_parts array indicates whether the module includes its own directory for triggers within Dolibarr's core triggers system, To generate the trigger file, simply use the "+" button provided by the ModuleBuilder interface in triggers section .

CSS / JS / CLI

  • CSS : Once generated, you can use the file to define custom styles that will be applied to the module's frontend, improving its appearance and user experience. You can specify styles for layout, colors, fonts, and more, ensuring your module aligns with the desired aesthetic and usability standards.
  • JavaScript (JS) : After generating a JS file, you can write scripts to handle user interactions, perform validations, manipulate DOM elements.
  • The Command Line Interface (CLI) file plays a crucial role in facilitating module interaction via the command line, allowing for the execution of scripts, or functions without a graphical interface. This is particularly useful for automating processes.

By utilizing the ModuleBuilder to generate these files, you simplify the initial setup process for incorporating CSS, JS, and CLI functionalities into your module. Each file serves a distinct purpose, contributing to the module's visual design, interactivity, and operational flexibility, ultimately enhancing its overall utility and integration within the Dolibarr ecosystem.

All these configurations was added in modYourModuleName.class.php file in folder htdocs/custom/YourModuleName/core/modules and you can edit it if you want but you should be careful when you manipulate this file specially with comments.