diff --git a/htdocs/contrat/services_list.php b/htdocs/contrat/services_list.php
index f78ed639804..006ed7d8005 100644
--- a/htdocs/contrat/services_list.php
+++ b/htdocs/contrat/services_list.php
@@ -525,7 +525,9 @@ print "\n";
$contractstatic=new Contrat($db);
$productstatic=new Product($db);
-$var=True; $i=0;
+$var=true;
+$i=0;
+$totalarray=array();
while ($i < min($num,$limit))
{
$obj = $db->fetch_object($resql);
@@ -542,6 +544,7 @@ while ($i < min($num,$limit))
print '
';
print $contractstatic->getNomUrl(1,16);
print ' | ';
+ if (! $i) $totalarray['nbfield']++;
}
// Service
if (! empty($arrayfields['p.description']['checked']))
@@ -563,6 +566,7 @@ while ($i < min($num,$limit))
if ($obj->type == 1) print img_object($obj->description,'service').' '.dol_trunc($obj->description,24);
}
print '';
+ if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['cd.qty']['checked']))
@@ -570,30 +574,45 @@ while ($i < min($num,$limit))
print '';
print $obj->qty;
print ' | ';
+ if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['cd.total_ht']['checked']))
{
- print '';
+ print ' | ';
print price($obj->total_ht);
print ' | ';
- }
+ $totalarray['totalht'] += $obj->total_ht;
+ if (! $i) {
+ $totalarray['displaytotalline']++;
+ $totalarray['nbfield']++;
+ $totalarray['totalhtfield']=$totalarray['nbfield'];
+ }
+ }
if (! empty($arrayfields['cd.total_tva']['checked']))
{
- print '';
+ print ' | ';
print price($obj->total_tva);
print ' | ';
- }
+ $totalarray['totalvat'] += $obj->total_tva;
+ if (! $i) {
+ $totalarray['nbfield']++;
+ $totalarray['totalvatfield']=$totalarray['nbfield'];
+ $totalarray['displaytotalline']++;
+ }
+ }
if (! empty($arrayfields['cd.tva_tx']['checked']))
{
- print '';
+ print ' | ';
print price2num($obj->tva_tx).'%';
print ' | ';
+ if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['cd.subprice']['checked']))
{
- print '';
+ print ' | ';
print price($obj->subprice);
print ' | ';
+ if (! $i) $totalarray['nbfield']++;
}
@@ -606,6 +625,7 @@ while ($i < min($num,$limit))
$companystatic->client=1;
print $companystatic->getNomUrl(1,'customer',28);
print '';
+ if (! $i) $totalarray['nbfield']++;
}
// Start date
@@ -617,10 +637,12 @@ while ($i < min($num,$limit))
print ' '.img_picto($langs->trans("Late"),"warning");
else print ' ';
print '';
+ if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['cd.date_ouverture']['checked']))
{
print ''.($obj->date_ouverture?dol_print_date($db->jdate($obj->date_ouverture)):' ').' | ';
+ if (! $i) $totalarray['nbfield']++;
}
// End date
if (! empty($arrayfields['cd.date_fin_validite']['checked']))
@@ -634,10 +656,12 @@ while ($i < min($num,$limit))
}
else print ' ';
print '';
+ if (! $i) $totalarray['nbfield']++;
}
if (! empty($arrayfields['cd.date_cloture']['checked']))
{
print ''.dol_print_date($db->jdate($obj->date_cloture)).' | ';
+ if (! $i) $totalarray['nbfield']++;
}
// Extra fields
@@ -675,6 +699,7 @@ while ($i < min($num,$limit))
print $staticcontratligne->LibStatut($obj->statut,5,($obj->date_fin_validite && $db->jdate($obj->date_fin_validite) < $now)?1:0);
}
print '';
+ if (! $i) $totalarray['nbfield']++;
}
// Action column
print '';
@@ -690,6 +715,25 @@ while ($i < min($num,$limit))
print "\n";
$i++;
}
+
+// 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 '
';
+}
+
$db->free($resql);
$parameters=array('sql' => $sql);