3'@phan-var-force array{nbfield:int,type?:array<int,string>,pos?:array<int,int>,val?:array<int,float>} $totalarray';
6if (!empty($totalarray[
'totalizable']) && is_array($totalarray[
'totalizable'])) {
7 foreach ($totalarray[
'totalizable'] as $keytotalizable => $valtotalizable) {
8 $totalarray[
'pos'][$valtotalizable[
'pos']] = $keytotalizable;
9 $totalarray[
'val'][$keytotalizable] = isset($valtotalizable[
'total']) ? $valtotalizable[
'total'] : 0;
13if (isset($totalarray[
'pos'])) {
15 print
'<tr class="liste_total">';
17 while ($i < $totalarray[
'nbfield']) {
19 if (!empty($totalarray[
'pos'][$i])) {
20 printTotalValCell($totalarray[
'type'][$i] ??
'', empty($totalarray[
'val'][$totalarray[
'pos'][$i]]) ? 0 : $totalarray[
'val'][$totalarray[
'pos'][$i]]);
23 if ((is_null($limit) || $num < $limit) && empty($offset)) {
24 print
'<td>'.$langs->trans(
"Total").
'</td>';
27 if (is_object($form)) {
28 print $form->textwithpicto($langs->trans(
"Total"), $langs->transnoentitiesnoconv(
"Totalforthispage"));
30 print $langs->trans(
"Totalforthispage");
41 if (
getDolGlobalString(
'MAIN_GRANDTOTAL_LIST_SHOW') && (!(is_null($limit) || $num < $limit))) {
42 if (isset($totalarray[
'pos']) && is_array($totalarray[
'pos']) && count($totalarray[
'pos']) > 0) {
45 foreach ($totalarray[
'pos'] as $field) {
46 $fieldforsum = preg_replace(
'/[^a-z0-9]/',
'', $field);
47 $tbsumfields[] =
"sum($field) as $fieldforsum";
49 if (isset($sqlfields)) {
50 $sqlforgrandtotal = preg_replace(
'/^'.preg_quote($sqlfields,
'/').
'/',
'SELECT '. implode(
",", $tbsumfields), $sql);
52 $sqlforgrandtotal = preg_replace(
'/^SELECT[a-zA-Z0-9\._\s\(\),=<>\:\-\']+\sFROM/',
'SELECT '. implode(
",", $tbsumfields).
' FROM ', $sql);
54 $sqlforgrandtotal = preg_replace(
'/GROUP BY .*$/',
'', $sqlforgrandtotal).
'';
55 $resql = $db->query($sqlforgrandtotal);
57 $sumsarray = $db->fetch_array($resql);
61 if (is_array($sumsarray) && count($sumsarray) > 0) {
62 print
'<tr class="liste_grandtotal">';
64 while ($i < $totalarray[
'nbfield']) {
66 if (!empty($totalarray[
'pos'][$i])) {
67 $fieldname = preg_replace(
'/[^a-z0-9]/',
'', $totalarray[
'pos'][$i]);
68 printTotalValCell($totalarray[
'type'][$i], $sumsarray[$fieldname]);
72 if (is_object($form)) {
73 print $form->textwithpicto($langs->trans(
"GrandTotal"), $langs->transnoentitiesnoconv(
"TotalforAllPages"));
75 print $langs->trans(
"GrandTotal");
97function printTotalValCell($type, $val)
105 print
'<td class="right">';
110 print
'<td class="left">';
111 print(!empty($val) ? $val :
'');
115 print
'<td class="right">';
116 print
price2num(!empty($val) ? $val : 0,
'MS');
120 print
'<td class="right">';
121 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 dolibarr global constant string value.