NEW Overwrite tpl with module_part['tpl'] is deprecated. USe hooks

instead.
This commit is contained in:
Laurent Destailleur 2020-03-19 10:15:34 +01:00
parent c94c33696a
commit fca6d45baa
2 changed files with 8 additions and 11 deletions

View File

@ -4083,6 +4083,7 @@ abstract class CommonObject
// Output template part (modules that overwrite templates must declare this into descriptor)
// Use global variables + $dateSelector + $seller and $buyer
// Note: This is deprecated. If you need to overwrite the tpl file, use instead the hook 'formAddObjectLine'.
$dirtpls = array_merge($conf->modules_parts['tpl'], array($defaulttpldir));
foreach ($dirtpls as $module => $reldir)
{
@ -4216,7 +4217,7 @@ abstract class CommonObject
* @param string $buyer Object of buyer third party
* @param int $selected Object line selected
* @param Extrafields $extrafields Object of extrafields
* @param string $defaulttpldir Directory where to find the template
* @param string $defaulttpldir Directory where to find the template (deprecated)
* @return void
*/
public function printObjectLine($action, $line, $var, $num, $i, $dateSelector, $seller, $buyer, $selected = 0, $extrafields = null, $defaulttpldir = '/core/tpl')
@ -4229,15 +4230,9 @@ abstract class CommonObject
$element = $this->element;
$text = ''; $description = ''; $type = 0;
$text = ''; $description = '';
// Show product and description
$type = (!empty($line->product_type) ? $line->product_type : $line->fk_product_type);
// Try to enhance type detection using date_start and date_end for free lines where type was not saved.
if (!empty($line->date_start)) $type = 1; // deprecated
if (!empty($line->date_end)) $type = 1; // deprecated
// Ligne en mode visu
// Line in view mode
if ($action != 'editline' || $selected != $line->id)
{
// Product
@ -4288,6 +4283,7 @@ abstract class CommonObject
// Output template part (modules that overwrite templates must declare this into descriptor)
// Use global variables + $dateSelector + $seller and $buyer
// Note: This is deprecated. If you need to overwrite the tpl file, use instead the hook printObjectLine and printObjectSubLine.
$dirtpls = array_merge($conf->modules_parts['tpl'], array($defaulttpldir));
foreach ($dirtpls as $module => $reldir)
{
@ -4313,12 +4309,12 @@ abstract class CommonObject
if ($this->statut == 0 && $action == 'editline' && $selected == $line->id)
{
$label = (!empty($line->label) ? $line->label : (($line->fk_product > 0) ? $line->product_label : ''));
$placeholder = ' placeholder="'.$langs->trans("Label").'"';
$line->pu_ttc = price2num($line->subprice * (1 + ($line->tva_tx / 100)), 'MU');
// Output template part (modules that overwrite templates must declare this into descriptor)
// Use global variables + $dateSelector + $seller and $buyer
// Note: This is deprecated. If you need to overwrite the tpl file, use instead the hook printObjectLine and printObjectSubLine.
$dirtpls = array_merge($conf->modules_parts['tpl'], array($defaulttpldir));
foreach ($dirtpls as $module => $reldir)
{

View File

@ -35,7 +35,7 @@
* $object_rights->creer initialized from = $object->getRights()
* $disableedit, $disablemove, $disableremove
*
* $type, $text, $description, $line
* $text, $description, $line
*/
// Protection to avoid direct call of template
@ -127,6 +127,7 @@ else
}
else
{
$type = (!empty($line->product_type) ? $line->product_type : $line->fk_product_type);
if ($type == 1) $text = img_object($langs->trans('Service'), 'service');
else $text = img_object($langs->trans('Product'), 'product');