mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-02-07 16:41:48 +01:00
Continue to integrate subtotals on fichinter (#36325)
* add CommonSubtotal usage on fichinter class * Add 'fichinter' to element check in subtotal_create * Implement subtotal line addition in card.php Added functionality to handle subtotal lines in the card. * Update card.php * Update permission checks for intervention module --------- Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
@@ -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'))) {
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
|
||||
* Copyright (C) 2011-2020 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2015-2020 Charlene Benke <charlie@patas-monkey.com>
|
||||
* Copyright (C) 2015-2025 Charlene Benke <charlene@patas-monkey.com>
|
||||
* Copyright (C) 2018 Nicolas ZABOURI <info@inovea-conseil.com>
|
||||
* Copyright (C) 2018-2025 Frédéric France <frederic.france@free.fr>
|
||||
* Copyright (C) 2023-2024 William Mead <william.mead@manchenumerique.fr>
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user