5'@phan-var-force array{nbfield:int,type?:array<int,string>,pos?:array<int,int>,val?:array<int,float>} $totalarray';
8if (!empty($totalarray[
'totalizable']) && is_array($totalarray[
'totalizable'])) {
9 foreach ($totalarray[
'totalizable'] as $keytotalizable => $valtotalizable) {
10 $totalarray[
'pos'][$valtotalizable[
'pos']] = $keytotalizable;
11 $totalarray[
'val'][$keytotalizable] = isset($valtotalizable[
'total']) ? $valtotalizable[
'total'] : 0;
15if (isset($totalarray[
'pos'])) {
17 print
'<tr class="liste_total">';
19 while ($i < $totalarray[
'nbfield']) {
21 if (!empty($totalarray[
'pos'][$i])) {
22 printTotalValCell($totalarray[
'type'][$i] ??
'', empty($totalarray[
'val'][$totalarray[
'pos'][$i]]) ? 0 : $totalarray[
'val'][$totalarray[
'pos'][$i]]);
25 if ((is_null($limit) || $num < $limit) && empty($offset)) {
26 print
'<td>'.$langs->trans(
"Total").
'</td>';
29 if (is_object($form)) {
30 print $form->textwithpicto($langs->trans(
"Total"), $langs->transnoentitiesnoconv(
"Totalforthispage"));
32 print $langs->trans(
"Totalforthispage");
43 if (
getDolGlobalString(
'MAIN_GRANDTOTAL_LIST_SHOW') && (!(is_null($limit) || $num < $limit))) {
44 if (isset($totalarray[
'pos']) && is_array($totalarray[
'pos']) && count($totalarray[
'pos']) > 0) {
47 foreach ($totalarray[
'pos'] as $field) {
48 $fieldforsum = preg_replace(
'/[^a-z0-9]/',
'', $field);
49 $tbsumfields[] =
"sum($field) as $fieldforsum";
51 if (isset($sqlfields)) {
52 $sqlforgrandtotal = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT '. implode(
",", $tbsumfields), $sql);
54 $sqlforgrandtotal = preg_replace(
'/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/',
'SELECT '. implode(
",", $tbsumfields).
' FROM ', $sql);
56 $sqlforgrandtotal = preg_replace(
'/GROUP BY .*$/',
'', $sqlforgrandtotal).
'';
57 $resql = $db->query($sqlforgrandtotal);
59 $sumsarray = $db->fetch_array($resql);
63 if (is_array($sumsarray) && count($sumsarray) > 0) {
64 print
'<tr class="liste_grandtotal">';
66 while ($i < $totalarray[
'nbfield']) {
68 if (!empty($totalarray[
'pos'][$i])) {
69 $fieldname = preg_replace(
'/[^a-z0-9]/',
'', $totalarray[
'pos'][$i]);
70 printTotalValCell($totalarray[
'type'][$i], $sumsarray[$fieldname]);
74 if (is_object($form)) {
75 print $form->textwithpicto($langs->trans(
"GrandTotal"), $langs->transnoentitiesnoconv(
"TotalforAllPages"));
77 print $langs->trans(
"GrandTotal");
99function printTotalValCell($type, $val)
107 print
'<td class="right">';
112 print
'<td class="left">';
113 print(!empty($val) ? $val :
'');
117 print
'<td class="right">';
118 print
price2num(!empty($val) ? $val : 0,
'MS');
122 print
'<td class="right">';
123 print
price(!empty($val) ? $val : 0);
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
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.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.