dolibarr 21.0.0-alpha
list_print_subtotal.tpl.php
1<?php
2
3'@phan-var-force array{nbfield:int,pos?:array<int,int>,val?:array<int,float>} $totalarray';
4
5// Move fields of totalizable into the common array pos and val
6if (!empty($subtotalarray['totalizable']) && is_array($subtotalarray['totalizable'])) {
7 foreach ($subtotalarray['totalizable'] as $keytotalizable => $valtotalizable) {
8 $totalarray['pos'][$valtotalizable['pos']] = $keytotalizable;
9 $subtotalarray['val'][$keytotalizable] = isset($valtotalizable['total']) ? $valtotalizable['total'] : 0;
10 }
11}
12// Show total line
13if (isset($totalarray['pos'])) {
14 print '<tr class="liste_total">';
15 $j = 0;
16 while ($j < $totalarray['nbfield']) {
17 $j++;
18 if (!empty($totalarray['pos'][$j])) {
19 switch ($totalarray['pos'][$j]) {
20 case 'duration':
21 print '<td class="right">';
22 print(!empty($subtotalarray['val'][$totalarray['pos'][$j]]) ? convertSecondToTime($subtotalarray['val'][$totalarray['pos'][$j]], 'allhourmin') : 0);
23 print '</td>';
24 break;
25 case 'string':
26 print '<td class="left">';
27 print(!empty($subtotalarray['val'][$totalarray['pos'][$j]]) ? $subtotalarray['val'][$totalarray['pos'][$j]] : '');
28 print '</td>';
29 break;
30 case 'stock':
31 print '<td class="right">';
32 print price2num(!empty($subtotalarray['val'][$totalarray['pos'][$j]]) ? $subtotalarray['val'][$totalarray['pos'][$j]] : 0, 'MS');
33 print '</td>';
34 break;
35 default:
36 print '<td class="right">';
37 print price(!empty($subtotalarray['val'][$totalarray['pos'][$j]]) ? $subtotalarray['val'][$totalarray['pos'][$j]] : 0);
38 print '</td>';
39 break;
40 }
41 $subtotalarray['val'][$totalarray['pos'][$j]] = 0;
42 } else {
43 if ($j == 1) {
44 print '<td>'.$langs->trans("SubTotal").'</td>';
45 } else {
46 print '<td></td>';
47 }
48 }
49 }
50 print '</tr>';
51}
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:242
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.