diff --git a/htdocs/core/tpl/list_print_total.tpl.php b/htdocs/core/tpl/list_print_total.tpl.php
index 288f3b8f72e..9b4fa75c751 100644
--- a/htdocs/core/tpl/list_print_total.tpl.php
+++ b/htdocs/core/tpl/list_print_total.tpl.php
@@ -13,13 +13,28 @@ if (isset($totalarray['pos'])) {
while ($i < $totalarray['nbfield']) {
$i++;
if (!empty($totalarray['pos'][$i])) {
- print '
';
- if (isset($totalarray['type']) && $totalarray['type'][$i] == 'duration') {
- print (!empty($totalarray['val'][$totalarray['pos'][$i]])?convertSecondToTime($totalarray['val'][$totalarray['pos'][$i]], 'allhourmin'):0);
- } else {
- print price(!empty($totalarray['val'][$totalarray['pos'][$i]])?$totalarray['val'][$totalarray['pos'][$i]]:0);
+ switch ($totalarray['type'][$i]) {
+ case 'duration';
+ print ' | ';
+ print (!empty($totalarray['val'][$totalarray['pos'][$i]])?convertSecondToTime($totalarray['val'][$totalarray['pos'][$i]], 'allhourmin'):0);
+ print ' | ';
+ break;
+ case 'string';
+ print '';
+ print (!empty($totalarray['val'][$totalarray['pos'][$i]]) ? $totalarray['val'][$totalarray['pos'][$i]] : '');
+ print ' | ';
+ break;
+ case 'stock';
+ print '';
+ print price2num(!empty($totalarray['val'][$totalarray['pos'][$i]]) ? $totalarray['val'][$totalarray['pos'][$i]] : 0, 'MS');
+ print ' | ';
+ break;
+ default;
+ print '';
+ print price(!empty($totalarray['val'][$totalarray['pos'][$i]])?$totalarray['val'][$totalarray['pos'][$i]]:0);
+ print ' | ';
+ break;
}
- print '';
} else {
if ($i == 1) {
if (is_null($limit) || $num < $limit) {
diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php
index ac740974d88..1412ea2fcf5 100644
--- a/htdocs/product/stock/card.php
+++ b/htdocs/product/stock/card.php
@@ -595,35 +595,60 @@ if ($action == 'create') {
print '
';
+ $totalarray = array();
+ $totalarray['val'] = array ();
+ $totalarray['pos'] = array ();
+ $totalarray['type'] = array ();
+ $totalarray['nbfield'] = 0;
+
// TODO Create $arrayfields with all fields to show
print '';
print "";
- $parameters = array();
+ $parameters = array('totalarray' => &$totalarray);
$reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
+
print_liste_field_titre("Product", "", "p.ref", "&id=".$id, "", "", $sortfield, $sortorder);
print_liste_field_titre("Label", "", "p.label", "&id=".$id, "", "", $sortfield, $sortorder);
print_liste_field_titre("NumberOfUnit", "", "ps.reel", "&id=".$id, "", '', $sortfield, $sortorder, 'right ');
+ $totalarray['nbfield'] += 3;
+ $totalarray['pos'][$totalarray['nbfield']] = 'totalunit';
+ $totalarray['type'][$totalarray['nbfield']] = 'stock';
+
if (!empty($conf->global->PRODUCT_USE_UNITS)) {
print_liste_field_titre("Unit", "", "p.fk_unit", "&id=".$id, "", 'align="left"', $sortfield, $sortorder);
+ $totalarray['nbfield']++;
+ $totalarray['pos'][$totalarray['nbfield']] = 'units';
+ $totalarray['type'][$totalarray['nbfield']] = 'string';
}
+
print_liste_field_titre($form->textwithpicto($langs->trans("AverageUnitPricePMPShort"), $langs->trans("AverageUnitPricePMPDesc")), "", "p.pmp", "&id=".$id, "", '', $sortfield, $sortorder, 'right ');
+ $totalarray['nbfield']++;
+
print_liste_field_titre("EstimatedStockValueShort", "", "", "&id=".$id, "", '', $sortfield, $sortorder, 'right ');
+ $totalarray['nbfield']++;
+ $totalarray['pos'][$totalarray['nbfield']] = 'totalvalue';
+
if (empty($conf->global->PRODUIT_MULTIPRICES)) {
print_liste_field_titre("SellPriceMin", "", "p.price", "&id=".$id, "", '', $sortfield, $sortorder, 'right ');
+ $totalarray['nbfield']++;
}
if (empty($conf->global->PRODUIT_MULTIPRICES)) {
print_liste_field_titre("EstimatedStockValueSellShort", "", "", "&id=".$id, "", '', $sortfield, $sortorder, 'right ');
+ $totalarray['nbfield']++;
+ $totalarray['pos'][$totalarray['nbfield']] = 'totalvaluesell';
}
if ($user->rights->stock->mouvement->creer) {
print_liste_field_titre('');
+ $totalarray['nbfield']++;
}
if ($user->rights->stock->creer) {
print_liste_field_titre('');
+ $totalarray['nbfield']++;
}
// Hook fields
- $parameters = array('sortfield'=>$sortfield, 'sortorder'=>$sortorder);
+ $parameters = array('sortfield'=>$sortfield, 'sortorder'=>$sortorder, 'totalarray' => &$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print "
\n";
@@ -708,7 +733,7 @@ if ($action == 'create') {
//print ''.dol_print_date($objp->datem).' | ';
print '';
- $parameters = array('obj'=>$objp);
+ $parameters = array('obj'=>$objp, 'totalarray' => &$totalarray);
$reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
@@ -807,34 +832,20 @@ if ($action == 'create') {
}
$db->free($resql);
- // Total
- print '
| '.$langs->trans("Total").' | ';
- print '';
- $valtoshow = price2num($totalunit, 'MS');
- if (empty($conf->global->PRODUCT_USE_UNITS) || $sameunits) {
- print empty($valtoshow) ? '0' : $valtoshow;
- }
- print ' | ';
- print '';
- if (empty($conf->global->PRODUCT_USE_UNITS) && $sameunits) {
- print $langs->trans($productstatic->getLabelOfUnit());
- }
- print ' | ';
- print ''.price(price2num($totalvalue, 'MT')).' | ';
- if (empty($conf->global->PRODUIT_MULTIPRICES)) {
- print ' | ';
- print ''.price(price2num($totalvaluesell, 'MT')).' | ';
+ $totalarray['val']['totalunit'] = $totalunit;
+ $totalarray['val']['totalvalue'] = price2num($totalvalue, 'MT');
+ $totalarray['val']['totalvaluesell'] = price2num($totalvaluesell, 'MT');
+ $totalarray['val']['units'] = $langs->trans($productstatic->getLabelOfUnit());
+
+ $parameters = array('totalarray' => &$totalarray);
+ // Note that $action and $object may have been modified by hook
+ $reshook = $hookmanager->executeHooks('printFieldListTotal', $parameters, $object);
+ if ($reshook < 0) {
+ setEventMessages($hookmanager->error, $hookmanager->errors);
}
- if ($user->rights->stock->mouvement->creer) {
- print ' | ';
- }
-
- if ($user->rights->stock->creer) {
- print ' | ';
- }
-
- print '
';
+ // Show total line
+ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
} else {
dol_print_error($db);
}