# AdvancedTooltip

Dolibarr module to **customize the `getNomUrl()` tooltips per object type**: toggle,
reorder and add the entries shown when hovering an object link.

Publisher: **Pichinov**. License: **GPLv3+**.

## What it does

For each supported object, an admin screen lists the entries that appear in its
hover tooltip and lets you:

- **toggle** any entry on/off,
- **reorder** entries by drag-and-drop (a grip handle); a *Default* column shows
  each entry's native position and a *Default order* button restores it,
- **add predefined entries** (e.g. the third party / `thirdparty`),
- **toggle / add extrafields** — every extra field of the object is listed (and can
  be injected even when it is not flagged "show in tooltip"),
- keep any not-yet-configured entry visible (appended at the end).

The entries and their live preview are **discovered dynamically** from a recent
sample object, and stored per object type in `llx_advancedtooltip_entry`.

## Requirement — hookable tooltips (option A)

The module works through the core **`getTooltipContent`** hook. That hook only fires
for a `getNomUrl()` tooltip if the object builds its label via
`CommonObject::getTooltipContent()` (instead of calling `getTooltipContentArray()`
directly). Upstream proposal: **Dolibarr/dolibarr PR #39629** (supplier documents:
`FactureFournisseur`, `CommandeFournisseur`, `SupplierProposal`, `Reception`).

Until that lands in the core you run, apply the one-line change to each target
`getNomUrl()`:

```php
- $label = implode($this->getTooltipContentArray($params));
+ $label = $this->getTooltipContent($params);
```

The module registers the matching `<element>dao` hook contexts:
`invoice_supplierdao`, `order_supplierdao`, `supplier_proposaldao`, `receptiondao`.

## Install

1. Copy the module into `htdocs/custom/advancedtooltip/` (or deploy the zip via
   *Home → Setup → Modules → Deploy/install external module*).
2. Enable **AdvancedTooltip** in the module list.
3. Configure it: *Setup → AdvancedTooltip*, or
   `custom/advancedtooltip/admin/setup.php`.

## Extending

- **More predefined entries**: add them to
  `ActionsAdvancedtooltip::getPredefinedProviders()` and resolve them in
  `resolvePredefined()`.
- **More objects**: add the object to `$supported` in `admin/setup.php` and its
  `<element>dao` context to `module_parts['hooks']` in the descriptor (and make sure
  the object's `getNomUrl()` uses `getTooltipContent()`).

## Notes

- After changing the hook contexts of an already-enabled install, the
  `MAIN_MODULE_ADVANCEDTOOLTIP_HOOKS` constant is not overwritten by `init()`:
  disable/enable the module (or clear that constant) to re-register them.
