From 643564d45c3e2bda41c4f864c148c13906d279ad Mon Sep 17 00:00:00 2001 From: ThomasNgr-OpenDSI Date: Wed, 19 Mar 2025 18:12:02 +0100 Subject: [PATCH] add advanced right to reopen a propal (#33416) * add advanced right to reopen a propal * use NOT insetad of empty() for getDolGlobalBool() * fix travis --- htdocs/comm/propal/card.php | 8 ++++++-- htdocs/core/modules/modPropale.class.php | 7 +++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 0c3e67760a3..ec9cbabce13 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -142,6 +142,10 @@ $usercancreateinvoice = ($user->hasRight('facture', 'creer') == 1); $usercancreatecontract = ($user->hasRight('contrat', 'creer') == 1); $usercancreateintervention = ($user->hasRight('ficheinter', 'creer') == 1); $usercancreatepurchaseorder = ($user->hasRight('fournisseur', 'commande', 'creer') || $user->hasRight('supplier_order', 'creer')); +$usercanreopen = ((!getDolGlobalBool('MAIN_USE_ADVANCED_PERMS') && $usercancreate) || (getDolGlobalBool('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('propal', 'propal_advance', 'reopen'))); +if (getDolGlobalBool('PROPAL_DISALLOW_REOPEN')) { + $usercanreopen = false; +} $permissionnote = $usercancreate; // Used by the include of actions_setnotes.inc.php $permissiondellink = $usercancreate; // Used by the include of actions_dellink.inc.php @@ -830,7 +834,7 @@ if (empty($reshook)) { } } } - } elseif ($action == 'confirm_reopen' && $usercanclose && !GETPOST('cancel', 'alpha')) { + } elseif ($action == 'confirm_reopen' && ((!getDolGlobalBool('MAIN_USE_ADVANCED_PERMS') && $usercanclose) || $usercanreopen) && !GETPOST('cancel', 'alpha')) { // Reopen proposal // prevent browser refresh from reopening proposal several times if ($object->status == Propal::STATUS_SIGNED || $object->status == Propal::STATUS_NOTSIGNED || $object->status == Propal::STATUS_BILLED || $object->status == Propal::STATUS_CANCELED) { @@ -3140,7 +3144,7 @@ if ($action == 'create') { } // ReOpen - if (((getDolGlobalString('PROPAL_REOPEN_UNSIGNED_ONLY') && $object->status == Propal::STATUS_NOTSIGNED) || (!getDolGlobalString('PROPAL_REOPEN_UNSIGNED_ONLY') && ($object->status == Propal::STATUS_SIGNED || $object->status == Propal::STATUS_NOTSIGNED || $object->status == Propal::STATUS_BILLED || $object->status == Propal::STATUS_CANCELED))) && $usercanclose) { + if (((getDolGlobalString('PROPAL_REOPEN_UNSIGNED_ONLY') && $object->status == Propal::STATUS_NOTSIGNED) || (!getDolGlobalString('PROPAL_REOPEN_UNSIGNED_ONLY') && ($object->status == Propal::STATUS_SIGNED || $object->status == Propal::STATUS_NOTSIGNED || $object->status == Propal::STATUS_BILLED || $object->status == Propal::STATUS_CANCELED))) && ((!getDolGlobalBool('MAIN_USE_ADVANCED_PERMS') && $usercanclose) || $usercanreopen)) { print ''.$langs->trans('ReOpen').''; } diff --git a/htdocs/core/modules/modPropale.class.php b/htdocs/core/modules/modPropale.class.php index 2ec295da236..52b4398904f 100644 --- a/htdocs/core/modules/modPropale.class.php +++ b/htdocs/core/modules/modPropale.class.php @@ -181,6 +181,13 @@ class modPropale extends DolibarrModules $this->rights[$r][3] = 0; // La permission est-elle une permission par default $this->rights[$r][4] = 'export'; + $r++; + $this->rights[$r][0] = 29; // id de la permission + $this->rights[$r][1] = 'Reopen commercial proposals'; // Set proposal to signed or refused + $this->rights[$r][2] = 'w'; // type de la permission (deprecie a ce jour) + $this->rights[$r][3] = 0; // La permission est-elle une permission par default + $this->rights[$r][4] = 'propal_advance'; + $this->rights[$r][5] = 'reopen'; // Menus //-------