diff --git a/htdocs/fichinter/card.php b/htdocs/fichinter/card.php index 8b4709d53d3..18f383d3ab3 100644 --- a/htdocs/fichinter/card.php +++ b/htdocs/fichinter/card.php @@ -1312,6 +1312,19 @@ if ($action == 'create') { $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneIntervention', $object->ref), 'confirm_clone', $formquestion, 'yes', 1); } + // Subtotal line form + if ($action == 'add_title_line') { + $langs->load('subtotals'); + $type = 'title'; + $depth_array = $object->getPossibleLevels($langs); + require dol_buildpath('/core/tpl/subtotal_create.tpl.php'); + } elseif ($action == 'add_subtotal_line') { + $langs->load('subtotals'); + $type = 'subtotal'; + $titles = $object->getPossibleTitles(); + require dol_buildpath('/core/tpl/subtotal_create.tpl.php'); + } + if (!$formconfirm) { $parameters = array('formConfirm' => $formconfirm, 'lineid' => $lineid); $reshook = $hookmanager->executeHooks('formConfirm', $parameters, $object, $action); // Note that $action and $object may have been modified by hook @@ -1766,6 +1779,29 @@ if ($action == 'create') { $params = array(); if ($user->socid == 0) { if ($action != 'editdescription' && ($action != 'presend')) { + // Subtotal + if ($object->status == Fichinter::STATUS_DRAFT && isModEnabled('subtotals') && getDolGlobalString('SUBTOTAL_TITLE_'.strtoupper($object->element))) { + $langs->load('subtotals'); + + $url_button = array(); + $url_button[] = array( + 'lang' => 'subtotals', + 'enabled' => (isModEnabled('intervention') && $object->status == Fichinter::STATUS_DRAFT), + 'perm' => (bool) $user->hasRight('intervention', 'creer'), + 'label' => $langs->trans('AddTitleLine'), + 'url' => '/fichinter/card.php?id='.$object->id.'&action=add_title_line&token='.newToken() + ); + + $url_button[] = array( + 'lang' => 'subtotals', + 'enabled' => (isModEnabled('intervention') && $object->status == Fichinter::STATUS_DRAFT), + 'perm' => (bool) $user->hasRight('intervention', 'creer'), + 'label' => $langs->trans('AddSubtotalLine'), + 'url' => '/fichinter/card.php?id='.$object->id.'&action=add_subtotal_line&token='.newToken() + ); + print dolGetButtonAction('', $langs->trans('Subtotal'), 'default', $url_button, '', true); + } + // Validate if ($object->status == Fichinter::STATUS_DRAFT && (count($object->lines) > 0 || getDolGlobalString('FICHINTER_DISABLE_DETAILS') == '1')) { if ((!getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('ficheinter', 'creer')) || (getDolGlobalString('MAIN_USE_ADVANCED_PERMS') && $user->hasRight('ficheinter', 'ficheinter_advance', 'validate'))) { diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php index 608ba13d61a..47b1d8a765e 100644 --- a/htdocs/fichinter/class/fichinter.class.php +++ b/htdocs/fichinter/class/fichinter.class.php @@ -4,7 +4,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2011-2020 Juanjo Menent * Copyright (C) 2015 Marcos García - * Copyright (C) 2015-2020 Charlene Benke + * Copyright (C) 2015-2025 Charlene Benke * Copyright (C) 2018 Nicolas ZABOURI * Copyright (C) 2018-2025 Frédéric France * Copyright (C) 2023-2024 William Mead @@ -32,6 +32,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinterligne.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/commonsignedobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/subtotals/class/commonsubtotal.class.php'; + /** * Class to manage interventions @@ -40,7 +42,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonsignedobject.class.php'; */ class Fichinter extends CommonObject { - use CommonSignedObject; + use CommonSignedObject, CommonSubtotal; /** * @var string Prefix to check for any trigger code of any business class to prevent bad value for trigger code.