From e736235a3085cc2abff5365d62fb8a29b2f0dd17 Mon Sep 17 00:00:00 2001 From: Lucas Marcouiller <45882981+Hystepik@users.noreply.github.com> Date: Thu, 26 Sep 2024 21:36:49 +0200 Subject: [PATCH] Qual create button to factorize services buttons in ficheinter/card.php (#31065) * Qual create button to factorize services buttons in ficheinter/card.php * Fix Ci --------- Co-authored-by: Hystepik Co-authored-by: Laurent Destailleur --- htdocs/fichinter/card.php | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 7c1809cf9be..6010907c5dd 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1726,6 +1726,7 @@ if ($action == 'create') { $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if (empty($reshook)) { + $params = array(); if ($user->socid == 0) { if ($action != 'editdescription' && ($action != 'presend')) { // Validate @@ -1775,15 +1776,18 @@ if ($action == 'create') { print ''; } + $arrayofcreatebutton = array(); // Proposal if (isModEnabled("service") && isModEnabled("propal") && $object->statut > Fichinter::STATUS_DRAFT) { $langs->load("propal"); if ($object->statut < Fichinter::STATUS_BILLED) { - if ($user->hasRight('propal', 'creer')) { - print ''; - } else { - print ''; - } + $arrayofcreatebutton[] = array( + 'url' => '/comm/propal/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid, + 'label' => $langs->trans('AddProp'), + 'lang' => 'propal', + 'perm' => $user->hasRight('propal', 'creer'), + 'enabled' => true, + ); } } @@ -1791,11 +1795,13 @@ if ($action == 'create') { if (isModEnabled('invoice') && $object->statut > Fichinter::STATUS_DRAFT) { $langs->load("bills"); if ($object->statut < Fichinter::STATUS_BILLED) { - if ($user->hasRight('facture', 'creer')) { - print ''; - } else { - print ''; - } + $arrayofcreatebutton[] = array( + 'url' => '/compta/facture/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid, + 'label' => $langs->trans('AddBill'), + 'lang' => 'bills', + 'perm' => $user->hasRight('facture', 'creer'), + 'enabled' => true, + ); } if (getDolGlobalString('FICHINTER_CLASSIFY_BILLED')) { // Option deprecated. In a future, billed must be managed with a dedicated field to 0 or 1 @@ -1807,6 +1813,10 @@ if ($action == 'create') { } } + if (count($arrayofcreatebutton)) { + print dolGetButtonAction('', $langs->trans("Create"), 'default', $arrayofcreatebutton, '', true, $params); + } + // Sign if ($object->statut > Fichinter::STATUS_DRAFT) { if ($object->signed_status != Fichinter::$SIGNED_STATUSES['STATUS_SIGNED_ALL']) {