dolibarr 25.0.0-alpha
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 $usemulticurrency = (isModEnabled('multicurrency') && $object->multicurrency_code != getDolCurrency());
39 $subtotal_total_value = $object->getSubtotalLineAmountValue($line, $usemulticurrency); // @phan-suppress-current-line PhanPluginUnknownObjectMethodCall
40 $substitutionarray['subtotals_total'] = ($subtotal_total_value == 0) ? "" : price($subtotal_total_value);
41 $substitutionarray['subtotals_level'] = abs($line->qty);
42 } else {
43 $substitutionarray['is_subtotals_line'] = false;
44 $substitutionarray['is_not_subtotals_line'] = true;
45 $substitutionarray['is_subtotals_title'] = false;
46 $substitutionarray['is_subtotals_subtotal'] = false;
47 $substitutionarray['subtotals_total'] = 0;
48 $substitutionarray['subtotals_level'] = 0;
49 }
50}
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
getDolCurrency()
Return the main currency ('EUR', 'USD', ...)
isModEnabled($module)
Is Dolibarr module enabled.