dolibarr 19.0.3
list_print_total.tpl.php
1<?php
2
3// Move fields of totalizable into the common array pos and val
4if (!empty($totalarray['totalizable']) && is_array($totalarray['totalizable'])) {
5 foreach ($totalarray['totalizable'] as $keytotalizable => $valtotalizable) {
6 $totalarray['pos'][$valtotalizable['pos']] = $keytotalizable;
7 $totalarray['val'][$keytotalizable] = isset($valtotalizable['total']) ? $valtotalizable['total'] : 0;
8 }
9}
10// Show total line
11if (isset($totalarray['pos'])) {
12 print '<tr class="liste_total">';
13 $i = 0;
14 while ($i < $totalarray['nbfield']) {
15 $i++;
16 if (!empty($totalarray['pos'][$i])) {
17 // if $totalarray['type'] not present we consider it as number
18 if (empty($totalarray['type'][$i])) {
19 $totalarray['type'][$i] = 'real';
20 }
21 switch ($totalarray['type'][$i]) {
22 case 'duration':
23 print '<td class="right">';
24 print (!empty($totalarray['val'][$totalarray['pos'][$i]]) ? convertSecondToTime($totalarray['val'][$totalarray['pos'][$i]], 'allhourmin') : 0);
25 print '</td>';
26 break;
27 case 'string': // This type is no more used. type is now varchar(x)
28 print '<td class="left">';
29 print (!empty($totalarray['val'][$totalarray['pos'][$i]]) ? $totalarray['val'][$totalarray['pos'][$i]] : '');
30 print '</td>';
31 break;
32 case 'stock':
33 print '<td class="right">';
34 print price2num(!empty($totalarray['val'][$totalarray['pos'][$i]]) ? $totalarray['val'][$totalarray['pos'][$i]] : 0, 'MS');
35 print '</td>';
36 break;
37 default:
38 print '<td class="right">';
39 print price(!empty($totalarray['val'][$totalarray['pos'][$i]]) ? $totalarray['val'][$totalarray['pos'][$i]] : 0);
40 print '</td>';
41 break;
42 }
43 } else {
44 if ($i == 1) {
45 if (is_null($limit) || $num < $limit) {
46 print '<td>'.$langs->trans("Total").'</td>';
47 } else {
48 print '<td>';
49 if (is_object($form)) {
50 print $form->textwithpicto($langs->trans("Total"), $langs->transnoentitiesnoconv("Totalforthispage"));
51 } else {
52 print $langs->trans("Totalforthispage");
53 }
54 print '</td>';
55 }
56 } else {
57 print '<td></td>';
58 }
59 }
60 }
61 print '</tr>';
62}
convertSecondToTime($iSecond, $format='all', $lengthOfDay=86400, $lengthOfWeek=7)
Return, in clear text, value of a number of seconds in days, hours and minutes.
Definition date.lib.php:243
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.