From a38ffa02ac52e4446460db6b28e3c446e9483e18 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Thu, 4 Dec 2025 10:18:01 +0100 Subject: [PATCH] fix: subtotal feature button availablity according setup --- htdocs/comm/propal/card.php | 7 ++++--- htdocs/commande/card.php | 7 ++++--- htdocs/compta/facture/card-rec.php | 7 ++++--- htdocs/compta/facture/card.php | 7 ++++--- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index d273223d628..38fca9278e3 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -3456,14 +3456,15 @@ if ($action == 'create') { if (empty($reshook)) { if ($action != 'editline') { // Subtotal - if ($object->status == Propal::STATUS_DRAFT && isModEnabled('subtotals') && getDolGlobalString('SUBTOTAL_TITLE_'.strtoupper($object->element))) { + if ($object->status == Propal::STATUS_DRAFT && isModEnabled('subtotals') + && (getDolGlobalInt('SUBTOTAL_TITLE_'.strtoupper($object->element)) || getDolGlobalInt('SUBTOTAL_'.strtoupper($object->element)))) { $langs->load('subtotals'); $url_button = array(); $url_button[] = array( 'lang' => 'subtotals', - 'enabled' => (isModEnabled('propal') && $object->status == Propal::STATUS_DRAFT), + 'enabled' => (isModEnabled('propal') && $object->status == Propal::STATUS_DRAFT && getDolGlobalInt('SUBTOTAL_TITLE_'.strtoupper($object->element))), 'perm' => (bool) $usercancreate, 'label' => $langs->trans('AddTitleLine'), 'url' => '/comm/propal/card.php?id='.$object->id.'&action=add_title_line&token='.newToken() @@ -3471,7 +3472,7 @@ if ($action == 'create') { $url_button[] = array( 'lang' => 'subtotals', - 'enabled' => (isModEnabled('propal') && $object->status == Propal::STATUS_DRAFT), + 'enabled' => (isModEnabled('propal') && $object->status == Propal::STATUS_DRAFT && getDolGlobalInt('SUBTOTAL_'.strtoupper($object->element))), 'perm' => (bool) $usercancreate, 'label' => $langs->trans('AddSubtotalLine'), 'url' => '/comm/propal/card.php?id='.$object->id.'&action=add_subtotal_line&token='.newToken() diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 25fc87772b5..b67dc1ccbbc 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -3445,14 +3445,15 @@ if ($action == 'create' && $usercancreate) { } // Subtotal - if ($object->status == Commande::STATUS_DRAFT && isModEnabled('subtotals') && getDolGlobalString('SUBTOTAL_TITLE_'.strtoupper($object->element))) { + if ($object->status == Commande::STATUS_DRAFT && isModEnabled('subtotals') + && (getDolGlobalInt('SUBTOTAL_TITLE_'.strtoupper($object->element)) || getDolGlobalInt('SUBTOTAL_'.strtoupper($object->element)))) { $langs->load('subtotals'); $url_button = array(); $url_button[] = array( 'lang' => 'subtotals', - 'enabled' => (isModEnabled('order') && $object->status == Commande::STATUS_DRAFT), + 'enabled' => (isModEnabled('order') && $object->status == Commande::STATUS_DRAFT && getDolGlobalInt('SUBTOTAL_TITLE_'.strtoupper($object->element))), 'perm' => (bool) $usercancreate, 'label' => $langs->trans('AddTitleLine'), 'url' => '/commande/card.php?id='.$object->id.'&action=add_title_line&token='.newToken() @@ -3460,7 +3461,7 @@ if ($action == 'create' && $usercancreate) { $url_button[] = array( 'lang' => 'subtotals', - 'enabled' => (isModEnabled('order') && $object->status == Commande::STATUS_DRAFT), + 'enabled' => (isModEnabled('order') && $object->status == Commande::STATUS_DRAFT && getDolGlobalInt('SUBTOTAL_'.strtoupper($object->element))), 'perm' => (bool) $usercancreate, 'label' => $langs->trans('AddSubtotalLine'), 'url' => '/commande/card.php?id='.$object->id.'&action=add_subtotal_line&token='.newToken() diff --git a/htdocs/compta/facture/card-rec.php b/htdocs/compta/facture/card-rec.php index d342afd0fed..687a10d0f32 100644 --- a/htdocs/compta/facture/card-rec.php +++ b/htdocs/compta/facture/card-rec.php @@ -2076,14 +2076,15 @@ if ($action == 'create') { ); // Subtotal - if (empty($object->suspended) && isModEnabled('subtotals') && getDolGlobalString('SUBTOTAL_TITLE_'.strtoupper($object->element))) { + if (empty($object->suspended) && isModEnabled('subtotals') + && (getDolGlobalInt('SUBTOTAL_TITLE_'.strtoupper($object->element)) || getDolGlobalInt('SUBTOTAL_'.strtoupper($object->element)))) { $langs->load("subtotals"); $url_button = array(); $url_button[] = array( 'lang' => 'subtotals', - 'enabled' => (isModEnabled('invoice') && $object->status == Facture::STATUS_DRAFT), + 'enabled' => (isModEnabled('invoice') && $object->status == Facture::STATUS_DRAFT && getDolGlobalInt('SUBTOTAL_TITLE_'.strtoupper($object->element))), 'perm' => (bool) $usercancreate, 'label' => $langs->trans('AddTitleLine'), 'url' => '/compta/facture/card-rec.php?id='.$object->id.'&action=add_title_line&token='.newToken() @@ -2091,7 +2092,7 @@ if ($action == 'create') { $url_button[] = array( 'lang' => 'subtotals', - 'enabled' => (isModEnabled('invoice') && $object->status == Facture::STATUS_DRAFT), + 'enabled' => (isModEnabled('invoice') && $object->status == Facture::STATUS_DRAFT && getDolGlobalInt('SUBTOTAL_'.strtoupper($object->element))), 'perm' => (bool) $usercancreate, 'label' => $langs->trans('AddSubtotalLine'), 'url' => '/compta/facture/card-rec.php?id='.$object->id.'&action=add_subtotal_line&token='.newToken() diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index d83c4b4fb0e..41f1f015c84 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -6390,14 +6390,15 @@ if ($action == 'create') { } // Subtotal - if ($object->status == Facture::STATUS_DRAFT && isModEnabled('subtotals') && getDolGlobalString('SUBTOTAL_TITLE_'.strtoupper($object->element))) { + if ($object->status == Facture::STATUS_DRAFT && isModEnabled('subtotals') + && (getDolGlobalInt('SUBTOTAL_TITLE_'.strtoupper($object->element)) || getDolGlobalInt('SUBTOTAL_'.strtoupper($object->element)))) { $langs->load("subtotals"); $url_button = array(); $url_button[] = array( 'lang' => 'subtotals', - 'enabled' => (isModEnabled('invoice') && $object->status == Facture::STATUS_DRAFT), + 'enabled' => (isModEnabled('invoice') && $object->status == Facture::STATUS_DRAFT && getDolGlobalInt('SUBTOTAL_TITLE_'.strtoupper($object->element))), 'perm' => (bool) $usercancreate, 'label' => $langs->trans('AddTitleLine'), 'url' => '/compta/facture/card.php?facid='.$object->id.'&action=add_title_line&token='.newToken() @@ -6405,7 +6406,7 @@ if ($action == 'create') { $url_button[] = array( 'lang' => 'subtotals', - 'enabled' => (isModEnabled('invoice') && $object->status == Facture::STATUS_DRAFT), + 'enabled' => (isModEnabled('invoice') && $object->status == Facture::STATUS_DRAFT && getDolGlobalInt('SUBTOTAL_'.strtoupper($object->element))), 'perm' => (bool) $usercancreate, 'label' => $langs->trans('AddSubtotalLine'), 'url' => '/compta/facture/card.php?facid='.$object->id.'&action=add_subtotal_line&token='.newToken()