diff --git a/htdocs/accountancy/bookkeeping/list.php b/htdocs/accountancy/bookkeeping/list.php
index 5158e12ebb6..f449a99c8bf 100644
--- a/htdocs/accountancy/bookkeeping/list.php
+++ b/htdocs/accountancy/bookkeeping/list.php
@@ -922,8 +922,8 @@ while ($i < min($num, $limit))
{
print '
' . ($line->debit ? price($line->debit) : ''). ' ';
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totaldebitfield']=$totalarray['nbfield'];
- $totalarray['totaldebit'] += $line->debit;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='totaldebit';
+ $totalarray['val']['totaldebit'] += $line->debit;
}
// Amount credit
@@ -931,8 +931,8 @@ while ($i < min($num, $limit))
{
print '' . ($line->credit ? price($line->credit) : '') . ' ';
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalcreditfield']=$totalarray['nbfield'];
- $totalarray['totalcredit'] += $line->credit;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='totalcredit';
+ $totalarray['val']['totalcredit'] += $line->credit;
}
// Lettering code
@@ -998,29 +998,7 @@ while ($i < min($num, $limit))
}
// Show total line
-if (isset($totalarray['totaldebitfield']) || isset($totalarray['totalcreditfield']))
-{
- $i=0;
- print '';
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if ($i == 1)
- {
- if ($num < $limit && empty($offset)) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- elseif ($totalarray['totaldebitfield'] == $i) print ''.price($totalarray['totaldebit']).' ';
- elseif ($totalarray['totalcreditfield'] == $i) print ''.price($totalarray['totalcredit']).' ';
- else print ' ';
- }
- $parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
- $reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
- print $hookmanager->resPrint;
-
- print ' ';
-}
-
+include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
print "";
diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php
index a66323654d8..81d6b7625b7 100644
--- a/htdocs/adherents/list.php
+++ b/htdocs/adherents/list.php
@@ -919,26 +919,8 @@ while ($i < min($num, $limit))
}
// Show total line
-if (isset($totalarray['pos']))
-{
- print '';
- $i=0;
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if (! empty($totalarray['pos'][$i])) print ''.price($totalarray['val'][$totalarray['pos'][$i]]).' ';
- else
- {
- if ($i == 1)
- {
- if ($num < $limit) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- else print ' ';
- }
- }
- print ' ';
-}
+include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
+
// If no record found
if ($num == 0)
diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php
index dbc14e2999e..c66dce0e8fd 100644
--- a/htdocs/adherents/subscription/list.php
+++ b/htdocs/adherents/subscription/list.php
@@ -588,26 +588,8 @@ while ($i < min($num, $limit))
}
// Show total line
-if (isset($totalarray['pos']))
-{
- print '';
- $i=0;
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if (! empty($totalarray['pos'][$i])) print ''.price($totalarray['val'][$totalarray['pos'][$i]]).' ';
- else
- {
- if ($i == 1)
- {
- if ($num < $limit) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- else print ' ';
- }
- }
- print ' ';
-}
+include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
+
// If no record found
if ($num == 0)
diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php
index 718ebfdc64d..b6f8abe27da 100644
--- a/htdocs/adherents/type.php
+++ b/htdocs/adherents/type.php
@@ -827,9 +827,12 @@ if ($rowid > 0)
$doleditor->Create();
print "";
+ // Other attributes
+ include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_edit.tpl.php';
+
// Other attributes
$parameters=array();
- $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $act, $action); // Note that $action and $object may have been modified by hook
+ $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
if (empty($reshook))
{
@@ -838,33 +841,6 @@ if ($rowid > 0)
print '';
- // Extra field
- if (empty($reshook))
- {
- print '';
- if (is_array($extrafields->attributes['adherent_type']['label']))
- {
- foreach($extrafields->attributes['adherent_type']['label'] as $key=>$label)
- {
- if (isset($_POST["options_" . $key])) {
- if (is_array($_POST["options_" . $key])) {
- // $_POST["options"] is an array but following code expects a comma separated string
- $value = implode(",", $_POST["options_" . $key]);
- } else {
- $value = $_POST["options_" . $key];
- }
- } else {
- $value = $object->array_options["options_" . $key];
- }
-
- print ''.$label.' ';
- print $extrafields->showInputField($key, $value);
- print " \n";
- }
- }
- print '
';
- }
-
dol_fiche_end();
print '';
diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php
index 5145f5dd083..9cb83e3784b 100644
--- a/htdocs/admin/emailcollector_list.php
+++ b/htdocs/admin/emailcollector_list.php
@@ -497,26 +497,8 @@ while ($i < min($num, $limit))
}
// Show total line
-if (isset($totalarray['pos']))
-{
- print '
';
- $i=0;
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if (! empty($totalarray['pos'][$i])) print ''.price($totalarray['val'][$totalarray['pos'][$i]]).' ';
- else
- {
- if ($i == 1)
- {
- if ($num < $limit) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- else print ' ';
- }
- }
- print ' ';
-}
+include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
+
// If no record found
if ($num == 0)
diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php
index 139c6815072..028de9a32a5 100644
--- a/htdocs/admin/mails_senderprofile_list.php
+++ b/htdocs/admin/mails_senderprofile_list.php
@@ -461,26 +461,8 @@ while ($i < min($num, $limit))
}
// Show total line
-if (isset($totalarray['pos']))
-{
- print '
';
- $i=0;
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if (! empty($totalarray['pos'][$i])) print ''.price($totalarray['val'][$totalarray['pos'][$i]]).' ';
- else
- {
- if ($i == 1)
- {
- if ($num < $limit) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- else print ' ';
- }
- }
- print ' ';
-}
+include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
+
// If no record found
if ($num == 0)
diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php
index aa690b9468a..40899c56fa7 100644
--- a/htdocs/bom/bom_list.php
+++ b/htdocs/bom/bom_list.php
@@ -555,26 +555,8 @@ while ($i < min($num, $limit))
}
// Show total line
-if (isset($totalarray['pos']))
-{
- print '
';
- $i=0;
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if (! empty($totalarray['pos'][$i])) print ''.price($totalarray['val'][$totalarray['pos'][$i]]).' ';
- else
- {
- if ($i == 1)
- {
- if ($num < $limit) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- else print ' ';
- }
- }
- print ' ';
-}
+include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
+
// If no record found
if ($num == 0)
diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php
index 0c52fea9f35..bccc742aa8e 100644
--- a/htdocs/comm/propal/list.php
+++ b/htdocs/comm/propal/list.php
@@ -947,24 +947,24 @@ if ($resql)
{
print '
'.price($obj->total_ht)." \n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalhtfield']=$totalarray['nbfield'];
- $totalarray['totalht'] += $obj->total_ht;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='p.total_ht';
+ $totalarray['val']['p.total_ht'] += $obj->total_ht;
}
// Amount VAT
if (! empty($arrayfields['p.total_vat']['checked']))
{
print '
'.price($obj->total_vat)." \n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalvatfield']=$totalarray['nbfield'];
- $totalarray['totalvat'] += $obj->total_vat;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='p.total_vat';
+ $totalarray['val']['p.total_vat'] += $obj->total_vat;
}
// Amount TTC
if (! empty($arrayfields['p.total_ttc']['checked']))
{
print '
'.price($obj->total_ttc)." \n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield'];
- $totalarray['totalttc'] += $obj->total_ttc;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='p.total_ttc';
+ $totalarray['val']['p.total_ttc'] += $obj->total_ttc;
}
// Amount invoiced
if(! empty($arrayfields['p.total_ht_invoiced']['checked'])) {
@@ -984,8 +984,8 @@ if ($resql)
print '
'.price($totalInvoiced)." \n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalhtinvoicedfield']=$totalarray['nbfield'];
- $totalarray['totalhtinvoiced'] += $totalInvoiced;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='p.total_ht_invoiced';
+ $totalarray['val']['p.total_ht_invoiced'] += $obj->total_ht_invoiced;
}
// Amount invoiced
if(! empty($arrayfields['p.total_invoiced']['checked'])) {
@@ -1005,8 +1005,8 @@ if ($resql)
print '
'.price($totalInvoiced)." \n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalinvoicedfield']=$totalarray['nbfield'];
- $totalarray['totalinvoiced'] += $totalInvoiced;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='p.total_invoiced';
+ $totalarray['val']['p.total_invoiced'] += $obj->total_invoiced;
}
$userstatic->id=$obj->fk_user_author;
@@ -1120,45 +1120,7 @@ if ($resql)
}
// Show total line
- if (isset($totalarray['totalhtfield'])
- || isset($totalarray['totalvatfield'])
- || isset($totalarray['totalttcfield'])
- || isset($totalarray['totalamfield'])
- || isset($totalarray['totalrtpfield'])
- || isset($totalarray['totalizable'])
- )
- {
- print '
';
- $i=0;
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if ($i == 1)
- {
- if ($num < $limit && empty($offset)) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- elseif ($totalarray['totalhtfield'] == $i) print ''.price($totalarray['totalht']).' ';
- elseif ($totalarray['totalvatfield'] == $i) print ''.price($totalarray['totalvat']).' ';
- elseif ($totalarray['totalttcfield'] == $i) print ''.price($totalarray['totalttc']).' ';
- elseif ($totalarray['totalhtinvoicedfield'] == $i) print ''.price($totalarray['totalhtinvoiced']).' ';
- elseif ($totalarray['totalinvoicedfield'] == $i) print ''.price($totalarray['totalinvoiced']).' ';
- elseif ($totalarray['totalizable']) {
- $printed = false;
- foreach ($totalarray['totalizable'] as $totalizable) {
- if ($totalizable['pos']==$i && ! $printed) {
- print ''.price($totalizable['total']).' ';
- $printed = true;
- }
- }
- if (! $printed) {
- print ' ';
- }
- }
- else print ' ';
- }
- print ' ';
- }
+ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
$db->free($resql);
diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php
index 23af81ab24e..c196f0a8296 100644
--- a/htdocs/commande/list.php
+++ b/htdocs/commande/list.php
@@ -1057,24 +1057,25 @@ if ($resql)
{
print '
'.price($obj->total_ht)." \n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalhtfield']=$totalarray['nbfield'];
- $totalarray['totalht'] += $obj->total_ht;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='c.total_ht';
+ $totalarray['val']['c.total_ht'] += $obj->total_ht;
+
}
// Amount VAT
if (! empty($arrayfields['c.total_vat']['checked']))
{
print '
'.price($obj->total_tva)." \n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalvatfield']=$totalarray['nbfield'];
- $totalarray['totalvat'] += $obj->total_tva;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='c.total_tva';
+ $totalarray['val']['c.total_tva'] += $obj->total_tva;
}
// Amount TTC
if (! empty($arrayfields['c.total_ttc']['checked']))
{
print '
'.price($obj->total_ttc)." \n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield'];
- $totalarray['totalttc'] += $obj->total_ttc;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='c.total_ttc';
+ $totalarray['val']['c.total_ttc'] += $obj->total_ttc;
}
// Extra fields
@@ -1139,30 +1140,7 @@ if ($resql)
}
// Show total line
- if (isset($totalarray['totalhtfield'])
- || isset($totalarray['totalvatfield'])
- || isset($totalarray['totalttcfield'])
- || isset($totalarray['totalamfield'])
- || isset($totalarray['totalrtpfield'])
- )
- {
- print '
';
- $i=0;
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if ($i == 1)
- {
- if ($num < $limit && empty($offset)) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- elseif ($totalarray['totalhtfield'] == $i) print ''.price($totalarray['totalht']).' ';
- elseif ($totalarray['totalvatfield'] == $i) print ''.price($totalarray['totalvat']).' ';
- elseif ($totalarray['totalttcfield'] == $i) print ''.price($totalarray['totalttc']).' ';
- else print ' ';
- }
- print ' ';
- }
+ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
$db->free($resql);
diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php
index 4a9d0947b1e..d23f5126375 100644
--- a/htdocs/compta/bank/bankentries_list.php
+++ b/htdocs/compta/bank/bankentries_list.php
@@ -919,13 +919,13 @@ if ($resql)
if (! empty($arrayfields['b.debit']['checked']))
{
print '
';
- print ' ';
+ print ' ';
print ' ';
}
if (! empty($arrayfields['b.credit']['checked']))
{
print '
';
- print ' ';
+ print ' ';
print ' ';
}
if (! empty($arrayfields['balancebefore']['checked']))
@@ -1085,6 +1085,7 @@ if ($resql)
if ($tmpnbfieldbeforebalance)
{
print '
';
+ print ' ';
print ' ';
}
@@ -1110,6 +1111,7 @@ if ($resql)
';
print '';
print '
';
+ print ' ';
print ' ';
print '';
}
@@ -1529,7 +1531,6 @@ if ($resql)
print ' '.img_warning($langs->trans("ReconciliationLate"));
}
}
- print ' ';
if ($user->rights->banque->modifier)
{
print '
rowid.'&id='.$objp->bankid.'&page='.$page.'">';
diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php
index e1e7ca777b5..2244a73b02a 100644
--- a/htdocs/compta/bank/list.php
+++ b/htdocs/compta/bank/list.php
@@ -563,8 +563,8 @@ foreach ($accounts as $key=>$type)
print ' '.price($solde, 0, $langs, 0, -1, -1, $objecttmp->currency_code).' ';
print '';
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalbalancefield']=$totalarray['nbfield'];
- $totalarray['totalbalance'] += $solde;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='balance';
+ $totalarray['val']['balance'] += $solde;
}
// Action column
@@ -594,22 +594,10 @@ if (! $found)
}
// Show total line
-if (isset($totalarray['totalbalancefield']) && $lastcurrencycode != 'various') // If there is several currency, $lastcurrencycode is set to 'various' before
+if ($lastcurrencycode != 'various') // If there is several currency, $lastcurrencycode is set to 'various' before
{
- print '
';
- $i=0;
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if ($i == 1)
- {
- if ($num < $limit && empty($offset)) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- elseif ($totalarray['totalbalancefield'] == $i) print ''.price($totalarray['totalbalance'], 0, $langs, 0, -1, -1, $lastcurrencycode).' ';
- else print ' ';
- }
- print ' ';
+ // Show total line
+ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
}
print '';
diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php
index cad88367aa0..d73d6d8a391 100644
--- a/htdocs/compta/bank/various_payment/list.php
+++ b/htdocs/compta/bank/various_payment/list.php
@@ -256,15 +256,19 @@ if ($result)
// Ref
print "
".$variousstatic->getNomUrl(1)." \n";
+ if (! $i) $totalarray['nbfield']++;
// Label payment
print "
".dol_trunc($obj->label, 40)." \n";
+ if (! $i) $totalarray['nbfield']++;
// Date payment
print '
'.dol_print_date($db->jdate($obj->datep), 'day')." \n";
+ if (! $i) $totalarray['nbfield']++;
// Type
print '
'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.' ';
+ if (! $i) $totalarray['nbfield']++;
// Account
if (! empty($conf->banque->enabled))
@@ -289,6 +293,7 @@ if ($result)
}
else print ' ';
print '';
+ if (! $i) $totalarray['nbfield']++;
}
// Accounting account
@@ -297,6 +302,7 @@ if ($result)
$accountingaccount->fetch('', $obj->accountancy_code, 1);
print '
'.$accountingaccount->getNomUrl(0, 1, 1, '', 1).' ';
+ if (! $i) $totalarray['nbfield']++;
}
// Debit
@@ -304,8 +310,10 @@ if ($result)
if ($obj->sens == 0)
{
print price($obj->amount);
- $totalarray['totaldeb'] += $obj->amount;
+ $totalarray['val']['total_deb'] += $obj->amount;
}
+ if (! $i) $totalarray['nbfield']++;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='total_deb';
print "";
// Credit
@@ -313,8 +321,10 @@ if ($result)
if ($obj->sens == 1)
{
print price($obj->amount);
- $totalarray['totalcred'] += $obj->amount;
+ $totalarray['val']['total_cred'] += $obj->amount;
}
+ if (! $i) $totalarray['nbfield']++;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='total_cred';
print "";
print "
";
@@ -326,12 +336,8 @@ if ($result)
if (! empty($conf->banque->enabled)) $colspan++;
if (! empty($conf->accounting->enabled)) $colspan++;
- print '
';
- print ''.$langs->trans("Total").' ';
- print ''.price($totalarray['totaldeb'])." ";
- print ''.price($totalarray['totalcred'])." ";
- print ' ';
- print ' ';
+ // Show total line
+ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
print "";
print '
';
diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php
index 45129b6ee19..7a40d6638ee 100644
--- a/htdocs/compta/cashcontrol/cashcontrol_list.php
+++ b/htdocs/compta/cashcontrol/cashcontrol_list.php
@@ -516,26 +516,8 @@ while ($i < min($num, $limit))
}
// Show total line
-if (isset($totalarray['pos']))
-{
- print '';
- $i=0;
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if (! empty($totalarray['pos'][$i])) print ''.price($totalarray['val'][$totalarray['pos'][$i]]).' ';
- else
- {
- if ($i == 1)
- {
- if ($num < $limit) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- else print ' ';
- }
- }
- print ' ';
-}
+include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
+
// If no record found
if ($num == 0)
diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php
index 8af3495afc8..2a2477fce5e 100644
--- a/htdocs/compta/cashcontrol/report.php
+++ b/htdocs/compta/cashcontrol/report.php
@@ -216,22 +216,22 @@ if ($resql)
if ($objp->amount < 0)
{
print price($objp->amount * -1);
- $totalarray['totaldeb'] += $objp->amount;
+ $totalarray['val']['totaldebfield'] += $objp->amount;
}
print "\n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totaldebfield']=$totalarray['nbfield'];
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='totaldebfield';
// Credit
print '';
if ($objp->amount > 0)
{
print price($objp->amount);
- $totalarray['totalcred'] += $objp->amount;
+ $totalarray['val']['totalcredfield'] += $objp->amount;
}
print " \n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalcredfield']=$totalarray['nbfield'];
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='totalcredfield';
print "";
@@ -239,24 +239,7 @@ if ($resql)
}
// Show total line
- if (isset($totalarray['totaldebfield']) || isset($totalarray['totalcredfield']))
- {
- print '';
- $i=0;
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if ($i == 1)
- {
- if ($num < $limit && empty($offset)) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- elseif ($totalarray['totaldebfield'] == $i) print ''.price(-1 * $totalarray['totaldeb']).' ';
- elseif ($totalarray['totalcredfield'] == $i) print ''.price($totalarray['totalcred']).' ';
- else print ' ';
- }
- print ' ';
- }
+ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
print "";
diff --git a/htdocs/compta/facture/invoicetemplate_list.php b/htdocs/compta/facture/invoicetemplate_list.php
index 941aa0723ef..12e437e6110 100644
--- a/htdocs/compta/facture/invoicetemplate_list.php
+++ b/htdocs/compta/facture/invoicetemplate_list.php
@@ -676,28 +676,9 @@ if ($resql)
print ''.$langs->trans("NoRecordFound").' ';
}
- //var_dump($totalarray);
// Show total line
- if (isset($totalarray['pos']))
- {
- print '';
- $i=0;
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if (! empty($totalarray['pos'][$i])) print ''.price($totalarray['val'][$totalarray['pos'][$i]]).' ';
- else
- {
- if ($i == 1)
- {
- if ($num < $limit) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- else print ' ';
- }
- }
- print ' ';
- }
+ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
+
print "";
print "";
diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php
index 43f8d41db10..75945106b72 100644
--- a/htdocs/compta/facture/list.php
+++ b/htdocs/compta/facture/list.php
@@ -1232,40 +1232,40 @@ if ($resql)
{
print ''.price($obj->total_ht)." \n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalhtfield']=$totalarray['nbfield'];
- $totalarray['totalht'] += $obj->total_ht;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_ht';
+ $totalarray['val']['f.total_ht'] += $obj->total_ht;
}
// Amount VAT
if (! empty($arrayfields['f.total_vat']['checked']))
{
print ''.price($obj->total_vat)." \n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalvatfield']=$totalarray['nbfield'];
- $totalarray['totalvat'] += $obj->total_vat;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_vat';
+ $totalarray['val']['f.total_vat'] += $obj->total_vat;
}
// Amount LocalTax1
if (! empty($arrayfields['f.total_localtax1']['checked']))
{
print ''.price($obj->total_localtax1)." \n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totallocaltax1field']=$totalarray['nbfield'];
- $totalarray['totallocaltax1'] += $obj->total_localtax1;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_localtax1';
+ $totalarray['val']['f.total_localtax1'] += $obj->total_localtax1;
}
// Amount LocalTax2
if (! empty($arrayfields['f.total_localtax2']['checked']))
{
print ''.price($obj->total_localtax2)." \n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totallocaltax2field']=$totalarray['nbfield'];
- $totalarray['totallocaltax2'] += $obj->total_localtax2;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_localtax2';
+ $totalarray['val']['f.total_localtax2'] += $obj->total_localtax2;
}
// Amount TTC
if (! empty($arrayfields['f.total_ttc']['checked']))
{
print ''.price($obj->total_ttc)." \n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield'];
- $totalarray['totalttc'] += $obj->total_ttc;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_ttc';
+ $totalarray['val']['f.total_ttc'] += $obj->total_ttc;
}
if(! empty($arrayfields['f.retained_warranty']['checked']))
@@ -1277,16 +1277,16 @@ if ($resql)
{
print ''.(! empty($totalpay)?price($totalpay, 0, $langs):' ').' '; // TODO Use a denormalized field
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalamfield']=$totalarray['nbfield'];
- $totalarray['totalam'] += $totalpay;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='totalam';
+ $totalarray['val']['totalam'] += $totalpay;
}
if (! empty($arrayfields['rtp']['checked']))
{
print ''.(! empty($remaintopay)?price($remaintopay, 0, $langs):' ').' '; // TODO Use a denormalized field
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalrtpfield']=$totalarray['nbfield'];
- $totalarray['totalrtp'] += $remaintopay;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='rtp';
+ $totalarray['val']['rtp'] += $remaintopay;
}
// Extra fields
@@ -1345,35 +1345,7 @@ if ($resql)
}
// Show total line
- if (isset($totalarray['totalhtfield'])
- || isset($totalarray['totalvatfield'])
- || isset($totalarray['totallocaltax1field'])
- || isset($totalarray['totallocaltax2field'])
- || isset($totalarray['totalttcfield'])
- || isset($totalarray['totalamfield'])
- || isset($totalarray['totalrtpfield'])
- ) {
- print '';
- $i=0;
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if ($i == 1)
- {
- if ($num < $limit && empty($offset)) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- elseif ($totalarray['totalhtfield'] == $i) print ''.price($totalarray['totalht']).' ';
- elseif ($totalarray['totalvatfield'] == $i) print ''.price($totalarray['totalvat']).' ';
- elseif ($totalarray['totallocaltax1field'] == $i) print ''.price($totalarray['totallocaltax1']).' ';
- elseif ($totalarray['totallocaltax2field'] == $i) print ''.price($totalarray['totallocaltax2']).' ';
- elseif ($totalarray['totalttcfield'] == $i) print ''.price($totalarray['totalttc']).' ';
- elseif ($totalarray['totalamfield'] == $i) print ''.price($totalarray['totalam']).' ';
- elseif ($totalarray['totalrtpfield'] == $i) print ''.price($totalarray['totalrtp']).' ';
- else print ' ';
- }
- print ' ';
- }
+ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
}
$db->free($resql);
diff --git a/htdocs/compta/paiement/list.php b/htdocs/compta/paiement/list.php
index 7faa2727ae4..c3eaece8c93 100644
--- a/htdocs/compta/paiement/list.php
+++ b/htdocs/compta/paiement/list.php
@@ -373,26 +373,8 @@ if ($resql)
}
// Show total line
- if (isset($totalarray['pos']))
- {
- print '';
- $i=0;
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if (! empty($totalarray['pos'][$i])) print ''.price($totalarray['val'][$totalarray['pos'][$i]]).' ';
- else
- {
- if ($i == 1)
- {
- if ($num < $limit) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- else print ' ';
- }
- }
- print ' ';
- }
+ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
+
print "\n";
print "";
diff --git a/htdocs/compta/sociales/list.php b/htdocs/compta/sociales/list.php
index 6fbf174abc5..50d062612f8 100644
--- a/htdocs/compta/sociales/list.php
+++ b/htdocs/compta/sociales/list.php
@@ -292,8 +292,8 @@ if ($resql)
// Amount
print ''.price($obj->amount).' ';
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield'];
- $totalarray['totalttc'] += $obj->amount;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='totalttcfield';
+ $totalarray['val']['totalttcfield'] += $obj->amount;
// Due date
print ''.dol_print_date($db->jdate($obj->date_ech), 'day').' ';
@@ -307,20 +307,7 @@ if ($resql)
}
// Show total line
- if (isset($totalarray['totalttcfield']))
- {
- print '';
- if ($num < $limit && empty($offset)) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- print ' ';
- print ' ';
- print ' ';
- print ''.price($totalarray['totalttc']).' ';
- print ' ';
- print ' ';
- print ' ';
- print ' ';
- }
+ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
print '';
print '';
diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php
index a7656289fdd..00627eeb622 100644
--- a/htdocs/contrat/services_list.php
+++ b/htdocs/contrat/services_list.php
@@ -599,24 +599,18 @@ while ($i < min($num, $limit))
print '';
print price($obj->total_ht);
print ' ';
- $totalarray['totalht'] += $obj->total_ht;
- if (! $i) {
- $totalarray['displaytotalline']++;
- $totalarray['nbfield']++;
- $totalarray['totalhtfield']=$totalarray['nbfield'];
- }
+ if (! $i) $totalarray['nbfield']++;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='cd.total_ht';
+ $totalarray['val']['cd.total_ht'] += $obj->total_ht;
}
if (! empty($arrayfields['cd.total_tva']['checked']))
{
print '';
print price($obj->total_tva);
print ' ';
- $totalarray['totalvat'] += $obj->total_tva;
- if (! $i) {
- $totalarray['nbfield']++;
- $totalarray['totalvatfield']=$totalarray['nbfield'];
- $totalarray['displaytotalline']++;
- }
+ if (! $i) $totalarray['nbfield']++;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='cd.total_tva';
+ $totalarray['val']['cd.total_tva'] += $obj->total_tva;
}
if (! empty($arrayfields['cd.tva_tx']['checked']))
{
@@ -734,22 +728,7 @@ while ($i < min($num, $limit))
}
// Show total line
-if (isset($totalarray['displaytotalline'])) {
- print '';
- $i=0;
- while ($i < $totalarray['nbfield']) {
- $i++;
- if ($i == 1) {
- if ($num < $limit && empty($offset)) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- elseif ($totalarray['totalhtfield'] == $i) print ''.price($totalarray['totalht']).' ';
- elseif ($totalarray['totalvatfield'] == $i) print ''.price($totalarray['totalvat']).' ';
- elseif ($totalarray['totalttcfield'] == $i) print ''.price($totalarray['totalttc']).' ';
- else print ' ';
- }
- print ' ';
-}
+include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
$db->free($resql);
diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php
index 83734acd36e..439bc1e030f 100644
--- a/htdocs/core/class/extrafields.class.php
+++ b/htdocs/core/class/extrafields.class.php
@@ -224,9 +224,10 @@ class ExtraFields
* @param string $entity Entity of extrafields (for multicompany modules)
* @param string $langfile Language file
* @param string $enabled Condition to have the field enabled or not
+ * @param int $totalizable Is a measure. Must show a total on lists
* @return int <=0 if KO, >0 if OK
*/
- public function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique = 0, $required = 0, $default_value = '', $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $computed = '', $entity = '', $langfile = '', $enabled = '1')
+ public function addExtraField($attrname, $label, $type, $pos, $size, $elementtype, $unique = 0, $required = 0, $default_value = '', $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0)
{
if (empty($attrname)) return -1;
if (empty($label)) return -1;
@@ -243,7 +244,7 @@ class ExtraFields
if ($result > 0 || $err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' || $type == 'separate')
{
// Add declaration of field into table
- $result2=$this->create_label($attrname, $label, $type, $pos, $size, $elementtype, $unique, $required, $param, $alwayseditable, $perms, $list, $help, $default_value, $computed, $entity, $langfile, $enabled);
+ $result2=$this->create_label($attrname, $label, $type, $pos, $size, $elementtype, $unique, $required, $param, $alwayseditable, $perms, $list, $help, $default_value, $computed, $entity, $langfile, $enabled, $totalizable);
$err2=$this->errno;
if ($result2 > 0 || ($err1 == 'DB_ERROR_COLUMN_ALREADY_EXISTS' && $err2 == 'DB_ERROR_RECORD_ALREADY_EXISTS'))
{
@@ -371,9 +372,10 @@ class ExtraFields
* @param string $entity Entity of extrafields
* @param string $langfile Language file
* @param string $enabled Condition to have the field enabled or not
+ * @param int $totalizable Is a measure. Must show a total on lists
* @return int <=0 if KO, >0 if OK
*/
- private function create_label($attrname, $label = '', $type = '', $pos = 0, $size = 0, $elementtype = 'member', $unique = 0, $required = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1')
+ private function create_label($attrname, $label = '', $type = '', $pos = 0, $size = 0, $elementtype = 'member', $unique = 0, $required = 0, $param = '', $alwayseditable = 0, $perms = '', $list = '-1', $help = '', $default = '', $computed = '', $entity = '', $langfile = '', $enabled = '1', $totalizable = 0)
{
// phpcs:enable
global $conf,$user;
@@ -424,7 +426,8 @@ class ExtraFields
$sql.= " fk_user_modif,";
$sql.= " datec,";
$sql.= " enabled,";
- $sql.= " help";
+ $sql.= " help,";
+ $sql.= " totalizable";
$sql.= " )";
$sql.= " VALUES('".$attrname."',";
$sql.= " '".$this->db->escape($label)."',";
@@ -446,7 +449,8 @@ class ExtraFields
$sql .= " " . (is_object($user) ? $user->id : 0). ",";
$sql .= "'" . $this->db->idate(dol_now()) . "',";
$sql.= " ".($enabled?"'".$this->db->escape($enabled)."'":"1").",";
- $sql.= " ".($help?"'".$this->db->escape($help)."'":"null");
+ $sql.= " ".($help?"'".$this->db->escape($help)."'":"null").",";
+ $sql.= " ".($totalizable?'1':'0');
$sql.=')';
dol_syslog(get_class($this)."::create_label", LOG_DEBUG);
diff --git a/htdocs/core/tpl/commonfields_add.tpl.php b/htdocs/core/tpl/commonfields_add.tpl.php
index ffc18853af7..5f17b3e2c68 100644
--- a/htdocs/core/tpl/commonfields_add.tpl.php
+++ b/htdocs/core/tpl/commonfields_add.tpl.php
@@ -56,7 +56,7 @@ foreach($object->fields as $key => $val)
if (in_array($val['type'], array('int', 'integer'))) $value = GETPOST($key, 'int');
elseif ($val['type'] == 'text' || $val['type'] == 'html') $value = GETPOST($key, 'none');
else $value = GETPOST($key, 'alpha');
- print $object->showInputField($val, $key, $value, '', '', '', 0);
+ print $object->showInputField($val, $key, $value, '', '', '', 0, $object->table_element);
print '';
print '';
}
diff --git a/htdocs/core/tpl/commonfields_edit.tpl.php b/htdocs/core/tpl/commonfields_edit.tpl.php
index e023354952a..f3ed2a91f6f 100644
--- a/htdocs/core/tpl/commonfields_edit.tpl.php
+++ b/htdocs/core/tpl/commonfields_edit.tpl.php
@@ -55,8 +55,8 @@ foreach($object->fields as $key => $val)
elseif ($val['type'] == 'text' || $val['type'] == 'html') $value = GETPOSTISSET($key)?GETPOST($key, 'none'):$object->$key;
else $value = GETPOSTISSET($key)?GETPOST($key, 'alpha'):$object->$key;
//var_dump($val.' '.$key.' '.$value);
- if ($val['noteditable']) print $object->showOutputField($val, $key, $value, '', '', '', 0);
- else print $object->showInputField($val, $key, $value, '', '', '', 0);
+ if ($val['noteditable']) print $object->showOutputField($val, $key, $value, '', '', '', 0, $object->table_element);
+ else print $object->showInputField($val, $key, $value, '', '', '', 0, $object->table_element);
print '';
print '';
}
diff --git a/htdocs/core/tpl/extrafields_view.tpl.php b/htdocs/core/tpl/extrafields_view.tpl.php
index f19cfff136e..6a61686e5cc 100644
--- a/htdocs/core/tpl/extrafields_view.tpl.php
+++ b/htdocs/core/tpl/extrafields_view.tpl.php
@@ -171,7 +171,7 @@ if (empty($reshook) && is_array($extrafields->attributes[$object->table_element]
print ' ';
print ' ';
print ' ';
- print $extrafields->showInputField($key, $value, '', '', '', 0, $object->id);
+ print $extrafields->showInputField($key, $value, '', '', '', 0, $object->id, $object->table_element);
print ' ';
diff --git a/htdocs/core/tpl/list_print_total.tpl.php b/htdocs/core/tpl/list_print_total.tpl.php
new file mode 100644
index 00000000000..3cf5ded3989
--- /dev/null
+++ b/htdocs/core/tpl/list_print_total.tpl.php
@@ -0,0 +1,29 @@
+ $valtotalizable) {
+ $totalarray['pos'][$valtotalizable['pos']] = $keytotalizable;
+ $totalarray['val'][$keytotalizable] = $valtotalizable['total'];
+ }
+}
+// Show total line
+if (isset($totalarray['pos']))
+{
+ print '';
+ $i=0;
+ while ($i < $totalarray['nbfield'])
+ {
+ $i++;
+ if (! empty($totalarray['pos'][$i])) print ''.price($totalarray['val'][$totalarray['pos'][$i]]).' ';
+ else
+ {
+ if ($i == 1)
+ {
+ if ($num < $limit) print ''.$langs->trans("Total").' ';
+ else print ''.$langs->trans("Totalforthispage").' ';
+ }
+ else print ' ';
+ }
+ }
+ print ' ';
+}
diff --git a/htdocs/expensereport/list.php b/htdocs/expensereport/list.php
index 73331228f2f..91d0efec9cc 100644
--- a/htdocs/expensereport/list.php
+++ b/htdocs/expensereport/list.php
@@ -738,24 +738,24 @@ if ($resql)
{
print ''.price($obj->total_ht)." \n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalhtfield']=$totalarray['nbfield'];
- $totalarray['totalht'] += $obj->total_ht;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='d.total_ht';
+ $totalarray['val']['d.total_ht'] += $obj->total_ht;
}
// Amount VAT
if (! empty($arrayfields['d.total_vat']['checked']))
{
print ''.price($obj->total_tva)." \n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalvatfield']=$totalarray['nbfield'];
- $totalarray['totalvat'] += $obj->total_tva;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='d.total_tva';
+ $totalarray['val']['d.total_tva'] += $obj->total_tva;
}
// Amount TTC
if (! empty($arrayfields['d.total_ttc']['checked']))
{
print ''.price($obj->total_ttc)." \n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield'];
- $totalarray['totalttc'] += $obj->total_ttc;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='d.total_ttc';
+ $totalarray['val']['d.total_ttc'] += $obj->total_ttc;
}
// Extra fields
@@ -815,25 +815,7 @@ if ($resql)
}
// Show total line
- if (isset($totalarray['totalhtfield']))
- {
- print '';
- $i=0;
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if ($i == 1)
- {
- if ($num < $limit && empty($offset)) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- elseif ($totalarray['totalhtfield'] == $i) print ''.price($totalarray['totalht']).' ';
- elseif ($totalarray['totalvatfield'] == $i) print ''.price($totalarray['totalvat']).' ';
- elseif ($totalarray['totalttcfield'] == $i) print ''.price($totalarray['totalttc']).' ';
- else print ' ';
- }
- print ' ';
- }
+ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
$db->free($resql);
diff --git a/htdocs/fichinter/list.php b/htdocs/fichinter/list.php
index 028fd3f717b..eeebd317977 100644
--- a/htdocs/fichinter/list.php
+++ b/htdocs/fichinter/list.php
@@ -602,8 +602,8 @@ if ($resql)
{
print ''.convertSecondToTime($obj->duree, 'allhourmin').' ';
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totaldurationfield']=$totalarray['nbfield'];
- $totalarray['totalduration']+=$obj->duree;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='fd.duree';
+ $totalarray['val']['fd.duree'] += $obj->duree;
}
// Action column
print '';
@@ -623,23 +623,7 @@ if ($resql)
}
// Show total line
- if (isset($totalarray['totalduration']))
- {
- print ' ';
- $i=0;
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if ($i == 1)
- {
- if ($num < $limit && empty($offset)) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- elseif ($totalarray['totaldurationfield'] == $i) print ''.convertSecondToTime($totalarray['totalduration'], 'allhourmin').' ';
- else print ' ';
- }
- print ' ';
- }
+ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
$db->free($resql);
diff --git a/htdocs/fourn/commande/list.php b/htdocs/fourn/commande/list.php
index f14a8d92c66..523543eb8e8 100644
--- a/htdocs/fourn/commande/list.php
+++ b/htdocs/fourn/commande/list.php
@@ -1063,24 +1063,24 @@ if ($resql)
{
print ''.price($obj->total_ht)." \n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalhtfield']=$totalarray['nbfield'];
- $totalarray['totalht'] += $obj->total_ht;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='cf.total_ht';
+ $totalarray['val']['cf.total_ht'] += $obj->total_ht;
}
// Amount VAT
if (! empty($arrayfields['cf.total_vat']['checked']))
{
print ''.price($obj->total_tva)." \n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalvatfield']=$totalarray['nbfield'];
- $totalarray['totalvat'] += $obj->total_tva;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='cf.total_vat';
+ $totalarray['val']['cf.total_vat'] += $obj->total_tva;
}
// Amount TTC
if (! empty($arrayfields['cf.total_ttc']['checked']))
{
print ''.price($obj->total_ttc)." \n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield'];
- $totalarray['totalttc'] += $obj->total_ttc;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='cf.total_ttc';
+ $totalarray['val']['cf.total_ttc'] += $obj->total_ttc;
}
// Extra fields
@@ -1134,28 +1134,9 @@ if ($resql)
}
// Show total line
- if (isset($totalarray['totalhtfield']))
- {
- print '';
- $i=0;
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if ($i == 1)
- {
- if ($num < $limit) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- elseif ($totalarray['totalhtfield'] == $i) print ''.price($totalarray['totalht']).' ';
- elseif ($totalarray['totalvatfield'] == $i) print ''.price($totalarray['totalvat']).' ';
- elseif ($totalarray['totalttcfield'] == $i) print ''.price($totalarray['totalttc']).' ';
- else print ' ';
- }
+ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
- print ' ';
- }
-
$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
$reshook=$hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php
index c06c070d45e..db1fba3001a 100644
--- a/htdocs/fourn/facture/list.php
+++ b/htdocs/fourn/facture/list.php
@@ -1003,56 +1003,56 @@ if ($resql)
{
print ''.price($obj->total_ht)." \n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalhtfield']=$totalarray['nbfield'];
- $totalarray['totalht'] += $obj->total_ht;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_ht';
+ $totalarray['val']['f.total_ht'] += $obj->total_ht;
}
// Amount VAT
if (! empty($arrayfields['f.total_vat']['checked']))
{
print ''.price($obj->total_vat)." \n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalvatfield']=$totalarray['nbfield'];
- $totalarray['totalvat'] += $obj->total_vat;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_vat';
+ $totalarray['val']['f.total_vat'] += $obj->total_vat;
}
// Amount LocalTax1
if (! empty($arrayfields['f.total_localtax1']['checked']))
{
print ''.price($obj->total_localtax1)." \n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totallocaltax1field']=$totalarray['nbfield'];
- $totalarray['totallocaltax1'] += $obj->total_localtax1;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_localtax1';
+ $totalarray['val']['f.total_localtax1'] += $obj->total_localtax1;
}
// Amount LocalTax2
if (! empty($arrayfields['f.total_localtax2']['checked']))
{
print ''.price($obj->total_localtax2)." \n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totallocaltax2field']=$totalarray['nbfield'];
- $totalarray['totallocaltax2'] += $obj->total_localtax2;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_localtax2';
+ $totalarray['val']['f.total_localtax2'] += $obj->total_localtax2;
}
// Amount TTC
if (! empty($arrayfields['f.total_ttc']['checked']))
{
print ''.price($obj->total_ttc)." \n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield'];
- $totalarray['totalttc'] += $obj->total_ttc;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='f.total_ttc';
+ $totalarray['val']['f.total_ttc'] += $obj->total_ttc;
}
if (! empty($arrayfields['dynamount_payed']['checked']))
{
print ''.(! empty($totalpay)?price($totalpay, 0, $langs):' ').' '; // TODO Use a denormalized field
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalamfield']=$totalarray['nbfield'];
- $totalarray['totalam'] += $totalpay;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='totalam';
+ $totalarray['val']['totalam'] += $totalpay;
}
if (! empty($arrayfields['rtp']['checked']))
{
print ''.(! empty($remaintopay)?price($remaintopay, 0, $langs):' ').' '; // TODO Use a denormalized field
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalrtpfield']=$totalarray['nbfield'];
- $totalarray['totalrtp'] += $remaintopay;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='rtp';
+ $totalarray['val']['rtp'] += $remaintopay;
}
@@ -1105,35 +1105,7 @@ if ($resql)
}
// Show total line
- if (isset($totalarray['totalhtfield'])
- || isset($totalarray['totalvatfield'])
- || isset($totalarray['totallocaltax1field'])
- || isset($totalarray['totallocaltax2field'])
- || isset($totalarray['totalttcfield'])
- || isset($totalarray['totalamfield'])
- || isset($totalarray['totalrtpfield'])
- ) {
- print '';
- $i=0;
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if ($i == 1)
- {
- if ($num < $limit && empty($offset)) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- elseif ($totalarray['totalhtfield'] == $i) print ''.price($totalarray['totalht']).' ';
- elseif ($totalarray['totalvatfield'] == $i) print ''.price($totalarray['totalvat']).' ';
- elseif ($totalarray['totallocaltax1field'] == $i) print ''.price($totalarray['totallocaltax1']).' ';
- elseif ($totalarray['totallocaltax2field'] == $i) print ''.price($totalarray['totallocaltax2']).' ';
- elseif ($totalarray['totalttcfield'] == $i) print ''.price($totalarray['totalttc']).' ';
- elseif ($totalarray['totalamfield'] == $i) print ''.price($totalarray['totalam']).' ';
- elseif ($totalarray['totalrtpfield'] == $i) print ''.price($totalarray['totalrtp']).' ';
- else print ' ';
- }
- print ' ';
- }
+ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
}
$db->free($resql);
diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php
index 1dc10406a24..eb7c8af3ef0 100644
--- a/htdocs/fourn/facture/paiement.php
+++ b/htdocs/fourn/facture/paiement.php
@@ -1024,26 +1024,7 @@ if (empty($action) || $action == 'list')
}
// Show total line
- if (isset($totalarray['pos']))
- {
- print '';
- $i=0;
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if (! empty($totalarray['pos'][$i])) print ''.price($totalarray['val'][$totalarray['pos'][$i]]).' ';
- else
- {
- if ($i == 1)
- {
- if ($num < $limit) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- else print ' ';
- }
- }
- print ' ';
- }
+ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
print "";
print "";
diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php
index 0224b7f12d2..6fd3f2b3705 100644
--- a/htdocs/modulebuilder/template/myobject_list.php
+++ b/htdocs/modulebuilder/template/myobject_list.php
@@ -540,26 +540,7 @@ while ($i < min($num, $limit))
}
// Show total line
-if (isset($totalarray['pos']))
-{
- print '';
- $i=0;
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if (! empty($totalarray['pos'][$i])) print ''.price($totalarray['val'][$totalarray['pos'][$i]]).' ';
- else
- {
- if ($i == 1)
- {
- if ($num < $limit) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- else print ' ';
- }
- }
- print ' ';
-}
+include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
// If no record found
if ($num == 0)
diff --git a/htdocs/mrp/mo_list.php b/htdocs/mrp/mo_list.php
index 7612700e4e5..6124101cffa 100644
--- a/htdocs/mrp/mo_list.php
+++ b/htdocs/mrp/mo_list.php
@@ -524,26 +524,8 @@ while ($i < min($num, $limit))
}
// Show total line
-if (isset($totalarray['pos']))
-{
- print '';
- $i=0;
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if (! empty($totalarray['pos'][$i])) print ''.price($totalarray['val'][$totalarray['pos'][$i]]).' ';
- else
- {
- if ($i == 1)
- {
- if ($num < $limit) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- else print ' ';
- }
- }
- print ' ';
-}
+include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
+
// If no record found
if ($num == 0)
diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php
index c99525f5740..aa01088744f 100644
--- a/htdocs/opensurvey/list.php
+++ b/htdocs/opensurvey/list.php
@@ -425,26 +425,8 @@ while ($i < min($num, $limit))
}
// Show total line
-if (isset($totalarray['pos']))
-{
- print '';
- $i=0;
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if (! empty($totalarray['pos'][$i])) print ''.price($totalarray['val'][$totalarray['pos'][$i]]).' ';
- else
- {
- if ($i == 1)
- {
- if ($num < $limit) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- else print ' ';
- }
- }
- print ' ';
-}
+include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
+
// If no record found
if ($num == 0)
diff --git a/htdocs/product/inventory/list.php b/htdocs/product/inventory/list.php
index de1fa138f81..ac2ac589200 100644
--- a/htdocs/product/inventory/list.php
+++ b/htdocs/product/inventory/list.php
@@ -484,26 +484,8 @@ while ($i < min($num, $limit))
}
// Show total line
-if (isset($totalarray['pos']))
-{
- print '';
- $i=0;
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if (! empty($totalarray['pos'][$i])) print ''.price($totalarray['val'][$totalarray['pos'][$i]]).' ';
- else
- {
- if ($i == 1)
- {
- if ($num < $limit) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- else print ' ';
- }
- }
- print ' ';
-}
+include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
+
// If no record found
if ($num == 0)
diff --git a/htdocs/product/stock/productlot_list.php b/htdocs/product/stock/productlot_list.php
index 8dc8f34b7e0..4c306dc1702 100644
--- a/htdocs/product/stock/productlot_list.php
+++ b/htdocs/product/stock/productlot_list.php
@@ -514,25 +514,7 @@ if ($resql)
}
// Show total line
- if (isset($totalarray['totalhtfield']))
- {
- print '';
- $i=0;
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if ($i == 1)
- {
- if ($num < $limit && empty($offset)) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- elseif ($totalarray['totalhtfield'] == $i) print ''.price($totalarray['totalht']).' ';
- elseif ($totalarray['totalvatfield'] == $i) print ''.price($totalarray['totalvat']).' ';
- elseif ($totalarray['totalttcfield'] == $i) print ''.price($totalarray['totalttc']).' ';
- else print ' ';
- }
- print ' ';
- }
+ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
$db->free($resql);
diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php
index b4e17377add..61a96af9f58 100644
--- a/htdocs/projet/list.php
+++ b/htdocs/projet/list.php
@@ -834,11 +834,11 @@ while ($i < min($num, $limit))
if (strcmp($obj->opp_amount, ''))
{
print price($obj->opp_amount, 1, $langs, 1, -1, -1, '');
- $totalarray['totalopp'] += $obj->opp_amount;
+ $totalarray['val']['p.opp_amount'] += $obj->opp_amount;
}
print '';
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totaloppfield']=$totalarray['nbfield'];
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='p.opp_amount';
}
// Opp percent
if (! empty($arrayfields['p.opp_percent']['checked']))
@@ -855,11 +855,11 @@ while ($i < min($num, $limit))
if ($obj->budget_amount != '')
{
print price($obj->budget_amount, 1, $langs, 1, -1, -1);
- $totalarray['totalbudget'] += $obj->budget_amount;
+ $totalarray['val']['p.budget_amount'] += $obj->budget_amount;
}
print '';
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalbudgetfield']=$totalarray['nbfield'];
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='p.budget_amount';
}
// Usage opportunity
if (! empty($arrayfields['p.usage_opportunity']['checked']))
@@ -940,24 +940,7 @@ while ($i < min($num, $limit))
}
// Show total line
-if (isset($totalarray['totaloppfield']) || isset($totalarray['totalbudgetfield']))
-{
- print '';
- $i=0;
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if ($i == 1)
- {
- if ($num < $limit && empty($offset)) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- elseif ($totalarray['totaloppfield'] == $i) print ''.price($totalarray['totalopp'], 1, $langs, 1, -1, -1).' ';
- elseif ($totalarray['totalbudgetfield'] == $i) print ''.price($totalarray['totalbudget'], 1, $langs, 1, -1, -1).' ';
- else print ' ';
- }
- print ' ';
-}
+include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
$db->free($resql);
diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php
index 326782f5a55..5215c82a062 100644
--- a/htdocs/projet/tasks/list.php
+++ b/htdocs/projet/tasks/list.php
@@ -733,6 +733,8 @@ while ($i < min($num, $limit))
//else print '--:--';
print '';
if (! $i) $totalarray['nbfield']++;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.planned_workload';
+ $totalarray['val']['t.planned_workload'] += $obj->planned_workload;
if (! $i) $totalarray['totalplannedworkloadfield']=$totalarray['nbfield'];
$totalarray['totalplannedworkload'] += $obj->planned_workload;
}
@@ -749,6 +751,8 @@ while ($i < min($num, $limit))
else print '';
print '';
if (! $i) $totalarray['nbfield']++;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.duration_effective';
+ $totalarray['val']['t.duration_effective'] += $obj->duration_effective;
if (! $i) $totalarray['totaldurationeffectivefield']=$totalarray['nbfield'];
$totalarray['totaldurationeffective'] += $obj->duration_effective;
}
@@ -775,8 +779,10 @@ while ($i < min($num, $limit))
}
print '';
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalprogress_declaredfield']=$totalarray['nbfield'];
- $totalarray['totaldurationdeclared'] += $obj->planned_workload * $obj->progress / 100;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.progress';
+ $totalarray['val']['t.progress'] += ($obj->planned_workload * $obj->progress / 100);
+ if (! $i) $totalarray['totalprogress_declaredfield']=$totalarray['nbfield'];
+ $totalarray['totaldurationdeclared'] += $obj->planned_workload * $obj->progress / 100;
}
// Progress summary
if (! empty($arrayfields['t.progress_summary']['checked']))
@@ -787,7 +793,7 @@ while ($i < min($num, $limit))
}
print '';
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalprogress_summary']=$totalarray['nbfield'];
+ if (! $i) $totalarray['totalprogress_summary']=$totalarray['nbfield'];
}
// Time not billed
if (! empty($arrayfields['t.tobill']['checked']))
@@ -796,6 +802,7 @@ while ($i < min($num, $limit))
if ($obj->usage_bill_time)
{
print convertSecondToTime($obj->tobill, 'allhourmin');
+ $totalarray['val']['t.tobill'] += $obj->tobill;
$totalarray['totaltobill'] += $obj->tobill;
}
else
@@ -804,6 +811,7 @@ while ($i < min($num, $limit))
}
print '';
if (! $i) $totalarray['nbfield']++;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.tobill';
if (! $i) $totalarray['totaltobillfield']=$totalarray['nbfield'];
}
// Time billed
@@ -813,6 +821,7 @@ while ($i < min($num, $limit))
if ($obj->usage_bill_time)
{
print convertSecondToTime($obj->billed, 'allhourmin');
+ $totalarray['val']['t.billed'] += $obj->billed;
$totalarray['totalbilled'] += $obj->billed;
}
else
@@ -821,6 +830,7 @@ while ($i < min($num, $limit))
}
print '';
if (! $i) $totalarray['nbfield']++;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.billed';
if (! $i) $totalarray['totalbilledfield']=$totalarray['nbfield'];
}
// Extra fields
@@ -870,8 +880,9 @@ while ($i < min($num, $limit))
$i++;
}
// Show total line
+//include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
if (isset($totalarray['totaldurationeffectivefield']) || isset($totalarray['totalplannedworkloadfield']) || isset($totalarray['totalprogress_calculatedfield'])
- || isset($totalarray['totaltobill']) || isset($totalarray['totalbilled']))
+ || isset($totalarray['totaltobill']) || isset($totalarray['totalbilled']))
{
print '';
$i=0;
@@ -889,7 +900,7 @@ if (isset($totalarray['totaldurationeffectivefield']) || isset($totalarray['tota
elseif ($totalarray['totalprogress_declaredfield'] == $i) print ''.($totalarray['totalplannedworkload'] > 0 ? round(100 * $totalarray['totaldurationdeclared'] / $totalarray['totalplannedworkload'], 2).' %' : '').' ';
elseif ($totalarray['totaltobillfield'] == $i) print ''.convertSecondToTime($totalarray['totaltobill'], $plannedworkloadoutputformat).' ';
elseif ($totalarray['totalbilledfield'] == $i) print ''.convertSecondToTime($totalarray['totalbilled'], $plannedworkloadoutputformat).' ';
- else print ' ';
+ else print ' ';
}
print ' ';
}
diff --git a/htdocs/projet/tasks/time.php b/htdocs/projet/tasks/time.php
index 24e5d067186..559931b3ff4 100644
--- a/htdocs/projet/tasks/time.php
+++ b/htdocs/projet/tasks/time.php
@@ -1282,6 +1282,8 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
}
print '';
if (! $i) $totalarray['nbfield']++;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='t.task_duration';
+ $totalarray['val']['t.task_duration'] += $task_time->task_duration;
if (! $i) $totalarray['totaldurationfield']=$totalarray['nbfield'];
$totalarray['totalduration'] += $task_time->task_duration;
}
@@ -1294,11 +1296,13 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
print price($value, 1, $langs, 1, -1, -1, $conf->currency);
print '';
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalvaluefield']=$totalarray['nbfield'];
- $totalarray['totalvalue'] += $value;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='value';
+ $totalarray['val']['value'] += $value;
+ if (! $i) $totalarray['totalvaluefield']=$totalarray['nbfield'];
+ $totalarray['totalvalue'] += $value;
}
- // Invoiced - Value billed
+ // Invoiced
if (! empty($arrayfields['valuebilled']['checked']))
{
print ''; // invoice_id and invoice_line_id
@@ -1687,27 +1691,27 @@ if (($id > 0 || ! empty($ref)) || $projectidforalltimes > 0)
}
// Show total line
+ //include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
if (isset($totalarray['totaldurationfield']) || isset($totalarray['totalvaluefield']))
{
- print ' ';
- $i=0;
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if ($i == 1)
- {
- if ($num < $limit && empty($offset)) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- elseif ($totalarray['totaldurationfield'] == $i) print ''.convertSecondToTime($totalarray['totalduration'], 'allhourmin').' ';
- elseif ($totalarray['totalvaluefield'] == $i) print ''.price($totalarray['totalvalue']).' ';
- //elseif ($totalarray['totalvaluebilledfield'] == $i) print ''.price($totalarray['totalvaluebilled']).' ';
- else print ' ';
- }
- print ' ';
+ print '';
+ $i=0;
+ while ($i < $totalarray['nbfield'])
+ {
+ $i++;
+ if ($i == 1)
+ {
+ if ($num < $limit && empty($offset)) print ''.$langs->trans("Total").' ';
+ else print ''.$langs->trans("Totalforthispage").' ';
+ }
+ elseif ($totalarray['totaldurationfield'] == $i) print ''.convertSecondToTime($totalarray['totalduration'], 'allhourmin').' ';
+ elseif ($totalarray['totalvaluefield'] == $i) print ''.price($totalarray['totalvalue']).' ';
+ //elseif ($totalarray['totalvaluebilledfield'] == $i) print ''.price($totalarray['totalvaluebilled']).' ';
+ else print ' ';
+ }
+ print ' ';
}
-
-
+
if (! count($tasks))
{
$totalnboffields = 1;
diff --git a/htdocs/societe/website.php b/htdocs/societe/website.php
index 81698820eb8..43387d9d8c2 100644
--- a/htdocs/societe/website.php
+++ b/htdocs/societe/website.php
@@ -501,26 +501,8 @@ while ($i < min($num, $limit))
}
// Show total line
-if (isset($totalarray['pos']))
-{
- print '';
- $i=0;
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if (! empty($totalarray['pos'][$i])) print ''.price($totalarray['val'][$totalarray['pos'][$i]]).' ';
- else
- {
- if ($i == 1)
- {
- if ($num < $limit) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- else print ' ';
- }
- }
- print ' ';
-}
+include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
+
// If no record found
if ($num == 0)
diff --git a/htdocs/supplier_proposal/list.php b/htdocs/supplier_proposal/list.php
index e8cad1541ed..2afadd8857a 100644
--- a/htdocs/supplier_proposal/list.php
+++ b/htdocs/supplier_proposal/list.php
@@ -749,24 +749,25 @@ if ($resql)
{
print ''.price($obj->total_ht)." \n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalhtfield']=$totalarray['nbfield'];
- $totalarray['totalht'] += $obj->total_ht;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='sp.total_ht';
+ $totalarray['val']['sp.total_ht'] += $obj->total_ht;
+
}
// Amount VAT
if (! empty($arrayfields['sp.total_vat']['checked']))
{
print ''.price($obj->total_vat)." \n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalvatfield']=$totalarray['nbfield'];
- $totalarray['totalvat'] += $obj->total_vat;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='sp.total_vat';
+ $totalarray['val']['sp.total_vat'] += $obj->total_vat;
}
// Amount TTC
if (! empty($arrayfields['sp.total_ttc']['checked']))
{
print ''.price($obj->total_ttc)." \n";
if (! $i) $totalarray['nbfield']++;
- if (! $i) $totalarray['totalttcfield']=$totalarray['nbfield'];
- $totalarray['totalttc'] += $obj->total_ttc;
+ if (! $i) $totalarray['pos'][$totalarray['nbfield']]='sp.total_ttc';
+ $totalarray['val']['sp.total_ttc'] += $obj->total_ttc;
}
$userstatic->id=$obj->fk_user_author;
@@ -831,30 +832,7 @@ if ($resql)
}
// Show total line
- if (isset($totalarray['totalhtfield'])
- || isset($totalarray['totalvatfield'])
- || isset($totalarray['totalttcfield'])
- || isset($totalarray['totalamfield'])
- || isset($totalarray['totalrtpfield'])
- )
- {
- print '';
- $i=0;
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if ($i == 1)
- {
- if ($num < $limit && empty($offset)) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- elseif ($totalarray['totalhtfield'] == $i) print ''.price($totalarray['totalht']).' ';
- elseif ($totalarray['totalvatfield'] == $i) print ''.price($totalarray['totalvat']).' ';
- elseif ($totalarray['totalttcfield'] == $i) print ''.price($totalarray['totalttc']).' ';
- else print ' ';
- }
- print ' ';
- }
+ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
$db->free($resql);
diff --git a/htdocs/ticket/list.php b/htdocs/ticket/list.php
index 4ca9140145b..1360dc6efcd 100644
--- a/htdocs/ticket/list.php
+++ b/htdocs/ticket/list.php
@@ -687,26 +687,8 @@ while ($i < min($num, $limit))
}
// Show total line
-if (isset($totalarray['pos']))
-{
- print '';
- $i=0;
- while ($i < $totalarray['nbfield'])
- {
- $i++;
- if (! empty($totalarray['pos'][$i])) print ''.price($totalarray['val'][$totalarray['pos'][$i]]).' ';
- else
- {
- if ($i == 1)
- {
- if ($num < $limit) print ''.$langs->trans("Total").' ';
- else print ''.$langs->trans("Totalforthispage").' ';
- }
- else print ' ';
- }
- }
- print ' ';
-}
+include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
+
// If no record found
if ($num == 0)
diff --git a/htdocs/zapier/hook_list.php b/htdocs/zapier/hook_list.php
index 2132cd5da25..21e9c991d07 100644
--- a/htdocs/zapier/hook_list.php
+++ b/htdocs/zapier/hook_list.php
@@ -570,27 +570,8 @@ while ($i < min($num, $limit)) {
}
// Show total line
-if (isset($totalarray['pos'])) {
- print '';
- $i=0;
- while ($i < $totalarray['nbfield']) {
- $i++;
- if (! empty($totalarray['pos'][$i])) {
- print ''.price($totalarray['val'][$totalarray['pos'][$i]]).' ';
- } else {
- if ($i == 1) {
- if ($num < $limit) {
- print ''.$langs->trans("Total").' ';
- } else {
- print ''.$langs->trans("Totalforthispage").' ';
- }
- } else {
- print ' ';
- }
- }
- }
- print ' ';
-}
+include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
+
// If no record found
if ($num == 0) {