dolibarr 24.0.0-beta
functions_subtotals.lib.php
1<?php
2/*
3 * Copyright (C) 2025
4 * Copyright (C) 2025-2026 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 * or see https://www.gnu.org/
19 */
20
31function subtotals_completesubstitutionarray_lines(&$substitutionarray, $langs, $object, $line)
32{
33 if (defined('SUBTOTALS_SPECIAL_CODE') && property_exists($object, 'ALLOWED_TYPES') && (in_array($object->element, $object::$ALLOWED_TYPES))) {
34 $substitutionarray['is_subtotals_line'] = ($line->special_code == constant('SUBTOTALS_SPECIAL_CODE'));
35 $substitutionarray['is_not_subtotals_line'] = !$substitutionarray['is_subtotals_line'];
36 $substitutionarray['is_subtotals_title'] = (($line->special_code == constant('SUBTOTALS_SPECIAL_CODE')) && $line->qty > 0);
37 $substitutionarray['is_subtotals_subtotal'] = (($line->special_code == constant('SUBTOTALS_SPECIAL_CODE')) && $line->qty < 0);
38 $subtotal_total = 0;
39 if (isModEnabled('multicurrency') && $object->multicurrency_code != getDolCurrency()) {
40 $subtotal_total = $object->getSubtotalLineMulticurrencyAmount($line); // @phan-suppress-current-line PhanPluginUnknownObjectMethodCall
41 } else {
42 $subtotal_total = $object->getSubtotalLineAmount($line); // @phan-suppress-current-line PhanPluginUnknownObjectMethodCall
43 }
44 $substitutionarray['subtotals_total'] = ($subtotal_total == 0) ? "" : $subtotal_total;
45 $substitutionarray['subtotals_level'] = abs($line->qty);
46 } else {
47 $substitutionarray['is_subtotals_line'] = false;
48 $substitutionarray['is_not_subtotals_line'] = true;
49 $substitutionarray['is_subtotals_title'] = false;
50 $substitutionarray['is_subtotals_subtotal'] = false;
51 $substitutionarray['subtotals_total'] = 0;
52 $substitutionarray['subtotals_level'] = 0;
53 }
54}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
getDolCurrency()
Return the main currency ('EUR', 'USD', ...)
isModEnabled($module)
Is Dolibarr module enabled.