add sample completeTabHead

This commit is contained in:
Frédéric FRANCE 2021-05-12 18:29:56 +02:00
parent 866c9d012f
commit 23fe7d1b63
No known key found for this signature in database
GPG Key ID: 06809324E4B2ABC1
3 changed files with 57 additions and 6 deletions

View File

@ -303,5 +303,56 @@ class ActionsMyModule
return 0;
}
/**
* Execute action completeTabsHead
*
* @param array $parameters Array of parameters
* @param CommonObject $object The object to process (an invoice if you are in invoice module, a propale in propale's module, etc...)
* @param string $action 'add', 'update', 'view'
* @param Hookmanager $hookmanager hookmanager
* @return int <0 if KO,
* =0 if OK but we want to process standard actions too,
* >0 if OK and we want to replace standard actions.
*/
public function completeTabsHead(&$parameters, &$object, &$action, $hookmanager)
{
global $langs, $conf, $user;
if (!isset($parameters['object']->element)) {
return 0;
}
if ($parameters['mode'] == 'remove') {
// utilisé si on veut faire disparaitre des onglets.
return 0;
} elseif ($parameters['mode'] == 'add') {
$langs->load('mymodule@mymodule');
// utilisé si on veut ajouter des onglets.
$counter = count($parameters['head']);
$element = $parameters['object']->element;
$id = $parameters['object']->id;
// verifier le type d'onglet comme member_stats où ça ne doit pas apparaitre
// if (in_array($element, ['societe', 'member', 'contrat', 'fichinter', 'project', 'propal', 'commande', 'facture', 'order_supplier', 'invoice_supplier'])) {
if (in_array($element, ['context1', 'context2'])) {
$datacount = 0;
$parameters['head'][$counter][0] = dol_buildpath('/mymodule/mymodule_tab.php', 1) . '?id=' . $id . '&amp;module='.$element;
$parameters['head'][$counter][1] = $langs->trans('MyModuleTab');
if ($datacount > 0) {
$parameters['head'][$counter][1] .= '<span class="badge marginleftonlyshort">' . $datacount . '</span>';
}
$parameters['head'][$counter][2] = 'mymoduleemails';
$counter++;
}
if ($counter > 0 && (int) DOL_VERSION < 14) {
$this->results = $parameters['head'];
// return 1 to replace standard code
return 1;
} else {
// en V14 et + $parameters['head'] est modifiable par référence
return 0;
}
}
}
/* Add here any other hooked methods... */
}

View File

@ -6767,9 +6767,9 @@ div.phpdebugbar-widgets-templates a.phpdebugbar-widgets-editor-link:before
/* ============================================================================== */
span.clipboardCPValue.hidewithsize {
width: 0 !important;
display: inline-block;
color: transparent;
width: 0 !important;
display: inline-block;
color: transparent;
}
.clipboardCPShowOnHover .clipboardCPButton {

View File

@ -6611,9 +6611,9 @@ div.phpdebugbar-widgets-templates a.phpdebugbar-widgets-editor-link:before
/* ============================================================================== */
span.clipboardCPValue.hidewithsize {
width: 0 !important;
display: inline-block;
color: transparent;
width: 0 !important;
display: inline-block;
color: transparent;
}
.clipboardCPShowOnHover .clipboardCPButton {